From 248c08ae0fe167dd0f685a6f25b54da7a63a3e57 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Apr 2022 09:55:50 +0530 Subject: [PATCH 1/9] The Token.py file path is not correct. Rmeoved as its not required --- deployment/scripts/azure/bootstrap.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/deployment/scripts/azure/bootstrap.sh b/deployment/scripts/azure/bootstrap.sh index 0bd15e4..449c19a 100644 --- a/deployment/scripts/azure/bootstrap.sh +++ b/deployment/scripts/azure/bootstrap.sh @@ -1,11 +1,6 @@ +#!/bin/bash if [ -z "$DEPLOYMENTS_BASE_DIR" ]; then export DEPLOYMENTS_BASE_DIR=deployment; fi -#export AZURE_POLICY_SERVICE_URL=https://$AZURE_DNS_NAME/api/policy/v1/policies -BEARER_TOKEN=`python $AZURE_DEPLOYMENTS_SUBDIR/Token.py` -export BEARER_TOKEN=$BEARER_TOKEN - -#python3 $DEPLOYMENTS_BASE_DIR/scripts/BootstrapDefaultPolicies.py -u $AZURE_POLICY_SERVICE_URL - python3 $DEPLOYMENTS_BASE_DIR/scripts/azure/BootstrapBundles.py \ No newline at end of file -- GitLab From bf53cb118441429a2feba73a7ceac08cdc78e180 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 10:08:17 +0530 Subject: [PATCH 2/9] Fixing the logic to chose some default policies to create tar --- deployment/scripts/azure/BootstrapBundles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/scripts/azure/BootstrapBundles.py b/deployment/scripts/azure/BootstrapBundles.py index 3db1dde..a15f593 100644 --- a/deployment/scripts/azure/BootstrapBundles.py +++ b/deployment/scripts/azure/BootstrapBundles.py @@ -20,7 +20,7 @@ class BootstrapBundles: with tarfile.open(tar_name, "w:gz") as tar_handle: for root, dirs, files in os.walk(path): for file in files: - if file.endswith(".rego"): + if file == "legal.rego" or file == "entitlements.rego" or file == "dataauthz.rego": tar_handle.add(os.path.join(root, file)) def upload_bundles(self): -- GitLab From 5b8858511096627455b596953a28f9cf180c7099 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 10:38:53 +0530 Subject: [PATCH 3/9] Debugging failed test case --- tests/integration/test_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index b11917a..5aafc1b 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -17,6 +17,8 @@ def test_fetch_policies(client, token, service_url, data_partition): response = requests.get(service_url, headers={'Authorization': 'Bearer ' + token, 'data-partition-id': data_partition}) + print("token:"+token) + print(service_url) assert response.status_code == 200 # need to standardize the namespaces for bundles and then enable the test -- GitLab From b6b628dfa7d5007d3209824d6898f02d296f0ed2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 10:49:37 +0530 Subject: [PATCH 4/9] Debugging failed test case --- tests/azure/run-integration-tests.sh | 2 +- tests/integration/test_api.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/azure/run-integration-tests.sh b/tests/azure/run-integration-tests.sh index 4c16284..7611adc 100644 --- a/tests/azure/run-integration-tests.sh +++ b/tests/azure/run-integration-tests.sh @@ -20,7 +20,7 @@ echo $DATA_PARTITION svctoken=$(python3 tests/azure/azure_jwt_client.py) echo "Token received" - +echo $svctoken cd tests/integration python3 -m pytest --token=$svctoken --service_url=$AZURE_POLICY_SERVICE_URL --data_partition=$DATA_PARTITION diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 5aafc1b..66d3393 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -17,8 +17,9 @@ def test_fetch_policies(client, token, service_url, data_partition): response = requests.get(service_url, headers={'Authorization': 'Bearer ' + token, 'data-partition-id': data_partition}) - print("token:"+token) - print(service_url) + print("token:"+token); + print(service_url); + print(response.json()); assert response.status_code == 200 # need to standardize the namespaces for bundles and then enable the test -- GitLab From 1c4b6667610679b2008acc7d9b057278e45ed02f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 11:07:20 +0530 Subject: [PATCH 5/9] Debugging failed test case --- tests/azure/azure_jwt_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/azure/azure_jwt_client.py b/tests/azure/azure_jwt_client.py index 18a9bbe..ff40475 100644 --- a/tests/azure/azure_jwt_client.py +++ b/tests/azure/azure_jwt_client.py @@ -25,6 +25,8 @@ def get_azure_id_token(): app = msal.ConfidentialClientApplication(client_id=client_id, authority=authority_uri, client_credential=client_secret) result = app.acquire_token_for_client(scopes=scopes) token = result.get('access_token') + print('Resource Id'); + print(resource_id); print(token); except Exception as e: print(e) -- GitLab From 0e1775aeb078e2789f7840378e2887ee5dede9c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 11:44:51 +0530 Subject: [PATCH 6/9] Debugging failed test case --- devops/template/integration-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/template/integration-tests.yaml b/devops/template/integration-tests.yaml index e69e62c..df9d68e 100644 --- a/devops/template/integration-tests.yaml +++ b/devops/template/integration-tests.yaml @@ -37,7 +37,7 @@ steps: targetType: 'inline' script: | export AZURE_TENANT_ID=$(AZURE_TENANT_ID) - export AZURE_AD_APP_RESOURCE_ID=$(AZURE_AD_APP_RESOURCE_ID) + export AZURE_AD_APP_RESOURCE_ID=$(AZURE_APP_ID) export AZURE_CLIENT_ID=$(INTEGRATION_TESTER) export AZURE_CLIENT_SECRET=$(AZURE_TESTER_SERVICEPRINCIPAL_SECRET) export DATA_PARTITION=$(DATA_PARTITION_ID) -- GitLab From 5a4a035b0844e08ea0ab5089653fe107d6a062e2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 12:00:01 +0530 Subject: [PATCH 7/9] Azure: Debugging failed test case --- tests/azure/azure_jwt_client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/azure/azure_jwt_client.py b/tests/azure/azure_jwt_client.py index ff40475..10ef08f 100644 --- a/tests/azure/azure_jwt_client.py +++ b/tests/azure/azure_jwt_client.py @@ -6,6 +6,7 @@ def get_azure_id_token(): resource_id = os.getenv('AZURE_AD_APP_RESOURCE_ID') client_id = os.getenv('AZURE_CLIENT_ID') client_secret = os.getenv('AZURE_CLIENT_SECRET') + temp = os.getenv('AZURE_APP_ID') if tenant_id is None: print('Please pass tenant Id to generate token') exit(1) @@ -27,6 +28,8 @@ def get_azure_id_token(): token = result.get('access_token') print('Resource Id'); print(resource_id); + print("Temp"); + print(temp); print(token); except Exception as e: print(e) -- GitLab From ad2d048931dee3a19d65b37ad471dfe1765717d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 12:09:27 +0530 Subject: [PATCH 8/9] Azure: Debugging failed test case --- devops/template/integration-tests.yaml | 2 +- tests/azure/azure_jwt_client.py | 5 +---- tests/azure/run-integration-tests.sh | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/devops/template/integration-tests.yaml b/devops/template/integration-tests.yaml index df9d68e..e69e62c 100644 --- a/devops/template/integration-tests.yaml +++ b/devops/template/integration-tests.yaml @@ -37,7 +37,7 @@ steps: targetType: 'inline' script: | export AZURE_TENANT_ID=$(AZURE_TENANT_ID) - export AZURE_AD_APP_RESOURCE_ID=$(AZURE_APP_ID) + export AZURE_AD_APP_RESOURCE_ID=$(AZURE_AD_APP_RESOURCE_ID) export AZURE_CLIENT_ID=$(INTEGRATION_TESTER) export AZURE_CLIENT_SECRET=$(AZURE_TESTER_SERVICEPRINCIPAL_SECRET) export DATA_PARTITION=$(DATA_PARTITION_ID) diff --git a/tests/azure/azure_jwt_client.py b/tests/azure/azure_jwt_client.py index 10ef08f..174ee4e 100644 --- a/tests/azure/azure_jwt_client.py +++ b/tests/azure/azure_jwt_client.py @@ -3,10 +3,9 @@ import msal; def get_azure_id_token(): tenant_id = os.getenv('AZURE_TENANT_ID') - resource_id = os.getenv('AZURE_AD_APP_RESOURCE_ID') + resource_id = os.getenv('AZURE_APP_ID') client_id = os.getenv('AZURE_CLIENT_ID') client_secret = os.getenv('AZURE_CLIENT_SECRET') - temp = os.getenv('AZURE_APP_ID') if tenant_id is None: print('Please pass tenant Id to generate token') exit(1) @@ -28,8 +27,6 @@ def get_azure_id_token(): token = result.get('access_token') print('Resource Id'); print(resource_id); - print("Temp"); - print(temp); print(token); except Exception as e: print(e) diff --git a/tests/azure/run-integration-tests.sh b/tests/azure/run-integration-tests.sh index 7611adc..bed93d7 100644 --- a/tests/azure/run-integration-tests.sh +++ b/tests/azure/run-integration-tests.sh @@ -21,6 +21,7 @@ svctoken=$(python3 tests/azure/azure_jwt_client.py) echo "Token received" echo $svctoken +echo $pwd cd tests/integration - +echo "Running Teststs" python3 -m pytest --token=$svctoken --service_url=$AZURE_POLICY_SERVICE_URL --data_partition=$DATA_PARTITION -- GitLab From 6c99151d3b69abb417b16cefffa48ba74dd48175 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2022 12:17:12 +0530 Subject: [PATCH 9/9] Fixedfailed test case --- tests/azure/azure_jwt_client.py | 2 -- tests/azure/run-integration-tests.sh | 5 ++--- tests/integration/test_api.py | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/azure/azure_jwt_client.py b/tests/azure/azure_jwt_client.py index 174ee4e..ca28ae9 100644 --- a/tests/azure/azure_jwt_client.py +++ b/tests/azure/azure_jwt_client.py @@ -25,8 +25,6 @@ def get_azure_id_token(): app = msal.ConfidentialClientApplication(client_id=client_id, authority=authority_uri, client_credential=client_secret) result = app.acquire_token_for_client(scopes=scopes) token = result.get('access_token') - print('Resource Id'); - print(resource_id); print(token); except Exception as e: print(e) diff --git a/tests/azure/run-integration-tests.sh b/tests/azure/run-integration-tests.sh index bed93d7..4c16284 100644 --- a/tests/azure/run-integration-tests.sh +++ b/tests/azure/run-integration-tests.sh @@ -20,8 +20,7 @@ echo $DATA_PARTITION svctoken=$(python3 tests/azure/azure_jwt_client.py) echo "Token received" -echo $svctoken -echo $pwd + cd tests/integration -echo "Running Teststs" + python3 -m pytest --token=$svctoken --service_url=$AZURE_POLICY_SERVICE_URL --data_partition=$DATA_PARTITION diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 66d3393..618eeb8 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -17,9 +17,7 @@ def test_fetch_policies(client, token, service_url, data_partition): response = requests.get(service_url, headers={'Authorization': 'Bearer ' + token, 'data-partition-id': data_partition}) - print("token:"+token); - print(service_url); - print(response.json()); + assert response.status_code == 200 # need to standardize the namespaces for bundles and then enable the test -- GitLab