From d4e6561f2d65e2deab3a418f55b4ae4d8b6c8457 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Thu, 1 Oct 2020 20:45:43 +0200 Subject: [bug] remove apiURL from bonafide it seems this was an attempt to make this injectable for tests, but it can work by changing config variables too. --- pkg/vpn/bonafide/bonafide.go | 26 ++++++----------------- pkg/vpn/bonafide/bonafide_sip_integration_test.go | 8 ++++++- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'pkg/vpn') diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go index fe22deb..973416a 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 ee74efe..3a7fc7f 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 { -- cgit v1.2.3