forked from bitly/oauth2_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The intention is to refresh the cookie whenever the user accesses an authenticated service with less than `cookie-refresh` time to go before the cookie expires.
- Loading branch information
Mike Bland
committed
May 8, 2015
1 parent
5cbdb74
commit 8e2d836
Showing
5 changed files
with
41 additions
and
7 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
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 |
---|---|---|
|
@@ -353,8 +353,31 @@ func TestProcessCookie(t *testing.T) { | |
assert.Equal(t, "michael.bland", user) | ||
} | ||
|
||
func TestProcessCookieError(t *testing.T) { | ||
func TestProcessCookieNoCookieError(t *testing.T) { | ||
pc_test := NewProcessCookieTest() | ||
_, _, _, ok := pc_test.ProcessCookie() | ||
assert.Equal(t, false, ok) | ||
} | ||
|
||
func TestProcessCookieRefreshNotSet(t *testing.T) { | ||
pc_test := NewProcessCookieTest() | ||
cookie := pc_test.MakeCookie("[email protected]") | ||
cookie.Expires = time.Now().Add(time.Duration(23) * time.Hour) | ||
pc_test.req.AddCookie(cookie) | ||
|
||
_, _, _, ok := pc_test.ProcessCookie() | ||
assert.Equal(t, true, ok) | ||
assert.Equal(t, []string(nil), pc_test.rw.HeaderMap["Set-Cookie"]) | ||
} | ||
|
||
func TestProcessCookieRefresh(t *testing.T) { | ||
pc_test := NewProcessCookieTest() | ||
cookie := pc_test.MakeCookie("[email protected]") | ||
cookie.Expires = time.Now().Add(time.Duration(23) * time.Hour) | ||
pc_test.req.AddCookie(cookie) | ||
|
||
pc_test.proxy.CookieRefresh = time.Duration(24) * time.Hour | ||
_, _, _, ok := pc_test.ProcessCookie() | ||
assert.Equal(t, true, ok) | ||
assert.NotEqual(t, []string(nil), pc_test.rw.HeaderMap["Set-Cookie"]) | ||
} |
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