functional-tests: Use Name attribute in backups

- The operations create backup, restore, delete and download are done
based on the name of the backup archive.
- Using select-all to uncheck all checkboxes for a minor speedup while
creating backups.
- Using the new name-based tests for backups for 3 apps

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Minor indentation fix]
[sunil: Use older API for searching links in Splinter, no advantage with new]
[sunil: Update patch for coturn and coquelicot]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>

test use name fixes

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2020-02-06 19:13:22 +05:30 committed by Sunil Mohan Adapa
parent f13ad07ecb
commit 2bf652f469
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
36 changed files with 107 additions and 99 deletions

View File

@ -2,5 +2,4 @@
url = https://localhost:4430 url = https://localhost:4430
username = tester username = tester
password = testingtesting password = testingtesting
delete_root_backup_archives = true
samba_port = 4450 samba_port = 4450

View File

@ -10,8 +10,8 @@ Background:
Scenario: Browser waits for redirect after restoring a backup Scenario: Browser waits for redirect after restoring a backup
Given the bind application is enabled Given the bind application is enabled
When I create a backup of the bind app data When I create a backup of the bind app data with name test_backups
And I restore the bind app data backup And I restore the bind app data backup with name test_backups
And I open the main page And I open the main page
And I wait for 5 seconds And I wait for 5 seconds
Then the main page should be shown Then the main page should be shown
@ -19,8 +19,8 @@ Scenario: Browser waits for redirect after restoring a backup
Scenario: Download, upload and restore a backup Scenario: Download, upload and restore a backup
Given the bind application is enabled Given the bind application is enabled
When I set bind forwarders to 1.1.1.1 When I set bind forwarders to 1.1.1.1
And I create a backup of the bind app data And I create a backup of the bind app data with name test_backups
And I set bind forwarders to 1.0.0.1 And I set bind forwarders to 1.0.0.1
And I download the latest app data backup And I download the app data backup with name test_backups
And I restore the downloaded app data backup And I restore the downloaded app data backup
Then bind forwarders should be 1.1.1.1 Then bind forwarders should be 1.1.1.1

View File

@ -35,10 +35,10 @@ Scenario: Backup and restore bind
Given the bind application is enabled Given the bind application is enabled
When I set bind forwarders to 1.1.1.1 When I set bind forwarders to 1.1.1.1
And I disable bind DNSSEC And I disable bind DNSSEC
And I create a backup of the bind app data And I create a backup of the bind app data with name test_bind
And I set bind forwarders to 1.0.0.1 And I set bind forwarders to 1.0.0.1
And I enable bind DNSSEC And I enable bind DNSSEC
And I restore the bind app data backup And I restore the bind app data backup with name test_bind
Then bind forwarders should be 1.1.1.1 Then bind forwarders should be 1.1.1.1
And bind DNSSEC should be disabled And bind DNSSEC should be disabled

View File

@ -41,10 +41,10 @@ Scenario: Backup and restore coquelicot
When I modify the coquelicot upload password to beforebackup123 When I modify the coquelicot upload password to beforebackup123
And I modify the maximum file size of coquelicot to 128 And I modify the maximum file size of coquelicot to 128
And I upload the sample local file to coquelicot with password beforebackup123 And I upload the sample local file to coquelicot with password beforebackup123
And I create a backup of the coquelicot app data And I create a backup of the coquelicot app data with name test_coquelicot
And I modify the coquelicot upload password to afterbackup123 And I modify the coquelicot upload password to afterbackup123
And I modify the maximum file size of coquelicot to 64 And I modify the maximum file size of coquelicot to 64
And I restore the coquelicot app data backup And I restore the coquelicot app data backup with name test_coquelicot
And I download the uploaded file from coquelicot And I download the uploaded file from coquelicot
Then the coquelicot service should be running Then the coquelicot service should be running
And I should be able to login to coquelicot with password beforebackup123 And I should be able to login to coquelicot with password beforebackup123

View File

