def test_bad_url(env_vars, authorizer): bad_server = SecretServer( f"https://{env_vars['tenant']}.secretservercloud.com/nonexistent", authorizer, ) with pytest.raises(SecretServerError): bad_server.get_secret(env_vars["secret_id"])
def tss_backend(**kwargs): authorizer = PasswordGrantAuthorizer(kwargs['server_url'], kwargs['username'], kwargs['password']) secret_server = SecretServer(kwargs['server_url'], authorizer) secret_dict = secret_server.get_secret(kwargs['secret_id']) secret = ServerSecret(**secret_dict) return secret.fields[kwargs['secret_field']]
def test_bad_url(server_json): bad_server = SecretServer( f"https://{server_json['tenant']}.secretservercloud.com/nonexistent", server_json["username"], server_json["password"], ) with pytest.raises(SecretServerError): bad_server.get_secret(1)
def __init__(self, **server_parameters): super(TSSClientV1, self).__init__() authorizer = self._get_authorizer(**server_parameters) self._client = SecretServer( server_parameters["base_url"], authorizer, server_parameters["api_path_uri"] )
def __init__(self, **server_parameters): super(TSSClientV0, self).__init__() if server_parameters.get("domain"): raise AnsibleError("The 'domain' option requires 'python-tss-sdk' version 1.0.0 or greater") self._client = SecretServer( server_parameters["base_url"], server_parameters["username"], server_parameters["password"], server_parameters["api_path_uri"], server_parameters["token_path_uri"], )
def Client(server_parameters): return SecretServer(**server_parameters)
from thycotic.secrets.server import SecretServer secret_server = SecretServer("https://secretserverurl/SecretServer", "username", "password", "domain") secret = secret_server.get_secret(1) print(secret)
def test_access_token_authorizer(env_vars, authorizer): assert SecretServer( f"https://{env_vars['tenant']}.secretservercloud.com/", AccessTokenAuthorizer(authorizer.get_access_token()), ).get_secret(env_vars["secret_id"])["id"] == int(env_vars["secret_id"])