diff --git a/pkg/backend/init.go b/pkg/backend/init.go index f7dd87a2fb9c656b1db98ec6904ba0797decace2..f76ab49b42ef9929bc0ee17d210aa58c5653bcdd 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -117,5 +117,4 @@ func initializeAutostart(conf *config.Config) bitmask.Autostart { log.Printf("Error enabling autostart: %v", err) } return autostart - } diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go index 727d62af6ad78506c51374f88ad1d86c7eb411ea..02ee544dcc8c429121293ddceb9bfe1cf10549f4 100644 --- a/pkg/bitmask/init.go +++ b/pkg/bitmask/init.go @@ -57,6 +57,7 @@ func ConfigureProvider(opts *ProviderOpts) { config.BinaryName = opts.BinaryName config.Auth = opts.Auth config.GeolocationAPI = opts.GeolocationURL + config.APIURL = opts.ApiURL config.CaCert = []byte(opts.CaCert) } @@ -67,10 +68,10 @@ func InitializeLogger() { } } -func initBitmask() (Bitmask, error) { +func initBitmaskVPN() (Bitmask, error) { b, err := vpn.Init() if err != nil { - log.Printf("An error ocurred starting bitmask: %v", err) + log.Printf("An error ocurred starting bitmask vpn: %v", err) } return b, err } @@ -83,7 +84,7 @@ func InitializeBitmask(conf *config.Config) (Bitmask, error) { os.MkdirAll(config.Path, os.ModePerm) } - b, err := initBitmask() + b, err := initBitmaskVPN() if err != nil { return nil, err } diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go index fe22deb25b4580e44ce7c01506f6d7ccd24dbc95..973416a62bbba23add1142638a801fa6ad1bef94 100644 --- a/pkg/vpn/bonafide/bonafide.go +++ b/pkg/vpn/bonafide/bonafide.go @@ -48,7 +48,6 @@ type Bonafide struct { tzOffsetHours int auth authentication token []byte - apiURL string } type Gateway struct { @@ -178,24 +177,13 @@ func (b *Bonafide) GetPemCertificate() ([]byte, error) { } func (b *Bonafide) getURL(object string) string { - if b.apiURL == "" { - switch object { - case "cert": - return config.APIURL + certPathv1 - case "certv3": - return config.APIURL + certPathv3 - case "auth": - return config.APIURL + authPathv3 - } - } else { - switch object { - case "cert": - return b.apiURL + certPathv1 - case "certv3": - return b.apiURL + certPathv3 - case "auth": - return b.apiURL + authPathv3 - } + switch object { + case "cert": + return config.APIURL + certPathv1 + case "certv3": + return config.APIURL + certPathv3 + case "auth": + return config.APIURL + authPathv3 } log.Println("BUG: unknown url object") return "" diff --git a/pkg/vpn/bonafide/bonafide_sip_integration_test.go b/pkg/vpn/bonafide/bonafide_sip_integration_test.go index ee74efe4dc9847f7fca6099cdfc1109968a7cb79..3a7fc7f80853951fe22b4da1ba2855b5f54232cf 100644 --- a/pkg/vpn/bonafide/bonafide_sip_integration_test.go +++ b/pkg/vpn/bonafide/bonafide_sip_integration_test.go @@ -20,6 +20,8 @@ import ( "bytes" "os" "testing" + + "0xacab.org/leap/bitmask-vpn/pkg/config" ) type SIPCreds struct { @@ -44,12 +46,16 @@ func getSIPCreds() SIPCreds { return creds } +func initTestConfigSIP() { + config.APIURL = "https://localhost:8000/" +} + func _TestSIPIntegrationGetCert(t *testing.T) { // FIXME: we need to automatize the webapi start + initTestConfigSIP() creds := getSIPCreds() b := New() - b.apiURL = "http://localhost:8000/" b.auth = &sipAuthentication{b.client, b.getURL("auth")} ok, err := b.DoLogin(creds.userOk, creds.passOk) if err != nil {