Exemple #1
0
    def test_case_form_empty(self):
        """test minimum form requirements / INVALID"""

        # get object
        form = CaseForm(data={})
        # compare
        self.assertFalse(form.is_valid())
Exemple #2
0
    def test_case_name_form_filled(self):
        """ test minimum form requirements / VALID """

        # get object
        form = CaseForm(data={'case_name': 'case_1'})
        # compare
        self.assertTrue(form.is_valid())
Exemple #3
0
    def test_case_name_too_many_chars(self):
        """ test for max length """

        # get object
        form = CaseForm(data={
            'case_name':
            'ddddddddddddddddddddddddddddddddddddddddddddddddddd'
        })
        # compare
        self.assertFalse(form.is_valid())
Exemple #4
0
    def test_case_name_proper_chars(self):
        """ test for max length """

        # get object
        form = CaseForm(data={
            'case_name':
            'dddddddddddddddddddddddddddddddddddddddddddddddddd'
        })
        # compare
        self.assertTrue(form.is_valid())
Exemple #5
0
def cases_add(request):
    if request.method == 'POST':
        form = CaseForm(request.POST)
        if form.is_valid():
            case = form.save(commit=False)
            case.case_created_by_user_id = request.user
            case.save()
            case.logger(str(request.user), " CASES_ADD_EXECUTED")
            messages.success(request, 'Case added')
            return redirect('/cases')
Exemple #6
0
    def test_casepriority_form_filled(self):
        """test minimum form requirements / INVALID"""

        # get objects
        casepriority_1 = Casepriority.objects.get(
            casepriority_name='casepriority_1')

        # get object
        form = CaseForm(data={
            'case_name': 'case_1',
            'casepriority': casepriority_1,
        })
        # compare
        self.assertFalse(form.is_valid())
Exemple #7
0
    def test_tag_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['tag'].label, 'Tags')
Exemple #8
0
    def test_casestatus_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['casestatus'].label, 'Casestatus (*)')
Exemple #9
0
    def test_case_is_incident_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['case_is_incident'].label, 'Is incident')
Exemple #10
0
    def test_case_name_form_label(self):
        """ test form label """

        # get object
        form = CaseForm()
        # compare
        self.assertEquals(form.fields['case_name'].label, 'Case name (*)')
Exemple #11
0
    def test_casetype_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['casetype'].empty_label,
                         'Select casetype (optional)')
Exemple #12
0
    def test_case_note_internal_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['case_note_internal'].label,
                         'Internal note')
Exemple #13
0
    def test_case_note_analysisresult_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['case_note_analysisresult'].label,
                         'Analysis result')
Exemple #14
0
    def test_case_name_too_many_chars(self):
        """test for max length"""

        # get objects
        casepriority_1 = Casepriority.objects.get(
            casepriority_name='casepriority_1')
        casestatus_1 = Casestatus.objects.get(casestatus_name='casestatus_1')

        # get object
        form = CaseForm(
            data={
                'case_name': 'd' * 51,
                'casepriority': casepriority_1,
                'casestatus': casestatus_1,
            })
        # compare
        self.assertFalse(form.is_valid())
Exemple #15
0
    def test_case_id_external_form_label(self):
        """test form label"""

        # get object
        form = CaseForm()
        # compare
        self.assertEqual(form.fields['case_id_external'].label,
                         'Case external ID')
Exemple #16
0
        case.logger(str(self.request.user), " CASEDETAIL_ENTERED")
        return context

@login_required(login_url="/login")
def cases_add(request):
    if request.method == 'POST':
        form = CaseForm(request.POST)
        if form.is_valid():
            case = form.save(commit=False)
            case.case_created_by_user_id = request.user
            case.save()
            case.logger(str(request.user), " CASES_ADD_EXECUTED")
            messages.success(request, 'Case added')
            return redirect('/cases')
    else:
        form = CaseForm()
        debug_logger(str(request.user), " CASES_ADD_ENTERED")
    return render(request, 'dfirtrack_main/case/cases_add.html', {'form': form})

@login_required(login_url="/login")
def cases_edit(request, pk):
    case = get_object_or_404(Case, pk=pk)
    if request.method == 'POST':
        form = CaseForm(request.POST, instance=case)
        if form.is_valid():
            case = form.save(commit=False)
            case.case_created_by_user_id = request.user
            case.save()
            case.logger(str(request.user), " CASES_EDIT_EXECUTED")
            messages.success(request, 'Case edited')
            return redirect('/cases')