def test_deleted_report_deletes_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report(
         "test match report", 'dummy')
     match_report.save()
     self.assertEqual(MatchReport.objects.count(), 1)
     self.report.delete()
     self.assertEqual(MatchReport.objects.count(), 0)
    def create_match(self, user, identifier):
        self.most_recent_report = Report(owner=user)
        self.most_recent_report.encrypt_record("test report 1", "key")
        match_report = MatchReport(report=self.most_recent_report)
        match_report_content = MatchReportContent(
            identifier=identifier, perp_name=identifier,
            email='*****@*****.**', phone="123",
        )
        match_report.encrypt_match_report(
            json.dumps(match_report_content.__dict__),
            identifier,
        )

        matches = MatchingApi.find_matches(identifier)
        return matches
Example #3
0
    def create_match(self, user, identifier):
        self.most_recent_report = Report(owner=user)
        self.most_recent_report.encrypt_record("test report 1", "key")
        match_report = MatchReport(report=self.most_recent_report)
        match_report_content = MatchReportContent(
            identifier=identifier,
            perp_name=identifier,
            email="*****@*****.**",
            phone="123",
        )
        match_report.encrypt_match_report(
            json.dumps(match_report_content.__dict__), identifier)

        matches = MatchingApi.find_matches(identifier)
        return matches
Example #4
0
 def test_deleted_report_deletes_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
     self.assertEqual(MatchReport.objects.count(), 1)
     self.report.delete()
     self.assertEqual(MatchReport.objects.count(), 0)
Example #5
0
    def test_can_decrypt_old_match_report(self):
        legacy_match_report = LegacyMatchReportData()
        legacy_match_report.encrypt_match_report("test legacy match report",
                                                 "dumbo")

        legacy_report = LegacyReportData()
        legacy_report.encrypt_record(
            "this text should be encrypted otherwise bad things",
            key='this is my key')
        report = Report(owner=self.user,
                        encrypted=legacy_report.encrypted,
                        salt=legacy_report.salt)
        report.save()

        new_match_report = MatchReport(
            report=report,
            encrypted=legacy_match_report.encrypted,
            salt=legacy_match_report.salt,
        )
        new_match_report.save()
        self.assertEqual(new_match_report.get_match("dumbo"),
                         "test legacy match report")
 def test_deleted_report_doesnt_delete_sent_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
     user2 = User.objects.create_user(username="******", password="******")
     report2 = Report(owner=user2)
     report2.encrypt_record("test report 2", "key")
     report2.save()
     match_report2 = MatchReport(report=report2)
     match_report2.encrypt_match_report("test match report 2", 'dummy')
     match_report2.save()
     sent_match_report = SentMatchReport.objects.create()
     sent_match_report.reports.add(match_report, match_report2)
     self.report.match_found = True
     self.report.save()
     report2.match_found = True
     report2.save()
     self.assertIsNotNone(match_report.sentmatchreport_set.first())
     self.assertIsNotNone(match_report2.sentmatchreport_set.first())
     self.assertEqual(
         match_report,
         SentMatchReport.objects.first().reports.all()[0])
     self.assertEqual(
         match_report2,
         SentMatchReport.objects.first().reports.all()[1])
     self.report.delete()
     self.assertEqual(Report.objects.count(), 1)
     self.assertEqual(MatchReport.objects.count(), 1)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
     self.assertEqual(SentMatchReport.objects.first().reports.count(), 1)
     self.assertEqual(
         SentMatchReport.objects.first().reports.first(),
         match_report2)
     self.assertTrue(Report.objects.first().match_found)
     report2.delete()
     self.assertEqual(Report.objects.count(), 0)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
    def test_can_decrypt_old_match_report(self):
        legacy_match_report = LegacyMatchReportData()
        legacy_match_report.encrypt_match_report(
            "test legacy match report", "dumbo")

        legacy_report = LegacyReportData()
        legacy_report.encrypt_record(
            "this text should be encrypted otherwise bad things",
            key='this is my key')
        report = Report(
            owner=self.user,
            encrypted=legacy_report.encrypted,
            salt=legacy_report.salt)
        report.save()

        new_match_report = MatchReport(
            report=report,
            encrypted=legacy_match_report.encrypted,
            salt=legacy_match_report.salt,
        )
        new_match_report.save()
        self.assertEqual(
            new_match_report.get_match("dumbo"),
            "test legacy match report")
Example #8
0
 def setUp(self):
     super().setUp()
     self.client_post_report_creation()
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
Example #9
0
 def test_deleted_report_doesnt_delete_sent_match_report(self):
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()
     user2 = User.objects.create_user(username="******", password="******")
     report2 = Report(owner=user2)
     report2.encrypt_record("test report 2", "key")
     report2.save()
     match_report2 = MatchReport(report=report2)
     match_report2.encrypt_match_report("test match report 2", 'dummy')
     match_report2.save()
     sent_match_report = SentMatchReport.objects.create()
     sent_match_report.reports.add(match_report, match_report2)
     self.report.match_found = True
     self.report.save()
     report2.match_found = True
     report2.save()
     self.assertIsNotNone(match_report.sentmatchreport_set.first())
     self.assertIsNotNone(match_report2.sentmatchreport_set.first())
     self.assertEqual(match_report,
                      SentMatchReport.objects.first().reports.all()[0])
     self.assertEqual(match_report2,
                      SentMatchReport.objects.first().reports.all()[1])
     self.report.delete()
     self.assertEqual(Report.objects.count(), 1)
     self.assertEqual(MatchReport.objects.count(), 1)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
     self.assertEqual(SentMatchReport.objects.first().reports.count(), 1)
     self.assertEqual(SentMatchReport.objects.first().reports.first(),
                      match_report2)
     self.assertTrue(Report.objects.first().match_found)
     report2.delete()
     self.assertEqual(Report.objects.count(), 0)
     self.assertEqual(SentMatchReport.objects.first(), sent_match_report)
 def setUp(self):
     super().setUp()
     self.client_post_report_creation()
     match_report = MatchReport(report=self.report)
     match_report.encrypt_match_report("test match report", 'dummy')
     match_report.save()