@@ -95,12 +95,20 @@ func TestProfileCommands(t *testing.T) {
9595 t .Errorf ("expected '* test-prof (test.looker.com:19999)', got %q" , out )
9696 }
9797
98- // 4. Add another profile
99- _ , err = executeCommand ("profile" , "add" , "test-prof2" , "--host" , "test2.looker.com" , "--port" , "20000" )
98+ // 4. Add another profile with --ssl=false
99+ _ , err = executeCommand ("profile" , "add" , "test-prof2" , "--host" , "test2.looker.com" , "--port" , "20000" , "--ssl=false" )
100100 if err != nil {
101101 t .Fatalf ("profile add failed: %v" , err )
102102 }
103103
104+ cfgCheck , err := config .Load ()
105+ if err != nil {
106+ t .Fatalf ("failed to load config: %v" , err )
107+ }
108+ if cfgCheck .Profiles ["test-prof2" ].SSL == nil || * cfgCheck .Profiles ["test-prof2" ].SSL != false {
109+ t .Errorf ("expected test-prof2 SSL to be false, got %v" , cfgCheck .Profiles ["test-prof2" ].SSL )
110+ }
111+
104112 // 5. List profiles (check default marker)
105113 out , err = executeCommand ("profile" , "ls" )
106114 if err != nil {
@@ -176,11 +184,13 @@ func TestInitClient_Profile(t *testing.T) {
176184 _ = RootCmd .PersistentFlags ().Set ("port" , "19999" )
177185 _ = RootCmd .PersistentFlags ().Set ("client-id" , "" )
178186 _ = RootCmd .PersistentFlags ().Set ("client-secret" , "" )
187+ _ = RootCmd .PersistentFlags ().Set ("ssl" , "true" )
179188 _ = RootCmd .PersistentFlags ().Set ("verify-ssl" , "true" )
180189 RootCmd .PersistentFlags ().Lookup ("host" ).Changed = false
181190 RootCmd .PersistentFlags ().Lookup ("port" ).Changed = false
182191 RootCmd .PersistentFlags ().Lookup ("client-id" ).Changed = false
183192 RootCmd .PersistentFlags ().Lookup ("client-secret" ).Changed = false
193+ RootCmd .PersistentFlags ().Lookup ("ssl" ).Changed = false
184194 RootCmd .PersistentFlags ().Lookup ("verify-ssl" ).Changed = false
185195 cfgProfile = ""
186196
@@ -307,4 +317,64 @@ func TestInitClient_Profile(t *testing.T) {
307317 t .Errorf ("expected verifySSL to be true from flag, got false" )
308318 }
309319 })
320+
321+ t .Run ("Profile ssl is used when flag is omitted" , func (t * testing.T ) {
322+ cfg , _ := config .Load ()
323+ falseVal := false
324+ cfg .Profiles ["prof-no-https" ] = config.Profile {
325+ Host : "profile-host.com" ,
326+ Port : "1234" ,
327+ ClientID : "prof-id" ,
328+ ClientSecret : "prof-sec" ,
329+ SSL : & falseVal ,
330+ }
331+ _ = cfg .Save ()
332+ _ = RootCmd .PersistentFlags ().Set ("profile" , "prof-no-https" )
333+ _ = RootCmd .PersistentFlags ().Set ("ssl" , "true" )
334+ RootCmd .PersistentFlags ().Lookup ("ssl" ).Changed = false
335+ defer func () {
336+ _ = RootCmd .PersistentFlags ().Set ("profile" , "" )
337+ cfgProfile = ""
338+ }()
339+
340+ wrapper , err := initClient (context .Background (), false )
341+ if err != nil {
342+ t .Fatalf ("initClient failed: %v" , err )
343+ }
344+
345+ if wrapper .Session .Config .BaseUrl != "http://profile-host.com:1234" {
346+ t .Errorf ("expected base URL 'http://profile-host.com:1234', got '%s'" , wrapper .Session .Config .BaseUrl )
347+ }
348+ })
349+
350+ t .Run ("Explicit ssl flag overrides profile value" , func (t * testing.T ) {
351+ cfg , _ := config .Load ()
352+ falseVal := false
353+ cfg .Profiles ["prof-no-https" ] = config.Profile {
354+ Host : "profile-host.com" ,
355+ Port : "1234" ,
356+ ClientID : "prof-id" ,
357+ ClientSecret : "prof-sec" ,
358+ SSL : & falseVal ,
359+ }
360+ _ = cfg .Save ()
361+ _ = RootCmd .PersistentFlags ().Set ("profile" , "prof-no-https" )
362+ _ = RootCmd .PersistentFlags ().Set ("ssl" , "true" )
363+ RootCmd .PersistentFlags ().Lookup ("ssl" ).Changed = true
364+ defer func () {
365+ _ = RootCmd .PersistentFlags ().Set ("profile" , "" )
366+ cfgProfile = ""
367+ _ = RootCmd .PersistentFlags ().Set ("ssl" , "true" )
368+ RootCmd .PersistentFlags ().Lookup ("ssl" ).Changed = false
369+ }()
370+
371+ wrapper , err := initClient (context .Background (), false )
372+ if err != nil {
373+ t .Fatalf ("initClient failed: %v" , err )
374+ }
375+
376+ if wrapper .Session .Config .BaseUrl != "https://profile-host.com:1234" {
377+ t .Errorf ("expected base URL 'https://profile-host.com:1234', got '%s'" , wrapper .Session .Config .BaseUrl )
378+ }
379+ })
310380}
0 commit comments