コード例 #1
0
    def test_setup_security_services_set(self, neutron_network_provider,
                                         mock_manila_scenario):
        ctxt = self._get_context(
            neutron_network_provider=neutron_network_provider)
        inst = manila_security_services.SecurityServices(ctxt)

        inst.setup()

        self.assertEqual(self.TENANTS_AMOUNT, mock_manila_scenario.call_count)
        self.assertEqual(mock_manila_scenario.call_args_list, [
            mock.call({
                "task": inst.task,
                "owner_id": "foo_uuid",
                "config": {
                    "api_versions": []
                },
                "user": user
            }) for user in inst.context["users"] if user["id"] == 0
        ])
        mock_create_security_service = (
            mock_manila_scenario.return_value._create_security_service)
        expected_calls = []
        for ss in self.SECURITY_SERVICES:
            expected_calls.extend([mock.call(**ss), mock.call().to_dict()])
        mock_create_security_service.assert_has_calls(expected_calls)
        self.assertEqual(self.TENANTS_AMOUNT * len(self.SECURITY_SERVICES),
                         mock_create_security_service.call_count)
        self.assertEqual(
            self.TENANTS_AMOUNT,
            len(inst.context["config"][CONTEXT_NAME]["security_services"]))
        for tenant in inst.context["tenants"]:
            self.assertEqual(
                self.TENANTS_AMOUNT,
                len(inst.context["tenants"][tenant][CONTEXT_NAME]
                    ["security_services"]))
コード例 #2
0
    def test_cleanup_security_services_enabled(self, mock_resource_manager):
        ctxt = self._get_context()
        inst = manila_security_services.SecurityServices(ctxt)

        inst.cleanup()

        mock_resource_manager.cleanup.assert_called_once_with(
            names=["manila.security_services"],
            users=ctxt["users"],
            superclass=manila_utils.ManilaScenario,
            task_id="foo_uuid")
コード例 #3
0
    def test_init(self):
        context = {
            "task": mock.MagicMock(),
            "config": {
                CONTEXT_NAME: {
                    "foo": "bar"
                },
                "not_manila": {
                    "not_manila_key": "not_manila_value"
                },
            }
        }

        inst = manila_security_services.SecurityServices(context)

        self.assertEqual("bar", inst.config.get("foo"))
        self.assertFalse(inst.config.get("security_services"))
        self.assertEqual(445, inst.get_order())
        self.assertEqual(CONTEXT_NAME, inst.get_name())
コード例 #4
0
    def test_setup_security_services_not_set(self, mock_manila_scenario):
        ctxt = self._get_context(security_services=[])
        inst = manila_security_services.SecurityServices(ctxt)

        inst.setup()

        self.assertFalse(mock_manila_scenario.called)
        self.assertFalse(
            mock_manila_scenario.return_value._create_security_service.called)
        self.assertIn(CONTEXT_NAME, inst.context["config"])
        self.assertIn("security_services",
                      inst.context["config"][CONTEXT_NAME])
        self.assertEqual(
            0, len(inst.context["config"][CONTEXT_NAME]["security_services"]))
        for tenant in inst.context["tenants"]:
            self.assertEqual(
                0,
                len(inst.context["tenants"][tenant][CONTEXT_NAME]
                    ["security_services"]))