1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import unittest
from unittest import mock
from ...authentication.revoke_token import RevokeToken
class TestRevokeToken(unittest.TestCase):
@mock.patch("auth0.rest.RestClient.post")
def test_revoke_refresh_token(self, mock_post):
a = RevokeToken("my.domain.com", "cid")
# regular apps
a.revoke_refresh_token(token="tkn")
args, kwargs = mock_post.call_args
self.assertEqual(args[0], "https://my.domain.com/oauth/revoke")
self.assertEqual(kwargs["data"], {"client_id": "cid", "token": "tkn"})
# confidential apps
a = RevokeToken("my.domain.com", "cid", client_secret="sh!")
a.revoke_refresh_token(token="tkn")
args, kwargs = mock_post.call_args
self.assertEqual(args[0], "https://my.domain.com/oauth/revoke")
self.assertEqual(
kwargs["data"], {"client_id": "cid", "token": "tkn", "client_secret": "sh!"}
)
|