Package: secread
Thycotic Secret Server ReaderThis Python module allows to retrive secrets from Thycotic Secret Server.
It utilizes the REST APIsee:https://docs.thycotic.com/ss/10.8.0/api-scripting/rest-api-reference-downloadLicenseMITInstallationInstallation withPyPi:pipinstallsecreadInstallation withpoetry:poetryaddsecreadConfigurationTo configure the module use following environment variables. It is also possible
to provide the file '.env' with the settings# copy the template as environment filecp.env.example.env# Edit configuration filevi.env############################################################################## Settings for Thycotic Secret Server ReaderSECRET_SERVER_SITE='https://pw.example.com/SecretServer'SECRET_SERVER_AUTH_API='/oauth2/token'SECRET_SERVER_USERNAME='apiuser'SECRET_SERVER_PASSWORD='my_password_for_apiuser'# Values for SECRET_SERVER_SSL_VERIFY# - True    server certificate will be verified (Default)# - False   server certificate will be ignored; warning# - Path    path to trusted cerificate bundle e.g. '/etc/ssl/certs/ca-bundle.trust.crt'SECRET_SERVER_SSL_VERIFY='/etc/ssl/certs/ca-bundle.trust.crt'# Default field-items to extract from result.SECRET_SERVER_DEFAULT_SLUGS='["id", "url", "username", "password"]'# SECRET_SERVER_IS_DUMMY (Default: False)# - False: Secert-Server-API is active# - True: The API will not be used. SECRET_SERVER_TEST_DUMMY_RESULT will be returned# SECRET_SERVER_IS_DUMMY=FalseSECRET_SERVER_TEST_DUMMY_RESULT='{"id": "12345", username": "testuser", "password": "testpassword", "url": "https://localhost/SecretServer"}'# 'name' of the secret that is used for testing on live server# TEST_SECRET_NAME='GitLab Token netsearch-ro'DevelopmentThe installation instruction forpoetryis here:https://python-poetry.org/docs/#installationgitclonehttps://github.com/jifox/secret-server-reader.gitcdsecret-server-reader# Set python environment to use for development# poetry env use python3.8# Install the modulepoetryinstall# Execute tests (be sure to configure the system before)poetryrunpytest-vUpdate pypiBefore updating pypi, the version number must be incremented in following files:pyproject.tomlsecread/init.pysecread/tests/test_secread.pypoetrybuild
poetrypublishExamples"""Tests for module secread"""importosimportpytestfromsecreadimport__version__,SecretServerdeftest_version():assert__version__=="0.1.1"@pytest.fixturedefsec_server():returnSecretServer()deftest_default_slugs_is_a_list(sec_server:SecretServer):slugs=sec_server.SECRET_SERVER_DEFAULT_SLUGSassertisinstance(slugs,list)deftest_secretserver(sec_server:SecretServer):token=sec_server.getAuthToken()assertlen(token)>0,"Token could not be read"deftest_get_secret_response_by_name(sec_server:SecretServer):secname=os.getenv("TEST_SECRET_NAME","GitLab Token netsearch-ro")res=sec_server.searchSecretResponse(secname)fields=sec_server.getFieldItemWithSlug(res)assert"username"infields.keys(),"Missing username"assert"password"infields.keys(),"Missing password"deftest_get_secret_by_name(sec_server:SecretServer):secname=os.getenv("TEST_SECRET_NAME","GitLab Token netsearch-ro")res=sec_server.searchSecret(secname)assert"username"inres.keys(),"Missing username"assert"password"inres.keys(),"Missing password"