diff --git a/integration/run_its.sh b/integration/run_its.sh index de462b6..839f110 100755 --- a/integration/run_its.sh +++ b/integration/run_its.sh @@ -33,6 +33,7 @@ match() { matchConstant() { if [[ "$1" != "$2" ]]; then echo "- FAILED" + echo "expected = $1, actual= $2" cleanup 1 fi echo "- PASSED" @@ -141,4 +142,13 @@ if [ "$?" -ne 0 ]; then fi StatusCode=$(jq '.summary.providerStatuses[] | select(.provider== "snyk") ' ./responses/component.json | jq .status) matchConstant "200" "$StatusCode" + +echo "RUNNING JavaScript integration test for Validate Token Function With wrong token, expecting getting 401 http status code " +answerAboutToken=$(node testers/javascript/index.js validateToken veryBadToken) +matchConstant "401" "$answerAboutToken" + +echo "RUNNING JavaScript integration test for Validate Token Function With no token at all, Expecting getting 400 http status code" +answerAboutToken=$(node testers/javascript/index.js validateToken ) +matchConstant "400" "$answerAboutToken" + cleanup 0 diff --git a/integration/testers/javascript/index.js b/integration/testers/javascript/index.js index 16598bf..bce312a 100644 --- a/integration/testers/javascript/index.js +++ b/integration/testers/javascript/index.js @@ -19,5 +19,15 @@ if ('component' === args[0]) { process.exit(0) } +if ('validateToken' === args[0]) { + // args[1] - the token passed + let tokens = { + "EXHORT_SNYK_TOKEN" : args[1] + } + let res = await exhort.validateToken(tokens) + console.log(res) + process.exit(0) +} + console.log(`unknown action ${args}`) process.exit(1) diff --git a/src/index.js b/src/index.js index 4177a19..a6fba09 100644 --- a/src/index.js +++ b/src/index.js @@ -98,5 +98,6 @@ async function componentAnalysis(manifestType, data, opts = {}) { } async function validateToken(opts = {}) { + url = selectExhortBackend(opts) return await analysis.validateToken(url, opts) // throws error request sending failed }