Skip to content

Commit

Permalink
fix: make pluggable auth tests work in all environments (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScruffyProdigy committed Aug 23, 2022
1 parent 04a9e69 commit bb5c979
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tests/test_pluggable.py
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

0 comments on commit bb5c979

Please sign in to comment.