Skip to content

E2E Portals Test 🌀 #171

E2E Portals Test 🌀

E2E Portals Test 🌀 #171

Workflow file for this run

name: E2E Portals Test 🌀
on:
workflow_dispatch: ~
push:
branches: [ main ]
pull_request:
branches: [ main ]
merge_group:
jobs:
e2e_portals_test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: ⚡ Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 'stable'
default: true
profile: minimal
components: rustfmt, clippy
- name: ⚡ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: tests/e2e/package-lock.json
- name: 📦 Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libssl-dev jq
- name: 🔨 Build Tavern & Socks5
run: |
go mod download
go build -v -o tavern_bin ./tavern
go build -v -o socks5_bin ./bin/socks5
- name: 🚀 Run Tavern
env:
HTTP_LISTEN_ADDR: ":8000"
run: |
./tavern_bin > tavern.log 2>&1 &
echo "Waiting for Tavern to start..."
# Wait for port 8000
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 8000
- name: 🤖 Build & Run Agent
working-directory: implants/imixv2
env:
IMIX_CALLBACK_URI: "http://localhost:8000"
IMIX_CALLBACK_INTERVAL: 1
run: |
# Fetch the pubkey and verify it's not empty
PUBKEY=$(curl -s http://localhost:8000/status | jq -r .Pubkey)
if [ -z "$PUBKEY" ] || [ "$PUBKEY" == "null" ]; then
echo "Error: Could not fetch Pubkey from Tavern"
exit 1
fi
export IMIX_SERVER_PUBKEY=$PUBKEY
echo "Got pubkey: $IMIX_SERVER_PUBKEY"
echo "Building imixv2..."
cargo build --bin imixv2 --target-dir ./build
# Run agent and pipe logs to a file
./build/debug/imixv2 > agent.log 2>&1 &
# Give the agent a moment to perform the initial handshake
echo "Agent started. Waiting for initial callback..."
sleep 5
- name: 🎭 Install Playwright
working-directory: tests/e2e
run: |
npm ci
npx playwright install --with-deps chromium
- name: 🧪 Run Portal Provisioning Test
working-directory: tests/e2e
run: |
npx playwright test tests/portal.spec.ts
- name: 🔍 Retrieve Portal ID
id: get_portal_id
run: |
QUERY='query { portals { edges { node { id } } } }'
# Send GraphQL query to Tavern
RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" \
-d "{\"query\": \"$QUERY\"}" http://localhost:8000/graphql)
echo "GraphQL Response: $RESPONSE"
PORTAL_ID=$(echo $RESPONSE | jq -r '.data.portals.edges[0].node.id')
if [ -z "$PORTAL_ID" ] || [ "$PORTAL_ID" == "null" ]; then
echo "Error: Could not retrieve Portal ID"
exit 1
fi
echo "PORTAL_ID=$PORTAL_ID" >> $GITHUB_ENV
echo "Retrieved Portal ID: $PORTAL_ID"
- name: 🌐 Start Socks5 Proxy
env:
TAVERN_API_TOKEN: ${{ secrets.TEST_TAVERN_API_TOKEN }}
run: |
./socks5_bin -portal $PORTAL_ID -listen 127.0.0.1:1080 -upstream 127.0.0.1:8000 &
echo "Socks5 Proxy started on port 1080"
# Wait for port 1080
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 1080
- name: 📄 Prepare Mock Data & Server
run: |
# Generate 1MB random file
dd if=/dev/urandom of=test_data.bin bs=1M count=1
sha256sum test_data.bin > original_checksum.txt
echo "Original Checksum:"
cat original_checksum.txt
# Start Python HTTP Server on port 9000
python3 -m http.server 9000 &
echo "HTTP Server started on port 9000"
sleep 2
- name: 🔄 Transfer & Verification
run: |
# Download through proxy
curl -v -x socks5://127.0.0.1:1080 -o downloaded_data.bin http://127.0.0.1:9000/test_data.bin
sha256sum downloaded_data.bin > downloaded_checksum.txt
echo "Downloaded Checksum:"
cat downloaded_checksum.txt
# Compare hashes
ORIGINAL=$(awk '{print $1}' original_checksum.txt)
DOWNLOADED=$(awk '{print $1}' downloaded_checksum.txt)
if [ "$ORIGINAL" != "$DOWNLOADED" ]; then
echo "Error: Checksums do not match!"
exit 1
fi
echo "Success: Data integrity verified."
- name: 📂 Upload Service Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-portal-logs
path: |
tavern.log
implants/imixv2/agent.log