diff --git a/systemtests/CMakeLists.txt b/systemtests/CMakeLists.txt index ef0d4f8c5fc..571180d39dc 100644 --- a/systemtests/CMakeLists.txt +++ b/systemtests/CMakeLists.txt @@ -29,7 +29,7 @@ function(ConfigureFilesToSystemtest srcdir subdirectory globexpression configure foreach(CURRENT_FILE ${ALL_FILES}) MATH(EXPR COUNT "${COUNT}+1") string(REPLACE "${CMAKE_SOURCE_DIR}/" "" TARGET_FILE ${CURRENT_FILE}) - string(REPLACE ".in" "" TARGET_FILE ${TARGET_FILE}) + string(REGEX REPLACE ".in$" "" TARGET_FILE ${TARGET_FILE}) # do not mess with .ini files #MESSAGE(STATUS "configuring ${TARGET_FILE}" ) string(REPLACE "${srcdir}/${subdirectory}" "" TARGET_FILE ${TARGET_FILE}) configure_file(${CURRENT_FILE} ${PROJECT_BINARY_DIR}/${subdirectory}/${TARGET_FILE} ${configure_option}) @@ -37,6 +37,17 @@ function(ConfigureFilesToSystemtest srcdir subdirectory globexpression configure MESSAGE(STATUS "Configured ${COUNT} files from ${srcdir} to ${subdirectory} with glob ${globexpression} ${configure_option}" ) endfunction() +# generic function to probe for a python module +function(PythonModuleStatus module) + EXECUTE_PROCESS(COMMAND "${PYTHON}" "-c" "import ${module}" RESULT_VARIABLE ${module}_status ERROR_QUIET) + STRING(TOUPPER ${module} module_uppercase) + IF(${module}_status EQUAL 0) + SET("PYTHON_${module_uppercase}_FOUND" TRUE PARENT_SCOPE) + ELSE() + SET("PYTHON_${module_uppercase}_FOUND" FALSE PARENT_SCOPE) + ENDIF() +endfunction() + macro(CheckForEnabledAndDisabledListEntry TEST_NAME_TO_CHECK) IF(${TEST_NAME_TO_CHECK} IN_LIST SYSTEM_TESTS AND ${TEST_NAME_TO_CHECK} IN_LIST SYSTEM_TESTS_DISABLED) message(FATAL_ERROR "The test name: ${TEST_NAME} is listed ambiguously in SYSTEM_TESTS and SYSTEM_TESTS_DISABLED at the same time") @@ -48,8 +59,8 @@ file(STRINGS ${CMAKE_SOURCE_DIR}/core/src/cats/cats.h DB_VERSION_STRING REGEX .* string(REGEX MATCH [0-9]+ BDB_VERSION ${DB_VERSION_STRING}) find_program(PERL perl) - - +find_program(PYTHON python) +find_program(PHP php) # set variable values to be replaced by configure_file #set(DEFAULT_DB_TYPE ${default_db_backend}) @@ -107,7 +118,6 @@ set(working_dir ${PROJECT_BINARY_DIR}/working) set(piddir ${PROJECT_BINARY_DIR}/piddir) file(MAKE_DIRECTORY ${piddir}) - #set(BASEPORT ${dir_port}) # for config-lib.sh: do not remove @DB___@ but replace them with the original @@ -116,10 +126,6 @@ set(DB_USER @DB_USER@) set(DB_PASS @DB_PASS@) set(DB_VERSION @DB_VERSION@) - - - - ConfigureFilesToSystemtest("systemtests" "data" "*.tgz" COPYONLY) ConfigureFilesToSystemtest("systemtests" "scripts" "functions" @ONLY) @@ -194,6 +200,7 @@ IF(PAM_WRAPPER_LIBRARIES) # BareosFindLibrary(pam_wrapper) ENDIF() ENDIF() + MESSAGE( STATUS "PAM_EXEC_FOUND: " ${PAM_EXEC_FOUND} ) IF(ENABLE_BCONSOLE_PAM_TEST) @@ -202,6 +209,39 @@ ELSE() list(APPEND SYSTEM_TESTS_DISABLED "bconsole-pam") ENDIF() +SET(PHP_FOUND FALSE) +SET(PYTHON_FOUND FALSE) +SET(PYTHON_SELENIUM_FOUND "NOT SEARCHED") +SET(CHROMEDRIVER_FOUND "NOT SEARCHED") + +IF(PHP) + SET(PHP_FOUND TRUE) + IF(PYTHON) + SET(PYTHON_FOUND TRUE) + PythonModuleStatus("selenium") # sets PYTHON_SELENIUM_FOUND to TRUE or FALSE + IF(${PYTHON_SELENIUM_FOUND}) + find_program(CHROMEDRIVER chromedriver) + IF(CHROMEDRIVER) + SET(CHROMEDRIVER_FOUND TRUE) + SET(ENABLE_WEBUI_SELENIUM_TEST TRUE) + ELSE() + SET(CHROMEDRIVER_FOUND FALSE) + ENDIF() + ENDIF() + ENDIF() +ENDIF() + +MESSAGE(STATUS "PHP_FOUND: " ${PHP_FOUND}) +MESSAGE(STATUS "PYTHON_FOUND: " ${PYTHON_FOUND}) +MESSAGE(STATUS "PYTHON_SELENIUM_FOUND: " ${PYTHON_SELENIUM_FOUND}) +MESSAGE(STATUS "CHROMEDRIVER_FOUND: " ${CHROMEDRIVER_FOUND}) + +IF(ENABLE_WEBUI_SELENIUM_TEST) + list(APPEND SYSTEM_TESTS "webui-selenium") +ELSE() + list(APPEND SYSTEM_TESTS_DISABLED "webui-selenium") +ENDIF() + set(BASEPORT 42001) foreach(TEST_NAME ${SYSTEM_TESTS}) @@ -229,7 +269,7 @@ foreach(TEST_NAME ${SYSTEM_TESTS}) math(EXPR fd_port "${BASEPORT} + 1") math(EXPR sd_port "${BASEPORT} + 2") math(EXPR sd2_port "${BASEPORT} + 3") - + math(EXPR php_port "${BASEPORT} + 4") # set(DEFAULT_DB_TYPE ) set(archivedir ${current_test_directory}/storage) @@ -246,6 +286,15 @@ foreach(TEST_NAME ${SYSTEM_TESTS}) file(MAKE_DIRECTORY ${tmpdir}) file(MAKE_DIRECTORY ${working_dir}) + # webui-selenium + IF(${TEST_NAME} STREQUAL "webui-selenium") + set(WEBUICONFDIR ${current_test_directory}/etc/bareos-webui) #used for testenvironment settings + file(MAKE_DIRECTORY ${WEBUICONFDIR}) + configure_file("${CMAKE_SOURCE_DIR}/webui/config/autoload/global.php.in" "${current_test_directory}/webui/config/autoload/global.php" @ONLY) + configure_file("${CMAKE_SOURCE_DIR}/systemtests/tests/webui-selenium/directors.ini.in" "${current_test_directory}/etc/bareos-webui/directors.ini" @ONLY) + file(COPY "${CMAKE_SOURCE_DIR}/webui/install/configuration.ini" DESTINATION "${current_test_directory}/etc/bareos-webui/configuration.ini") + ENDIF() + ConfigureFilesToSystemtest("systemtests" "tests/${TEST_NAME}" "*" @ONLY) configure_file("environment.in" "tests/${TEST_NAME}/environment" @ONLY) @@ -318,3 +367,4 @@ execute_process(COMMAND execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${scriptdir}/bareos ${bindir}/bareos) + diff --git a/systemtests/environment.in b/systemtests/environment.in index 89bd24fc5ed..b7dbe2c1e64 100644 --- a/systemtests/environment.in +++ b/systemtests/environment.in @@ -56,3 +56,21 @@ export db_password=@db_password@ export db_user=@db_user@ export PAM_WRAPPER_LIBRARIES=@PAM_WRAPPER_LIBRARIES@ + +# +# Selenium test +# + +export BAREOS_WEBUI_CONFDIR=@WEBUICONFDIR@ + +export BAREOS_WEBUI_BROWSER=chrome +export BAREOS_WEBUI_CHROMEDRIVER_PATH=@CHROMEDRIVER@ + +export BAREOS_WEBUI_BASE_URL=http://localhost:@php_port@/ +export BAREOS_WEBUI_USERNAME=admin +export BAREOS_WEBUI_PASSWORD=admin +export BAREOS_WEBUI_CLIENT_NAME=bareos-fd +export BAREOS_WEBUI_RESTOREFILE=${PROJECT_BINARY_DIR} +export BAREOS_WEBUI_LOG_PATH=${logdir} +export BAREOS_WEBUI_DELAY=1 + diff --git a/systemtests/tests/webui-selenium/directors.ini.in b/systemtests/tests/webui-selenium/directors.ini.in new file mode 100644 index 00000000000..a6930caea3c --- /dev/null +++ b/systemtests/tests/webui-selenium/directors.ini.in @@ -0,0 +1,82 @@ +; +; Bareos WebUI Configuration File +; +; File: /usr/local/etc/bareos-webui/directors.ini +; + +;------------------------------------------------------------------------------ +; Section localhost-dir +;------------------------------------------------------------------------------ +[localhost-dir] + +; Enable or disable section. Possible values are "yes" or "no", the default is "yes". +enabled = "yes" + +; Fill in the IP-Address or FQDN of you director. +diraddress = "localhost" + +; Default value is 9101 +dirport = @dir_port@ + +; Set catalog to explicit value if you have multiple catalogs +;catalog = "MyCatalog" + +; Set the console name and password for a dedicated pam console; +; the counterpart console-config in the director must have set +; UsePamAuthentication = yes +;pam_console_name = "admin" +;pam_console_password = "admin" + +; TLS verify peer +; Possible values: true or false +tls_verify_peer = false + +; Server can do TLS +; Possible values: true or false +server_can_do_tls = false + +; Server requires TLS +; Possible values: true or false +server_requires_tls = false + +; Client can do TLS +; Possible values: true or false +client_can_do_tls = false + +; Client requires TLS +; Possible value: true or false +client_requires_tls = false + +; Path to the certificate authority file +; E.g. ca_file = "/usr/local/etc/bareos/tls/BareosCA.crt" +;ca_file = "" + +; Path to the cert file which needs to contain the client certificate and the key in PEM encoding +; E.g. ca_file = "/usr/local/etc/bareos/tls/restricted-named-console.pem" +;cert_file = "" + +; Passphrase needed to unlock the above cert file if set +;cert_file_passphrase = "" + +; Allowed common names +; E.g. allowed_cns = "host1.example.com" +;allowed_cns = "" + +;------------------------------------------------------------------------------ +; Section another-host-dir +;------------------------------------------------------------------------------ +[another-host-dir] +enabled = "no" +diraddress = "192.168.120.1" +dirport = 9101 +;catalog = "MyCatalog" +;tls_verify_peer = false +;server_can_do_tls = false +;server_requires_tls = false +;client_can_do_tls = false +;client_requires_tls = false +;ca_file = "" +;cert_file = "" +;cert_file_passphrase = "" +;allowed_cns = "" + diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf.in new file mode 100644 index 00000000000..479bc6fecbb --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf.in @@ -0,0 +1,8 @@ +Catalog { + Name = MyCatalog + #dbdriver = "@DEFAULT_DB_TYPE@" + dbdriver = "XXX_REPLACE_WITH_DATABASE_DRIVER_XXX" + dbname = "@db_name@" + dbuser = "@db_user@" + dbpassword = "@db_password@" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/client/bareos-fd.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/client/bareos-fd.conf.in new file mode 100644 index 00000000000..470ca702035 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/client/bareos-fd.conf.in @@ -0,0 +1,7 @@ +Client { + Name = bareos-fd + Description = "Client resource of the Director itself." + Address = localhost + Password = "@fd_password@" # password for FileDaemon + FD PORT = @fd_port@ +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/admin.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/admin.conf new file mode 100644 index 00000000000..fe312662e3e --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/admin.conf @@ -0,0 +1,17 @@ +# +# Restricted console used by bareos-webui +# +Console { + Name = admin + Password = "admin" + Profile = "webui-admin" + + + # As php does not support TLS-PSK, + # and the director has TLS enabled by default, + # we need to either disable TLS or setup + # TLS with certificates. + # + # For testing purposes we disable it here + TLS Enable = No +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/bareos-mon.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/bareos-mon.conf.in new file mode 100644 index 00000000000..d276adcb87d --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/console/bareos-mon.conf.in @@ -0,0 +1,7 @@ +Console { + Name = bareos-mon + Description = "Restricted console used by tray-monitor to get the status of the director." + Password = "@mon_dir_password@" + CommandACL = status, .status + JobACL = *all* +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/director/bareos-dir.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/director/bareos-dir.conf.in new file mode 100644 index 00000000000..5546d140d72 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/director/bareos-dir.conf.in @@ -0,0 +1,27 @@ +Director { # define myself + Name = bareos-dir + QueryFile = "@scriptdir@/query.sql" + Maximum Concurrent Jobs = 10 + Password = "@dir_password@" # Console password + Messages = Daemon + Auditing = yes + + # Enable the Heartbeat if you experience connection losses + # (eg. because of your router or firewall configuration). + # Additionally the Heartbeat can be enabled in bareos-sd and bareos-fd. + # + # Heartbeat Interval = 1 min + + # remove comment in next line to load dynamic backends from specified directory + Backend Directory = @backenddir@ + + # remove comment from "Plugin Directory" to load plugins from specified directory. + # if "Plugin Names" is defined, only the specified plugins will be loaded, + # otherwise all director plugins (*-dir.so) from the "Plugin Directory". + # + # Plugin Directory = "@plugindir@" + # Plugin Names = "" + Working Directory = "@working_dir@" + Pid Directory = "@piddir@" + DirPort = @dir_port@ +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf new file mode 100644 index 00000000000..ec1a47c971b --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf @@ -0,0 +1,11 @@ +FileSet { + Name = "Catalog" + Description = "Backup the catalog dump and Bareos configuration files." + Include { + Options { + signature = MD5 + } + File = "/var/lib/bareos/bareos.sql" # database dump + File = "/usr/local/etc/bareos" # configuration + } +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf.in new file mode 100644 index 00000000000..c7cdc433fe1 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/Catalog.conf.in @@ -0,0 +1,11 @@ +FileSet { + Name = "Catalog" + Description = "Backup the catalog dump and Bareos configuration files." + Include { + Options { + signature = MD5 + } + File = "@working_dir@/@db_name@.sql" # database dump + File = "@confdir@" # configuration + } +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf new file mode 100644 index 00000000000..3a3336823ac --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf @@ -0,0 +1,31 @@ +FileSet { + Name = "LinuxAll" + Description = "Backup all regular filesystems, determined by filesystem type." + Include { + Options { + Signature = MD5 # calculate md5 checksum per file + One FS = No # change into other filessytems + FS Type = btrfs + FS Type = ext2 # filesystems of given types will be backed up + FS Type = ext3 # others will be ignored + FS Type = ext4 + FS Type = reiserfs + FS Type = jfs + FS Type = xfs + FS Type = zfs + } + File = / + } + # Things that usually have to be excluded + # You have to exclude /var/lib/bareos/storage + # on your bareos server + Exclude { + File = /var/lib/bareos + File = /var/lib/bareos/storage + File = /proc + File = /tmp + File = /var/tmp + File = /.journal + File = /.fsck + } +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf.in new file mode 100644 index 00000000000..cee45dfa3ed --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf.in @@ -0,0 +1,31 @@ +FileSet { + Name = "LinuxAll" + Description = "Backup all regular filesystems, determined by filesystem type." + Include { + Options { + Signature = MD5 # calculate md5 checksum per file + One FS = No # change into other filessytems + FS Type = btrfs + FS Type = ext2 # filesystems of given types will be backed up + FS Type = ext3 # others will be ignored + FS Type = ext4 + FS Type = reiserfs + FS Type = jfs + FS Type = xfs + FS Type = zfs + } + File = / + } + # Things that usually have to be excluded + # You have to exclude @archivedir@ + # on your bareos server + Exclude { + File = @working_dir@ + File = @archivedir@ + File = /proc + File = /tmp + File = /var/tmp + File = /.journal + File = /.fsck + } +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/SelfTest.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/SelfTest.conf new file mode 100644 index 00000000000..a117233f531 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/fileset/SelfTest.conf @@ -0,0 +1,11 @@ +FileSet { + Name = "SelfTest" + Description = "fileset just to backup some files for selftest" + Include { + Options { + Signature = MD5 # calculate md5 checksum per file + } + #File = "/usr/local/sbin" + File= + RunBeforeJob = "@scriptdir@/make_catalog_backup.pl MyCatalog" + + # This deletes the copy of the catalog + RunAfterJob = "@scriptdir@/delete_catalog_backup" + + # This sends the bootstrap via mail for disaster recovery. + # Should be sent to another system, please change recipient accordingly + Write Bootstrap = "|@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" @job_email@" # (#01) + Priority = 11 # run after main backup +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/RestoreFiles.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/RestoreFiles.conf.in new file mode 100644 index 00000000000..577f6f9b6bb --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/RestoreFiles.conf.in @@ -0,0 +1,11 @@ +Job { + Name = "RestoreFiles" + Description = "Standard Restore template. Only one such job is needed for all standard Jobs/Clients/Storage ..." + Type = Restore + Client = bareos-fd + FileSet = "LinuxAll" + Storage = File + Pool = Incremental + Messages = Standard + Where = @tmp@/bareos-restores +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/backup-bareos-fd.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/backup-bareos-fd.conf.in new file mode 100644 index 00000000000..ca1891f9620 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/job/backup-bareos-fd.conf.in @@ -0,0 +1,5 @@ +Job { + Name = "backup-bareos-fd" + JobDefs = "DefaultJob" + Client = "bareos-fd" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf.in new file mode 100644 index 00000000000..0d1c0bd04e7 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf.in @@ -0,0 +1,16 @@ +JobDefs { + Name = "DefaultJob" + Type = Backup + Level = Incremental + Client = bareos-fd + FileSet = "SelfTest" # selftest fileset (#13) + Schedule = "WeeklyCycle" + Storage = File + Messages = Standard + Pool = Incremental + Priority = 10 + Write Bootstrap = "@working_dir@/%c.bsr" + Full Backup Pool = Full # write Full Backups into "Full" Pool (#05) + Differential Backup Pool = Differential # write Diff Backups into "Differential" Pool (#08) + Incremental Backup Pool = Incremental # write Incr Backups into "Incremental" Pool (#11) +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Daemon.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Daemon.conf.in new file mode 100644 index 00000000000..ce0e5ec6778 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Daemon.conf.in @@ -0,0 +1,9 @@ +Messages { + Name = Daemon + Description = "Message delivery for daemon messages (no job)." + mailcommand = "@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \<%r\>\" -s \"Bareos daemon message\" %r" + mail = @job_email@ = all, !skipped, !audit # (#02) + console = all, !skipped, !saved, !audit + append = "@logdir@/bareos.log" = all, !skipped, !audit + append = "@logdir@/bareos-audit.log" = audit +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Standard.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Standard.conf.in new file mode 100644 index 00000000000..fdcc1f735e5 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/messages/Standard.conf.in @@ -0,0 +1,11 @@ +Messages { + Name = Standard + Description = "Reasonable message delivery -- send most everything to email address and to the console." + operatorcommand = "@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \<%r\>\" -s \"Bareos: Intervention needed for %j\" %r" + mailcommand = "@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r" + operator = @job_email@ = mount # (#03) + mail = @job_email@ = all, !skipped, !saved, !audit # (#02) + console = all, !skipped, !saved, !audit + append = "@logdir@/bareos.log" = all, !skipped, !saved, !audit + catalog = all, !skipped, !saved, !audit +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Differential.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Differential.conf new file mode 100644 index 00000000000..25ce24821ab --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Differential.conf @@ -0,0 +1,10 @@ +Pool { + Name = Differential + Pool Type = Backup + Recycle = yes # Bareos can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 90 days # How long should the Differential Backups be kept? (#09) + Maximum Volume Bytes = 10G # Limit Volume size to something reasonable + Maximum Volumes = 100 # Limit number of Volumes in Pool + Label Format = "Differential-" # Volumes will be labeled "Differential-" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Full.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Full.conf new file mode 100644 index 00000000000..867fc66b483 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Full.conf @@ -0,0 +1,10 @@ +Pool { + Name = Full + Pool Type = Backup + Recycle = yes # Bareos can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 365 days # How long should the Full Backups be kept? (#06) + Maximum Volume Bytes = 50G # Limit Volume size to something reasonable + Maximum Volumes = 100 # Limit number of Volumes in Pool + Label Format = "Full-" # Volumes will be labeled "Full-" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Incremental.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Incremental.conf new file mode 100644 index 00000000000..f4dbbab6650 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Incremental.conf @@ -0,0 +1,10 @@ +Pool { + Name = Incremental + Pool Type = Backup + Recycle = yes # Bareos can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 30 days # How long should the Incremental Backups be kept? (#12) + Maximum Volume Bytes = 1G # Limit Volume size to something reasonable + Maximum Volumes = 100 # Limit number of Volumes in Pool + Label Format = "Incremental-" # Volumes will be labeled "Incremental-" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Scratch.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Scratch.conf new file mode 100644 index 00000000000..3a489b19871 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/pool/Scratch.conf @@ -0,0 +1,4 @@ +Pool { + Name = Scratch + Pool Type = Scratch +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/operator.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/operator.conf new file mode 100644 index 00000000000..6edd0166dca --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/operator.conf @@ -0,0 +1,18 @@ +Profile { + Name = operator + Description = "Profile allowing normal Bareos operations." + + Command ACL = !.bvfs_clear_cache, !.exit, !.sql + Command ACL = !configure, !create, !delete, !purge, !prune, !sqlquery, !umount, !unmount + Command ACL = *all* + + Catalog ACL = *all* + Client ACL = *all* + FileSet ACL = *all* + Job ACL = *all* + Plugin Options ACL = *all* + Pool ACL = *all* + Schedule ACL = *all* + Storage ACL = *all* + Where ACL = *all* +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/webui-admin.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/webui-admin.conf new file mode 100644 index 00000000000..860af09e4fa --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/profile/webui-admin.conf @@ -0,0 +1,15 @@ +# +# bareos-webui webui-admin profile resource +# +Profile { + Name = "webui-admin" + CommandACL = !.bvfs_clear_cache, !.exit, !.sql, !configure, !create, !delete, !purge, !prune, !sqlquery, !umount, !unmount, *all* + Job ACL = *all* + Schedule ACL = *all* + Catalog ACL = *all* + Pool ACL = *all* + Storage ACL = *all* + Client ACL = *all* + FileSet ACL = *all* + Where ACL = *all* +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycle.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycle.conf new file mode 100644 index 00000000000..a2181c7db3d --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycle.conf @@ -0,0 +1,6 @@ +Schedule { + Name = "WeeklyCycle" +# Run = Full 1st sat at 21:00 # (#04) +# Run = Differential 2nd-5th sat at 21:00 # (#07) +# Run = Incremental mon-fri at 21:00 # (#10) +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycleAfterBackup.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycleAfterBackup.conf new file mode 100644 index 00000000000..49b245671cb --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/schedule/WeeklyCycleAfterBackup.conf @@ -0,0 +1,5 @@ +Schedule { + Name = "WeeklyCycleAfterBackup" + Description = "This schedule does the catalog. It starts after the WeeklyCycle." +# Run = Full mon-fri at 21:10 +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/storage/File.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/storage/File.conf.in new file mode 100644 index 00000000000..4058ddc7edc --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-dir.d/storage/File.conf.in @@ -0,0 +1,8 @@ +Storage { + Name = File + Address = @hostname@ # N.B. Use a fully qualified name here (do not use "localhost" here). + Password = "@sd_password@" + Device = FileStorage + Media Type = File + SD Port = @sd_port@ +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/client/myself.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/client/myself.conf.in new file mode 100644 index 00000000000..30a1d912c5b --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/client/myself.conf.in @@ -0,0 +1,20 @@ +Client { + Name = @basename@-fd + Maximum Concurrent Jobs = 20 + + # remove comment from "Plugin Directory" to load plugins from specified directory. + # if "Plugin Names" is defined, only the specified plugins will be loaded, + # otherwise all filedaemon plugins (*-fd.so) from the "Plugin Directory". + # + # Plugin Directory = "@plugindir@" + # Plugin Names = "" + + # if compatible is set to yes, we are compatible with bacula + # if set to no, new bareos features are enabled which is the default + # compatible = yes + + Working Directory = "@working_dir@" + Pid Directory = "@piddir@" + FD Port = @fd_port@ + +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-dir.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-dir.conf.in new file mode 100644 index 00000000000..c8dc7085a45 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-dir.conf.in @@ -0,0 +1,5 @@ +Director { + Name = bareos-dir + Password = "@fd_password@" + Description = "Allow the configured Director to access this file daemon." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-mon.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-mon.conf.in new file mode 100644 index 00000000000..630c3a9abd3 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/director/bareos-mon.conf.in @@ -0,0 +1,6 @@ +Director { + Name = bareos-mon + Password = "@mon_fd_password@" + Monitor = yes + Description = "Restricted Director, used by tray-monitor to get the status of this file daemon." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/messages/Standard.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/messages/Standard.conf new file mode 100644 index 00000000000..97788e00573 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-fd.d/messages/Standard.conf @@ -0,0 +1,5 @@ +Messages { + Name = Standard + Director = bareos-dir = all, !skipped, !restored + Description = "Send relevant messages to the Director." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/device/FileStorage.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/device/FileStorage.conf.in new file mode 100644 index 00000000000..d7f2d1dcf19 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/device/FileStorage.conf.in @@ -0,0 +1,11 @@ +Device { + Name = FileStorage + Media Type = File + Archive Device = @archivedir@ + LabelMedia = yes; # lets Bareos label unlabeled media + Random Access = yes; + AutomaticMount = yes; # when device opened, read it + RemovableMedia = no; + AlwaysOpen = no; + Description = "File device. A connecting Director must have the same Name and MediaType." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-dir.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-dir.conf.in new file mode 100644 index 00000000000..deef3360c2d --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-dir.conf.in @@ -0,0 +1,5 @@ +Director { + Name = bareos-dir + Password = "@sd_password@" + Description = "Director, who is permitted to contact this storage daemon." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-mon.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-mon.conf.in new file mode 100644 index 00000000000..e3cfdee6315 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/director/bareos-mon.conf.in @@ -0,0 +1,6 @@ +Director { + Name = bareos-mon + Password = "@mon_sd_password@" + Monitor = yes + Description = "Restricted Director, used by tray-monitor to get the status of this storage daemon." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/messages/Standard.conf b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/messages/Standard.conf new file mode 100644 index 00000000000..468348e62fc --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/messages/Standard.conf @@ -0,0 +1,5 @@ +Messages { + Name = Standard + Director = bareos-dir = all + Description = "Send all messages to the Director." +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in new file mode 100644 index 00000000000..cfdc01a1ca8 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bareos-sd.d/storage/bareos-sd.conf.in @@ -0,0 +1,14 @@ +Storage { + Name = bareos-sd + Maximum Concurrent Jobs = 20 + + # remove comment from "Plugin Directory" to load plugins from specified directory. + # if "Plugin Names" is defined, only the specified plugins will be loaded, + # otherwise all storage plugins (*-sd.so) from the "Plugin Directory". + # + # Plugin Directory = "@plugindir@" + # Plugin Names = "" + Working Directory = "@working_dir@" + Pid Directory = "@piddir@" + SD Port = @sd_port@ +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/bconsole.conf.in b/systemtests/tests/webui-selenium/etc/bareos/bconsole.conf.in new file mode 100644 index 00000000000..ecb6ad00dce --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/bconsole.conf.in @@ -0,0 +1,10 @@ +# +# Bareos User Agent (or Console) Configuration File +# + +Director { + Name = @basename@-dir + DIRport = @dir_port@ + address = @hostname@ + Password = "@dir_password@" +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/client/FileDaemon-local.conf.in b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/client/FileDaemon-local.conf.in new file mode 100644 index 00000000000..dd00dd9f103 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/client/FileDaemon-local.conf.in @@ -0,0 +1,5 @@ +Client { + Name = @basename@-fd + Address = localhost + Password = "@mon_fd_password@" # password for FileDaemon +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/director/Director-local.conf.in b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/director/Director-local.conf.in new file mode 100644 index 00000000000..55dae492250 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/director/Director-local.conf.in @@ -0,0 +1,4 @@ +Director { + Name = bareos-dir + Address = localhost +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/monitor/bareos-mon.conf.in b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/monitor/bareos-mon.conf.in new file mode 100644 index 00000000000..cddfa253945 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/monitor/bareos-mon.conf.in @@ -0,0 +1,7 @@ +Monitor { + # Name to establish connections to Director Console, Storage Daemon and File Daemon. + Name = bareos-mon + # Password to access the Director + Password = "@mon_dir_password@" # password for the Directors + RefreshInterval = 30 seconds +} diff --git a/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/storage/StorageDaemon-local.conf.in b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/storage/StorageDaemon-local.conf.in new file mode 100644 index 00000000000..6538f4fd248 --- /dev/null +++ b/systemtests/tests/webui-selenium/etc/bareos/tray-monitor.d/storage/StorageDaemon-local.conf.in @@ -0,0 +1,5 @@ +Storage { + Name = bareos-sd + Address = localhost + Password = "@mon_sd_password@" # password for StorageDaemon +} diff --git a/systemtests/tests/webui-selenium/testrunner.in b/systemtests/tests/webui-selenium/testrunner.in new file mode 100755 index 00000000000..2ea52de6f49 --- /dev/null +++ b/systemtests/tests/webui-selenium/testrunner.in @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Run a simple backup +# then restore it. +# +TestName="$(basename "$(pwd)")" +export TestName + +JobName=backup-bareos-fd +. ./environment +. ${scripts}/functions + +${scripts}/cleanup +${scripts}/setup + + +# Directory to backup. +# This directory will be created by setup_data(). +BackupDirectory="${tmp}/data" + +# Use a tgz to setup data to be backuped. +# Data will be placed at "${tmp}/data/". +setup_data + +start_test + +cat <$tmp/bconcmds +@$out /dev/null +messages +@$out $tmp/log1.out +run job=$JobName yes +wait +messages +quit +END_OF_DATA + +run_bareos + +@PHP@ -S 127.0.0.1:@php_port@ -t @PROJECT_SOURCE_DIR@/../webui/public/ &> $tmp/php.out & + +PHP_PID=$(echo $!) + +# run tests but stop the test run on the first error or failure +@PYTHON@ @CMAKE_SOURCE_DIR@/webui/tests/selenium/webui-selenium-test.py --fail &> $tmp/selenium.out + +estat=$? +export estat + +kill "${PHP_PID}" + +stop_bareos + +end_test diff --git a/webui/config/autoload/global.php.in b/webui/config/autoload/global.php.in index 458b39463c3..861ce3bc980 100644 --- a/webui/config/autoload/global.php.in +++ b/webui/config/autoload/global.php.in @@ -35,8 +35,13 @@ * file. */ -$directors_ini = "@WEBUICONFDIR@/directors.ini"; -$configuration_ini = "@WEBUICONFDIR@/configuration.ini"; +if(!empty(getenv('BAREOS_WEBUI_CONFDIR'))) { + $directors_ini = getenv('BAREOS_WEBUI_CONFDIR')."/directors.ini"; + $configuration_ini = getenv('BAREOS_WEBUI_CONFDIR')."/configuration.ini"; +} else { + $directors_ini = "@WEBUICONFDIR@/directors.ini"; + $configuration_ini = "@WEBUICONFDIR@/configuration.ini"; +} $directors = null; $configuration = null; diff --git a/webui/tests/selenium/webui-selenium-test.py b/webui/tests/selenium/webui-selenium-test.py index 6e08acea8e1..e15520491b2 100755 --- a/webui/tests/selenium/webui-selenium-test.py +++ b/webui/tests/selenium/webui-selenium-test.py @@ -98,7 +98,8 @@ def __init__(self, username, password): class SeleniumTest(unittest.TestCase): - browser = 'firefox' + browser = 'chrome' + chromdriverpath = None base_url = 'http://127.0.0.1/bareos-webui' username = 'admin' password = 'secret' @@ -179,8 +180,14 @@ def setUp(self): self.__setUpTravis() else: if self.browser == 'chrome': - chromedriverpath = self.getChromedriverpath() - self.driver = webdriver.Chrome(chromedriverpath) + self.chromedriverpath = self.getChromedriverpath() + self.driver = webdriver.Chrome(self.chromedriverpath) + # disable experimental feature + opt = webdriver.ChromeOptions() + opt.add_experimental_option('w3c',False) + self.driver = webdriver.Chrome(chrome_options=opt) + # set explicit window size + self.driver.set_window_size(1920,1080) elif self.browser == "firefox": d = DesiredCapabilities.FIREFOX d['loggingPrefs'] = {'browser': 'ALL'} @@ -304,12 +311,10 @@ def test_restore(self): self.wait_for_element(By.XPATH, '//a[contains(text(),"%s/")]' % i).send_keys(Keys.ARROW_RIGHT) self.wait_for_element(By.XPATH, '//a[contains(text(),"%s")]' % pathlist[-1]).click() # Submit restore - self.wait_and_click(By.XPATH, '//input[@id="submit"]') - # Confirms alert - self.assertRegexpMatches(self.close_alert_and_get_its_text(), r'^Are you sure[\s\S]$') - # switch to dashboard to prevent that modals are open before logout - self.wait_and_click(By.XPATH, '//a[contains(@href, "/dashboard/")]', By.XPATH, '//div[@id="modal-002"]//button[.="Close"]') - self.close_alert_and_get_its_text() + self.wait_and_click(By.XPATH, '//button[@id="btn-form-submit"]') + # Confirm modals + self.wait_and_click(By.XPATH, '//div[@id="modal-003"]//button[.="OK"]') + self.wait_and_click(By.XPATH, '//div[@id="modal-002"]//button[.="Close"]') # Logout self.logout() @@ -401,10 +406,12 @@ def logout(self): # def getChromedriverpath(self): - # On OS X: Chromedriver path is 'usr/local/lib/chromium-browser/chromedriver' - for chromedriverpath in ['/usr/lib/chromium-browser/chromedriver', '/usr/local/lib/chromium-browser/chromedriver']: - if os.path.isfile(chromedriverpath): - return chromedriverpath + if SeleniumTest.chromedriverpath is None: + for chromedriverpath in ['/usr/local/sbin/chromedriver', '/usr/local/bin/chromedriver']: + if os.path.isfile(chromedriverpath): + return chromedriverpath + else: + return SeleniumTest.chromedriverpath raise IOError('Chrome Driver file not found.') def wait_and_click(self, by, value, modal_by=None, modal_value=None): @@ -503,31 +510,31 @@ def get_env(): if not available or set use defaults. ''' - chromedriverpath = os.environ.get('BAREOS_CHROMEDRIVER_PATH') + chromedriverpath = os.environ.get('BAREOS_WEBUI_CHROMEDRIVER_PATH') if chromedriverpath: SeleniumTest.chromedriverpath = chromedriverpath - browser = os.environ.get('BAREOS_BROWSER') + browser = os.environ.get('BAREOS_WEBUI_BROWSER') if browser: SeleniumTest.browser = browser - base_url = os.environ.get('BAREOS_BASE_URL') + base_url = os.environ.get('BAREOS_WEBUI_BASE_URL') if base_url: SeleniumTest.base_url = base_url.rstrip('/') - username = os.environ.get('BAREOS_USERNAME') + username = os.environ.get('BAREOS_WEBUI_USERNAME') if username: SeleniumTest.username = username - password = os.environ.get('BAREOS_PASSWORD') + password = os.environ.get('BAREOS_WEBUI_PASSWORD') if password: SeleniumTest.password = password - client = os.environ.get('BAREOS_CLIENT_NAME') + client = os.environ.get('BAREOS_WEBUI_CLIENT_NAME') if client: SeleniumTest.client = client - restorefile = os.environ.get('BAREOS_RESTOREFILE') + restorefile = os.environ.get('BAREOS_WEBUI_RESTOREFILE') if restorefile: SeleniumTest.restorefile = restorefile - logpath = os.environ.get('BAREOS_LOG_PATH') + logpath = os.environ.get('BAREOS_WEBUI_LOG_PATH') if logpath: SeleniumTest.logpath = logpath - sleeptime = os.environ.get('BAREOS_DELAY') + sleeptime = os.environ.get('BAREOS_WEBUI_DELAY') if sleeptime: SeleniumTest.sleeptime = float(sleeptime) if os.environ.get('TRAVIS_COMMIT'): @@ -540,3 +547,4 @@ def get_env(): if __name__ == '__main__': get_env() unittest.main() +