Skip to content
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

Add Logout method. #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions terminalone/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def _auth_session_id(self, session_id, api_key, expires=None):
)
self._check_session()

def logout(self):
"""Remove all session information."""
self.session.headers['Authorization'] = None
self.session.cookies['adama_session'] = None

def fetch_resource_owner_password_token(self, username, password,
client_id, client_secret):
"""Authenticate using OAuth2.
Expand Down
7 changes: 7 additions & 0 deletions tests/test_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ def setUp(self):
def test_minimum_creds_for_oauth2(self):
"""Test Minimum Credentials."""
self.assertEqual(self.t1.auth_params['method'], 'oauth2-resourceowner')

@responses.activate
def test_logout(self):
"""Test if logout removes credentials."""
self.assertIsNotNone(self.t1.session.headers['Authorization'])
self.t1.logout()
self.assertIsNone(self.t1.session.headers['Authorization'])