@@ -98,15 +98,16 @@ func TestClientConfiguration(t *testing.T) {
9898 })
9999
100100 t .Run ("With CloudID" , func (t * testing.T ) {
101+ // bar.cloud.es.io$abc123$def456
101102 c , err := NewClient (Config {CloudID : "foo:YmFyLmNsb3VkLmVzLmlvJGFiYzEyMyRkZWY0NTY=" })
102103 if err != nil {
103104 t .Fatalf ("Unexpected error: %s" , err )
104105 }
105106
106107 u := c .Transport .(* estransport.Client ).URLs ()[0 ].String ()
107108
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 )
110111 }
111112 })
112113
@@ -237,16 +238,30 @@ func TestAddrsToURLs(t *testing.T) {
237238
238239func TestCloudID (t * testing.T ) {
239240 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+ },
246253 }
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+ }
249263 }
264+
250265 })
251266
252267 t .Run ("Invalid format" , func (t * testing.T ) {
0 commit comments