Skip to content

Commit

Permalink
fix: inject variable/secret TEST_SNYK_TOKEN into workflow step (#4898)
Browse files Browse the repository at this point in the history
* fix: inject variable/secret TEST_SNYK_TOKEN into workflow step

* fix: replace all occurrences of SMOKE_TESTS_SNYK_TOKEN

---------

Co-authored-by: Catalina Oyaneder <cat2608@gmail.com>
  • Loading branch information
bastiandoetsch and cat2608 authored Oct 10, 2023
1 parent d8cd708 commit dde78c9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ jobs:
- name: Run alpine test
if: ${{ matrix.snyk_install_method == 'alpine-binary' }}
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t snyk-cli-alpine -f ./test/smoke/alpine/Dockerfile ./test
docker run -eCI=1 -eSMOKE_TESTS_SNYK_TOKEN -eGITHUB_TOKEN snyk-cli-alpine
docker run -eCI=1 -eTEST_SNYK_TOKEN -eGITHUB_TOKEN snyk-cli-alpine
- name: Install snyk from Docker bundle
if: ${{ matrix.snyk_install_method == 'docker-bundle' && matrix.os == 'macos' }}
Expand All @@ -108,10 +108,10 @@ jobs:
- name: Run npm test with Root user
if: ${{ matrix.snyk_install_method == 'npm-root-user' }}
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
run: |
docker build -t snyk-docker-root -f ./test/smoke/docker-root/Dockerfile ./test
docker run -eCI=1 -eSMOKE_TESTS_SNYK_TOKEN snyk-docker-root
docker run -eCI=1 -eTEST_SNYK_TOKEN snyk-docker-root
- name: Install Snyk with binary - Non-Windows
if: ${{ matrix.snyk_install_method == 'binary' && matrix.os != 'windows' }}
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
working-directory: test/smoke
shell: bash -l {0} # run bash with --login flag to load .bash_profile that's used by yarn install method
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
run: |
which snyk
snyk version
Expand All @@ -192,6 +192,6 @@ jobs:
working-directory: test/smoke
shell: powershell
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
run: |
sh ./run-shellspec-win.sh
2 changes: 1 addition & 1 deletion .github/workflows/snyk-protect-production-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
- run: npx npm@7 install
- run: npx npm@7 run test:smoke -w @snyk/protect
env:
SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
PRODUCTION_TEST: '1'
2 changes: 1 addition & 1 deletion scripts/run-smoke-tests-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ fi
echo "Installing fixture project with npm install"
npm install --silent --prefix test/fixtures/basic-npm

SNYK_COMMAND="node ${PWD}/bin/snyk" REGRESSION_TEST=1 SMOKE_TESTS_SKIP_TEST_THAT_OPENS_BROWSER=1 SMOKE_TESTS_SNYK_TOKEN=$SNYK_API_TOKEN shellspec --chdir test/smoke test/smoke/spec/snyk_auth_spec.sh -f d
SNYK_COMMAND="node ${PWD}/bin/snyk" REGRESSION_TEST=1 SMOKE_TESTS_SKIP_TEST_THAT_OPENS_BROWSER=1 TEST_SNYK_TOKEN=$SNYK_API_TOKEN shellspec --chdir test/smoke test/smoke/spec/snyk_auth_spec.sh -f d
2 changes: 1 addition & 1 deletion test/smoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ This will open a browser in one instance unless it's disabled with `SMOKE_TESTS_
To run the Alpine test in Docker locally (you probably don't want to…):

```
docker build -f ./test/smoke/alpine/Dockerfile -t snyk-cli-alpine ./test/ && docker run --rm -eSMOKE_TESTS_SNYK_TOKEN=$SNYK_API_TOKEN snyk-cli-alpine
docker build -f ./test/smoke/alpine/Dockerfile -t snyk-cli-alpine ./test/ && docker run --rm -eTEST_SNYK_TOKEN=$SNYK_API_TOKEN snyk-cli-alpine
```

_Note: Alpine image is not copying/mounting everything, so you might need to add anything new to the `test/smoke/alpine/Dockerfile`_
4 changes: 2 additions & 2 deletions test/smoke/spec/snyk_auth_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Describe "Snyk CLI Authorization"
End

It "updates config file if given legit token"
When run snyk auth "${SMOKE_TESTS_SNYK_TOKEN}"
When run snyk auth "${TEST_SNYK_TOKEN}"
The output should include "Your account has been authenticated. Snyk is now ready to be used."
The status should be success
# TODO: unusable with our current docker issues
The stderr should equal ""
The result of "print_snyk_config()" should include "api: ${SMOKE_TESTS_SNYK_TOKEN}"
The result of "print_snyk_config()" should include "api: ${TEST_SNYK_TOKEN}"
End
End

0 comments on commit dde78c9

Please sign in to comment.