@ -17,9 +17,9 @@ Scenario: Enable coturn application
# TODO: Improve this by checking that secret and domain did not change # TODO: Improve this by checking that secret and domain did not change
Scenario: Backup and restore coturn Scenario: Backup and restore coturn
Given the coturn application is enabled Given the coturn application is enabled
When I create a backup of the coturn app data When I create a backup of the coturn app data with name test_coturn
And I restore the coturn app data backup And I restore the coturn app data backup
Then the coturn service should be running Then the coturn service should be running with name test_coturn
Scenario: Disable coturn application Scenario: Disable coturn application
Given the coturn application is enabled Given the coturn application is enabled

View File

@ -25,7 +25,7 @@ Scenario: Set timezone
Scenario: Backup and restore datetime Scenario: Backup and restore datetime
When I set the time zone to Africa/Accra When I set the time zone to Africa/Accra
And I create a backup of the datetime app data And I create a backup of the datetime app data with name test_datetime
And I set the time zone to Africa/Cairo And I set the time zone to Africa/Cairo
And I restore the datetime app data backup And I restore the datetime app data backup with name test_datetime
Then the time zone should be Africa/Accra Then the time zone should be Africa/Accra

View File

@ -23,9 +23,9 @@ Scenario: Backup and restore deluge
Given the deluge application is enabled Given the deluge application is enabled
When all torrents are removed from deluge When all torrents are removed from deluge
And I upload a sample torrent to deluge And I upload a sample torrent to deluge
And I create a backup of the deluge app data And I create a backup of the deluge app data with name test_deluge
And all torrents are removed from deluge And all torrents are removed from deluge
And I restore the deluge app data backup And I restore the deluge app data backup with name test_deluge
Then the deluge service should be running Then the deluge service should be running
And there should be 1 torrents listed in deluge And there should be 1 torrents listed in deluge

View File

@ -10,7 +10,7 @@ Background:
Scenario: Backup and restore configuration Scenario: Backup and restore configuration
Given dynamicdns is configured Given dynamicdns is configured
When I create a backup of the dynamicdns app data When I create a backup of the dynamicdns app data with name test_dynamicdns
And I change the dynamicdns configuration And I change the dynamicdns configuration
And I restore the dynamicdns app data backup And I restore the dynamicdns app data backup with name test_dynamicdns
Then dynamicdns should have the original configuration Then dynamicdns should have the original configuration

View File

@ -26,9 +26,9 @@ Scenario: Disable message archive management
Scenario: Backup and restore ejabberd Scenario: Backup and restore ejabberd
Given the ejabberd application is enabled Given the ejabberd application is enabled
And I have added a contact to my roster And I have added a contact to my roster
When I create a backup of the ejabberd app data When I create a backup of the ejabberd app data with name test_ejabberd
And I delete the contact from my roster And I delete the contact from my roster
And I restore the ejabberd app data backup And I restore the ejabberd app data backup with name test_ejabberd
Then I should have a contact on my roster Then I should have a contact on my roster
Scenario: Disable ejabberd application Scenario: Disable ejabberd application

View File

@ -36,9 +36,9 @@ Scenario: Delete repository
Scenario: Backup and restore gitweb Scenario: Backup and restore gitweb
Given the gitweb application is enabled Given the gitweb application is enabled
And a repository And a repository
When I create a backup of the gitweb app data When I create a backup of the gitweb app data with name test_gitweb
And I delete the repository And I delete the repository
And I restore the gitweb app data backup And I restore the gitweb app data backup with name test_gitweb
Then the repository should be restored Then the repository should be restored
And the gitweb site should be available And the gitweb site should be available

View File

@ -16,9 +16,9 @@ Scenario: Enable wiki application
Scenario: Backup and restore wiki Scenario: Backup and restore wiki
Given the wiki application is enabled Given the wiki application is enabled
When there is an ikiwiki wiki When there is an ikiwiki wiki
And I create a backup of the ikiwiki app data And I create a backup of the ikiwiki app data with name test_ikiwiki
And I delete the ikiwiki wiki And I delete the ikiwiki wiki
And I restore the ikiwiki app data backup And I restore the ikiwiki app data backup with name test_ikiwiki
Then the ikiwiki wiki should be restored Then the ikiwiki wiki should be restored
Scenario: Disable wiki application Scenario: Disable wiki application

View File

@ -13,6 +13,6 @@ Scenario: Install jsxc application
Scenario: Backup and restore jsxc Scenario: Backup and restore jsxc
Given the jsxc application is installed Given the jsxc application is installed
When I create a backup of the jsxc app data When I create a backup of the jsxc app data with name test_jsxc
And I restore the jsxc app data backup And I restore the jsxc app data backup with name test_jsxc
Then the jsxc site should be available Then the jsxc site should be available

View File

@ -65,10 +65,10 @@ Scenario: Upload SVG image
Scenario: Backup and restore mediawiki Scenario: Backup and restore mediawiki
Given the mediawiki application is enabled Given the mediawiki application is enabled
When I create a backup of the mediawiki app data When I create a backup of the mediawiki app data with name test_mediawiki
When I enable mediawiki public registrations When I enable mediawiki public registrations
And I delete the mediawiki main page And I delete the mediawiki main page
And I restore the mediawiki app data backup And I restore the mediawiki app data backup with name test_mediawiki
Then the mediawiki main page should be restored Then the mediawiki main page should be restored
Then the mediawiki site should allow creating accounts Then the mediawiki site should allow creating accounts

View File

@ -24,9 +24,9 @@ Scenario: Backup and restore mldonkey
Given the mldonkey application is enabled Given the mldonkey application is enabled
When all ed2k files are removed from mldonkey When all ed2k files are removed from mldonkey
And I upload a sample ed2k file to mldonkey And I upload a sample ed2k file to mldonkey
And I create a backup of the mldonkey app data And I create a backup of the mldonkey app data with name test_mldonkey
And all ed2k files are removed from mldonkey And all ed2k files are removed from mldonkey
And I restore the mldonkey app data backup And I restore the mldonkey app data backup with name test_mldonkey
Then the mldonkey service should be running Then the mldonkey service should be running
And there should be 1 ed2k files listed in mldonkey And there should be 1 ed2k files listed in mldonkey

View File

@ -29,7 +29,7 @@ Scenario: Publish HTTPS keys
Scenario: Backup and restore monkeysphere Scenario: Backup and restore monkeysphere
When I import SSH key for mydomain.example in monkeysphere When I import SSH key for mydomain.example in monkeysphere
And I import HTTPS key for mydomain.example in monkeysphere And I import HTTPS key for mydomain.example in monkeysphere
And I create a backup of the monkeysphere app data And I create a backup of the monkeysphere app data with name test_monkeysphere
And I restore the monkeysphere app data backup And I restore the monkeysphere app data backup with name test_monkeysphere
Then the SSH key should imported for mydomain.example in monkeysphere Then the SSH key should imported for mydomain.example in monkeysphere
And the HTTPS key should imported for mydomain.example in monkeysphere And the HTTPS key should imported for mydomain.example in monkeysphere

View File

@ -17,8 +17,8 @@ Scenario: Enable mumble application
# certificates are restored. # certificates are restored.
Scenario: Backup and restore mumble Scenario: Backup and restore mumble
Given the mumble application is enabled Given the mumble application is enabled
When I create a backup of the mumble app data When I create a backup of the mumble app data with name test_mumble
And I restore the mumble app data backup And I restore the mumble app data backup with name test_mumble
Then the mumble service should be running Then the mumble service should be running
Scenario: Disable mumble application Scenario: Disable mumble application

View File

@ -21,8 +21,8 @@ Scenario: Download openvpn profile
Scenario: Backup and restore openvpn Scenario: Backup and restore openvpn
Given the openvpn application is enabled Given the openvpn application is enabled
And I download openvpn profile And I download openvpn profile
When I create a backup of the openvpn app data When I create a backup of the openvpn app data with name test_openvpn
And I restore the openvpn app data backup And I restore the openvpn app data backup with name test_openvpn
Then the openvpn profile downloaded should be same as before Then the openvpn profile downloaded should be same as before
Scenario: Disable openvpn application Scenario: Disable openvpn application

View File

@ -21,9 +21,9 @@ Scenario: Configure pagekite application
Scenario: Backup and restore pagekite Scenario: Backup and restore pagekite
Given the pagekite application is enabled Given the pagekite application is enabled
When I configure pagekite with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret When I configure pagekite with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret
And I create a backup of the pagekite app data And I create a backup of the pagekite app data with name test_pagekite
And I configure pagekite with host afterbackup.example.com, port 8082, kite name afterbackup.example.com and kite secret afterbackupsecret And I configure pagekite with host afterbackup.example.com, port 8082, kite name afterbackup.example.com and kite secret afterbackupsecret
And I restore the pagekite app data backup And I restore the pagekite app data backup with name test_pagekite
Then the pagekite service should be running Then the pagekite service should be running
And pagekite should be configured with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret And pagekite should be configured with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret

View File

@ -15,8 +15,8 @@ Scenario: Enable privoxy application
Scenario: Backup and restore privoxy Scenario: Backup and restore privoxy
Given the privoxy application is enabled Given the privoxy application is enabled
When I create a backup of the privoxy app data When I create a backup of the privoxy app data with name test_privoxy
And I restore the privoxy app data backup And I restore the privoxy app data backup with name test_privoxy
Then the privoxy service should be running Then the privoxy service should be running
Scenario: Disable privoxy application Scenario: Disable privoxy application

View File

@ -16,8 +16,8 @@ Scenario: Enable quassel application
# TODO: Improve this to actually check that data configured servers is restored. # TODO: Improve this to actually check that data configured servers is restored.
Scenario: Backup and restore quassel Scenario: Backup and restore quassel
Given the quassel application is enabled Given the quassel application is enabled
When I create a backup of the quassel app data When I create a backup of the quassel app data with name test_quassel
And I restore the quassel app data backup And I restore the quassel app data backup with name test_quassel
Then the quassel service should be running Then the quassel service should be running
Scenario: Disable quassel application Scenario: Disable quassel application

View File

@ -15,8 +15,8 @@ Scenario: Enable roundcube application
Scenario: Backup and restore roundcube Scenario: Backup and restore roundcube
Given the roundcube application is enabled Given the roundcube application is enabled
When I create a backup of the roundcube app data When I create a backup of the roundcube app data with name test_roundcube
And I restore the roundcube app data backup And I restore the roundcube app data backup with name test_roundcube
Then the roundcube site should be available Then the roundcube site should be available
Scenario: Disable roundcube application Scenario: Disable roundcube application

View File

@ -40,9 +40,9 @@ Scenario: Disable open samba share
Scenario: Backup and restore samba Scenario: Backup and restore samba
Given the samba application is enabled Given the samba application is enabled
When I enable the home samba share When I enable the home samba share
And I create a backup of the samba app data And I create a backup of the samba app data with name test_samba
And I disable the home samba share And I disable the home samba share
And I restore the samba app data backup And I restore the samba app data backup with name test_samba
Then the samba service should be running Then the samba service should be running
And I can write to the home samba share And I can write to the home samba share

View File

@ -15,8 +15,8 @@ Scenario: Enable searx application
Scenario: Backup and restore searx Scenario: Backup and restore searx
Given the searx application is enabled Given the searx application is enabled
When I create a backup of the searx app data When I create a backup of the searx app data with name test_searx
And I restore the searx app data backup And I restore the searx app data backup with name test_searx
Then the searx site should be available Then the searx site should be available
Scenario: Enable public access Scenario: Enable public access

View File

@ -14,9 +14,9 @@ Scenario: Disable restricted console logins
Scenario: Backup and restore security Scenario: Backup and restore security
When I enable restricted console logins When I enable restricted console logins
And I create a backup of the security app data And I create a backup of the security app data with name test_security
And I disable restricted console logins And I disable restricted console logins
And I restore the security app data backup And I restore the security app data backup with name test_security
Then restricted console logins should be enabled Then restricted console logins should be enabled
Scenario: Enable restricted console logins Scenario: Enable restricted console logins

View File

@ -17,9 +17,9 @@ Scenario: Enable shadowsocks application
Scenario: Backup and restore shadowsocks Scenario: Backup and restore shadowsocks
Given the shadowsocks application is enabled Given the shadowsocks application is enabled
When I configure shadowsocks with server example.com and password beforebackup123 When I configure shadowsocks with server example.com and password beforebackup123
And I create a backup of the shadowsocks app data And I create a backup of the shadowsocks app data with name test_shadowsocks
And I configure shadowsocks with server example.org and password afterbackup123 And I configure shadowsocks with server example.org and password afterbackup123
And I restore the shadowsocks app data backup And I restore the shadowsocks app data backup with name test_shadowsocks
Then the shadowsocks service should be running Then the shadowsocks service should be running
And shadowsocks should be configured with server example.com and password beforebackup123 And shadowsocks should be configured with server example.com and password beforebackup123

View File

@ -44,8 +44,8 @@ Scenario: Public share
Scenario: Backup and restore sharing Scenario: Backup and restore sharing
Given share tmp is not available Given share tmp is not available
When I add a share tmp from path /tmp for admin When I add a share tmp from path /tmp for admin
And I create a backup of the sharing app data And I create a backup of the sharing app data with name test_sharing
And I remove share tmp And I remove share tmp
And I restore the sharing app data backup And I restore the sharing app data backup with name test_sharing
Then the share tmp should be listed from path /tmp for admin Then the share tmp should be listed from path /tmp for admin
And the share tmp should be accessible And the share tmp should be accessible

View File

@ -22,6 +22,6 @@ Scenario: Disable ssh application
# restored. # restored.
Scenario: Backup and restore ssh Scenario: Backup and restore ssh
Given the ssh application is enabled Given the ssh application is enabled
When I create a backup of the ssh app data When I create a backup of the ssh app data with name test_ssh
And I restore the ssh app data backup And I restore the ssh app data backup with name test_ssh
Then the ssh service should be running Then the ssh service should be running

View File

@ -20,7 +20,7 @@ Scenario: Configure snapshots
Scenario: Backup and restore snapshot Scenario: Backup and restore snapshot
When I configure snapshots with free space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0 When I configure snapshots with free space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0
And I create a backup of the snapshot app data And I create a backup of the snapshot app data with name test_storage_snapshots
And I configure snapshots with free space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1 And I configure snapshots with free space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1
And I restore the snapshot app data backup And I restore the snapshot app data backup with name test_storage_snapshots
Then snapshots should be configured with free space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0 Then snapshots should be configured with free space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0

View File

@ -29,9 +29,9 @@ Scenario: Backup and restore syncthing
Given the syncthing application is enabled Given the syncthing application is enabled
And syncthing folder Test is not present And syncthing folder Test is not present
When I add a folder /tmp as syncthing folder Test When I add a folder /tmp as syncthing folder Test
And I create a backup of the syncthing app data And I create a backup of the syncthing app data with name test_syncthing
And I remove syncthing folder Test And I remove syncthing folder Test
And I restore the syncthing app data backup And I restore the syncthing app data backup with name test_syncthing
Then syncthing folder Test should be present Then syncthing folder Test should be present
Scenario: Disable syncthing application Scenario: Disable syncthing application

View File

@ -40,9 +40,9 @@ Scenario: Remove tahoe introducer
Scenario: Backup and restore tahoe Scenario: Backup and restore tahoe
Given the tahoe application is enabled Given the tahoe application is enabled
And backupdomain.example is a tahoe introducer And backupdomain.example is a tahoe introducer
When I create a backup of the tahoe app data When I create a backup of the tahoe app data with name test_tahoe
And I remove backupdomain.example as a tahoe introducer And I remove backupdomain.example as a tahoe introducer
And I restore the tahoe app data backup And I restore the tahoe app data backup with name test_tahoe
Then the tahoe service should be running Then the tahoe service should be running
And backupdomain.example should be a tahoe connected introducer And backupdomain.example should be a tahoe connected introducer

View File

@ -44,10 +44,10 @@ Scenario: Backup and restore tor
And tor relay is enabled And tor relay is enabled
And tor bridge relay is enabled And tor bridge relay is enabled
And tor hidden services are enabled And tor hidden services are enabled
When I create a backup of the tor app data When I create a backup of the tor app data with name test_tor
And I disable tor relay And I disable tor relay
And I disable tor hidden services And I disable tor hidden services
And I restore the tor app data backup And I restore the tor app data backup with name test_tor
Then the tor service should be running Then the tor service should be running
And tor relay should be enabled And tor relay should be enabled
And tor bridge relay should be enabled And tor bridge relay should be enabled

View File

@ -23,9 +23,9 @@ Scenario: Backup and restore transmission
Given the transmission application is enabled Given the transmission application is enabled
When all torrents are removed from transmission When all torrents are removed from transmission
And I upload a sample torrent to transmission And I upload a sample torrent to transmission
And I create a backup of the transmission app data And I create a backup of the transmission app data with name test_transmission
And all torrents are removed from transmission And all torrents are removed from transmission
And I restore the transmission app data backup And I restore the transmission app data backup with name test_transmission
Then the transmission service should be running Then the transmission service should be running
And there should be 1 torrents listed in transmission And there should be 1 torrents listed in transmission

View File

@ -16,9 +16,9 @@ Scenario: Enable ttrss application
Scenario: Backup and restore ttrss Scenario: Backup and restore ttrss
Given the ttrss application is enabled Given the ttrss application is enabled
And I subscribe to a feed in ttrss And I subscribe to a feed in ttrss
When I create a backup of the ttrss app data When I create a backup of the ttrss app data with name test_ttrss
And I unsubscribe from the feed in ttrss And I unsubscribe from the feed in ttrss
And I restore the ttrss app data backup And I restore the ttrss app data backup with name test_ttrss
Then the ttrss service should be running Then the ttrss service should be running
And I should be subscribed to the feed in ttrss And I should be subscribed to the feed in ttrss

View File

@ -14,9 +14,9 @@ Scenario: Enable automatic upgrades
Scenario: Backup and restore upgrades Scenario: Backup and restore upgrades
When I enable automatic upgrades When I enable automatic upgrades
And I create a backup of the upgrades app data And I create a backup of the upgrades app data with name test_upgrades
And I disable automatic upgrades And I disable automatic upgrades
And I restore the upgrades app data backup And I restore the upgrades app data backup with name test_upgrades
Then automatic upgrades should be enabled Then automatic upgrades should be enabled
Scenario: Disable automatic upgrades Scenario: Disable automatic upgrades

View File

@ -167,22 +167,27 @@ def dynamicdns_has_original_config(session_browser):
assert system.dynamicdns_has_original_config(session_browser) assert system.dynamicdns_has_original_config(session_browser)
@when(parsers.parse('I create a backup of the {app_name:w} app data')) @when(
def backup_create(session_browser, app_name): parsers.parse(
if config.getboolean('DEFAULT', 'delete_root_backup_archives'): 'I create a backup of the {app_name:w} app data with name {archive_name:w}'
system.backup_delete_root_archives(session_browser) ))
system.backup_create(session_browser, app_name) def backup_create(session_browser, app_name, archive_name):
system.backup_create(session_browser, app_name, archive_name)
@when(parsers.parse('I download the latest app data backup')) @when(
def backup_download(session_browser, downloaded_file_info): parsers.parse('I download the app data backup with name {archive_name:w}'))
file_path = system.download_latest_backup(session_browser) def backup_download(session_browser, downloaded_file_info, archive_name):
file_path = system.download_backup(session_browser, archive_name)
downloaded_file_info['path'] = file_path downloaded_file_info['path'] = file_path
@when(parsers.parse('I restore the {app_name:w} app data backup')) @when(
def backup_restore(session_browser, app_name): parsers.parse(
system.backup_restore(session_browser, app_name) 'I restore the {app_name:w} app data backup with name {archive_name:w}'
))
def backup_restore(session_browser, app_name, archive_name):
system.backup_restore(session_browser, app_name, archive_name)
@when(parsers.parse('I restore the downloaded app data backup')) @when(parsers.parse('I restore the downloaded app data backup'))

View File

@ -190,22 +190,30 @@ def dynamicdns_change_config(browser):
submit(browser) submit(browser)
def backup_delete_root_archives(browser): def _click_button_and_confirm(browser, href):
"""Delete all archives of the root borg repository""" buttons = browser.find_link_by_href(href)
browser.visit(default_url + '/plinth/sys/backups/') if buttons:
path = "//a[starts-with(@href,'/plinth/sys/backups/root/delete/')]" buttons.first.click()
while browser.find_by_xpath(path):
browser.find_by_xpath(path).first.click()
with wait_for_page_update(browser, with wait_for_page_update(browser,
expected_url='/plinth/sys/backups/'): expected_url='/plinth/sys/backups/'):
submit(browser) submit(browser)
def backup_create(browser, app_name): def backup_delete_archive_by_name(browser, archive_name):
nav_to_module(browser, 'backups')
href = f'/plinth/sys/backups/root/delete/{archive_name}/'
_click_button_and_confirm(browser, href)
def backup_create(browser, app_name, archive_name=None):
application.install(browser, 'backups') application.install(browser, 'backups')
if archive_name:
backup_delete_archive_by_name(browser, archive_name)
browser.find_link_by_href('/plinth/sys/backups/create/').first.click() browser.find_link_by_href('/plinth/sys/backups/create/').first.click()
for app in browser.find_by_css('input[type=checkbox]'): browser.find_by_id('select-all').uncheck()
app.uncheck() if archive_name:
browser.find_by_id('id_backups-name').fill(archive_name)
# ensure the checkbox is scrolled into view # ensure the checkbox is scrolled into view
browser.execute_script('window.scrollTo(0, 0)') browser.execute_script('window.scrollTo(0, 0)')
@ -213,13 +221,10 @@ def backup_create(browser, app_name):
submit(browser) submit(browser)
def backup_restore(browser, app_name): def backup_restore(browser, app_name, archive_name=None):
nav_to_module(browser, 'backups') nav_to_module(browser, 'backups')
path = "//a[starts-with(@href,'/plinth/sys/backups/root/restore-archive/')]" href = f'/plinth/sys/backups/root/restore-archive/{archive_name}/'
# assume that want to restore the last (most recently created) backup _click_button_and_confirm(browser, href)
browser.find_by_xpath(path).last.click()
with wait_for_page_update(browser, expected_url='/plinth/sys/backups/'):
submit(browser)
def backup_upload_and_restore(browser, app_name, downloaded_file_path): def backup_upload_and_restore(browser, app_name, downloaded_file_path):
@ -234,11 +239,10 @@ def backup_upload_and_restore(browser, app_name, downloaded_file_path):
submit(browser) submit(browser)
def download_latest_backup(browser): def download_backup(browser, archive_name=None):
nav_to_module(browser, 'backups') nav_to_module(browser, 'backups')
path = "//a[starts-with(@href,'/plinth/sys/backups/root/download/')]" href = f'/plinth/sys/backups/root/download/{archive_name}/'
ele = browser.driver.find_elements_by_xpath(path)[0] url = config['DEFAULT']['url'] + href
url = ele.get_attribute('href')
file_path = download_file_logged_in(browser, url, suffix='.tar.gz') file_path = download_file_logged_in(browser, url, suffix='.tar.gz')
return file_path return file_path