Пример #1
0
    def test_loading_v2(self):
        section = uuid.uuid4().hex
        auth_url = uuid.uuid4().hex
        username = uuid.uuid4().hex
        password = uuid.uuid4().hex
        trust_id = uuid.uuid4().hex
        tenant_id = uuid.uuid4().hex

        self.conf_fixture.config(auth_section=section, group=self.GROUP)
        loading.register_auth_conf_options(self.conf_fixture.conf,
                                           group=self.GROUP)

        opts = loading.get_auth_plugin_conf_options(v2.Password())
        self.conf_fixture.register_opts(opts, group=section)

        self.conf_fixture.config(auth_type=self.V2PASS,
                                 auth_url=auth_url,
                                 username=username,
                                 password=password,
                                 trust_id=trust_id,
                                 tenant_id=tenant_id,
                                 group=section)

        a = loading.load_auth_from_conf_options(self.conf_fixture.conf,
                                                self.GROUP)

        self.assertEqual(auth_url, a.auth_url)
        self.assertEqual(username, a.username)
        self.assertEqual(password, a.password)
        self.assertEqual(trust_id, a.trust_id)
        self.assertEqual(tenant_id, a.tenant_id)
Пример #2
0
    def test_get_named(self):
        loaded_opts = loading.get_plugin_options('v2password')
        plugin_opts = v2.Password().get_options()

        loaded_names = set([o.name for o in loaded_opts])
        plugin_names = set([o.name for o in plugin_opts])

        self.assertEqual(plugin_names, loaded_names)
Пример #3
0
    def _load_auth_plugin(self):
        if self.admin_auth:
            return self.admin_auth
        self.auth_plugin = ks_loading.load_auth_from_conf_options(
            CONF, self.group)

        if self.deprecated_opts_for_v2 and not self.auth_plugin:
            LOG.warn(_LW("Not specifying auth options is deprecated"))
            self.auth_plugin = v2.Password().load_from_options(
                **self.deprecated_opts_for_v2)

        if self.auth_plugin:
            return self.auth_plugin

        msg = _('Cannot load auth plugin for %s') % self.group
        raise self.exception_module.Unauthorized(message=msg)