diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-07-02 10:00:57 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-07-04 11:55:05 +0200 |
commit | 9e6101e4b225804fbe38f40ebd49516e5e10ecce (patch) | |
tree | 53fda1055ad1ab26c2e98a0166aca860e8c8fc47 /aai-traversal/src/main/scripts/putTool.sh | |
parent | 589066bc5238e8d86fe893949d1a48cfdc16309b (diff) |
Use eclipse-temurin:8-jre-alpine docker base image in aai-traversal
- replace aai-common base image with plain java 8 jre
- remove custom folders and users to simplify setup
- fix janino, guava and activemq vulnerabilities
- remove apache httpclient, jsonassert, aaf-cadi and spring-test dependencies
Issue-ID: AAI-3913
Change-Id: Icca637b5adb8e9a480912c4e2b7d9e83ee3e29ba
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-traversal/src/main/scripts/putTool.sh')
-rw-r--r-- | aai-traversal/src/main/scripts/putTool.sh | 114 |
1 files changed, 58 insertions, 56 deletions
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh index 6f22067..28463f4 100644 --- a/aai-traversal/src/main/scripts/putTool.sh +++ b/aai-traversal/src/main/scripts/putTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/sh # # ============LICENSE_START======================================================= # org.onap.aai @@ -78,16 +78,11 @@ echo `date` " Starting $0 for resource $RESOURCE" ALLOWHTTPRESPONSES=$3 XFROMAPPID="AAI-TOOLS" -XTRANSID=`uuidgen` +XTRANSID="someUUID" -userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) -if [ "${userid}" != "aaiadmin" ]; then - echo "You must be aaiadmin to run $0. The id used $userid." - exit 1 -fi -PROJECT_HOME=/opt/app/aai-traversal +: ${PROJECT_HOME:=/opt/app/aai-traversal} prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties log_dir=$PROJECT_HOME/logs/misc today=$(date +\%Y-\%m-\%d) @@ -130,62 +125,69 @@ fi fname=$JSONFILE if [ -f /tmp/$(basename $JSONFILE) ]; then - fname=/tmp/$(basename $JSONFILE) + fname=/tmp/$(basename $JSONFILE) elif [ ! -f $JSONFILE ]; then - echo "The file $JSONFILE does not exist" - exit -1 + echo "The file $JSONFILE does not exist" + exit -1 fi if [ $MISSING_PROP = false ]; then - if [ $USEBASICAUTH = false ]; then - AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem" - else - AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" - fi - if [ $RETURNRESPONSE = true ]; then - curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE | jq '.' - RC=$? - else - result=`curl --request PUT -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE` - #echo "result is $result." - RC=0; - if [ $? -eq 0 ]; then - case $result in - +([0-9])?) - if [[ "$result" -ge 200 && $result -lt 300 ]] - then - echo "PUT result is OK, $result" - else - if [ -z $ALLOWHTTPRESPONSES ]; then - echo "PUT request failed, response code was $result" - RC=$result - else - contains $ALLOWHTTPRESPONSES $result - if [ $? -ne 0 ] - then - echo "PUT request failed, unexpected response code was $result" - RC=$result - else - echo "PUT result is expected, $result" - fi - fi - fi - ;; - *) - echo "PUT request failed, response was $result" - RC=-1 - ;; - + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + if [ $RETURNRESPONSE = true ]; then + curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE | jq '.' + RC=$? + else + result=`curl --request PUT -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE` + #echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + # Match one or more digits optionally followed by another character + *[0-9]*) + if [ "$result" -ge 200 ] && [ "$result" -lt 300 ]; then + echo "PUT result is OK, $result" + else + if [ -z "$ALLOWHTTPRESPONSES" ]; then + echo "PUT request failed, response code was $result" + RC=$result + else + # Function to check if a string is in a list of strings + contains() { + for item in $1; do + if [ "$item" = "$2" ]; then + return 0 + fi + done + return 1 + } + contains "$ALLOWHTTPRESPONSES" "$result" + if [ $? -ne 0 ]; then + echo "PUT request failed, unexpected response code was $result" + RC=$result + else + echo "PUT result is expected, $result" + fi + fi + fi + ;; + *) + echo "PUT request failed, response was $result" + RC=-1 + ;; esac - else + else echo "FAILED to send request to $RESTURL" RC=-1 - fi - fi + fi + fi else - echo "usage: $0 resource file [expected-failure-codes]" - RC=-1 + echo "usage: $0 resource file [expected-failure-codes]" + RC=-1 fi echo `date` " Done $0, returning $RC" -exit $RC
\ No newline at end of file +exit $RC |