-
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.
Merge pull request #31 from JoshuaOndieki/ft-logout-158791514
[Delivers #158791514] Logout API Endpoint
- Loading branch information
Showing
6 changed files
with
69 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
This module tests logout | ||
""" | ||
import unittest | ||
import json | ||
|
||
from ridemyway.tests.tests_v2 import V2BaseTest | ||
from ridemyway.tests.tests_v2.urls import SIGNUP, LOGIN, LOGOUT | ||
from ridemyway.tests.tests_v2.data import VALID_DRIVER | ||
|
||
|
||
class TestLogout(V2BaseTest): | ||
""" | ||
Tests logout API endpoint | ||
- Auth: '/api/v2/auth/logout' # POST | ||
""" | ||
|
||
def test_user_can_logout_successfully(self): | ||
self.client().post(SIGNUP, data=VALID_DRIVER) | ||
self.response = self.client().post(LOGIN, data=VALID_DRIVER) | ||
result = json.loads(self.response.data.decode()) | ||
access_token = result['access_token'] | ||
self.response = self.client().post(LOGOUT, | ||
headers=dict( | ||
Authorization="Bearer " + | ||
access_token)) | ||
# Attempt to logout again | ||
self.response = self.client().post(LOGOUT, | ||
headers=dict( | ||
Authorization="Bearer " + | ||
access_token)) | ||
self.assertEqual(self.response.status_code, 401, | ||
msg='Should return 401 status code for' + | ||
' use of blacklisted token') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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