def test_get_authorization_code(self): """Test client's auth code URI generation and provider's response.""" uri = self.client.get_authorization_code_uri(scope='example') response = self.provider.get_authorization_code_from_uri(uri) # Check status code self.assertEquals(302, response.status_code) # Check the non-query portion of the redirect URL redirect = response.headers['Location'] self.assertEquals(utils.url_dequery(redirect), MOCK_REDIRECT_URI) # Check params in the redirect URL params = utils.url_query_params(redirect) self.assertEquals(3, len(params)) self.assertEquals(40, len(params['code'])) self.assertEquals('123', params['param']) self.assertEquals('example', params['scope'])
def test_url_dequery(self): """Test url dequery removes query portion of URL.""" result = utils.url_dequery(self.base_url) self.assertEquals(result, 'https://www.myapp.com/some/path;hello')