def test_process_credentials_regex(self): fake_req = mock.MagicMock() fake_resp = mock.MagicMock() cors = CORS(allow_credentials_origins_regex='.*\.rackspace\..*') cors._set_allow_credentials = mock.Mock() self.assertEqual( cors._process_credentials(fake_req, fake_resp, 'www.rackspace.com'), True) cors._set_allow_credentials.assert_called_once_with(fake_resp)
def test_process_credentials_disallow(self): fake_req = mock.MagicMock() fake_resp = mock.MagicMock() cors = CORS(allow_credentials_origins_list=['not_rackspace'], allow_credentials_origins_regex='.*\.rackspace\..*') cors._set_allow_credentials = mock.Mock() self.assertEqual( cors._process_credentials(fake_req, fake_resp, 'some_other_domain.lan'), False) self.assertEqual(cors._set_allow_credentials.call_count, 0)