Skip to content

Commit

Permalink
wip: debugging smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Oct 13, 2023
1 parent 086da71 commit 5c5c1ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/smoke_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,43 @@
id: metadata
run: echo ::set-output name=tag::1.0.0

- name: Install Cypress
run: npm install -g [email protected]

- name: Build plugin
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
run: |
./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar
- name: Start the Nexus container with Snyk plugin mounted
run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

- name: Wait for Nexus start
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

- name: Wait for API status endpoint
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

- name: Run Cypress to log in to Nexus and set up Snyk plugin
working-directory: test/smoke
run: |
docker exec nexus cat /nexus-data/admin.password > /tmp/password
export NEXUS_PASS=$(cat /tmp/password)
echo $NEXUS_PASS
cat /tmp/password
cypress run
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
# - name: Install Cypress
# run: npm install -g [email protected]

# - name: Build plugin
# env:
# TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
# TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
# run: |
# ./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
# ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar

# - name: Start the Nexus container with Snyk plugin mounted
# run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

# - name: Wait for Nexus start
# run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

# - name: Wait for API status endpoint
# run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

# - name: Run Cypress to log in to Nexus and set up Snyk plugin
# working-directory: test/smoke
# run: |
# docker exec nexus cat /nexus-data/admin.password > /tmp/password
# export NEXUS_PASS=$(cat /tmp/password)
# echo $NEXUS_PASS
# cat /tmp/password
# cypress run
# env:
# TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
# TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}

- name: Setup npm
run: npm install

- name: Lint Node.js
run: npm run lint:formatting
# - name: Lint Node.js
# run: npm run lint:formatting

- name: Run Jest tests against running Nexus
run: |
Expand Down
7 changes: 5 additions & 2 deletions test/the.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ it('can download a non-vulnerable package', async () => {
expect(res.status).toBe(200);
});

it('throws when trying to download a vulnerable package', async () => {
it.only('throws when trying to download a vulnerable package', async () => {
const url = buildNexusArtifactDownloadUrl(
'com.fasterxml.jackson.core',
'jackson-databind',
'2.6.5',
);

let capturedErr;
let res;

try {
const res = await axios.get(url, {
res = await axios.get(url, {
headers: {
Authorization: `Basic ${nexusAuth}`,
},
Expand All @@ -55,5 +56,7 @@ it('throws when trying to download a vulnerable package', async () => {
capturedErr = err;
}

console.log('****', 'res ****\n', JSON.stringify(res, null, 2), '\n');
console.log('****', 'capturedErr ****\n', JSON.stringify(capturedErr, null, 2), '\n');
expect(capturedErr.response.status).toEqual(500);
});

0 comments on commit 5c5c1ee

Please sign in to comment.