def test_discover_auth_system_options(self, mock_iter_entry_points): """Test that we can load the auth system options.""" class FakePlugin(base.BaseAuthPlugin): @staticmethod def add_opts(parser): parser.add_argument('--auth_system_opt', default=False, action='store_true', help="Fake option") return parser def authenticate(self, client): pass class MockEntrypoint(pkg_resources.EntryPoint): def load(self): return FakePlugin mock_iter_entry_points.side_effect = lambda _t: [ MockEntrypoint("fake", "fake", ["FakePlugin"])] parser = argparse.ArgumentParser() base.discover_auth_systems() base.load_auth_system_opts(parser) opts, args = parser.parse_known_args(['--auth_system_opt']) self.assertTrue(opts.auth_system_opt)
def test_load_auth_system_opts(self): self.useFixture(fixtures.MonkeyPatch( "os.environ", {"OS_TENANT_NAME": "fake-project", "OS_USERNAME": "******"})) parser = argparse.ArgumentParser() base.discover_auth_systems() base.load_auth_system_opts(parser) options = parser.parse_args( ["--os-auth-url=fake-url", "--os_auth_system=fake-system"]) self.assertTrue(options.os_tenant_name, "fake-project") self.assertTrue(options.os_username, "fake-username") self.assertTrue(options.os_auth_url, "fake-url") self.assertTrue(options.os_auth_system, "fake-system")
def test_discover_auth_system_options(self, mock_mgr_map): """Test that we can load the auth system options.""" class FakePlugin(base.BaseAuthPlugin): @classmethod def add_opts(cls, parser): parser.add_argument('--auth_system_opt', default=False, action='store_true', help="Fake option") def authenticate(self, http_client): pass mock_mgr_map.side_effect = ( lambda func: func(MockEntrypoint("fake", FakePlugin))) parser = argparse.ArgumentParser() base.discover_auth_systems() base.load_auth_system_opts(parser) opts, _args = parser.parse_known_args(['--auth_system_opt']) self.assertTrue(opts.auth_system_opt)