Beispiel #1
0
    def setUpTestData(cls):
        cls.user = UserFactory(password=PASSWORD)

        cls.Project = ProjectFactory._meta.model
        cls.ProjectAssignment = ProjectAssignmentFactory._meta.model
        cls.ReportFindingLink = ReportFindingLinkFactory._meta.model

        cls.current_project = ProjectFactory(
            start_date=date.today() - timedelta(days=14),
            end_date=date.today(),
            complete=True
        )
        cls.future_project = ProjectFactory(
            start_date=date.today() + timedelta(days=14),
            end_date=date.today() + timedelta(days=28),
            complete=False
        )
        ProjectAssignmentFactory(
            project=cls.current_project,
            operator=cls.user,
            start_date=date.today(),
            end_date=date.today() + timedelta(days=14),
        )
        ProjectAssignmentFactory(
            project=cls.future_project,
            operator=cls.user,
            start_date=date.today() + timedelta(days=14),
            end_date=date.today() + timedelta(days=28),
        )

        cls.report = ReportFactory(project=cls.current_project)
        ReportFindingLinkFactory.create_batch(3, report=cls.report, assigned_to=cls.user)

        cls.user_tasks = (
            cls.ReportFindingLink.objects.select_related("report", "report__project")
            .filter(
                Q(assigned_to=cls.user) & Q(report__complete=False) & Q(complete=False)
            )
            .order_by("report__project__end_date")[:10]
        )
        cls.user_projects = cls.ProjectAssignment.objects.select_related(
            "project", "project__client", "role"
        ).filter(Q(operator=cls.user))
        cls.active_projects = cls.ProjectAssignment.objects.select_related(
            "project", "project__client", "role"
        ).filter(Q(operator=cls.user) & Q(project__complete=False))

        cls.uri = reverse("home:dashboard")
Beispiel #2
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.project_dict = cls.project.__dict__
     cls.assignment_1 = ProjectAssignmentFactory(project=cls.project)
     cls.assignment_2 = ProjectAssignmentFactory(project=cls.project)
     cls.to_be_deleted = ProjectAssignmentFactory(project=cls.project)
     cls.new_assignee = UserFactory()
Beispiel #3
0
 def setUpTestData(cls):
     cls.unavailable_status = ServerStatusFactory(
         server_status="Unavailable")
     cls.server = StaticServerFactory()
     cls.unavailable_server = StaticServerFactory(
         server_status=cls.unavailable_status)
     cls.project = ProjectFactory()
Beispiel #4
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.report = ReportFactory(project=cls.project)
     cls.user = UserFactory(password=PASSWORD)
     cls.uri = reverse("reporting:report_create_no_project")
     cls.project_uri = reverse(
         "reporting:report_create", kwargs={"pk": cls.project.pk}
     )
Beispiel #5
0
    def test_crud_finding(self):
        # Create
        project = ProjectFactory(codename="S3kr3t Codename")

        # Read
        self.assertEqual(project.codename, "S3kr3t Codename")
        self.assertEqual(project.pk, project.id)
        self.assertQuerysetEqual(
            self.Project.objects.all(),
            [
                f"<Project: {project.start_date} {project.client} {project.project_type} (S3kr3t Codename)>"
            ],
        )

        # Update
        project.codename = "New Name"
        project.save()
        self.assertQuerysetEqual(
            self.Project.objects.all(),
            [
                f"<Project: {project.start_date} {project.client} {project.project_type} (New Name)>"
            ],
        )

        # Delete
        project.delete()
        assert not self.Project.objects.all().exists()
 def setUpTestData(cls):
     cls.unavailable_status = DomainStatusFactory(domain_status="Unavailable")
     cls.domain = DomainFactory(expiration=date.today() + timedelta(days=360))
     cls.unavailable_domain = DomainFactory(
         domain_status=cls.unavailable_status,
         expiration=date.today() + timedelta(days=360),
     )
     cls.expired_domain = DomainFactory(expiration=date.today() - timedelta(days=30))
     cls.project = ProjectFactory()
Beispiel #7
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.project_dict = cls.project.__dict__
     cls.objective_1 = ProjectObjectiveFactory(
         project=cls.project, deadline=cls.project.end_date
     )
     cls.objective_2 = ProjectObjectiveFactory(
         project=cls.project, deadline=cls.project.end_date
     )
     cls.to_be_deleted = ProjectObjectiveFactory(project=cls.project)
Beispiel #8
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.domain = HistoryFactory(project=cls.project)
     cls.server = ServerHistoryFactory(project=cls.project)
     cls.vps = TransientServerFactory(project=cls.project)
     cls.link = DomainServerConnectionFactory(
         project=cls.project,
         domain=cls.domain,
         static_server=cls.server,
         transient_server=None,
     )
     cls.link_dict = cls.link.__dict__
