From 8b2c318fde7d4e15e8661d4fd41cadecf8319d99 Mon Sep 17 00:00:00 2001 From: Sean Trantalis Date: Sun, 25 Aug 2024 14:52:18 -0400 Subject: [PATCH 1/6] fix: update kas-registry command with new flag --- xtest/abac.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xtest/abac.py b/xtest/abac.py index c3d925f6..f9ff5ba8 100644 --- a/xtest/abac.py +++ b/xtest/abac.py @@ -3,6 +3,7 @@ import logging import subprocess import sys +import base64 from pydantic import BaseModel from typing import Optional @@ -141,6 +142,10 @@ class KasGrantValue(BaseModel): value_id: str kas_id: Optional[str] = None +class KasPublicKeys(BaseModel): + pem: str + kid: str + alg: int class OpentdfCommandLineTool: @@ -169,8 +174,8 @@ def kas_registry_create(self, url: str, key: str) -> KasEntry: else: with open(key, "r") as file: keydata = file.read() - cmd += [f"--public-key-local={keydata}"] - + keydatab64 = base64.b64encode(keydata.encode()).decode('utf-8') + cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydatab64}", "kid": "1", "alg": 1}}]}}}}'] logger.info(f"kr-create [{' '.join(cmd)}]") process = subprocess.Popen(cmd, stdout=subprocess.PIPE) code = process.wait() From 40281d8a74d901b7c88760804b0b3ffda3b18fd2 Mon Sep 17 00:00:00 2001 From: Sean Trantalis Date: Sun, 25 Aug 2024 14:53:13 -0400 Subject: [PATCH 2/6] fix: update kas registry command to support new public keys flag --- xtest/abac.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtest/abac.py b/xtest/abac.py index f9ff5ba8..613f644c 100644 --- a/xtest/abac.py +++ b/xtest/abac.py @@ -175,7 +175,7 @@ def kas_registry_create(self, url: str, key: str) -> KasEntry: with open(key, "r") as file: keydata = file.read() keydatab64 = base64.b64encode(keydata.encode()).decode('utf-8') - cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydatab64}", "kid": "1", "alg": 1}}]}}}}'] + cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydatab64}", "kid": "r1", "alg": 1}}]}}}}'] logger.info(f"kr-create [{' '.join(cmd)}]") process = subprocess.Popen(cmd, stdout=subprocess.PIPE) code = process.wait() From 92daeceb6ee46e7241906994360e23742c350a16 Mon Sep 17 00:00:00 2001 From: Sean Trantalis Date: Sun, 25 Aug 2024 14:56:05 -0400 Subject: [PATCH 3/6] set tests repo checkout branch for testing --- .github/workflows/xtest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/xtest.yml b/.github/workflows/xtest.yml index a613020d..6c31e6fe 100644 --- a/.github/workflows/xtest.yml +++ b/.github/workflows/xtest.yml @@ -38,6 +38,7 @@ jobs: with: repository: opentdf/tests path: otdftests # use different name bc other repos might have tests directories + ref: kas-registry-fix - name: Set up Node 20 uses: actions/setup-node@v3 with: From 730e310a69a5c891426b9ba544e4cbd82a99c49a Mon Sep 17 00:00:00 2001 From: Sean Trantalis Date: Sun, 25 Aug 2024 15:07:20 -0400 Subject: [PATCH 4/6] don't base64 encode pem --- xtest/abac.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xtest/abac.py b/xtest/abac.py index 613f644c..d3d7556d 100644 --- a/xtest/abac.py +++ b/xtest/abac.py @@ -174,8 +174,7 @@ def kas_registry_create(self, url: str, key: str) -> KasEntry: else: with open(key, "r") as file: keydata = file.read() - keydatab64 = base64.b64encode(keydata.encode()).decode('utf-8') - cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydatab64}", "kid": "r1", "alg": 1}}]}}}}'] + cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydata}", "kid": "r1", "alg": 1}}]}}}}'] logger.info(f"kr-create [{' '.join(cmd)}]") process = subprocess.Popen(cmd, stdout=subprocess.PIPE) code = process.wait() From 40faeb6ec54c7ae05d32a8a1563df01d4b7883f2 Mon Sep 17 00:00:00 2001 From: Sean Trantalis Date: Sun, 25 Aug 2024 15:16:55 -0400 Subject: [PATCH 5/6] remove extra config --- xtest/abac.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/xtest/abac.py b/xtest/abac.py index d3d7556d..99ee098d 100644 --- a/xtest/abac.py +++ b/xtest/abac.py @@ -3,7 +3,6 @@ import logging import subprocess import sys -import base64 from pydantic import BaseModel from typing import Optional @@ -142,10 +141,6 @@ class KasGrantValue(BaseModel): value_id: str kas_id: Optional[str] = None -class KasPublicKeys(BaseModel): - pem: str - kid: str - alg: int class OpentdfCommandLineTool: From 6bb6f1e690c4f8d6d3f3de35503608ce3043bca6 Mon Sep 17 00:00:00 2001 From: Dave Mihalcik Date: Mon, 26 Aug 2024 08:26:07 -0400 Subject: [PATCH 6/6] json escape pem content --- xtest/abac.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtest/abac.py b/xtest/abac.py index 99ee098d..d9f75e41 100644 --- a/xtest/abac.py +++ b/xtest/abac.py @@ -169,7 +169,7 @@ def kas_registry_create(self, url: str, key: str) -> KasEntry: else: with open(key, "r") as file: keydata = file.read() - cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem": "{keydata}", "kid": "r1", "alg": 1}}]}}}}'] + cmd += [f'--public-keys={{"cached": {{"keys": [{{"pem":{json.dumps(keydata)}, "kid": "r1", "alg": 1}}]}}}}'] logger.info(f"kr-create [{' '.join(cmd)}]") process = subprocess.Popen(cmd, stdout=subprocess.PIPE) code = process.wait()