def validate_params(self):
        ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())

        validate(self.params, self.get_schema())

        if self.params.get('topic'):
            DBUtil.validate_topic(self.dynamodb, self.params['topic'])
Exemple #2
0
    def validate_params(self):
        ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())
        validate(self.params, self.get_schema())

        DBUtil.validate_article_existence(self.dynamodb,
                                          self.params['article_id'],
                                          status='public')
    def test_cast_parameter_to_int(self):
        schema = {
            'properties': {
                'limit': {
                    'type': 'integer'
                },
                'article_id': {
                    'type': 'string'
                },
                'sort_key': {
                    'type': 'integer'
                }
            }
        }

        params = {
            'limit': '100',
            'article_id': '150',
            'sort_key': 'ALIS',
            'other_key': '150'
        }

        ParameterUtil.cast_parameter_to_int(params, schema)

        expected_params = {
            'limit': 100,
            'article_id': '150',
            'sort_key': 'ALIS',
            'other_key': '150'
        }

        self.assertEqual(params, expected_params)
    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')
Exemple #5
0
 def validate_params(self):
     ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())
     UserUtil.verified_phone_and_email(self.event)
     validate(self.params, self.get_schema())
     DBUtil.validate_article_existence(
         self.dynamodb,
         self.event['pathParameters']['article_id'],
         user_id=self.event['requestContext']['authorizer']['claims']
         ['cognito:username'])
 def validate_params(self):
     ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())
     validate(self.params, self.get_schema())
     self.params['start'] = self.params.get('start', 0)
     self.params['end'] = self.params.get('end', 5)
     count = self.params['end'] - self.params['start']
     if count > 100:
         raise ValidationError('displayed items are over 100')
     if count < 1:
         raise ValidationError('displayed items are less than 1')
Exemple #7
0
    def validate_params(self):
        params = self.event.get('pathParameters')

        if params is None:
            raise ValidationError('pathParameters is required')

        if self.event.get('queryStringParameters') is not None:
            params.update(self.event.get('queryStringParameters'))
        ParameterUtil.cast_parameter_to_int(params, self.get_schema())

        validate(params, self.get_schema())
Exemple #8
0
    def validate_params(self):
        ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())

        validate(self.params, self.get_schema())
Exemple #9
0
 def validate_params(self):
     ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())
     self.params['tags'] = self.event[
         'multiValueQueryStringParameters'].get('tags')
     validate(self.params, self.get_schema())
Exemple #10
0
 def validate_params(self):
     UserUtil.verified_phone_and_email(self.event)
     ParameterUtil.cast_parameter_to_int(self.params, self.get_schema())
     validate(self.params, self.get_schema())