-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert timeout argument to int values when applicable #2050
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
67ff3b9
Convert timeout argument to int values when applicable
RaHus a43abd2
Convert reissue_time argument to int values when applicable
RaHus 7ca2b20
Remove unnecessary code
RaHus b6f0be8
Remove a leaked line from a local test
RaHus fa7886f
Convert max_age argument to int when applicable
RaHus e2519d6
Convert AuthTktCookieHelper time related parameters to int when appli…
RaHus 81cd598
Include CHANGES entry for converting time related parameters of AuthT…
RaHus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -254,3 +254,5 @@ Contributors | |
- Jesse Dhillon, 2015/10/07 | ||
|
||
- Amos Latteier, 2015/10/22 | ||
|
||
- Rami Chousein, 2015/10/28 |
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 |
---|---|---|
|
@@ -600,6 +600,15 @@ def _parseCookie(self, cookie): | |
cookies.load(cookie) | ||
return cookies.get('auth_tkt') | ||
|
||
def test_init_cookie_str_reissue_invalid(self): | ||
self.assertRaises(ValueError, self._makeOne, 'secret', reissue_time='invalid value') | ||
|
||
def test_init_cookie_str_timeout_invalid(self): | ||
self.assertRaises(ValueError, self._makeOne, 'secret', timeout='invalid value') | ||
|
||
def test_init_cookie_str_max_age_invalid(self): | ||
self.assertRaises(ValueError, self._makeOne, 'secret', max_age='invalid value') | ||
|
||
def test_identify_nocookie(self): | ||
helper = self._makeOne('secret') | ||
request = self._makeRequest() | ||
|
@@ -758,6 +767,12 @@ def test_identify_cookie_timed_out(self): | |
result = helper.identify(request) | ||
self.assertEqual(result, None) | ||
|
||
def test_identify_cookie_str_timeout(self): | ||
helper = self._makeOne('secret', timeout='1') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you just want to test that |
||
request = self._makeRequest({'HTTP_COOKIE':'auth_tkt=bogus'}) | ||
result = helper.identify(request) | ||
self.assertEqual(result, None) | ||
|
||
def test_identify_cookie_reissue(self): | ||
import time | ||
helper = self._makeOne('secret', timeout=10, reissue_time=0) | ||
|
@@ -774,6 +789,22 @@ def test_identify_cookie_reissue(self): | |
self.assertEqual(len(response.headerlist), 3) | ||
self.assertEqual(response.headerlist[0][0], 'Set-Cookie') | ||
|
||
def test_identify_cookie_str_reissue(self): | ||
import time | ||
helper = self._makeOne('secret', timeout=10, reissue_time='0') | ||
now = time.time() | ||
helper.auth_tkt.timestamp = now | ||
helper.now = now + 1 | ||
helper.auth_tkt.tokens = (text_('a'), ) | ||
request = self._makeRequest('bogus') | ||
result = helper.identify(request) | ||
self.assertTrue(result) | ||
self.assertEqual(len(request.callbacks), 1) | ||
response = DummyResponse() | ||
request.callbacks[0](request, response) | ||
self.assertEqual(len(response.headerlist), 3) | ||
self.assertEqual(response.headerlist[0][0], 'Set-Cookie') | ||
|
||
def test_identify_cookie_reissue_already_reissued_this_request(self): | ||
import time | ||
helper = self._makeOne('secret', timeout=10, reissue_time=0) | ||
|
@@ -1058,6 +1089,16 @@ def test_remember_insane_userid(self): | |
self.assertTrue('userid' in value.value) | ||
|
||
def test_remember_max_age(self): | ||
helper = self._makeOne('secret') | ||
request = self._makeRequest() | ||
result = helper.remember(request, 'userid', max_age=500) | ||
values = self._parseHeaders(result) | ||
self.assertEqual(len(result), 3) | ||
|
||
self.assertEqual(values[0]['max-age'], '500') | ||
self.assertTrue(values[0]['expires']) | ||
|
||
def test_remember_str_max_age(self): | ||
helper = self._makeOne('secret') | ||
request = self._makeRequest() | ||
result = helper.remember(request, 'userid', max_age='500') | ||
|
@@ -1067,6 +1108,11 @@ def test_remember_max_age(self): | |
self.assertEqual(values[0]['max-age'], '500') | ||
self.assertTrue(values[0]['expires']) | ||
|
||
def test_remember_str_max_age_invalid(self): | ||
helper = self._makeOne('secret') | ||
request = self._makeRequest() | ||
self.assertRaises(ValueError, helper.remember, request, 'userid', max_age='invalid value') | ||
|
||
def test_remember_tokens(self): | ||
helper = self._makeOne('secret') | ||
request = self._makeRequest() | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this test the timeout of the cookie? A bogus
auth_tkt
is already invalid and will always "timeout".