def test_adapter_filesecrets_from_arg(monkeypatch): monkeypatch.delenv("RPA_SECRET_FILE", raising=False) adapter = FileSecrets(RESOURCES / "secrets.json") secret = adapter.get_secret("windows") assert isinstance(secret, Secret) assert "password" in secret assert secret["password"] == "secret"
def test_adapter_filesecrets_from_env(monkeypatch): monkeypatch.setenv("RPA_SECRET_FILE", str(RESOURCES / "secrets.json")) adapter = FileSecrets() secret = adapter.get_secret("windows") assert isinstance(secret, Secret) assert "password" in secret assert secret["password"] == "secret"
def test_direct_instance_of_file_secret_manager(monkeypatch): monkeypatch.setenv("RPA_SECRET_FILE", "tests/resources/secrets.json") from RPA.Robocloud.Secrets import FileSecrets sm = FileSecrets() secrets_windows = sm.get_secret("windows") secrets_robocloud = sm.get_secret("robocloud") assert secrets_windows["domain"] == "windows" assert secrets_windows["login"] == "robot" assert secrets_windows["password"] == "secret" assert secrets_robocloud["url"] == "http://robocloud.ai/" assert secrets_robocloud["login"] == "robot" assert secrets_robocloud["password"] == "secret"
def test_adapter_filesecrets_unknown_secret(monkeypatch): monkeypatch.setenv("RPA_SECRET_FILE", str(RESOURCES / "secrets.json")) adapter = FileSecrets() with pytest.raises(KeyError): secret = adapter.get_secret("not-exist")
def test_adapter_filesecrets_invalid_file(monkeypatch): monkeypatch.setenv("RPA_SECRET_FILE", str(RESOURCES / "not-a-file.json")) # Should not raise adapter = FileSecrets() assert adapter.data == {}