@@ -98,15 +98,16 @@ func TestClientConfiguration(t *testing.T) {
98
98
})
99
99
100
100
t .Run ("With CloudID" , func (t * testing.T ) {
101
+ // bar.cloud.es.io$abc123$def456
101
102
c , err := NewClient (Config {CloudID : "foo:YmFyLmNsb3VkLmVzLmlvJGFiYzEyMyRkZWY0NTY=" })
102
103
if err != nil {
103
104
t .Fatalf ("Unexpected error: %s" , err )
104
105
}
105
106
106
107
u := c .Transport .(* estransport.Client ).URLs ()[0 ].String ()
107
108
108
- if u != "https://abc123.bar.cloud.es.io:9243 " {
109
- t .Errorf ("Unexpected URL, want=https://abc123.bar.cloud.es.io:9243 , got=%s" , u )
109
+ if u != "https://abc123.bar.cloud.es.io" {
110
+ t .Errorf ("Unexpected URL, want=https://abc123.bar.cloud.es.io, got=%s" , u )
110
111
}
111
112
})
112
113
@@ -237,16 +238,30 @@ func TestAddrsToURLs(t *testing.T) {
237
238
238
239
func TestCloudID (t * testing.T ) {
239
240
t .Run ("Parse" , func (t * testing.T ) {
240
- input := "name:" + base64 .StdEncoding .EncodeToString ([]byte ("host$es$kibana" ))
241
- expected := "https://es.host:9243"
242
-
243
- actual , err := addrFromCloudID (input )
244
- if err != nil {
245
- t .Errorf ("Unexpected error: %s" , err )
241
+ var testdata = []struct {
242
+ in string
243
+ out string
244
+ }{
245
+ {
246
+ in : "name:" + base64 .StdEncoding .EncodeToString ([]byte ("host$es$kibana" )),
247
+ out : "https://es.host" ,
248
+ },
249
+ {
250
+ in : "name:" + base64 .StdEncoding .EncodeToString ([]byte ("host:9243$es$kibana" )),
251
+ out : "https://es.host:9243" ,
252
+ },
246
253
}
247
- if actual != expected {
248
- t .Errorf ("Unexpected output, want=%q, got=%q" , expected , actual )
254
+
255
+ for _ , tt := range testdata {
256
+ actual , err := addrFromCloudID (tt .in )
257
+ if err != nil {
258
+ t .Errorf ("Unexpected error: %s" , err )
259
+ }
260
+ if actual != tt .out {
261
+ t .Errorf ("Unexpected output, want=%q, got=%q" , tt .out , actual )
262
+ }
249
263
}
264
+
250
265
})
251
266
252
267
t .Run ("Invalid format" , func (t * testing.T ) {
0 commit comments