Beispiel #9
0
    def setUpTestData(cls):
        cls.group_1 = GroupFactory(name="Group 1")
        cls.group_2 = GroupFactory(name="Group 2")
        cls.user = UserFactory(password=PASSWORD, groups=(cls.group_1, ))
        cls.project = ProjectFactory()
        cls.report = ReportFactory(project=cls.project)

        cls.num_of_findings = 3
        ReportFindingLinkFactory.create_batch(cls.num_of_findings,
                                              report=cls.report,
                                              assigned_to=cls.user)

        cls.uri = reverse("home:dashboard")
    def setUpTestData(cls):
        cls.ProjectObjective = ProjectObjectiveFactory._meta.model
        cls.project = ProjectFactory()
        for x in range(3):
            ProjectObjectiveFactory(project=cls.project)

        cls.server = StaticServerFactory()
        cls.aux_address_1 = AuxServerAddressFactory(
            static_server=cls.server, ip_address="1.1.1.1", primary=True
        )
        cls.aux_address_2 = AuxServerAddressFactory(
            static_server=cls.server, ip_address="1.1.1.2", primary=False
        )

        cls.scope = ProjectScopeFactory(
            project=cls.project,
            scope="1.1.1.1\r\n1.1.1.2\r\n1.1.1.3\r\n1.1.1.4\r\n1.1.1.5",
        )
Beispiel #11
0
    def test_checkout_adjustment_signal(self):
        yesterday = date.today() - timedelta(days=1)

        project = ProjectFactory(
            start_date=date.today() - timedelta(days=14),
            end_date=date.today() + timedelta(days=14),
        )

        domain_checkout = HistoryFactory(start_date=project.start_date,
                                         end_date=project.end_date,
                                         project=project)
        exp_domain_checkout = HistoryFactory(start_date=project.start_date,
                                             end_date=yesterday,
                                             project=project)
        server_checkout = ServerHistoryFactory(start_date=project.start_date,
                                               end_date=project.end_date,
                                               project=project)
        exp_server_checkout = ServerHistoryFactory(
            start_date=project.start_date, end_date=yesterday, project=project)

        new_start = project.start_date - timedelta(days=7)
        new_end = project.end_date + timedelta(days=7)

        project.start_date = new_start
        project.end_date = new_end
        project.save()

        domain_checkout.refresh_from_db()
        exp_domain_checkout.refresh_from_db()
        server_checkout.refresh_from_db()
        exp_server_checkout.refresh_from_db()

        self.assertEqual(domain_checkout.start_date, new_start)
        self.assertEqual(server_checkout.start_date, new_start)
        self.assertEqual(domain_checkout.end_date, new_end)
        self.assertEqual(server_checkout.end_date, new_end)
        self.assertEqual(exp_domain_checkout.end_date, yesterday)
        self.assertEqual(exp_server_checkout.end_date, yesterday)
Beispiel #12
0
 def test_valid_data(self):
     project = ProjectFactory()
     oplog = OplogFactory.build(project=project)
     form = self.form_data(**oplog.__dict__)
     self.assertTrue(form.is_valid())
Beispiel #13
0
 def setUpTestData(cls):
     cls.project = ProjectFactory(complete=False)
     cls.user = UserFactory(password=PASSWORD)
     cls.uri = reverse("oplog:oplog_create_no_project")
     cls.project_uri = reverse("oplog:oplog_create",
                               kwargs={"pk": cls.project.pk})
 def setUpTestData(cls):
     cls.project = ProjectFactory(complete=False)
     cls.user = UserFactory(password=PASSWORD)
     cls.uri = reverse("rolodex:ajax_toggle_project", kwargs={"pk": cls.project.pk})
Beispiel #15
0
 def test_prop_count_findings(self):
     project = ProjectFactory()
     report = ReportFactory(project=project)
     for x in range(3):
         ReportFindingLinkFactory(report=report)
     self.assertEqual(project.count_findings(), 3)
Beispiel #16
0
 def test_get_absolute_url(self):
     project = ProjectFactory()
     try:
         project.get_absolute_url()
     except:
         self.fail("Project.get_absolute_url() raised an exception")
Beispiel #17
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.project_dict = cls.project.__dict__
     cls.target_1 = ProjectTargetFactory(project=cls.project)
     cls.target_2 = ProjectTargetFactory(project=cls.project)
     cls.to_be_deleted = ProjectTargetFactory(project=cls.project)
Beispiel #18
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.project_dict = cls.project.__dict__
     cls.scope_1 = ProjectScopeFactory(project=cls.project)
     cls.scope_2 = ProjectScopeFactory(project=cls.project)
     cls.to_be_deleted = ProjectScopeFactory(project=cls.project)
Beispiel #19
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.report = ReportFactory(project=cls.project)
     cls.report_dict = cls.report.__dict__
Beispiel #20
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.project_dict = cls.project.__dict__
Beispiel #21
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.server = TransientServerFactory(project=cls.project)
     cls.server_dict = cls.server.__dict__