def test_no_credentials(self): with pytest.raises(ClickException) as e: configure.get_credential("test") assert e.value.message == ( "Provide API credential test. " "Either by using `elisctl configure`, or environment variable ELIS_TEST." )
def test_get_credential_from_file(self, isolated_cli_runner, configuration_path): with isolated_cli_runner.isolation(): configuration_path.parent.mkdir() config = configparser.RawConfigParser() config["default"] = {"test": "test%"} with configuration_path.open("w") as f: config.write(f) result = configure.get_credential("test") assert "test%" == result
def test_get_credential_from_env(self, isolated_cli_runner): with isolated_cli_runner.isolation(): result = configure.get_credential("test") assert "test" == result
def url(self) -> str: if self._url is None: _url = get_credential("url", self._profile).rstrip("/") self._url = f'{_url}{"/v1" if self._use_api_version else ""}' return self._url
def password(self) -> str: if self._password is None: self._password = get_credential("password", self._profile) return self._password
def user(self) -> str: if self._user is None: self._user = get_credential("username", self._profile) return self._user