示例#1
0
    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')
示例#3
0
    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)
示例#4
0
    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)