diff --git a/actions/gcp-gsm-parse-secrets/main.py b/actions/gcp-gsm-parse-secrets/main.py index dda015200..81ddc060d 100644 --- a/actions/gcp-gsm-parse-secrets/main.py +++ b/actions/gcp-gsm-parse-secrets/main.py @@ -55,16 +55,16 @@ def main( # Deduplicate the input secrets input_secrets = set(input_secrets.splitlines()) - output = "" + output = [] parsed_secret_names = [] for secret in input_secrets: - parsed_secret, parsed_secret_name = ( - parse_secret(secret, gcp_project, github_output_delimter) + "\n" + parsed_secret, parsed_secret_name = parse_secret( + secret, gcp_project, github_output_delimter ) - output += parsed_secret + output.append(parsed_secret) parsed_secret_names.append(parsed_secret_name) - set_github_action_output("secrets-list", output, github_output_delimter) + set_github_action_output("secrets-list", "\n".join(output), github_output_delimter) set_github_action_output( "secret-names", ",".join(parsed_secret_names), github_output_delimter ) diff --git a/actions/gcp-gsm-parse-secrets/tests.py b/actions/gcp-gsm-parse-secrets/tests.py index 66fee5679..32ca5c52f 100644 --- a/actions/gcp-gsm-parse-secrets/tests.py +++ b/actions/gcp-gsm-parse-secrets/tests.py @@ -2,17 +2,36 @@ from main import parse_secret + class TestParseSecret(unittest.TestCase): def test_parse_secret(self): - self.assertEqual(parse_secret("secret_name", "project_name"), "SECRET_NAME:project_name/secret_name") - self.assertEqual(parse_secret("secret_name/version", "project_name"), "SECRET_NAME:project_name/secret_name/version") - self.assertEqual(parse_secret("123-456", "project_name"), "123_456:project_name/123-456") - self.assertEqual(parse_secret("123___123___123", "project_name"), "123_123_123:project_name/123___123___123") - self.assertEqual(parse_secret("i-like_trains__why_this?", "project_name"), "I_LIKE_TRAINS_WHY_THIS:project_name/i-like_trains__why_this?") + self.assertEqual( + parse_secret("secret_name", "project_name")[0], + "SECRET_NAME:project_name/secret_name", + ) + self.assertEqual( + parse_secret("secret_name/version", "project_name")[0], + "SECRET_NAME:project_name/secret_name/version", + ) + self.assertEqual( + parse_secret("123-456", "project_name")[0], "123_456:project_name/123-456" + ) + self.assertEqual( + parse_secret("123___123___123", "project_name")[0], + "123_123_123:project_name/123___123___123", + ) + self.assertEqual( + parse_secret("i-like_trains__why_this?", "project_name")[0], + "I_LIKE_TRAINS_WHY_THIS:project_name/i-like_trains__why_this?", + ) def test_parse_secret_special(self): # FIXME: this test is failing and i dont know why - self.assertEqual(parse_secret("123&&123()123__123*__*_123", "project_name"), "123_123_123_123:project_name/123&&123()123__123*__*_123") + self.assertEqual( + parse_secret("123&&123()123__123*__*_123", "project_name")[0], + "123_123_123_123:project_name/123&&123()123__123*__*_123", + ) + -if __name__ == '__main__': - unittest.main() \ No newline at end of file +if __name__ == "__main__": + unittest.main()