def testWithMalformedRedirectUri(self): """ Test the rejection of a request with a malformed redirect uri. """ request = self.createAuthRequest(arguments={ 'response_type': self._RESPONSE_TYPE, 'client_id': self._VALID_CLIENT.id, 'redirect_uri': b'malformedRedirectUri\xFF\xFF', 'scope': 'All', 'state': b'state\xFF\xFF' }) result = self._AUTH_RESOURCE.render_GET(request) self.assertFailedRequest( request, result, MalformedParameterError('redirect_uri'), msg='Expected the auth resource to reject a request with a malformed redirect uri.')
def testAuthorizationMalformedClientIdInHeader(self): """ Test the rejection of a request with a malformed client id in the header. """ request = self.generateValidTokenRequest( arguments={ 'grant_type': 'refresh_token', 'refresh_token': self._VALID_REFRESH_TOKEN }) request.addAuthorization(b'malformedId\xFF\xFF', b'clientSecret') result = self._TOKEN_RESOURCE.render_POST(request) self.assertFailedTokenRequest( request, result, MalformedParameterError('client_id'), msg='Expected the token resource to reject a ' 'request with a malformed Authorization header.')
def testWithMalformedResponseType(self): """ Test the rejection of a request with a malformed response type. """ state = b'state\xFF\xFF' redirectUri = self._VALID_CLIENT.redirectUris[0] request = self.createAuthRequest(arguments={ 'response_type': b'malformedResponseType\xFF\xFF', 'client_id': self._VALID_CLIENT.id, 'redirect_uri': redirectUri, 'scope': 'All', 'state': state }) result = self._AUTH_RESOURCE.render_GET(request) self.assertFailedRequest( request, result, MalformedParameterError('response_type', state=state), redirectUri=redirectUri, msg='Expected the auth resource to reject ' 'a request with a malformed response type.')
def testAuthorizationMalformedClientSecret(self): """ Test the rejection of a request with an malformed client secret in the parameters. """ request = self.generateValidTokenRequest( arguments={ 'grant_type': 'refresh_token', 'client_id': self._VALID_CLIENT.id, 'client_secret': b'malformedSecret\xFF\xFF', 'refresh_token': self._VALID_REFRESH_TOKEN }) result = self._TOKEN_RESOURCE.render_POST(request) self.assertFailedTokenRequest( request, result, MalformedParameterError('client_secret'), msg= 'Expected the token resource to reject a request with a malformed client secret.' )
def testAuthorizationMalformedClientSecretInHeader(self): """ Test the rejection of a request with a malformed client secret in the header. """ client = getTestPasswordClient('malformedSecret') client.secret = b'malformedSecret\xFF\xFF' request = self.generateValidTokenRequest( arguments={ 'grant_type': 'refresh_token', 'refresh_token': self._VALID_REFRESH_TOKEN }) self._addAuthenticationToRequestHeader(request, client) result = self._TOKEN_RESOURCE.render_POST(request) self.assertFailedTokenRequest( request, result, MalformedParameterError('client_secret'), msg='Expected the token resource to reject a ' 'request with a malformed Authorization header.')