Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make pluggable auth tests work in all environments #1114

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions tests/test_pluggable.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,10 @@ def test_retrieve_subject_token_expired_token(self):
assert excinfo.match(r"The token returned by the executable is expired.")

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_file_cache(self):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = "actual_output_file"
def test_retrieve_subject_token_file_cache(self, tmpdir):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = tmpdir.join(
"actual_output_file"
)
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE = {
"command": "command",
"timeout_millis": 30000,
Expand Down Expand Up @@ -472,8 +474,10 @@ def test_retrieve_subject_token_no_file_cache(self):
assert subject_token == self.EXECUTABLE_OIDC_TOKEN

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_file_cache_value_error_report(self):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = "actual_output_file"
def test_retrieve_subject_token_file_cache_value_error_report(self, tmpdir):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = tmpdir.join(
"actual_output_file"
)
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE = {
"command": "command",
"timeout_millis": 30000,
Expand All @@ -499,8 +503,10 @@ def test_retrieve_subject_token_file_cache_value_error_report(self):
os.remove(ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE)

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_file_cache_refresh_error_retry(self):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = "actual_output_file"
def test_retrieve_subject_token_file_cache_refresh_error_retry(self, tmpdir):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = tmpdir.join(
"actual_output_file"
)
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE = {
"command": "command",
"timeout_millis": 30000,
Expand Down Expand Up @@ -637,7 +643,7 @@ def test_retrieve_subject_token_missing_error_code_message(self):

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_without_expiration_time_should_fail_when_output_file_specified(
self
self,
):
EXECUTABLE_SUCCESSFUL_OIDC_RESPONSE = {
"version": 1,
Expand Down Expand Up @@ -665,9 +671,11 @@ def test_retrieve_subject_token_without_expiration_time_should_fail_when_output_

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_without_expiration_time_should_fail_when_retrieving_from_output_file(
self
self, tmpdir
):
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = "actual_output_file"
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE_OUTPUT_FILE = tmpdir.join(
"actual_output_file"
)
ACTUAL_CREDENTIAL_SOURCE_EXECUTABLE = {
"command": "command",
"timeout_millis": 30000,
Expand All @@ -692,7 +700,7 @@ def test_retrieve_subject_token_without_expiration_time_should_fail_when_retriev

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_without_expiration_time_should_pass_when_output_file_not_specified(
self
self,
):
EXECUTABLE_SUCCESSFUL_OIDC_RESPONSE = {
"version": 1,
Expand Down