-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send JSON-encoded user session data through X-User header.
- Loading branch information
Rob Archibald
committed
Jan 24, 2017
1 parent
703ddf4
commit 7f3cef6
Showing
2 changed files
with
40 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,9 @@ func TestAuth(t *testing.T) { | |
} | ||
|
||
w = httptest.NewRecorder() | ||
storer = &mockAuthStorer{SessionReturn: &loginSession{Email: "[email protected]"}} | ||
storer = &mockAuthStorer{SessionReturn: &loginSession{UserID: 1, Email: "[email protected]", FullName: "Name"}} | ||
auth(storer, w, nil) | ||
if w.Header().Get("X-User") != "[email protected]" || storer.LastRun != "GetSession" { | ||
if w.Header().Get("X-User") != `{"UserID":1,"Email":"[email protected]","FullName":"Name"}` || storer.LastRun != "GetSession" { | ||
t.Error("expected User header to be set", w.Header().Get("X-User"), storer.LastRun) | ||
} | ||
} | ||
|
@@ -61,7 +61,7 @@ func TestAuthBasic(t *testing.T) { | |
w = httptest.NewRecorder() | ||
storer = &mockAuthStorer{SessionReturn: &loginSession{Email: "[email protected]"}} | ||
authBasic(storer, w, nil) | ||
if w.Header().Get("X-User") != "[email protected]" || storer.LastRun != "GetBasicAuth" { | ||
if w.Header().Get("X-User") != `{"UserID":0,"Email":"[email protected]","FullName":""}` || storer.LastRun != "GetBasicAuth" { | ||
t.Error("expected User header to be set", w.Header().Get("X-User"), storer.LastRun) | ||
} | ||
} | ||
|
@@ -129,8 +129,8 @@ func TestVerifyEmail(t *testing.T) { | |
|
||
func TestAddUserHeader(t *testing.T) { | ||
w := httptest.NewRecorder() | ||
addUserHeader(&loginSession{Email: "[email protected]"}, w) | ||
if w.Header().Get("X-User") != "[email protected]" { | ||
addUserHeader(`{"name": "value"}`, w) | ||
if w.Header().Get("X-User") != `{"name": "value"}` { | ||
t.Error("expected halfauth header", w.Header()) | ||
} | ||
} | ||
|