-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support username for get account
- Loading branch information
Showing
3 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,10 @@ func testingHTTPClient(handler http.Handler) (*http.Client, func()) { | |
// Based on information at https://keratin.github.io/authn-server/#/api?id=get-account | ||
func TestICGetAccount(t *testing.T) { | ||
type request struct { | ||
url string | ||
htusername string | ||
htpassword string | ||
id string | ||
url string | ||
htusername string | ||
htpassword string | ||
idOrUsername string | ||
} | ||
type response struct { | ||
id int | ||
|
@@ -71,10 +71,10 @@ func TestICGetAccount(t *testing.T) { | |
}{ | ||
{ | ||
request: request{ | ||
url: "http://test.com", | ||
htusername: "username", | ||
htpassword: "password", | ||
id: "1", | ||
url: "http://test.com", | ||
htusername: "username", | ||
htpassword: "password", | ||
idOrUsername: "1", | ||
}, | ||
response: response{ | ||
id: 1, | ||
|
@@ -87,10 +87,26 @@ func TestICGetAccount(t *testing.T) { | |
}, | ||
{ | ||
request: request{ | ||
url: "http://test.com", | ||
htusername: "username", | ||
htpassword: "password", | ||
id: "1", | ||
url: "http://test.com", | ||
htusername: "username", | ||
htpassword: "password", | ||
idOrUsername: "[email protected]", | ||
}, | ||
response: response{ | ||
id: 1, | ||
username: "[email protected]", | ||
locked: true, | ||
deleted: true, | ||
code: http.StatusOK, | ||
errorMsg: "", | ||
}, | ||
}, | ||
{ | ||
request: request{ | ||
url: "http://test.com", | ||
htusername: "username", | ||
htpassword: "password", | ||
idOrUsername: "1", | ||
}, | ||
response: response{ | ||
code: http.StatusNotFound, | ||
|
@@ -106,7 +122,7 @@ func TestICGetAccount(t *testing.T) { | |
assert.Equal(t, http.MethodGet, r.Method) | ||
assert.Equal(t, tc.request.htusername, username) | ||
assert.Equal(t, tc.request.htpassword, password) | ||
assert.Equal(t, "/accounts/"+tc.request.id, r.URL.Path) | ||
assert.Equal(t, "/accounts/"+tc.request.idOrUsername, r.URL.Path) | ||
w.WriteHeader(tc.response.code) | ||
//if we're mocking a good request, return the json | ||
if tc.response.code == http.StatusOK { | ||
|
@@ -129,7 +145,7 @@ func TestICGetAccount(t *testing.T) { | |
} | ||
cli.client = httpClient | ||
|
||
account, err := cli.GetAccount(tc.request.id) | ||
account, err := cli.GetAccount(tc.request.idOrUsername) | ||
if tc.response.errorMsg == "" { //Expecting no error | ||
assert.Nil(t, err) | ||
assert.Equal(t, tc.response.id, account.ID) | ||
|