Beispiel #1
0
    def test_systemuser_name_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = SystemuserForm(data={'systemuser_name': 'systemuser_1'})
        # compare
        self.assertFalse(form.is_valid())
Beispiel #2
0
    def test_systemuser_form_empty(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = SystemuserForm(data={})
        # compare
        self.assertFalse(form.is_valid())
Beispiel #3
0
    def test_systemuser_system_form_filled(self):
        """ test minimum form requirements / VALID """

        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = SystemuserForm(data={
            'systemuser_name': 'systemuser_1',
            'system': system_id,
        })
        # compare
        self.assertTrue(form.is_valid())
Beispiel #4
0
    def test_systemuser_name_too_many_chars(self):
        """test for max length"""

        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = SystemuserForm(data={
            'systemuser_name': 's' * 51,
            'system': system_id,
        })
        # compare
        self.assertFalse(form.is_valid())
Beispiel #5
0
    def test_systemuser_lastlogon_time_form_filled(self):
        """ test additional form content """

        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = SystemuserForm(data = {
            'systemuser_name': 'systemuser_1',
            'system': system_id,
            'systemuser_lastlogon_time': timezone.now(),
        })
        # compare
        self.assertTrue(form.is_valid())
Beispiel #6
0
    def test_systemuser_lastlogon_formatcheck(self):
        """ test input format """

        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = SystemuserForm(data = {
            'systemuser_name': 'systemuser_1',
            'system': system_id,
            'systemuser_lastlogon_time': 'wrong format',
        })
        # compare
        self.assertFalse(form.is_valid())
Beispiel #7
0
    def test_systemuser_system_form_label(self):
        """ test form label """

        # get object
        form = SystemuserForm()
        # compare
        self.assertEqual(form.fields['system'].label, 'System (*)')
Beispiel #8
0
    def test_systemuser_is_systemadmin_form_label(self):
        """ test form label """

        # get object
        form = SystemuserForm()
        # compare
        self.assertEqual(form.fields['systemuser_is_systemadmin'].label, 'Systemuser is systemadmin')
Beispiel #9
0
    def test_systemuser_lastlogon_time_form_label(self):
        """ test form label """

        # get object
        form = SystemuserForm()
        # compare
        self.assertEqual(form.fields['systemuser_lastlogon_time'].label, 'Last logon time (YYYY-MM-DD HH:MM:SS)')
Beispiel #10
0
def systemusers_add(request):
    if request.method == 'POST':
        form = SystemuserForm(request.POST)
        if form.is_valid():
            systemuser = form.save(commit=False)
            systemuser.save()
            systemuser.logger(str(request.user), " SYSTEMUSER_ADD_EXECUTED")
            messages.success(request, 'Systemuser added')
            return redirect('/systemusers')
    else:
        form = SystemuserForm()
        debug_logger(str(request.user), " SYSTEMUSER_ADD_ENTERED")
    return render(request, 'dfirtrack_main/systemuser/systemusers_add.html',
                  {'form': form})
Beispiel #11
0
def systemusers_edit(request, pk):
    systemuser = get_object_or_404(Systemuser, pk=pk)
    if request.method == 'POST':
        form = SystemuserForm(request.POST, instance=systemuser)
        if form.is_valid():
            systemuser = form.save(commit=False)
            systemuser.save()
            systemuser.logger(str(request.user), " SYSTEMUSER_EDIT_EXECUTED")
            messages.success(request, 'Systemuser edited')
            return redirect('/systemusers')
    else:
        form = SystemuserForm(instance=systemuser)
        systemuser.logger(str(request.user), " SYSTEMUSER_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/systemuser/systemusers_edit.html',
                  {'form': form})