Skip to content
Snippets Groups Projects
Unverified Commit 249a8844 authored by meskio's avatar meskio :tent: Committed by Kali Kaneko
Browse files

[bug] use the right http client to fetch the auth

parent c56df012
No related branches found
No related tags found
No related merge requests found
......@@ -19,9 +19,7 @@ import (
"errors"
)
type anonymousAuthentication struct {
client httpClient
}
type anonymousAuthentication struct{}
func (a *anonymousAuthentication) needsCredentials() bool {
return true
......
......@@ -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)
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment