From 249a8844b1aaf2cd2bf6fddc8da10a4defb656d2 Mon Sep 17 00:00:00 2001
From: Ruben Pollan <meskio@sindominio.net>
Date: Wed, 26 Feb 2020 19:17:16 +0100
Subject: [PATCH] [bug] use the right http client to fetch the auth

---
 pkg/vpn/bonafide/auth_anon.go | 4 +---
 pkg/vpn/bonafide/auth_sip.go  | 3 +--
 pkg/vpn/bonafide/bonafide.go  | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/pkg/vpn/bonafide/auth_anon.go b/pkg/vpn/bonafide/auth_anon.go
index 8a55e3a7..c6c5775a 100644
--- a/pkg/vpn/bonafide/auth_anon.go
+++ b/pkg/vpn/bonafide/auth_anon.go
@@ -19,9 +19,7 @@ import (
 	"errors"
 )
 
-type anonymousAuthentication struct {
-	client httpClient
-}
+type anonymousAuthentication struct{}
 
 func (a *anonymousAuthentication) needsCredentials() bool {
 	return true
diff --git a/pkg/vpn/bonafide/auth_sip.go b/pkg/vpn/bonafide/auth_sip.go
index 1bfef522..1f200bbf 100644
--- a/pkg/vpn/bonafide/auth_sip.go
+++ b/pkg/vpn/bonafide/auth_sip.go
@@ -19,7 +19,6 @@ import (
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
-	"net/http"
 	"strings"
 )
 
@@ -41,7 +40,7 @@ func (a *sipAuthentication) getToken(user, password string) ([]byte, error) {
 	if err != nil {
 		return nil, fmt.Errorf("Cannot encode credentials: %s", err)
 	}
-	resp, err := http.Post(a.authURI, "text/json", strings.NewReader(credJSON))
+	resp, err := a.client.Post(a.authURI, "text/json", strings.NewReader(credJSON))
 	if err != nil {
 		return nil, fmt.Errorf("Error on auth request: %v", err)
 	}
diff --git a/pkg/vpn/bonafide/bonafide.go b/pkg/vpn/bonafide/bonafide.go
index 4561eb1e..87801cca 100644
--- a/pkg/vpn/bonafide/bonafide.go
+++ b/pkg/vpn/bonafide/bonafide.go
@@ -105,10 +105,10 @@ func New() *Bonafide {
 		b.auth = &sipAuthentication{client, b.getURL("auth")}
 	case "anon":
 		log.Println("Client expects anon auth")
-		b.auth = &anonymousAuthentication{client}
+		b.auth = &anonymousAuthentication{}
 	default:
 		log.Println("Client expects invalid auth", auth)
-		b.auth = &anonymousAuthentication{client}
+		b.auth = &anonymousAuthentication{}
 	}
 
 	return b
-- 
GitLab