diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-25 09:11:17 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-25 09:17:48 +0300 |
commit | 4624e4cfd95649270db02616edde8d0ca249b63d (patch) | |
tree | 1c8a43f50533ca759d137f258e42862e8cf5e80f /contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py | |
parent | d2d971701bd8377ead5f973c96be81042774bd2a (diff) | |
download | ydb-4624e4cfd95649270db02616edde8d0ca249b63d.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py')
-rw-r--r-- | contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py b/contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py new file mode 100644 index 0000000000..6ff41e251c --- /dev/null +++ b/contrib/python/requests-oauthlib/tests/examples/test_native_spa_pkce_auth0.py @@ -0,0 +1,39 @@ +import os +import unittest + +from . import base + +class TestNativeAuth0Test(base.Sample, base.Browser, unittest.TestCase): + def setUp(self): + super().setUp() + self.client_id = os.environ.get("AUTH0_PKCE_CLIENT_ID") + self.idp_domain = os.environ.get("AUTH0_DOMAIN") + + if not self.client_id or not self.idp_domain: + self.skipTest("native auth0 is not configured properly") + + def test_login(self): + # redirect_uri is http:// + os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = "1" + + self.run_sample( + "native_spa_pkce_auth0.py", { + "OAUTH_CLIENT_ID": self.client_id, + "OAUTH_IDP_DOMAIN": self.idp_domain, + } + ) + authorize_url = self.wait_for_pattern("https://") + redirect_uri = self.authorize_auth0(authorize_url, "http://") + self.write(redirect_uri) + last_line = self.wait_for_end() + + import ast + response = ast.literal_eval(last_line) + self.assertIn("access_token", response) + self.assertIn("id_token", response) + self.assertIn("scope", response) + self.assertIn("openid", response["scope"]) + self.assertIn("expires_in", response) + self.assertIn("expires_at", response) + self.assertIn("token_type", response) + self.assertEqual("Bearer", response["token_type"]) |