Ejemplo n.º 1
0
    def test_get_user_token_no_parameter(self):
        state = 'some_state'
        auth = OAuth2.full_code_exchange(client_id,
                                         redirect_uri,
                                         client_secret,
                                         scope='all',
                                         state=state)

        with self.assertRaises(AssertionError):
            auth.get_user_token()
Ejemplo n.º 2
0
    def test_get_user_token_invalid_state(self):
        state = 'state_1'
        auth = OAuth2.full_code_exchange(client_id,
                                         redirect_uri,
                                         client_secret,
                                         scope='all',
                                         state=state)

        returned_code = 'some_code'
        returned_state = 'state_2'
        with self.assertRaises(InvalidStateError):
            auth.get_user_token(code=returned_code, state=returned_state)
Ejemplo n.º 3
0
    def test_get_user_token_code_flow(self, mock_post):
        # full code exchange flow

        state = 'some_state'
        code = 'some_code'
        code_flow_token = 'test'

        auth = OAuth2.full_code_exchange(client_id,
                                         redirect_uri,
                                         client_secret,
                                         scope='all',
                                         state=state)

        r = auth.get_user_token(code=code, state=state)
        self.assertEqual(r, code_flow_token)