def test_method_not_allowed(self): cors = CORS(allow_all_origins=True, allow_methods_list=['GET']) cors._get_requested_headers = mock.Mock(return_value=True) cors._process_allow_headers = mock.Mock() headers = [('origin', 'rackspace.com')] self.simulate_cors_request(cors, headers=headers, preflight=True, preflight_method='POST') self.assertEqual(cors._get_requested_headers.call_count, 1) self.assertEqual(cors._process_allow_headers.call_count, 0)
def test_no_requested_method(self): cors = CORS(allow_all_origins=True) cors._get_requested_headers = mock.Mock() cors._process_origin = mock.Mock(return_value=True) headers = [('origin', 'rackspace.com')] self.simulate_cors_request(cors, headers=headers, preflight=True, add_request_method=False) self.assertEqual(cors._process_origin.call_count, 1) self.assertEqual(cors._get_requested_headers.call_count, 0)