/usr/share/gocode/src/github.com/weppos/dnsimple-go/dnsimple/authentication_test.go is in golang-github-weppos-dnsimple-go-dev 0.0~git20160204.0.65c1ca7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | package dnsimple
import (
"fmt"
"testing"
)
func testCredentials(t *testing.T, credentials Credentials, expectedName, expectedValue string) {
headerName, headerValue := credentials.HttpHeader()
if headerName != expectedName {
t.Errorf("Header name: %v, want %v", headerName, expectedName)
}
if headerValue != expectedValue {
t.Errorf("Header value: %v, want %v", headerValue, expectedValue)
}
}
func TestDomainTokenCredentialsHttpHeader(t *testing.T) {
domainToken := "domain-token"
credentials := NewDomainTokenCredentials(domainToken)
testCredentials(t, credentials, httpHeaderDomainToken, domainToken)
}
func TestHttpBasicCredentialsHttpHeader(t *testing.T) {
email, password := "email", "password"
credentials := NewHttpBasicCredentials(email, password)
expectedHeaderValue := "Basic ZW1haWw6cGFzc3dvcmQ="
testCredentials(t, credentials, httpHeaderAuthorization, expectedHeaderValue)
}
func TestApiTokenCredentialsHttpHeader(t *testing.T) {
email, apiToken := "email", "api-token"
credentials := NewApiTokenCredentials(email, apiToken)
expectedHeaderValue := fmt.Sprintf("%v:%v", email, apiToken)
testCredentials(t, credentials, httpHeaderApiToken, expectedHeaderValue)
}
|