From 9ebe7cb7a629012bcf4a51e6f20452a413f7d91e Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Fri, 26 Sep 2025 09:52:59 +0800 Subject: [PATCH 1/5] refactor: use three componet --- executor/python_executor/credential.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/executor/python_executor/credential.py b/executor/python_executor/credential.py index e190345..7674e11 100644 --- a/executor/python_executor/credential.py +++ b/executor/python_executor/credential.py @@ -8,17 +8,22 @@ def __init__(self, type: str, value: str): def generate_credential_input(credential_path: str) -> CredentialInput | None: """Generate a CredentialInput from a credential path string. - The credential path should be in the format `${{OO_CREDENTIAL:type,id}}`. If the format is incorrect, + The credential path should be in the format `${{OO_CREDENTIAL:type,name,id}}`. If the format is incorrect, the function returns None. """ if not (credential_path.startswith("${{OO_CREDENTIAL:") and credential_path.endswith("}}")): + # logger warning("Credential path format is incorrect. Expected to start with '${{OO_CREDENTIAL:' and end with '}}'.") + return None + + if credential_path.count(",") != 3: + # logger warning("Credential path format is incorrect. Expected exactly three commas.") return None credential_path = credential_path.removeprefix("${{OO_CREDENTIAL:").removesuffix("}}") if credential_path: try: - type, id = credential_path.split(",", maxsplit=1) + type, name, id = credential_path.split(",", maxsplit=2) return CredentialInput(type, id) except ValueError: return None From 58e78f5e780c1fea9c22ed9009de6260e4983a77 Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Fri, 26 Sep 2025 09:54:18 +0800 Subject: [PATCH 2/5] refactor: rename field --- executor/python_executor/credential.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/python_executor/credential.py b/executor/python_executor/credential.py index 7674e11..3f3b848 100644 --- a/executor/python_executor/credential.py +++ b/executor/python_executor/credential.py @@ -1,9 +1,9 @@ from typing import Any, Dict from oocana import InputHandleDef class CredentialInput: - def __init__(self, type: str, value: str): + def __init__(self, type: str, id: str): self.type = type - self.value = value + self.id = id def generate_credential_input(credential_path: str) -> CredentialInput | None: """Generate a CredentialInput from a credential path string. From 0a12e47a4d5b2584643cd8fc460f7c4f2f2020d7 Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Fri, 26 Sep 2025 09:54:28 +0800 Subject: [PATCH 3/5] test: update test case --- executor/tests/test_credential.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/executor/tests/test_credential.py b/executor/tests/test_credential.py index 6b59317..d030f84 100644 --- a/executor/tests/test_credential.py +++ b/executor/tests/test_credential.py @@ -3,7 +3,7 @@ from oocana import InputHandleDef from typing import cast -ORIGIN_VALUE = "Custom,credential_id" +ORIGIN_VALUE = "Custom,credential_name,credential_id" class TestCredential(unittest.TestCase): @@ -33,7 +33,7 @@ def test_replace_credential(self): cred_input = v.get("c") self.assertIsInstance(cred_input, CredentialInput) self.assertEqual(cred_input.type, "Custom") - self.assertEqual(cred_input.value, "credential_id") + self.assertEqual(cred_input.id, "credential_id") def test_credential_without_content_media(self): @@ -70,20 +70,20 @@ def test_credential_in_other_string(self): def test_generate_credential_input_valid(self): """Test valid credential input generation""" - result = generate_credential_input("${{OO_CREDENTIAL:AWS,my_credential_id}}") + result = generate_credential_input("${{OO_CREDENTIAL:AWS,my_credential_name,my_credential_id}}") self.assertIsInstance(result, CredentialInput) result = cast(CredentialInput, result) self.assertEqual(result.type, "AWS") - self.assertEqual(result.value, "my_credential_id") + self.assertEqual(result.id, "my_credential_id") def test_generate_credential_input_invalid_format(self): """Test invalid credential input format""" # Missing prefix - result = generate_credential_input("AWS,my_credential_id") + result = generate_credential_input("AWS,my_credential_name,my_credential_id") self.assertIsNone(result) # Missing suffix - result = generate_credential_input("${{OO_CREDENTIAL:AWS,my_credential_id") + result = generate_credential_input("${{OO_CREDENTIAL:AWS,my_credential_name,my_credential_id") self.assertIsNone(result) # Wrong prefix @@ -98,5 +98,9 @@ def test_generate_credential_input_invalid_format(self): result = generate_credential_input("${{OO_CREDENTIAL:AWS}}") self.assertIsNone(result) + # Only two parameters (missing third) + result = generate_credential_input("${{OO_CREDENTIAL:AWS,my_credential}}") + self.assertIsNone(result) + if __name__ == '__main__': unittest.main() \ No newline at end of file From ae7717f3e03e7d510b0adf0cde2c2d8b6448e8bf Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Fri, 26 Sep 2025 09:57:42 +0800 Subject: [PATCH 4/5] fix count --- executor/python_executor/credential.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/python_executor/credential.py b/executor/python_executor/credential.py index 3f3b848..82a82f5 100644 --- a/executor/python_executor/credential.py +++ b/executor/python_executor/credential.py @@ -16,8 +16,8 @@ def generate_credential_input(credential_path: str) -> CredentialInput | None: # logger warning("Credential path format is incorrect. Expected to start with '${{OO_CREDENTIAL:' and end with '}}'.") return None - if credential_path.count(",") != 3: - # logger warning("Credential path format is incorrect. Expected exactly three commas.") + if credential_path.count(",") != 2: + # logger warning("Credential path format is incorrect. Expected exactly two commas.") return None credential_path = credential_path.removeprefix("${{OO_CREDENTIAL:").removesuffix("}}") From 88b70fcad5010c6015a4369e54fe993eaf00d104 Mon Sep 17 00:00:00 2001 From: leavesster <11785335+leavesster@users.noreply.github.com> Date: Fri, 26 Sep 2025 10:02:10 +0800 Subject: [PATCH 5/5] ignore name --- executor/python_executor/credential.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/python_executor/credential.py b/executor/python_executor/credential.py index 82a82f5..299cd7a 100644 --- a/executor/python_executor/credential.py +++ b/executor/python_executor/credential.py @@ -23,7 +23,7 @@ def generate_credential_input(credential_path: str) -> CredentialInput | None: credential_path = credential_path.removeprefix("${{OO_CREDENTIAL:").removesuffix("}}") if credential_path: try: - type, name, id = credential_path.split(",", maxsplit=2) + type, _name, id = credential_path.split(",", maxsplit=2) return CredentialInput(type, id) except ValueError: return None