def execute(self): if self.args["--describe"]: envs = login_lib.get_env_values() env_data = [[ envs['username'], envs['auth_url'], envs['project_id'], envs['user_domain_name'] ]] if len(env_data) == 0: utils.log_err("No Data...") print(self.__doc__) exit() print( tabulate(env_data, headers=[ "Username", "Auth URL", "Project ID", "Domain Name" ], tablefmt="grid")) exit() if (self.args["--domain"] and self.args["--keystone-url"]): try: username = self.args['--username'] auth_url = self.args['--keystone-url'] user_domain_name = self.args['--domain'] login_lib.do_login(auth_url=auth_url, user_domain_name=user_domain_name, username=username) except Exception as e: utils.log_err(e) if (not self.args["--domain"] and not self.args["--keystone-url"]): login_lib.do_login()
def execute(self): if self.args["--describe"]: envs = login_lib.get_env_values() try: env_data = [] for env in envs: data = [ env["username"], env["region"], env["name"], env["auth_url"], env["project_id"], env["user_domain_name"], env["status"], ] env_data.append(data) except: exit() if len(env_data) == 0: utils.log_err("No Data...") print(self.__doc__) exit() print( tabulate( env_data, headers=[ "Username", "Region", "Name", "Auth URL", "Project ID", "Domain Name", "Status", ], tablefmt="grid", )) exit() if not self.args["--region"] and not self.args["--username"]: login_lib.do_login() else: login_lib.do_login(username=self.args["--username"], region=self.args["--region"])
def test_do_login(self, monkeypatch): login.load_env_file() username = os.environ.get('OS_USERNAME') passwd = os.environ.get('OS_PASSWORD') # give value to input() prompt monkeypatch.setattr('builtins.input', lambda x: username) monkeypatch.setattr('getpass.getpass', lambda x: passwd) # return True is login succeed output = login.do_login() assert output == True
def test_do_login(self, monkeypatch): login.load_env_file() username = os.environ.get('OS_USERNAME') passwd = os.environ.get('OS_PASSWORD') # give value to input() prompt monkeypatch.setattr('builtins.input', lambda x: username) monkeypatch.setattr('getpass.getpass', lambda x: passwd) # return True is login succeed output = login.do_login() assert output == True
def execute(self): login_lib.do_login()
def test_do_login(self): output = login.do_login() self.assertTrue(output)
def execute(self): return login_lib.do_login()