コード例 #1
0
 def setUp(self):
     self.orig_requests_get = requests.get
     requests.get = self.mockRequest(
         self._get_idp_url(), {
             "authorization_endpoint": "https://test-auth-endpoint",
             "token_endpoint": "https://test-token-endpoint",
             "userinfo_endpoint": "https://test-userinfo-endpoint",
             "end_session_endpoint": "https://test-end-session-endpoint"
         })
     self.custos_authnz = custos_authnz.CustosAuthnz(
         'Custos', {'VERIFY_SSL': True}, {
             'url': self._get_base_idp_url(),
             'client_id': 'test-client-id',
             'client_secret': 'test-client-secret',
             'redirect_uri': 'https://test-redirect-uri',
             'realm': 'test-realm'
         })
     self.setupMocks()
     self.test_state = "abc123"
     self.test_nonce = b"4662892146306485421546981092"
     self.test_nonce_hash = hashlib.sha256(self.test_nonce).hexdigest()
     self.test_code = "test-code"
     self.test_username = "******"
     self.test_email = "test-email"
     self.test_alt_username = "******"
     self.test_alt_email = "test-alt-email"
     self.test_access_token = "test_access_token"
     self.test_refresh_token = "test_refresh_token"
     self.test_expires_in = 30
     self.test_refresh_expires_in = 1800
     self.test_user_id = str(uuid.uuid4())
     self.test_alt_user_id = str(uuid.uuid4())
     self.trans.request.url = "https://localhost:8000/authnz/custos/oidc/callback?state={test_state}&code={test_code}".format(
         test_state=self.test_state, test_code=self.test_code)
コード例 #2
0
 def test_authenticate_sets_env_var_when_localhost_redirect(self):
     """Verify that OAUTHLIB_INSECURE_TRANSPORT var is set with localhost redirect."""
     self.custos_authnz = custos_authnz.CustosAuthnz(
         'Custos', {'VERIFY_SSL': True}, {
             'url': self._get_base_idp_url(),
             'client_id': 'test-client-id',
             'client_secret': 'test-client-secret',
             'redirect_uri': 'http://localhost/auth/callback',
             'realm': 'test-realm'
         })
     self.setupMocks()
     self.assertIsNone(os.environ.get('OAUTHLIB_INSECURE_TRANSPORT', None))
     self.custos_authnz.authenticate(self.trans)
     self.assertEqual("1", os.environ['OAUTHLIB_INSECURE_TRANSPORT'])
コード例 #3
0
 def setUp(self):
     self.orig_requests_get = requests.get
     requests.get = self.mockRequest({
         self._get_well_known_url(): {
             "authorization_endpoint": "https://test-auth-endpoint",
             "token_endpoint": "https://test-token-endpoint",
             "userinfo_endpoint": "https://test-userinfo-endpoint",
             "end_session_endpoint": "https://test-end-session-endpoint",
         },
         self._get_credential_url(): {
             "iam_client_secret": "TESTSECRET"
         },
     })
     self.custos_authnz = custos_authnz.CustosAuthnz(
         "Custos",
         {"VERIFY_SSL": True},
         {
             "url": self._get_idp_url(),
             "client_id": "test-client-id",
             "client_secret": "test-client-secret",
             "redirect_uri": "https://test-redirect-uri",
             "realm": "test-realm",
         },
     )
     self.setupMocks()
     self.test_state = "abc123"
     self.test_nonce = b"4662892146306485421546981092"
     self.test_nonce_hash = hashlib.sha256(self.test_nonce).hexdigest()
     self.test_code = "test-code"
     self.test_username = "******"
     self.test_username_invalid = "*****@*****.**"
     self.test_email = "test-email"
     self.test_sub = "test-sub"
     self.test_alt_username = "******"
     self.test_alt_email = "test-alt-email"
     self.test_access_token = "test_access_token"
     self.test_refresh_token = "test_refresh_token"
     self.test_expires_in = 30
     self.test_refresh_expires_in = 1800
     self.test_user_id = str(uuid.uuid4())
     self.test_alt_user_id = str(uuid.uuid4())
     self.trans.request.url = f"https://localhost:8000/authnz/custos/oidc/callback?state={self.test_state}&code={self.test_code}"