Esempio n. 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"]))
Esempio n. 2
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(inst.config.get("foo"), "bar")
        self.assertFalse(inst.config.get("security_services"))
        self.assertIn(rally_consts.JSON_SCHEMA,
                      inst.CONFIG_SCHEMA.get("$schema"))
        self.assertEqual(False, inst.CONFIG_SCHEMA.get("additionalProperties"))
        self.assertEqual("object", inst.CONFIG_SCHEMA.get("type"))
        props = inst.CONFIG_SCHEMA.get("properties", {})
        self.assertEqual({"type": "array"}, props.get("security_services"))
        self.assertEqual(445, inst.get_order())
        self.assertEqual(CONTEXT_NAME, inst.get_name())
Esempio n. 3
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"])
Esempio n. 4
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")
Esempio n. 5
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(inst.config.get("foo"), "bar")
        self.assertFalse(inst.config.get("security_services"))
        self.assertEqual(445, inst.get_order())
        self.assertEqual(CONTEXT_NAME, inst.get_name())
Esempio n. 6
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"]))