Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit e39865d

Browse files
author
Grace Yim
committed
Add tests for ToopherIframe.is_authentication_granted
1 parent f9dc71d commit e39865d

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

test/test_toopher_iframe.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,25 @@ def test_is_authentication_granted_returns_false_when_user_is_returned(self):
208208
authentication_granted = self.iframe_api.is_authentication_granted(self._get_urlencoded_user_postback_data(), self.request_token)
209209
self.assertFalse(authentication_granted)
210210

211-
def test_is_authentication_granted_returns_false_when_missing_keys(self):
211+
def test_is_authentication_granted_returns_false_when_signature_validation_error_is_raised(self):
212212
data = self._get_auth_request_postback_data_as_dict()
213213
del data['id']
214214
authentication_granted = self.iframe_api.is_authentication_granted(self._get_urlencoded_auth_request_postback_data(data), self.request_token)
215215
self.assertFalse(authentication_granted)
216216

217+
def test_is_authentication_granted_returns_false_when_toopher_api_error_is_raised(self):
218+
data = self._get_auth_request_postback_data_as_dict()
219+
data['resource_type'] = 'invalid'
220+
authentication_granted = self.iframe_api.is_authentication_granted(data, self.request_token)
221+
self.assertFalse(authentication_granted)
222+
223+
def test_is_authentication_granted_returns_false_when_user_disabled_error_is_raised(self):
224+
data = self._get_auth_request_postback_data_as_dict()
225+
data['error_code'] = 704
226+
data['error_message'] = 'The specified user has disabled Toopher authentication.'
227+
authentication_granted = self.iframe_api.is_authentication_granted(data, self.request_token)
228+
self.assertFalse(authentication_granted)
229+
217230
def test_get_user_management_url(self):
218231
expected = 'https://api.toopher.test/v1/web/manage_user?username=jdoe&reset_email=jdoe%40example.com&expires=1300&v=2&oauth_nonce=12345678&oauth_timestamp=1000&oauth_version=1.0&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=abcdefg&oauth_signature=NjwH5yWPE2CCJL8v%2FMNknL%2BeTpE%3D'
219232
self.assertEqual(expected, self.iframe_api.get_user_management_url('jdoe', 'jdoe@example.com'))

0 commit comments

Comments
 (0)