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 1 commit
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
50 changes: 48 additions & 2 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ slack-bolt = "^1.22.0"
djlint = "^1.36.4"
pre-commit = "^4.1.0"
ruff = "^0.11.0"
hypothesis = "^6.129.4"

[tool.poetry.group.test.dependencies]
pytest = "^8.3.4"
Expand Down
26 changes: 26 additions & 0 deletions backend/tests/core/api/algolia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
import requests
import hypothesis
from django.core.cache import cache

from apps.core.api.algolia import algolia_search
Expand Down Expand Up @@ -138,3 +139,28 @@ def test_algolia_search_invalid_request(

assert response.status_code == requests.codes.bad_request
assert response_data["error"] == error_message

@hypothesis.given(
index_name=hypothesis.strategies.text(),
query=hypothesis.strategies.text(),
page=hypothesis.strategies.integers(min_value=1),
hits_per_page=hypothesis.strategies.integers(min_value=1, max_value=1000),
facet_filters=hypothesis.strategies.lists(hypothesis.strategies.text()),
)
def test_fuzz_algolia_search(self, index_name, query, page, hits_per_page, facet_filters):
"""Test the algolia_search function with fuzz testing."""
mock_request = Mock()
mock_request.method = "POST"
mock_request.body = json.dumps(
{
"facetFilters": facet_filters,
"hitsPerPage": hits_per_page,
"indexName": index_name,
"page": page,
"query": query,
}
)

response = algolia_search(mock_request)

assert response.status_code != requests.codes.server_error
Loading