Skip to content

Commit

Permalink
Merge pull request #3673 from ministryofjustice/fix-smoketest
Browse files Browse the repository at this point in the history
Use correct auth token in smoketest
  • Loading branch information
MatMoore authored Oct 16, 2023
2 parents b24f6b2 + 6a78345 commit 13b75cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/reusable_terraform_plan_apply_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,5 @@ jobs:
--role-session-name smoketesting-data-platform \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text))
export API_AUTH=$(aws secretsmanager get-secret-value --secret-id data-platform-api-auth-token --query 'SecretString' --output text --no-cli-pager)
pip install -r requirements.txt && python run_smoke_tests.py
13 changes: 11 additions & 2 deletions terraform/environments/data-platform/tests/run_smoke_tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import base64
import hashlib
import json
import os
import sys
import time

import boto3
import requests


filename = "test_data.csv"
data_product_name = "example_prison_data_product"
table_name = "testing"
Expand All @@ -15,6 +16,14 @@
url = base_url + presigned_url
glue = boto3.client("glue")

try:
auth_token = json.loads(os.environ['API_AUTH'])
print(auth_token.keys())
auth_token = auth_token['auth-token']
except KeyError:
print('API_AUTH environment variable should be set to a json containing auth-token')
sys.exit(1)


def md5_hash_file_contents(file) -> str:
"""This holds the file in memory to hash so
Expand All @@ -34,7 +43,7 @@ def md5_hash_file_contents(file) -> str:
"contentMD5": file_md5_hash,
}

headers = {"authorizationToken": "placeholder"}
headers = {"authorizationToken": auth_token}

# Get presigned url
response = requests.post(
Expand Down

0 comments on commit 13b75cf

Please sign in to comment.