|
| 1 | +import unittest |
| 2 | +from unittest import mock |
| 3 | + |
| 4 | +from ...authentication.pushed_authorization_requests import PushedAuthorizationRequests |
| 5 | + |
| 6 | + |
| 7 | +class TestRevokeToken(unittest.TestCase): |
| 8 | + @mock.patch("auth0.rest.RestClient.post") |
| 9 | + def test_par(self, mock_post): |
| 10 | + a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!") |
| 11 | + a.pushed_authorization_request( |
| 12 | + response_type="code", redirect_uri="https://example.com/callback" |
| 13 | + ) |
| 14 | + |
| 15 | + args, kwargs = mock_post.call_args |
| 16 | + |
| 17 | + self.assertEqual(args[0], "https://my.domain.com/oauth/par") |
| 18 | + self.assertEqual( |
| 19 | + kwargs["data"], |
| 20 | + { |
| 21 | + "client_id": "cid", |
| 22 | + "client_secret": "sh!", |
| 23 | + "response_type": "code", |
| 24 | + "redirect_uri": "https://example.com/callback", |
| 25 | + }, |
| 26 | + ) |
| 27 | + |
| 28 | + @mock.patch("auth0.rest.RestClient.post") |
| 29 | + def test_par_custom_params(self, mock_post): |
| 30 | + a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!") |
| 31 | + a.pushed_authorization_request( |
| 32 | + response_type="code", redirect_uri="https://example.com/callback", foo="bar" |
| 33 | + ) |
| 34 | + |
| 35 | + args, kwargs = mock_post.call_args |
| 36 | + |
| 37 | + self.assertEqual(args[0], "https://my.domain.com/oauth/par") |
| 38 | + self.assertEqual( |
| 39 | + kwargs["data"], |
| 40 | + { |
| 41 | + "client_id": "cid", |
| 42 | + "client_secret": "sh!", |
| 43 | + "response_type": "code", |
| 44 | + "redirect_uri": "https://example.com/callback", |
| 45 | + "foo": "bar", |
| 46 | + }, |
| 47 | + ) |
0 commit comments