def test_is_accessible_client_404(self): client_id = 123456789 user_id = 'user01' responses.add(responses.GET, settings.AUTHLETE_CLIENT_ENDPOINT + '/get/' + str(client_id), json={}, status=404) with self.assertRaises(RecordNotFoundError): AuthleteUtil.is_accessible_client(client_id, user_id)
def validate_params(self): ParameterUtil.cast_parameter_to_int(self.params, self.get_schema()) validate(self.params, self.get_schema()) user_id = self.event['requestContext']['authorizer']['claims']['cognito:username'] if not AuthleteUtil.is_accessible_client(self.params['client_id'], user_id): raise NoPermissionError('No permission on this resource')
def test_is_accessible_client_ok_false(self): client_id = 123456789 user_id = 'user01' responses.add(responses.GET, settings.AUTHLETE_CLIENT_ENDPOINT + '/get/' + str(client_id), json={'developer': user_id}, status=200) result = AuthleteUtil.is_accessible_client(client_id, 'user02') self.assertEqual(result, False)
def test_is_accessible_client_with_exception(self): client_id = 123456789 user_id = 'user01' with self.assertRaises(Exception): AuthleteUtil.is_accessible_client(client_id, user_id)