Skip to content

Commit 630a9e8

Browse files
Daniel Fettsingingwolfboy
authored andcommitted
Add test for OAuth Mutual TLS.
1 parent ae5c81d commit 630a9e8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_oauth2_session.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ def verifier(r, **kwargs):
7878
sess.send = verifier
7979
sess.get("https://i.b")
8080

81+
def test_mtls(self):
82+
cert = ('testsomething.example-client.pem', 'testsomething.example-client-key.pem')
83+
def verifier(r, **kwargs):
84+
self.assertIn('cert', kwargs)
85+
self.assertEqual(cert, kwargs['cert'])
86+
self.assertIn('client_id=' + self.client_id, r.body)
87+
resp = mock.MagicMock()
88+
resp.text = json.dumps(self.token)
89+
return resp
90+
91+
for client in self.clients:
92+
sess = OAuth2Session(client=client)
93+
sess.send = verifier
94+
95+
if isinstance(client, LegacyApplicationClient):
96+
sess.fetch_token('https://i.b', include_client_id=True, cert=cert, username="username1", password="password1")
97+
else:
98+
sess.fetch_token('https://i.b', include_client_id=True, cert=cert)
99+
81100
def test_authorization_url(self):
82101
url = "https://example.com/authorize?foo=bar"
83102

0 commit comments

Comments
 (0)