Esempio n. 1
0
def test_fortify_upload_successful_init_application_name_is_none(
        config_mock, auth_mock, upload_mock):
    expected_username = '******'
    expected_password = '******'
    expected_application = 'Test Application'
    expected_version = 'Test Version'
    expected_scan_name = 'Test Scan Name'
    expected_project_template = 'Test Template'

    auth_mock.return_value.authenticate.return_value = expected_username, expected_password
    config_mock.return_value.project_template = expected_project_template
    config_mock.return_value.application_name = expected_application

    fortify_upload = FortifyUpload(username=None,
                                   password=None,
                                   application_name=None,
                                   version_name=expected_version,
                                   scan_name=expected_scan_name,
                                   custom_value=None)

    assert fortify_upload.username == expected_username
    assert fortify_upload.password == expected_password

    # If scan_name is None, scan_name will equal version_name
    upload_mock.assert_called_once_with(expected_application, expected_version,
                                        expected_project_template,
                                        expected_scan_name, None)
    assert config_mock.call_count == 1
    assert auth_mock.call_count == 1
    assert upload_mock.call_count == 1
Esempio n. 2
0
def test_fortify_upload_upload_successful_upload(config_mock, auth_mock,
                                                 client_mock):
    expected_username = '******'
    expected_password = '******'
    expected_application = 'Test Application'
    expected_version = 'Test Version'
    expected_scan_name = 'Test Scan Name'
    expected_project_template = 'Test Template'
    expected_ssc_url = "test.url"

    auth_mock.return_value.authenticate.return_value = expected_username, expected_password
    config_mock.return_value.project_template = expected_project_template
    config_mock.return_value.ssc_url = expected_ssc_url

    fortify_upload = FortifyUpload(username=expected_username,
                                   password=expected_password,
                                   application_name=expected_application,
                                   version_name=expected_version,
                                   scan_name=expected_scan_name,
                                   custom_value=None)

    assert fortify_upload.username == expected_username
    assert fortify_upload.password == expected_password

    client_mock.assert_called_once_with(fortify_password='******',
                                        fortify_url='test.url',
                                        fortify_username='******')
    assert config_mock.call_count == 1
    assert auth_mock.call_count == 1
    assert client_mock.call_count == 1
Esempio n. 3
0
def test_fortify_upload_upload_throws_io_error(log_mock, config_mock,
                                               auth_mock, client_mock):
    expected_username = '******'
    expected_password = '******'
    expected_application = 'Test Application'
    expected_version = 'Test Version'
    expected_scan_name = 'Test Scan Name'
    expected_project_template = 'Test Template'

    auth_mock.return_value.authenticate.return_value = expected_username, expected_password
    config_mock.return_value.project_template = expected_project_template
    config_mock.project_template()
    client_mock.side_effect = io_error_exception

    with pytest.raises(SystemExit):
        FortifyUpload(username=expected_username,
                      password=expected_password,
                      application_name=expected_application,
                      version_name=expected_version,
                      scan_name=expected_scan_name,
                      custom_value=None)

    log_mock.assert_called_once()
Esempio n. 4
0
def fortify_upload_scan(fortify_user, fortify_password, application, version,
                        scan_name, custom_value):

    FortifyUpload(fortify_user, fortify_password, application, version,
                  scan_name, custom_value)