test_confidential_client_flow.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:globus-sdk-python 作者: globus 项目源码 文件源码
def test_oauth2_start_flow_default(self):
        """
        Starts a default GlobusAuthorizationCodeFlowManager,
        Confirms flow is initialized as expected, and can be used.
        """
        # starting with no flow
        self.assertIsNone(self.cac.current_oauth2_flow_manager)

        # confirms flow initialized with default flow values
        flow = self.cac.oauth2_start_flow("uri")
        self.assertIsInstance(flow, GlobusAuthorizationCodeFlowManager)
        self.assertEqual(flow.redirect_uri, "uri")
        self.assertEqual(flow.requested_scopes,
                         " ".join(DEFAULT_REQUESTED_SCOPES))
        self.assertEqual(flow.state, "_default")
        self.assertFalse(flow.refresh_tokens)

        # confirm client can get url via flow
        url_res = self.cac.oauth2_get_authorize_url()
        expected_vals = [self.cac.base_url + "v2/oauth2/authorize?",
                         "client_id=" + self.cac.client_id,
                         "redirect_uri=" + "uri",
                         "scope=" + quote_plus(
                             " ".join(DEFAULT_REQUESTED_SCOPES)),
                         "state=" + "_default",
                         "access_type=" + "online"]
        for val in expected_vals:
            self.assertIn(val, url_res)

        # confirm client can try exchanging code for tokens via flow
        with self.assertRaises(AuthAPIError) as apiErr:
            self.cac.oauth2_exchange_code_for_tokens("invalid_code")
        self.assertEqual(apiErr.exception.http_status, 401)
        self.assertEqual(apiErr.exception.code, "Error")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号