Beispiel #1
0
def admin_credentials(fortify, webinspect, clear, username, password):
    if fortify:
        fortify_auth = FortifyAuth()
        if clear:
            fortify_auth.clear_credentials()
            fortifyloghelper.log_info_credentials_clear_success()
        else:
            if username and password:
                try:
                    fortify_auth.write_credentials(username, password)
                    loghelper.log_info_credentials_store_success()

                except ValueError:
                    fortifyloghelper.log_error_credentials_not_stored()

            else:
                username, password = auth_prompt("Fortify")
                try:
                    fortify_auth.write_credentials(username, password)
                    loghelper.log_info_credentials_store_success()
                except ValueError:
                    fortifyloghelper.log_error_credentials_not_stored()

    elif webinspect:
        webinspect_auth = WebInspectAuth()
        if clear:
            webinspect_auth.clear_credentials()
            loghelper.log_info_webinspect_credential_clear_success()
        else:
            if username and password:
                try:
                    webinspect_auth.write_credentials(username, password)
                    loghelper.log_info_credentials_store_success()

                except ValueError:
                    fortifyloghelper.log_error_credentials_not_stored()

            else:
                username, password = auth_prompt("WebInspect")
                try:
                    webinspect_auth.write_credentials(username, password)
                    loghelper.log_info_credentials_store_success()

                except ValueError:
                    fortifyloghelper.log_error_credentials_not_stored()
    else:
        sys.stdout.write(
            str("Please specify either the --fortify or --webinspect options,\n"
                "if you wish to re-set your credentals append --clear"))
Beispiel #2
0
def test_authenticate_clear_credentials_success(secret_mock):
    fortify_auth = FortifyAuth()
    fortify_auth.clear_credentials()

    secret_mock.return_value.clear_credentials.assert_called_once_with(
        'fortify', 'username', 'password')