Esempio n. 1
0
    def test_parse_token_response(self):
        client = PasswordCredentialsClient(self.client_id)

        # Parse code and state
        response = client.parse_request_body_response(self.token_json, scope=self.scope)
        self.assertEqual(response, self.token)
        self.assertEqual(client.access_token, response.get(u"access_token"))
        self.assertEqual(client.refresh_token, response.get(u"refresh_token"))
        self.assertEqual(client.token_type, response.get(u"token_type"))

        # Mismatching state
        self.assertRaises(Warning, client.parse_request_body_response, self.token_json, scope=u"invalid")
Esempio n. 2
0
    def test_request_body(self):
        client = PasswordCredentialsClient(self.client_id, self.username,
                    self.password)

        # Basic, no extra arguments
        body = client.prepare_request_body(body=self.body)
        self.assertEqual(body, self.body_up)

        # With extra parameters, checked using length since order of
        # dict items is undefined
        body = client.prepare_request_body(body=self.body, **self.kwargs)
        self.assertEqual(len(body), len(self.body_kwargs))
Esempio n. 3
0
    def test_request_body(self):
        client = PasswordCredentialsClient(self.client_id, self.username,
                                           self.password)

        # Basic, no extra arguments
        body = client.prepare_request_body(body=self.body)
        self.assertEqual(body, self.body_up)

        # With extra parameters, checked using length since order of
        # dict items is undefined
        body = client.prepare_request_body(body=self.body, **self.kwargs)
        self.assertEqual(len(body), len(self.body_kwargs))
Esempio n. 4
0
    def test_request_body(self):
        client = PasswordCredentialsClient(self.client_id)

        # Basic, no extra arguments
        body = client.prepare_request_body(self.username, self.password,
                body=self.body)
        self.assertFormBodyEqual(body, self.body_up)

        # With extra parameters
        body = client.prepare_request_body(self.username, self.password,
                body=self.body, **self.kwargs)
        self.assertFormBodyEqual(body, self.body_kwargs)
Esempio n. 5
0
    def test_parse_token_response(self):
        client = PasswordCredentialsClient(self.client_id)

        # Parse code and state
        response = client.parse_request_body_response(self.token_json, scope=self.scope)
        self.assertEqual(response, self.token)
        self.assertEqual(client.access_token, response.get("access_token"))
        self.assertEqual(client.refresh_token, response.get("refresh_token"))
        self.assertEqual(client.token_type, response.get("token_type"))

        # Mismatching state
        self.assertRaises(Warning, client.parse_request_body_response, self.token_json, scope="invalid")
Esempio n. 6
0
    def test_request_body(self):
        client = PasswordCredentialsClient(self.client_id)

        # Basic, no extra arguments
        body = client.prepare_request_body(self.username,
                                           self.password,
                                           body=self.body)
        self.assertFormBodyEqual(body, self.body_up)

        # With extra parameters
        body = client.prepare_request_body(self.username,
                                           self.password,
                                           body=self.body,
                                           **self.kwargs)
        self.assertFormBodyEqual(body, self.body_kwargs)