Skip to content

Implement fuzztesting. #1139

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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
bc40efb
Add hypothesis to poetry and fuzz test the index endpoint.
ahmedxgouda Mar 19, 2025
6c18da7
Refactor import statements in algolia_test.py for consistency
ahmedxgouda Mar 19, 2025
4a17780
Add the client ip address to the request META.
ahmedxgouda Mar 19, 2025
75aa9fe
Add fuzz testing for Slack event handlers and refactor algolia fuzz t…
ahmedxgouda Mar 21, 2025
625cc0e
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Mar 21, 2025
b078e92
Refactor fuzz tests for Slack event handlers to improve readability a…
ahmedxgouda Mar 21, 2025
f1f6718
Fix the poetry lock file.
ahmedxgouda Mar 21, 2025
c0ed1f9
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Mar 27, 2025
998bd29
Remove fuzz testing from algolia_search unit tests
ahmedxgouda Mar 28, 2025
6b240b4
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Mar 28, 2025
f060510
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 1, 2025
ab68f1a
Create a docker file for fuzz-testing, add the run commands to the Ma…
ahmedxgouda Apr 1, 2025
d1d48ea
Refactor to improve quality
ahmedxgouda Apr 1, 2025
54f7fbe
Update fuzz testing setup: modify Makefile and Dockerfile, add entryp…
ahmedxgouda Apr 3, 2025
12b5139
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 3, 2025
21283f7
Update poetry.lock to reflect dependency changes and version updates
ahmedxgouda Apr 3, 2025
c47b9fd
Create a fuzz configuration, update docker file, makefile, and the te…
ahmedxgouda Apr 4, 2025
de81b25
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 4, 2025
5f79854
Refactor fuzz configuration by reorganizing imports and cleaning up w…
ahmedxgouda Apr 4, 2025
8330865
Update Dockerfile and entrypoint script to use Alpine base image and …
ahmedxgouda Apr 4, 2025
1ed4452
Run the server on port 8000 after the tests.
ahmedxgouda Apr 4, 2025
dd36f25
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 5, 2025
0a9068d
Create a docker compose file for fuzz testing.
ahmedxgouda Apr 6, 2025
c5363db
Add 'graphqler' to custom dictionary
ahmedxgouda Apr 7, 2025
ccc28c8
Load data from nest.json and add graphqler to cspell dict.
ahmedxgouda Apr 7, 2025
ef20adb
Remove model-bakery dependency from pyproject.toml and update poetry.…
ahmedxgouda Apr 7, 2025
845e1c1
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 7, 2025
8755056
Update graphqler command in docker compose and the healthcheck
ahmedxgouda Apr 8, 2025
6637d8c
Update graphql command to use backend service URL in docker-compose
ahmedxgouda Apr 8, 2025
decec65
Refactor docker-compose to build graphqler service from Dockerfile an…
ahmedxgouda Apr 9, 2025
672f097
Enhance fuzz testing setup: update Dockerfile and entrypoint scripts,…
ahmedxgouda Apr 10, 2025
ed62759
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 10, 2025
49fa5f8
Update fuzz-test-backend command to abort on container exit
ahmedxgouda Apr 10, 2025
e1533ab
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 10, 2025
dcba769
Add fuzz testing workflow and update image build steps
ahmedxgouda Apr 11, 2025
5e85b0b
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 11, 2025
70312c5
Add .env file creation step for fuzz tests in CI/CD workflow
ahmedxgouda Apr 11, 2025
751f105
Add Docker Hub login step for fuzz tests in CI/CD workflow
ahmedxgouda Apr 11, 2025
4cb975a
Refactor for the checks
ahmedxgouda Apr 11, 2025
47daeda
Refactor fuzz testing workflow: replace Docker Hub login with buildx …
ahmedxgouda Apr 11, 2025
5e08107
Fix fuzz tests workflow: rename docker-compose file
ahmedxgouda Apr 11, 2025
de6bf2e
Refactor fuzz-tests job.
ahmedxgouda Apr 11, 2025
d908fcf
Add environment variables for fuzz tests configuration
ahmedxgouda Apr 11, 2025
d3f2987
Update fuzz tests environment variables
ahmedxgouda Apr 11, 2025
d3fd074
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda Apr 19, 2025
7d5c20d
Resolve conflicts
ahmedxgouda Apr 22, 2025
03ecb0c
Fix poetry lock file
ahmedxgouda Apr 22, 2025
cf07402
Sort the custom-dict.
ahmedxgouda Apr 22, 2025
e0459d4
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda May 2, 2025
54ce26a
Update content hash in poetry.lock
ahmedxgouda May 2, 2025
deaf1d0
Add docker cache mounts to the backend image
ahmedxgouda May 2, 2025
2236c73
Add Redis configuration
ahmedxgouda May 2, 2025
8ada3b9
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda May 3, 2025
013537b
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda May 6, 2025
8ec969f
refactor yaml
ahmedxgouda May 6, 2025
3839ef1
Add docker cache mounts to graphql file
ahmedxgouda May 6, 2025
f1e2c56
Remove unnecessary chmod command for cache directories in Dockerfile
ahmedxgouda May 6, 2025
2fabe70
Merge branch 'main' into feature/fuzz-testing
ahmedxgouda May 7, 2025
56acd52
Merge branch 'main' into 'feature/fuzz-testing'
ahmedxgouda May 27, 2025
a2436f5
Fix poetry lock file
ahmedxgouda May 27, 2025
25b98f5
Add cache mounts to backend tests
ahmedxgouda May 27, 2025
eb8c087
Update cache mounts in graphql image
ahmedxgouda May 27, 2025
e27ce00
Update mkdir in graphql image
ahmedxgouda May 27, 2025
8d8e3fe
Remove duplicates
ahmedxgouda May 27, 2025
303f825
Update tests
ahmedxgouda May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/run-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,49 @@ jobs:
run: |
docker run --env-file frontend/.env.example ${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-frontend-e2e:latest pnpm run test:e2e

run-fuzz-tests:
name: Run fuzz tests
needs:
- scan-code
- scan-ci-dependencies
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Set up Docker buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2

- name: Create .env file for fuzz tests
run: |
touch backend/fuzz_tests/.env
echo "DJANGO_DB_HOST=None" >> backend/fuzz_tests/.env
echo "DJANGO_DB_NAME=None" >> backend/fuzz_tests/.env
echo "DJANGO_DB_PASSWORD=None" >> backend/fuzz_tests/.env
echo "DJANGO_DB_PORT=None" >> backend/fuzz_tests/.env
echo "DJANGO_DB_USER=None" >> backend/fuzz_tests/.env
echo "DJANGO_SETTINGS_MODULE=settings.fuzz" >> backend/fuzz_tests/.env
echo "DJANGO_CONFIGURATION=Fuzz" >> backend/fuzz_tests/.env
echo "DJANGO_ALGOLIA_APPLICATION_ID=None" >> backend/fuzz_tests/.env
echo "DJANGO_ALGOLIA_EXCLUDED_LOCAL_INDEX_NAMES=None" >> backend/fuzz_tests/.env
echo "DJANGO_ALGOLIA_WRITE_API_KEY=None" >> backend/fuzz_tests/.env
echo "DJANGO_ALLOWED_HOSTS=*" >> backend/fuzz_tests/.env
echo "DJANGO_AWS_ACCESS_KEY_ID=None" >> backend/fuzz_tests/.env
echo "DJANGO_AWS_SECRET_ACCESS_KEY=None" >> backend/fuzz_tests/.env
echo "DJANGO_OPEN_AI_SECRET_KEY=None" >> backend/fuzz_tests/.env
echo "DJANGO_PUBLIC_IP_ADDRESS=127.0.0.1" >> backend/fuzz_tests/.env
echo "DJANGO_RELEASE_VERSION=None" >> backend/fuzz_tests/.env
echo "DJANGO_SECRET_KEY=None" >> backend/fuzz_tests/.env
echo "DJANGO_SENTRY_DSN=None" >> backend/fuzz_tests/.env
echo "DJANGO_SLACK_BOT_TOKEN=None" >> backend/fuzz_tests/.env
echo "DJANGO_SLACK_SIGNING_SECRET=None" >> backend/fuzz_tests/.env
echo "GITHUB_TOKEN=None" >> backend/fuzz_tests/.env
echo "DJANGO_REDIS_HOST=None" >> backend/fuzz_tests/.env
echo "DJANGO_REDIS_PASSWORD=None" >> backend/fuzz_tests/.env

- name: Run fuzz tests
run: make fuzz-test-backend

build-staging-images:
name: Build Staging Images
environment: staging
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/update-nest-test-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,23 @@ jobs:
run: |
rm -rf /tmp/buildx-schema-poetry-cache
mv /tmp/buildx-schema-poetry-cache-new /tmp/buildx-schema-poetry-cache

- name: Build and push fuzz-test-backend image
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-backend:cache
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-backend:cache,mode=max
context: backend
file: backend/docker/Dockerfile.fuzz_tests
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-backend:latest

- name: Build and push fuzz-test-graphql image
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-graphql:cache
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-graphql:cache,mode=max
context: backend
file: backend/docker/Dockerfile.graphql_fuzz
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/owasp-nest-test-fuzz-graphql:latest
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ run:
docker compose -f docker/docker-compose-local.yaml build && \
docker compose -f docker/docker-compose-local.yaml up --remove-orphans

fuzz-test-backend:
@COMPOSE_BAKE=true docker compose -f docker/docker-compose-fuzz.yaml up --build --abort-on-container-exit --remove-orphans

test: \
test-nest-app \
test-schema
Expand Down
1 change: 1 addition & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ test-backend:
-t nest-test-backend
@docker run -e DJANGO_CONFIGURATION=Test --rm nest-test-backend pytest


update-backend-dependencies:
@cd backend && poetry update

Expand Down
74 changes: 74 additions & 0 deletions backend/docker/Dockerfile.fuzz_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM python:3.13-alpine AS builder

SHELL ["/bin/sh", "-o", "pipefail", "-c"]

ENV APK_CACHE_DIR="/home/owasp/.cache/apk" \
APK_SYMLINK_DIR="/etc/apk/cache" \
OWASP_GID=1000 \
OWASP_UID=1000 \
PIP_CACHE_DIR="/home/owasp/.cache/pip" \
POETRY_CACHE_DIR="/home/owasp/.cache/pypoetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
PYTHONUNBUFFERED=1

RUN mkdir -p ${APK_CACHE_DIR} ${POETRY_CACHE_DIR} && \
ln -fns ${APK_CACHE_DIR} ${APK_SYMLINK_DIR}

RUN --mount=type=cache,target=${APK_CACHE_DIR} \
apk update && apk upgrade && \
addgroup -S -g ${OWASP_GID} owasp && \
adduser -S -h /home/owasp -u ${OWASP_UID} -G owasp owasp && \
chown -R owasp:owasp /home/owasp

RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
python -m pip install poetry --cache-dir ${PIP_CACHE_DIR}

WORKDIR /home/owasp
USER owasp

# Copy Poetry configuration and install dependencies
COPY --chmod=444 poetry.lock pyproject.toml ./
RUN --mount=type=cache,target=${POETRY_CACHE_DIR},uid=${OWASP_UID},gid=${OWASP_GID} \
poetry install --no-root

# Copy application files
COPY apps apps
COPY manage.py wsgi.py ./
COPY settings settings
COPY static static
COPY templates templates
COPY fuzz_tests fuzz_tests
COPY data data
COPY fuzz_tests/.env .env
COPY docker/entrypoint_fuzz.sh entrypoint.sh

FROM python:3.13-alpine

SHELL ["/bin/sh", "-o", "pipefail", "-c"]

# Install runtime dependencies
RUN addgroup -S owasp && \
adduser -S -h /home/owasp -G owasp owasp && \
mkdir -p /home/owasp && \
chown owasp:owasp /home/owasp

ENV FORCE_COLOR=1 \
PATH="/home/owasp/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1

WORKDIR /home/owasp
USER owasp

# Copy built application from the builder stage
COPY --from=builder --chmod=555 --chown=owasp:owasp /home/owasp /home/owasp

RUN touch /home/owasp/fuzz_tests.db && \
chmod +x /home/owasp/fuzz_tests.db /home/owasp/entrypoint.sh


# Expose the running port
EXPOSE 8000

# Run fuzz tests

CMD ["/home/owasp/entrypoint.sh"]
41 changes: 41 additions & 0 deletions backend/docker/Dockerfile.graphql_fuzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM python:3.12-alpine

ENV APK_CACHE_DIR="/home/owasp/.cache/apk" \
APK_SYMLINK_DIR="/etc/apk/cache" \
OWASP_GID=1000 \
OWASP_UID=1000 \
PIP_CACHE_DIR="/home/owasp/.cache/pip" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
PYTHONUNBUFFERED=1

RUN mkdir -p ${APK_CACHE_DIR} && \
ln -fns ${APK_CACHE_DIR} ${APK_SYMLINK_DIR}

RUN --mount=type=cache,target=${APK_CACHE_DIR} \
apk update && apk upgrade && \
addgroup -S -g ${OWASP_GID} owasp && \
adduser -S -h /home/owasp -u ${OWASP_UID} -G owasp owasp && \
chown -R owasp:owasp /home/owasp

RUN --mount=type=cache,target=${APK_CACHE_DIR},uid=${OWASP_UID},gid=${OWASP_GID} \
apk add curl jq gcc musl-dev libffi-dev linux-headers

RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install graphqler --cache-dir ${PIP_CACHE_DIR}
Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin graphqler version and verify integrity.
Installing without a version or hash risks breakage or supply-chain attacks. Pin to a tested version and consider --require-hashes.

-RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
-    pip install graphqler --cache-dir ${PIP_CACHE_DIR}
+RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
+    pip install 'graphqler==<version>' --cache-dir ${PIP_CACHE_DIR} --no-deps
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install graphqler --cache-dir ${PIP_CACHE_DIR}
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install 'graphqler==<version>' --cache-dir ${PIP_CACHE_DIR} --no-deps
🤖 Prompt for AI Agents (early access)
In backend/docker/Dockerfile.graphql_fuzz at lines 22-23, the pip install command for graphqler lacks a specific version and hash verification, which can lead to instability or security risks. Modify the command to pin graphqler to a fixed, tested version by appending '==<version>' and add the '--require-hashes' option to enforce package integrity verification during installation.


WORKDIR /home/owasp

COPY docker/entrypoint_graphql_fuzz.sh entrypoint.sh

RUN touch /home/owasp/config.toml && \
chmod +x /home/owasp/config.toml && \
chown owasp:owasp /home/owasp/config.toml
Comment on lines +30 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Don’t touch an empty config; copy real settings.
Creating an empty config.toml leaves the fuzzing tool without its required configuration. Also, config files don’t need execute bits.

- RUN touch /home/owasp/config.toml && \
-    chmod +x /home/owasp/config.toml && \
-    chown owasp:owasp /home/owasp/config.toml
+ COPY config.toml /home/owasp/config.toml
+ RUN chmod 600 /home/owasp/config.toml && \
+    chown owasp:owasp /home/owasp/config.toml

Adjust source path to your repo structure.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN touch /home/owasp/config.toml && \
chmod +x /home/owasp/config.toml && \
chown owasp:owasp /home/owasp/config.toml
# Replace the empty touch+chmod+x with copying in a real config and setting proper perms
COPY config.toml /home/owasp/config.toml
RUN chmod 600 /home/owasp/config.toml && \
chown owasp:owasp /home/owasp/config.toml
🤖 Prompt for AI Agents (early access)
In backend/docker/Dockerfile.graphql_fuzz around lines 29 to 31, replace the creation of an empty config.toml file by copying the actual configuration file from the appropriate source path in the repository. Remove the chmod +x command since config files should not be executable. Ensure the copied config file has the correct ownership set to owasp:owasp.


# Create the graphql output dir and give permissions to the owasp user
RUN mkdir -p /home/owasp/fuzzing_results && \
chmod +x /home/owasp/fuzzing_results /home/owasp/entrypoint.sh && \
chown owasp:owasp /home/owasp/fuzzing_results /home/owasp/entrypoint.sh

USER owasp

CMD ["/home/owasp/entrypoint.sh"]
11 changes: 11 additions & 0 deletions backend/docker/entrypoint_fuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

python manage.py migrate
python manage.py collectstatic --noinput

# Load initial data
python manage.py load_data

pytest fuzz_tests

python manage.py runserver 0.0.0.0:8000
24 changes: 24 additions & 0 deletions backend/docker/entrypoint_graphql_fuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

echo "Retrieving CSRF token..."

CSRF_TOKEN=$(curl -s http://backend:8000/csrf/ | jq -r '.csrftoken')

if [ -z "$CSRF_TOKEN" ]; then
echo "Failed to retrieve CSRF token"
exit 1
fi

echo "CSRF token retrieved successfully: $CSRF_TOKEN"

cat > /home/owasp/config.toml << EOF
[CUSTOM_HEADERS]
X-CSRF-Token = "$CSRF_TOKEN"
EOF

echo "Custom headers configuration file created successfully"

sleep 5

echo "Starting fuzzing tests..."
python -m graphqler --config /home/owasp/config.toml --url http://backend:8000/graphql/ --mode run --path /home/owasp/fuzzing_results
Empty file.
Empty file.
43 changes: 43 additions & 0 deletions backend/fuzz_tests/slack/contribute_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Test Slack contribute event handler."""

from unittest.mock import MagicMock, patch

from django.conf import settings
from hypothesis import given
from hypothesis import strategies as st

from apps.slack.constants import (
OWASP_CONTRIBUTE_CHANNEL_ID,
)
from apps.slack.events.member_joined_channel.contribute import Contribute


class TestContributeEventHandler:
"""Test cases for the Contribute Slack event handler."""

@given(
events_enabled=st.booleans(),
project_count=st.integers(),
issue_count=st.integers(),
)
@patch("apps.owasp.models.project.Project.active_projects_count")
@patch("apps.github.models.issue.Issue.open_issues_count")
def test_handler_responses(
self,
mock_open_issues_count,
mock_active_projects_count,
events_enabled,
project_count,
issue_count,
):
"""Test the contribute event handler responses."""
settings.SLACK_EVENTS_ENABLED = events_enabled
mock_active_projects_count.return_value = project_count
mock_open_issues_count.return_value = issue_count
mock_slack_event = {"user": "U123456", "channel": OWASP_CONTRIBUTE_CHANNEL_ID}
mock_slack_client = MagicMock()
mock_slack_client.conversations_open.return_value = {"channel": {"id": "C123456"}}

contribute = Contribute()

contribute.handler(event=mock_slack_event, client=mock_slack_client, ack=MagicMock())
44 changes: 44 additions & 0 deletions backend/fuzz_tests/slack/gsoc_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""Test cases for the GSOC Slack event handler."""

from unittest.mock import MagicMock

from django.conf import settings
from hypothesis import given
from hypothesis import strategies as st

from apps.slack.constants import OWASP_GSOC_CHANNEL_ID
from apps.slack.events.member_joined_channel.gsoc import Gsoc


class TestGsocEventHandler:
"""Test cases for the GSOC Slack event handler."""

@given(
channel_id=st.text(),
)
def test_check_gsoc_handler(self, channel_id):
"""Test the check_gsoc_handler function."""
gsoc_module = __import__(
"apps.slack.events.member_joined_channel.gsoc",
fromlist=["gsoc_handler"],
)
check_gsoc_handler = getattr(
gsoc_module,
"check_gsoc_handler",
lambda x: x.get("channel") == OWASP_GSOC_CHANNEL_ID,
)

check_gsoc_handler({"channel": channel_id})

@given(
events_enabled=st.booleans(),
)
def test_handler_responses(self, events_enabled):
"""Test the GSOC event handler responses."""
settings.SLACK_EVENTS_ENABLED = events_enabled
mock_slack_event = {"user": "U123456", "channel": OWASP_GSOC_CHANNEL_ID}
mock_slack_client = MagicMock()
mock_slack_client.conversations_open.return_value = {"channel": {"id": "C123456"}}

gsoc = Gsoc()
gsoc.handler(event=mock_slack_event, client=mock_slack_client, ack=MagicMock())
Loading