Skip to content
Snippets Groups Projects
Commit f37e4f49 authored by Yunhua Koglin's avatar Yunhua Koglin
Browse files

Merge branch 'create-legal-tag-for-integration-tests' into 'master'

create unique legal tag with timestamp

See merge request !484
parents 1a077d9d 75deeeb2
No related branches found
No related tags found
2 merge requests!487Draft: Create unique legal tag with timestamp,!484create unique legal tag with timestamp
Pipeline #180362 failed
import os
import boto3
import jwt
def get_id_token():
client = boto3.client('cognito-idp', region_name=os.environ["AWS_REGION"])
userAuth = client.initiate_auth(
ClientId= os.environ['AWS_COGNITO_CLIENT_ID'],
AuthFlow= os.environ['AWS_COGNITO_AUTH_FLOW'],
AuthParameters= {
"USERNAME": os.environ['AWS_COGNITO_AUTH_PARAMS_USER'],
"PASSWORD": os.environ['AWS_COGNITO_AUTH_PARAMS_PASSWORD']
})
print(userAuth['AuthenticationResult']['AccessToken'])
def get_invalid_token():
#generate a dummy jwt
return jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256').decode("utf-8")
if __name__ == '__main__':
get_id_token()
boto3==1.14.40
PyJWT==1.7.1
\ No newline at end of file
......@@ -76,6 +76,9 @@ phases:
- GIT_SECRETS_SCAN_RESULT=$(git secrets --scan 2> ${OUTPUT_DIR}/git_secrets.out.txt && echo OK || echo FAILED)
- if [ "$GIT_SECRETS_SCAN_RESULT" = "FAILED" ]; then echo "Secrets detected!" && exit 1; fi
- cp devops/aws/aws_jwt_client.py testing/integration-tests/search-test-aws/build-aws/aws_jwt_client.py
- cp devops/aws/requirements.txt testing/integration-tests/search-test-aws/build-aws/requirements.txt
- echo "Building primary service assemblies..."
- mvn -ntp -B test install sonar:sonar -pl .,search-core,provider/search-aws -Ddeployment.environment=prod -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.branch.name=${BRANCH_NAME}
......
......@@ -23,7 +23,6 @@ export HOST=$SCHEMA_URL
export SEARCH_HOST=$SEARCH_URL
export STORAGE_HOST=$STORAGE_URL
export OTHER_RELEVANT_DATA_COUNTRIES=US
export LEGAL_TAG=opendes-public-usa-dataset-1
export DEFAULT_DATA_PARTITION_ID_TENANT1=opendes
export DEFAULT_DATA_PARTITION_ID_TENANT2=common
export ENTITLEMENTS_DOMAIN=example.com
......@@ -37,6 +36,33 @@ export ELASTIC_PORT=$ELASTIC_PORT
export ELASTIC_PASSWORD=$ELASTIC_PASSWORD
export ELASTIC_USER_NAME=$ELASTIC_USERNAME
timestamp=$(date +%s)
export LEGAL_TAG=opendes-public-usa-dataset-1-$timestamp
#### POPULATE LEGAL TAGS #########################################################################
pip3 install -r $SCRIPT_SOURCE_DIR/requirements.txt
token=$(python3 $SCRIPT_SOURCE_DIR/aws_jwt_client.py)
echo '**** Generating token *****************'
echo 'Register Legal tag before Integration Tests ...'
curl --location --request POST "$LEGAL_URL"'legaltags' \
--header 'accept: application/json' \
--header 'authorization: Bearer '"$token" \
--header 'content-type: application/json' \
--header 'data-partition-id: opendes' \
--data '{
"name": "public-usa-dataset-1-'$timestamp'",
"description": "test legal tag for search integration tests",
"properties": {
"countryOfOrigin":["US"],
"contractId":"A1234",
"expirationDate":"2099-01-25",
"dataType":"Public Domain Data",
"originator":"Default",
"securityClassification":"Public",
"exportClassification":"EAR99",
"personalData":"No Personal Data"
}
}'
#### RUN INTEGRATION TEST #########################################################################
mvn -ntp test -f "$SCRIPT_SOURCE_DIR"/../pom.xml -Dcucumber.options="--plugin junit:target/junit-report.xml"
......@@ -50,3 +76,12 @@ if [ -n "$1" ]
fi
exit $TEST_EXIT_CODE
#### DELETE LEGAL TAGS #########################################################################
echo Delete legaltag after Integration Tests...
curl --location --request DELETE "$LEGAL_URL"'legaltags/'$LEGAL_TAG \
--header 'Authorization: Bearer '"$token" \
--header 'data-partition-id: opendes' \
--header 'Content-Type: application/json'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment