def test_check_body_for_errors_pass(self):
     request = RequestClient(mock_data.apigateway_event(), None)
     response = ResponseClient()
     validator = RequestValidator(request, response, self.OPENAPI)
     validator._check_body_for_errors('v1-test-request',
                                      mock_data.valid_request())
     self.assertFalse(response.has_errors)
 def test_validate_params_fail(self):
     request = RequestClient(mock_data.apigateway_event(), None)
     response = ResponseClient()
     validator = RequestValidator(request, response, self.OPENAPI)
     validator._available_fields(['test_path'],
                                 {'test_path_fail': 'test_value'}, 'params')
     self.assertTrue(response.has_errors)
 def test_validate_path_params_pass(self):
     request = RequestClient(mock_data.apigateway_event(), None)
     response = ResponseClient()
     validator = RequestValidator(request, response, self.OPENAPI)
     validator._required_fields(['test_path'], {'test_path': 'test_value'},
                                'path parameters')
     self.assertFalse(response.has_errors)
 def test_validate_headers_fail(self):
     request = RequestClient(mock_data.apigateway_event(), None)
     response = ResponseClient()
     validator = RequestValidator(request, response, self.OPENAPI)
     validator._required_fields(['test-key'], {'test-key-fail': '123456'},
                                'headers')
     self.assertTrue(response.has_errors)
예제 #5
0
 def setUp(self):
     self.RequestClient = RequestClient(mock_data.apigateway_event(), None)
     self.RequestClientGraphQL = RequestClient(
         mock_data.apigateway_event_graphql(), None)
     self.RequestClientGraphQLEncoded = RequestClient(
         mock_data.apigateway_event_graphql(True), None)
     self.RequestClientFormEncoded = RequestClient(
         mock_data.apigateway_event_form_encoded(), None)
예제 #6
0
 def test_with_validation_require_headers_fail(self):
     response = handle_validation_required_headers_fail(mock_data.apigateway_event(), None)
     self.assertEqual(response['statusCode'], 400)
예제 #7
0
 def test_with_validation_require_headers(self):
     response = handle_validation_required_headers(mock_data.apigateway_event(), None)
     self.assertEqual(response['statusCode'], 200)
     self.assertEqual(response['body'], "Hello")
예제 #8
0
 def test_no_authorization(self):
     response = handle_no_validation(mock_data.apigateway_event(), None)
     self.assertEqual(response['statusCode'], 200)
     self.assertEqual(response['body'], "Hello")
 def test_get_schema(self):
     request = RequestClient(mock_data.apigateway_event(), None)
     response = ResponseClient()
     validator = RequestValidator(request, response, self.OPENAPI)
     schema = validator._get_combined_schema('v1-test-request')
     self.assertDictEqual(schema, mock_data.request_schema())