forked from remote/oauth2
Changed some test formatting.
Change-Id: Ia1f314ae5edd33bc91b5e950c6499c049219ee79
This commit is contained in:
@@ -43,15 +43,15 @@ func TestToken_Func(t *testing.T) {
|
|||||||
|
|
||||||
targetServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
targetServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if got, want := r.URL.String(), "/"; got != want {
|
if got, want := r.URL.String(), "/"; got != want {
|
||||||
t.Errorf("Unexpected request URL: got %v but want %v", got, want)
|
t.Errorf("URL.String(): got %v but want %v", got, want)
|
||||||
}
|
}
|
||||||
headerAuth := r.Header.Get("Authorization")
|
headerAuth := r.Header.Get("Authorization")
|
||||||
if got, want := headerAuth, "Basic cmJyZ25vZ25yaG9uZ28zYmk0Z2I5Z2hnOWc6bm90c29zZWNyZXQ="; got != want {
|
if got, want := headerAuth, "Basic cmJyZ25vZ25yaG9uZ28zYmk0Z2I5Z2hnOWc6bm90c29zZWNyZXQ="; got != want {
|
||||||
t.Errorf("Unexpected autohrization header: got %v but want %v", got, want)
|
t.Errorf("got %v but want %v", got, want)
|
||||||
}
|
}
|
||||||
headerContentType := r.Header.Get("Content-Type")
|
headerContentType := r.Header.Get("Content-Type")
|
||||||
if got, want := headerContentType, "application/x-www-form-urlencoded"; got != want {
|
if got, want := headerContentType, "application/x-www-form-urlencoded"; got != want {
|
||||||
t.Errorf("Unexpected Content-Type header: got %v but want %v", got, want)
|
t.Errorf("got %v but want %v", got, want)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -50,15 +50,18 @@ func TestRetrieveFileSubjectToken(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range fileSourceTests {
|
for _, test := range fileSourceTests {
|
||||||
|
test := test
|
||||||
tfc := testFileConfig
|
tfc := testFileConfig
|
||||||
tfc.CredentialSource = test.cs
|
tfc.CredentialSource = test.cs
|
||||||
|
|
||||||
out, err := tfc.parse().subjectToken()
|
t.Run(test.name, func(t *testing.T) {
|
||||||
if err != nil {
|
out, err := tfc.parse().subjectToken()
|
||||||
t.Fatalf("Method retrieveSubjectToken for type fileCredentialSource in test %v failed; %e", test.name, err)
|
if err != nil {
|
||||||
}
|
t.Errorf("Method subjectToken() errored.")
|
||||||
if out != test.want {
|
} else if test.want != out {
|
||||||
t.Errorf("Test %v for method retrieveSubjectToken for type fileCredentialSouce failed: expected %v but got %v", test.name, test.want, out)
|
t.Errorf("got %v but want %v", out, test.want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user