Beispiel #1
0
    def test_system_importer_file_csv_form_based_config_form_different_columns(
            self):
        """ test field validation / VALID """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm(data={
            'csv_column_system': 1,
            'csv_column_ip': 2,
        })
        # compare
        self.assertTrue(form.is_valid())
Beispiel #2
0
def system_importer_file_csv_form_based_config_view(request):

    # form was valid to post
    if request.method == "POST":

        # get config model
        model = SystemImporterFileCsvFormbasedConfigModel.objects.get(
            system_importer_file_csv_formbased_config_name=
            'SystemImporterFileCsvFormbasedConfig')
        # get form
        form = SystemImporterFileCsvFormbasedConfigForm(request.POST,
                                                        instance=model)

        if form.is_valid():

            # save settings
            model = form.save(commit=False)
            model.save()
            form.save_m2m()

            # create message
            messages.success(
                request, 'System importer file CSV form based config changed')

            # call logger
            info_logger(str(request.user),
                        " SYSTEM_IMPORTER_FILE_CSV_FORM_BASED_CONFIG_CHANGED")

            # close popup
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')

        else:
            # show form page again
            return render(
                request,
                'dfirtrack_config/system/system_importer_file_csv_form_based_config_popup.html',
                {
                    'form': form,
                })

    else:

        # get config model
        model = SystemImporterFileCsvFormbasedConfigModel.objects.get(
            system_importer_file_csv_formbased_config_name=
            'SystemImporterFileCsvFormbasedConfig')
        # get form
        form = SystemImporterFileCsvFormbasedConfigForm(instance=model)

    # show form page
    return render(
        request,
        'dfirtrack_config/system/system_importer_file_csv_form_based_config_popup.html',
        {
            'form': form,
        })
Beispiel #3
0
    def test_system_importer_file_csv_form_based_config_csv_skip_existing_system_form_label(
            self):
        """ test form label """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm()
        # compare
        self.assertEqual(form.fields['csv_skip_existing_system'].label,
                         'Skip existing systems')
Beispiel #4
0
    def test_system_importer_file_csv_form_based_config_csv_choice_ip_form_label(
            self):
        """ test form label """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm()
        # compare
        self.assertEqual(form.fields['csv_choice_ip'].label,
                         'CSV file contains IP addresses')
Beispiel #5
0
    def test_system_importer_file_csv_form_based_config_csv_headline_form_label(
            self):
        """ test form label """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm()
        # compare
        self.assertEqual(form.fields['csv_headline'].label,
                         'CSV file contains a headline row')
Beispiel #6
0
    def test_system_importer_file_csv_form_based_config_csv_remove_tag_form_label(
            self):
        """ test form label """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm()
        # compare
        self.assertEqual(
            form.fields['csv_remove_tag'].label,
            'Remove / overwrite existing tags for already existing systems')
Beispiel #7
0
    def test_system_importer_file_csv_form_based_config_csv_column_ip_form_label(
            self):
        """ test form label """

        # get object
        form = SystemImporterFileCsvFormbasedConfigForm()
        # compare
        self.assertEqual(
            form.fields['csv_column_ip'].label,
            'Number of the column in the CSV file that contains the IP addresses'
        )