def test_env_aws_retrieve_no_token(self): os.environ.clear() os.environ["AWS_ACCESS_KEY_ID"] = "access" os.environ["AWS_SECRET_ACCESS_KEY"] = "secret" provider = EnvAWS() creds, expiry = provider.retrieve() eq_(creds.access_key, "access") eq_(creds.secret_key, "secret") eq_(creds.session_token, None) eq_(expiry, None)
def test_chain_retrieve(self): # clear environment os.environ.clear() # prepare env for env_aws provider os.environ["AWS_ACCESS_KEY_ID"] = "access_aws" os.environ["AWS_SECRET_ACCESS_KEY"] = "secret_aws" os.environ["AWS_SESSION_TOKEN"] = "token_aws" # prepare env for env_minio os.environ["MINIO_ACCESS_KEY"] = "access_minio" os.environ["MINIO_SECRET_KEY"] = "secret_minio" # create chain provider with env_aws and env_minio providers chain = Chain(providers=[EnvAWS(), EnvMinio()]) # retireve provider (env_aws) has priority creds, expiry = chain.retrieve() # assert provider credentials eq_(creds.access_key, "access_aws") eq_(creds.secret_key, "secret_aws") eq_(creds.session_token, "token_aws") eq_(expiry, None)