Skip to content

Commit 38c064d

Browse files
authored
Merge pull request #156 from SocketDev/e2e-test
e2e tests for full scans + full scans with reachability
2 parents 9007613 + 4f2be5c commit 38c064d

File tree

6 files changed

+143
-2
lines changed

6 files changed

+143
-2
lines changed

.github/workflows/e2e-test.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: E2E Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
e2e-scan:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
13+
with:
14+
fetch-depth: 0
15+
16+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
17+
with:
18+
python-version: '3.12'
19+
20+
- name: Install CLI from local repo
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install .
24+
25+
- name: Run Socket CLI scan
26+
env:
27+
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_CLI_API_TOKEN }}
28+
run: |
29+
set -o pipefail
30+
socketcli \
31+
--target-path tests/e2e/fixtures/simple-npm \
32+
--disable-blocking \
33+
--enable-debug \
34+
2>&1 | tee /tmp/scan-output.log
35+
36+
- name: Verify scan produced a report
37+
run: |
38+
if grep -q "Full scan report URL: https://socket.dev/" /tmp/scan-output.log; then
39+
echo "PASS: Full scan report URL found"
40+
grep "Full scan report URL:" /tmp/scan-output.log
41+
elif grep -q "Diff Url: https://socket.dev/" /tmp/scan-output.log; then
42+
echo "PASS: Diff URL found"
43+
grep "Diff Url:" /tmp/scan-output.log
44+
else
45+
echo "FAIL: No report URL found in scan output"
46+
cat /tmp/scan-output.log
47+
exit 1
48+
fi
49+
50+
e2e-reachability:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
54+
with:
55+
fetch-depth: 0
56+
57+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
58+
with:
59+
python-version: '3.12'
60+
61+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
62+
with:
63+
node-version: '20'
64+
65+
- name: Install CLI from local repo
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install .
69+
70+
- name: Install uv
71+
run: pip install uv
72+
73+
- name: Run Socket CLI with reachability
74+
env:
75+
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_CLI_API_TOKEN }}
76+
run: |
77+
set -o pipefail
78+
socketcli \
79+
--target-path tests/e2e/fixtures/simple-npm \
80+
--reach \
81+
--disable-blocking \
82+
--enable-debug \
83+
2>&1 | tee /tmp/reach-output.log
84+
85+
- name: Verify reachability analysis completed
86+
run: |
87+
if grep -q "Reachability analysis completed successfully" /tmp/reach-output.log; then
88+
echo "PASS: Reachability analysis completed"
89+
grep "Reachability analysis completed successfully" /tmp/reach-output.log
90+
grep "Results written to:" /tmp/reach-output.log || true
91+
else
92+
echo "FAIL: Reachability analysis did not complete successfully"
93+
cat /tmp/reach-output.log
94+
exit 1
95+
fi
96+
97+
- name: Verify scan produced a report
98+
run: |
99+
if grep -q "Full scan report URL: https://socket.dev/" /tmp/reach-output.log; then
100+
echo "PASS: Full scan report URL found"
101+
grep "Full scan report URL:" /tmp/reach-output.log
102+
elif grep -q "Diff Url: https://socket.dev/" /tmp/reach-output.log; then
103+
echo "PASS: Diff URL found"
104+
grep "Diff Url:" /tmp/reach-output.log
105+
else
106+
echo "FAIL: No report URL found in scan output"
107+
cat /tmp/reach-output.log
108+
exit 1
109+
fi

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.71"
9+
version = "2.2.72"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socket.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 2
2+
3+
projectIgnorePaths:
4+
- "tests/e2e/fixtures/"

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.71'
2+
__version__ = '2.2.72'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const express = require('express')
2+
const lodash = require('lodash')
3+
4+
const app = express()
5+
6+
app.get('/', (req, res) => {
7+
const data = lodash.pick(req.query, ['name', 'age'])
8+
res.json(data)
9+
})
10+
11+
app.listen(3000, () => {
12+
console.log(`Test fixture ${__filename} running on port 3000`)
13+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "reach-test-fixture",
3+
"version": "1.0.0",
4+
"description": "Test fixture for reachability analysis",
5+
"main": "index.js",
6+
"dependencies": {
7+
"lodash": "4.17.21",
8+
"express": "4.18.2",
9+
"axios": "1.4.0"
10+
},
11+
"devDependencies": {
12+
"typescript": "5.0.4",
13+
"jest": "29.5.0"
14+
}
15+
}

0 commit comments

Comments
 (0)