Skip to content

Commit 8992f33

Browse files
committed
Add broken titles
1 parent 7b81a16 commit 8992f33

File tree

3 files changed

+82
-29
lines changed

3 files changed

+82
-29
lines changed

docker-compose.override.unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- "defectdojo_media_unit_tests:${DD_MEDIA_ROOT:-/app/media}"
1515
environment:
1616
PYTHONWARNINGS: error # We are strict about Warnings during testing
17-
DD_DEBUG: 'True'
17+
# DD_DEBUG: 'True'
1818
DD_TEST_DATABASE_NAME: ${DD_TEST_DATABASE_NAME:-test_defectdojo}
1919
DD_DATABASE_NAME: ${DD_TEST_DATABASE_NAME:-test_defectdojo}
2020
DD_DATABASE_ENGINE: ${DD_DATABASE_ENGINE:-django.db.backends.postgresql}

docker/entrypoint-unit-tests-devDocker.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,51 +37,51 @@ EOF
3737
exit 1
3838
}
3939

40-
python3 manage.py migrate
40+
# python3 manage.py migrate
4141

42-
# do the check with Django stack
43-
python3 manage.py check
42+
# # do the check with Django stack
43+
# python3 manage.py check
4444

45-
python3 manage.py spectacular --fail-on-warn > /dev/null || {
46-
cat <<-EOF
45+
# python3 manage.py spectacular --fail-on-warn > /dev/null || {
46+
# cat <<-EOF
4747

48-
********************************************************************************
48+
# ********************************************************************************
4949

50-
You made changes to the REST API without applying the correct schema annotations
50+
# You made changes to the REST API without applying the correct schema annotations
5151

52-
These schema annotations are needed to allow for the correct generation of
53-
the OpenAPI (v3) schema's and documentation.
52+
# These schema annotations are needed to allow for the correct generation of
53+
# the OpenAPI (v3) schema's and documentation.
5454

55-
Review the warnings generated by drf-spectacular and see "dojo/api_v2/views.py"
56-
and/or "dojo/api_v2/serializers.py".
55+
# Review the warnings generated by drf-spectacular and see "dojo/api_v2/views.py"
56+
# and/or "dojo/api_v2/serializers.py".
5757

58-
You can check for warnings locally by running
58+
# You can check for warnings locally by running
5959

60-
python3 manage.py spectacular > /dev/null
60+
# python3 manage.py spectacular > /dev/null
6161

62-
This will output only warnings/errors, or nothing if everything is OK.
62+
# This will output only warnings/errors, or nothing if everything is OK.
6363

64-
More info at: https://drf-spectacular.readthedocs.io/en/latest/customization.html
64+
# More info at: https://drf-spectacular.readthedocs.io/en/latest/customization.html
6565

66-
********************************************************************************
66+
# ********************************************************************************
6767

68-
EOF
69-
python3 manage.py spectacular > /dev/null
70-
}
68+
# EOF
69+
# python3 manage.py spectacular > /dev/null
70+
# }
7171

72-
echo "Unit Tests"
73-
echo "------------------------------------------------------------"
72+
# echo "Unit Tests"
73+
# echo "------------------------------------------------------------"
7474

7575
# Removing parallel and shuffle for now to maintain stability
76-
python3 manage.py test unittests -v 3 --keepdb --no-input --exclude-tag="non-parallel" || {
77-
exit 1;
78-
}
79-
python3 manage.py test unittests -v 3 --keepdb --no-input --tag="non-parallel" || {
80-
exit 1;
81-
}
76+
# python3 manage.py test unittests -v 3 --keepdb --no-input --exclude-tag="non-parallel" || {
77+
# exit 1;
78+
# }
79+
# python3 manage.py test unittests -v 3 --keepdb --no-input --tag="non-parallel" || {
80+
# exit 1;
81+
# }
8282

8383
# you can select a single file to "test" unit tests
84-
# python3 manage.py test unittests.tools.test_npm_audit_scan_parser.TestNpmAuditParser --keepdb -v 3
84+
python3 manage.py test unittests.test_notifications.TestNotificationWebhooks.test_events_messages --keepdb -v 3
8585

8686
# or even a single method
8787
# python3 manage.py test unittests.tools.test_npm_audit_scan_parser.TestNpmAuditParser.test_npm_audit_parser_many_vuln_npm7 --keepdb -v 3

unittests/test_notifications.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,3 +923,56 @@ def test_events_messages(self, mock):
923923
"url_ui": "http://localhost:8080/finding/235",
924924
}],
925925
})
926+
927+
with self.subTest("scan_added problematic titles"):
928+
BaseImporter(
929+
environment=Development_Environment.objects.get_or_create(name="Development")[0],
930+
scan_type="ZAP Scan",
931+
).notify_scan_added(
932+
test,
933+
updated_count=4,
934+
new_findings=[
935+
Finding.objects.create(test=test, title="Colon: New Finding", severity="Critical"),
936+
],
937+
findings_mitigated=[
938+
Finding.objects.create(test=test, title="[Brackets] Mitigated Finding", severity="Medium"),
939+
],
940+
findings_reactivated=[
941+
Finding.objects.create(test=test, title='"Quotation1" Reactivated Finding', severity="Low"),
942+
],
943+
findings_untouched=[
944+
Finding.objects.create(test=test, title="'Quotation2' Untouched Finding", severity="Info"),
945+
],
946+
)
947+
self.assertEqual(mock.call_args.kwargs["headers"]["X-DefectDojo-Event"], "scan_added")
948+
self.maxDiff = None
949+
self.assertEqual(mock.call_args.kwargs["json"]["findings"], {
950+
"new": [{
951+
"id": 232,
952+
"title": "Colon: New Finding",
953+
"severity": "Critical",
954+
"url_api": "http://localhost:8080/api/v2/findings/232/",
955+
"url_ui": "http://localhost:8080/finding/232",
956+
}],
957+
"mitigated": [{
958+
"id": 233,
959+
"title": "[Brackets] Mitigated Finding",
960+
"severity": "Medium",
961+
"url_api": "http://localhost:8080/api/v2/findings/233/",
962+
"url_ui": "http://localhost:8080/finding/233",
963+
}],
964+
"reactivated": [{
965+
"id": 234,
966+
"title": "\"Quotation1\" Reactivated Finding",
967+
"severity": "Low",
968+
"url_api": "http://localhost:8080/api/v2/findings/234/",
969+
"url_ui": "http://localhost:8080/finding/234",
970+
}],
971+
"untouched": [{
972+
"id": 235,
973+
"title": "'Quotation2' Untouched Finding",
974+
"severity": "Info",
975+
"url_api": "http://localhost:8080/api/v2/findings/235/",
976+
"url_ui": "http://localhost:8080/finding/235",
977+
}],
978+
})

0 commit comments

Comments
 (0)