import quantum.common.utils as utils
from quantum.openstack.common import policy
-
_POLICY_PATH = None
_POLICY_CACHE = {}
def reset():
global _POLICY_PATH
+ global _POLICY_CACHE
_POLICY_PATH = None
_POLICY_CACHE = {}
policy.reset()
real_target = _build_target(action, target, plugin, context)
match_list = _build_match_list(action, real_target)
credentials = context.to_dict()
+
policy.enforce(match_list, real_target, credentials,
exceptions.PolicyNotAuthorized, action=action)
'application/json': json_deserializer,
}
- plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)
+ if not plugin:
+ plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)
# Create the default configurations
args = ['--config-file', etcdir('quantum.conf.test')]
# If test_config specifies some config-file, use it, as well
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from quantum.tests.unit import test_db_plugin as test_plugin
+
+
+class LinuxBridgePluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
+
+ _plugin_name = ('quantum.plugins.linuxbridge.'
+ 'lb_quantum_plugin.LinuxBridgePluginV2')
+
+ def setUp(self):
+ super(LinuxBridgePluginV2TestCase, self).setUp(self._plugin_name)
+
+
+class TestLinuxBridgeBasicGet(test_plugin.TestBasicGet,
+ LinuxBridgePluginV2TestCase):
+ pass
+
+
+class TestLinuxBridgeV2HTTPResponse(test_plugin.TestV2HTTPResponse,
+ LinuxBridgePluginV2TestCase):
+ pass
+
+
+class TestLinuxBridgePortsV2(test_plugin.TestPortsV2,
+ LinuxBridgePluginV2TestCase):
+ pass
+
+
+class TestLinuxBridgeNetworksV2(test_plugin.TestNetworksV2,
+ LinuxBridgePluginV2TestCase):
+ pass
+
+
+class TestLinuxBridgeSubnetsV2(test_plugin.TestSubnetsV2,
+ LinuxBridgePluginV2TestCase):
+ pass
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from quantum.tests.unit import test_db_plugin as test_plugin
+
+
+class NecPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
+
+ _plugin_name = 'quantum.plugins.nec.nec_plugin.NECPluginV2'
+
+ def setUp(self):
+ super(NecPluginV2TestCase, self).setUp(self._plugin_name)
+
+
+class TestNecBasicGet(test_plugin.TestBasicGet, NecPluginV2TestCase):
+ pass
+
+
+class TestNecV2HTTPResponse(test_plugin.TestV2HTTPResponse,
+ NecPluginV2TestCase):
+ pass
+
+
+class TestNecPortsV2(test_plugin.TestPortsV2, NecPluginV2TestCase):
+ pass
+
+
+class TestNecNetworksV2(test_plugin.TestNetworksV2, NecPluginV2TestCase):
+ pass
+
+
+class TestNecSubnetsV2(test_plugin.TestSubnetsV2, NecPluginV2TestCase):
+ pass
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+
+import mock
+
+import quantum.common.test_lib as test_lib
+from quantum.plugins.nicira.nicira_nvp_plugin.tests import fake_nvpapiclient
+import quantum.tests.unit.test_db_plugin as test_plugin
+
+NICIRA_PATH = '../../plugins/nicira/nicira_nvp_plugin'
+NICIRA_PKG_PATH = 'quantum.plugins.nicira.nicira_nvp_plugin'
+
+
+class NiciraPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
+
+ _plugin_name = ('%s.QuantumPlugin.NvpPluginV2' % NICIRA_PKG_PATH)
+
+ def setUp(self):
+ config_file_path = os.path.abspath('%s/tests/nvp.ini.test'
+ % NICIRA_PATH)
+ test_lib.test_config['config_files'] = [config_file_path]
+ # mock nvp api client
+ fc = fake_nvpapiclient.FakeClient(os.path.abspath('%s/tests'
+ % NICIRA_PATH))
+ self.mock_nvpapi = mock.patch('%s.NvpApiClient.NVPApiHelper'
+ % NICIRA_PKG_PATH, autospec=True)
+ instance = self.mock_nvpapi.start()
+ instance.return_value.login.return_value = "the_cookie"
+
+ def _fake_request(*args, **kwargs):
+ return fc.fake_request(*args, **kwargs)
+
+ instance.return_value.request.side_effect = _fake_request
+ super(NiciraPluginV2TestCase, self).setUp(self._plugin_name)
+
+ def tearDown(self):
+ super(NiciraPluginV2TestCase, self).tearDown()
+ self.mock_nvpapi.stop()
+
+
+class TestNiciraBasicGet(test_plugin.TestBasicGet, NiciraPluginV2TestCase):
+ pass
+
+
+class TestNiciraV2HTTPResponse(test_plugin.TestV2HTTPResponse,
+ NiciraPluginV2TestCase):
+ pass
+
+
+class TestNiciraPortsV2(test_plugin.TestPortsV2, NiciraPluginV2TestCase):
+ pass
+
+
+class TestNiciraNetworksV2(test_plugin.TestNetworksV2,
+ NiciraPluginV2TestCase):
+ pass
+
+
+class TestNiciraSubnetsV2(test_plugin.TestSubnetsV2, NiciraPluginV2TestCase):
+ pass
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from quantum.tests.unit import test_db_plugin as test_plugin
+
+
+class OpenvswitchPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
+
+ _plugin_name = ('quantum.plugins.openvswitch.'
+ 'ovs_quantum_plugin.OVSQuantumPluginV2')
+
+ def setUp(self):
+ super(OpenvswitchPluginV2TestCase, self).setUp(self._plugin_name)
+
+
+class TestOpenvswitchBasicGet(test_plugin.TestBasicGet,
+ OpenvswitchPluginV2TestCase):
+ pass
+
+
+class TestOpenvswitchV2HTTPResponse(test_plugin.TestV2HTTPResponse,
+ OpenvswitchPluginV2TestCase):
+ pass
+
+
+class TestOpenvswitchPortsV2(test_plugin.TestPortsV2,
+ OpenvswitchPluginV2TestCase):
+ pass
+
+
+class TestOpenvswitchNetworksV2(test_plugin.TestNetworksV2,
+ OpenvswitchPluginV2TestCase):
+ pass
+
+
+class TestOpenvswitchSubnetsV2(test_plugin.TestSubnetsV2,
+ OpenvswitchPluginV2TestCase):
+ pass
def tearDown(self):
self.patcher.stop()
+ quantum.policy.reset()
def test_nonadmin_write_on_private_returns_403(self):
action = "update_network"
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import mock
+
+from quantum.tests.unit import test_db_plugin as test_plugin
+
+
+class RyuPluginV2TestCase(test_plugin.QuantumDbPluginV2TestCase):
+
+ _plugin_name = 'quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPluginV2'
+
+ def _patch_fake_ryu_client(self):
+ ryu_mod = mock.Mock()
+ ryu_app_mod = ryu_mod.app
+ ryu_app_client = ryu_app_mod.client
+ rest_nw_id = ryu_app_mod.rest_nw_id
+ rest_nw_id.NW_ID_EXTERNAL = '__NW_ID_EXTERNAL__'
+ rest_nw_id.NW_ID_UNKNOWN = '__NW_ID_UNKNOWN__'
+ return mock.patch.dict('sys.modules',
+ {'ryu': ryu_mod,
+ 'ryu.app': ryu_app_mod,
+ 'ryu.app.client': ryu_app_client,
+ 'ryu.app.rest_nw_id': rest_nw_id})
+
+ def setUp(self):
+ self.ryu_patcher = self._patch_fake_ryu_client()
+ self.ryu_patcher.start()
+ super(RyuPluginV2TestCase, self).setUp(self._plugin_name)
+
+
+class TestRyuBasicGet(test_plugin.TestBasicGet, RyuPluginV2TestCase):
+ pass
+
+
+class TestRyuV2HTTPResponse(test_plugin.TestV2HTTPResponse,
+ RyuPluginV2TestCase):
+ pass
+
+
+class TestRyuPortsV2(test_plugin.TestPortsV2, RyuPluginV2TestCase):
+ pass
+
+
+class TestRyuNetworksV2(test_plugin.TestNetworksV2, RyuPluginV2TestCase):
+ pass
+
+
+class TestRyuSubnetsV2(test_plugin.TestSubnetsV2, RyuPluginV2TestCase):
+ pass