def create_a_new_report_with_application_template_pdf():
    template_id = 6
    output_format = "PDF"
    entity_id = ["2", "3", "5"]
    report_name = "application_pdf"
    filters = [
        FilterDTO(filter_type=1,
                  excluded_values=["Information", "Low"],
                  included_values=None,
                  pattern=None)
    ]
    report_request = CreateReportDTO(template_id=template_id,
                                     output_format=output_format,
                                     entity_id=entity_id,
                                     report_name=report_name,
                                     filters=filters)

    report_content = get_report(report_request=report_request)

    if not report_content:
        return None

    report_folder = dirname(__file__)
    time_stamp = datetime.now().strftime('_%Y_%m_%d_%H_%M_%S')
    file_name = normpath(
        join(report_folder, report_name + time_stamp + "." + output_format))
    with open(str(file_name), "wb") as f_out:
        f_out.write(report_content)
def test_create_new_report_with_multi_teams_template_pdf():
    template_id = 5
    output_format = "PDF"
    entity_id = ["/CxServer", "/CxServer/CompanyTwo/AC_Dev_Team"]
    report_name = "multiple_team_pdf"
    filters = [
        FilterDTO(
            filter_type=1,
            excluded_values=["Information", "Low"],
            included_values=None,
            pattern=None
        )
    ]
    report_request = CreateReportDTO(
        template_id=template_id,
        output_format=output_format,
        entity_id=entity_id,
        report_name=report_name,
        filters=filters
    )
    check_report_generation_status_and_write_to_file(report_request, report_name, output_format)
def test_create_new_report_with_scan_template_vulnerability_type_oriented_pdf():
    template_id = 1
    output_format = "PDF"
    entity_id = ["1000017"]
    report_name = "scan_vulnerability_type_oriented_pdf"
    filters = [
        FilterDTO(
            filter_type=1,
            excluded_values=["Information", "Low"],
            included_values=None,
            pattern=None
        )
    ]
    report_request = CreateReportDTO(
        template_id=template_id,
        output_format=output_format,
        entity_id=entity_id,
        report_name=report_name,
        filters=filters
    )
    check_report_generation_status_and_write_to_file(report_request, report_name, output_format)
def test_create_a_new_report_with_application_template_json():
    template_id = 6
    output_format = "JSON"
    entity_id = ["2", "3", "5"]
    report_name = "application_json"
    filters = [
        FilterDTO(
            filter_type=1,
            excluded_values=["Information", "Low"],
            included_values=None,
            pattern=None
        )
    ]
    report_request = CreateReportDTO(
        template_id=template_id,
        output_format=output_format,
        entity_id=entity_id,
        report_name=report_name,
        filters=filters
    )
    check_report_generation_status_and_write_to_file(report_request, report_name, output_format)
def test_create_new_report_with_project_tempalte_pdf():
    template_id = 3
    output_format = "PDF"
    entity_id = ["2"]
    report_name = "project_pdf"
    filters = [
        FilterDTO(
            filter_type=1,
            excluded_values=["Information", "Low"],
            included_values=None,
            pattern=None
        )
    ]
    report_request = CreateReportDTO(
        template_id=template_id,
        output_format=output_format,
        entity_id=entity_id,
        report_name=report_name,
        filters=filters
    )
    check_report_generation_status_and_write_to_file(report_request, report_name, output_format)