def test_cached_session_expired(): now = time() + 2 * DEFAULT_SESSION_DURATION name, token, profile = CachedSession.make_name(), "token", "profile" with envvars(AWS_SESSION_TOKEN=token, AWS_SESSION_NAME=name, AWS_PROFILE=profile): cached_session = CachedSession.from_environment(now=now) assert_that(cached_session, is_(none()))
def test_cached_session_valid(): now = time() name, token, profile = CachedSession.make_name(), "token", "profile" with envvars(AWS_SESSION_TOKEN=token, AWS_SESSION_NAME=name, AWS_PROFILE=profile): cached_session = CachedSession.from_environment(now=now) assert_that(cached_session.name, is_(equal_to(name))) assert_that(cached_session.token, is_(equal_to(token)))
def test_get_profile_name_custom_profile_and_default_profile(): with envvars(AWS_PROFILE="custom", AWS_DEFAULT_PROFILE="other"): assert_that(get_profile_name(), is_(equal_to("custom")))
def test_cached_session_missing_argument(): now = time() token, profile = "token", "profile" with envvars(AWS_SESSION_TOKEN=token, AWS_PROFILE=profile): cached_session = CachedSession.from_environment(now=now) assert_that(cached_session, is_(none()))
def test_get_profile_name_custom_profile(): with envvars(AWS_PROFILE="custom"): assert_that(get_profile_name(), is_(equal_to("custom")))