MCPcopy Create free account
hub / github.com/CiscoPSIRT/openVulnQuery / AuthorizationTest

Class AuthorizationTest

tests/test_authorization.py:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49
50class AuthorizationTest(unittest.TestCase):
51 @mock.patch('openVulnQuery.authorization.requests.post',
52 side_effect=mocked_req_post)
53 def test_authorization_smoke_succeeds_mocked(self, mock_post):
54 data = authorization.get_oauth_token(
55 CLIENT_ID, CLIENT_SECRET, REQUEST_TOKEN_URL)
56 self.assertEqual(data, OAUTH2_RESPONSE_BOGUS_BUT_OK['access_token'])
57
58 @mock.patch('openVulnQuery.authorization.requests.post',
59 side_effect=mocked_req_post)
60 def test_authorization_smoke_raises_mocked(self, mock_post):
61 self.assertRaises(
62 requests.exceptions.HTTPError,
63 authorization.get_oauth_token,
64 CLIENT_ID, CLIENT_SECRET, NOT_FOUND_REQUEST_TOKEN_URL)
65
66 @mock.patch('openVulnQuery.authorization.requests.post',
67 side_effect=mocked_req_post)
68 def test_authorization_smoke_raises_details_mocked(self, mock_post):
69 with self.assertRaises(requests.exceptions.HTTPError) as e:
70 authorization.get_oauth_token(
71 CLIENT_ID, CLIENT_SECRET, NOT_FOUND_REQUEST_TOKEN_URL)
72 self.assertEqual(str(e.exception), HTTP_ERROR_MSG)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected