-
-
Notifications
You must be signed in to change notification settings - Fork 526
Implement e2e backend instance and fuzz testing for both GraphQL and REST endpoints #3386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7348e09
Establish an e2e backend instance locally and in CI/CD (#2429)
ahmedxgouda 4c09129
Fix running e2e backend (#2710)
ahmedxgouda 2e7c7d4
Implement fuzztesting. (#1139)
ahmedxgouda 70f5d72
Add redis cache to e2e and fuzz tests (#3041)
ahmedxgouda 2fc5538
Update volume names (#3102)
ahmedxgouda 67c4f0c
Migrate Fuzz tests tool to Schemathesis and add REST Fuzz tests (#3122)
ahmedxgouda a63f9bd
Update code
arkid15r 56af389
Update docker-compose files
arkid15r 6180e0f
Apply rabbit suggestions on the e2e feature branch (#3389)
ahmedxgouda eb1354d
Update strawberry_django decorators (#3404)
ahmedxgouda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: Run fuzz tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| test-file: | ||
| description: 'The test file to run fuzz tests on' | ||
| required: true | ||
| type: string | ||
| rest-url: | ||
| description: 'The REST API URL to test against' | ||
| required: false | ||
| type: string | ||
| default: 'http://localhost:9500/api/v0' | ||
|
|
||
| jobs: | ||
| run-fuzz-tests: | ||
| name: Run Fuzz Tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| services: | ||
| db: | ||
| image: pgvector/pgvector:pg16 | ||
| env: | ||
| POSTGRES_DB: nest_db_fuzz | ||
| POSTGRES_PASSWORD: nest_user_fuzz_password | ||
| POSTGRES_USER: nest_user_fuzz | ||
| options: >- | ||
| --health-cmd="pg_isready -U nest_user_fuzz -d nest_db_fuzz -h localhost -p 5432" | ||
| --health-interval=5s | ||
| --health-retries=5 | ||
| --health-timeout=5s | ||
| ports: | ||
| - 5432:5432 | ||
| cache: | ||
| image: redis:8.0.5-alpine3.21 | ||
| options: >- | ||
| --health-cmd="redis-cli ping" | ||
| --health-interval=5s | ||
| --health-retries=5 | ||
| --health-timeout=5s | ||
| ports: | ||
| - 6379:6379 | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | ||
|
|
||
| - name: Set up Docker buildx | ||
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f | ||
|
|
||
| - name: Setup Backend environment | ||
| uses: ./.github/workflows/setup-backend-environment | ||
| with: | ||
| db_username: nest_user_fuzz | ||
| db_name: nest_db_fuzz | ||
|
|
||
| - name: Run backend with fuzz environment variables | ||
| run: | | ||
| docker run -d --rm --name fuzz-nest-backend \ | ||
| --env-file backend/.env.fuzz.example \ | ||
| --network host \ | ||
| -e DJANGO_DB_HOST=localhost \ | ||
| -e DJANGO_REDIS_AUTH_ENABLED=False \ | ||
| -e DJANGO_REDIS_HOST=localhost \ | ||
| -p 9500:9500 \ | ||
| owasp/nest:test-backend-latest \ | ||
| sh -c ' | ||
| python manage.py migrate && | ||
| gunicorn wsgi:application --bind 0.0.0.0:9500 | ||
| ' | ||
|
|
||
| - name: Waiting for the backend to be ready | ||
| run: | | ||
| timeout 5m bash -c ' | ||
| until wget --spider http://localhost:9500/a; do | ||
| echo "Waiting for backend..." | ||
| sleep 5 | ||
| done | ||
| ' | ||
| echo "Backend is up!" | ||
|
|
||
| - name: Load Postgres data | ||
| env: | ||
| PGPASSWORD: nest_user_fuzz_password | ||
| run: | | ||
| set -euo pipefail | ||
| if ! pg_restore -h localhost -U nest_user_fuzz -d nest_db_fuzz < backend/data/nest.dump; then | ||
| echo "Data loading failed" | ||
| exit 1 | ||
| fi | ||
| echo "Data loading completed." | ||
|
|
||
| - name: Build Fuzz-testing image | ||
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | ||
| with: | ||
| cache-from: | | ||
| type=gha | ||
| type=registry,ref=owasp/nest:test-fuzz-backend-cache | ||
| cache-to: | | ||
| type=gha,compression=zstd | ||
| context: backend | ||
| file: docker/backend/Dockerfile.fuzz | ||
| load: true | ||
| platforms: linux/amd64 | ||
| tags: owasp/nest:test-fuzz-backend-latest | ||
|
|
||
| - name: Run fuzz tests | ||
| env: | ||
| TEST_FILE: ${{ inputs.test-file }} | ||
| REST_URL: ${{ inputs.rest-url }} | ||
| run: | | ||
| docker run \ | ||
| --network host \ | ||
| -e BASE_URL=http://localhost:9500 \ | ||
| -e CI=true \ | ||
| -e REST_URL="$REST_URL" \ | ||
| -e TEST_FILE="$TEST_FILE" \ | ||
| owasp/nest:test-fuzz-backend-latest | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Set up Backend environment | ||
|
|
||
| description: Sets up the Backend environment testing. | ||
|
|
||
| inputs: | ||
| db_username: | ||
| description: 'Database username' | ||
| required: true | ||
| db_name: | ||
| description: 'Database name' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Wait for database to be ready | ||
| env: | ||
| DB_USERNAME: ${{ inputs.db_username }} | ||
| DB_NAME: ${{ inputs.db_name }} | ||
| run: | | ||
| timeout 5m bash -c ' | ||
| until docker exec ${{ job.services.db.id }} pg_isready -U $DB_USERNAME -d $DB_NAME; do | ||
| echo "Waiting for database..." | ||
| sleep 5 | ||
| done | ||
| ' | ||
| shell: bash | ||
|
|
||
| - name: Install PostgreSQL client | ||
| run: sudo apt-get install -y postgresql-client | ||
| shell: bash | ||
|
|
||
| - name: Build backend image | ||
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | ||
| with: | ||
| cache-from: | | ||
| type=gha | ||
| cache-to: | | ||
| type=gha,compression=zstd | ||
| context: backend | ||
| file: docker/backend/Dockerfile | ||
| load: true | ||
| platforms: linux/amd64 | ||
| tags: owasp/nest:test-backend-latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.