Skip to content

Commit

Permalink
chg: [tp] Added model for storing test result
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Kieffer <[email protected]>
  • Loading branch information
romainkieffer committed Jul 24, 2024
1 parent f4a24a9 commit 0442494
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions testing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
MailDomain,
TlsScanHistory,
UserDomain,
TestReport
)


Expand All @@ -26,3 +27,4 @@ def get_username(self, obj):
admin.site.register(DMARCRecord)
admin.site.register(DMARCReport)
admin.site.register(TlsScanHistory)
admin.site.register(TestReport)
9 changes: 9 additions & 0 deletions testing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,12 @@ class DMARCReport(models.Model):

def __str__(self):
return f"{self.dmarc_record}-{self.mail_from}-{self.timestamp}"


class TestReport(models.Model):
tested_site = models.CharField(max_length=200, blank=True, null=True)
test_ran = models.CharField(max_length=200, blank=True, null=True)
report = models.JSONField()

def __str__(self):
return f"{self.test_ran}_{self.tested_site.replace('.', '-')}"
9 changes: 7 additions & 2 deletions testing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

from .zap import zap_scan

from .models import DMARCRecord, DMARCReport, MailDomain
from .models import DMARCRecord, DMARCReport, MailDomain, TestReport


@login_required
Expand Down Expand Up @@ -140,8 +140,13 @@ def zap_test(request):
nb_tests += 1
context = json_report['site'][0]
response = render(request, "check_zap.html", context)
test_report = TestReport(
tested_site=target,
test_ran="zap",
report=context
)
test_report.save()
response.set_cookie("nb_tests", nb_tests)
print("wat")
return response
# return HttpResponse(html_report)
else:
Expand Down

0 comments on commit 0442494

Please sign in to comment.