pagekite: Add functional tests

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-10-04 22:03:46 -07:00 committed by James Valleroy
parent 3ec55ddecd
commit 382e23636a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
5 changed files with 138 additions and 8 deletions

View File

@ -0,0 +1,39 @@
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
@apps @pagekite
Feature: Pagekite Public Visibility
Configure Pagekite public visitbility server.
Background:
Given I'm a logged in user
Given the pagekite application is installed
Scenario: Enable pagekite application
Given pagekite is disabled
When I enable pagekite
Then pagekite should be enabled
Scenario: Disable pagekite application
Given pagekite is enabled
When I disable pagekite
Then pagekite should be disabled
Scenario: Configure pagekite application
Given pagekite is enabled
When I configure pagekite with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret
Then pagekite should be configured with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret

View File

@ -130,3 +130,50 @@ def backup_export(browser, app_name):
@when(parsers.parse('I restore the {app_name:w} app data backup'))
def backup_restore(browser, app_name):
system.backup_restore(browser, app_name)
@given('pagekite is enabled')
def pagekite_is_enabled(browser):
system.pagekite_enable(browser, True)
@given('pagekite is disabled')
def pagekite_is_disabled(browser):
system.pagekite_enable(browser, False)
@when('I enable pagekite')
def pagekite_enable(browser):
system.pagekite_enable(browser, True)
@when('I disable pagekite')
def pagekite_disable(browser):
system.pagekite_enable(browser, False)
@then('pagekite should be enabled')
def pagekite_assert_enabled(browser):
assert system.pagekite_is_enabled(browser)
@then('pagekite should be disabled')
def pagekite_assert_disabled(browser):
assert not system.pagekite_is_enabled(browser)
@when(
parsers.parse(
'I configure pagekite with host {host:S}, port {port:d}, kite name {kite_name:S} and kite secret {kite_secret:w}'
))
def pagekite_configure(browser, host, port, kite_name, kite_secret):
system.pagekite_configure(browser, host, port, kite_name, kite_secret)
@then(
parsers.parse(
'pagekite should be configured with host {host:S}, port {port:d}, kite name {kite_name:S} and kite secret {kite_secret:w}'
))
def pagekite_assert_configured(browser, host, port, kite_name, kite_secret):
assert (host, port, kite_name,
kite_secret) == system.pagekite_get_configuration(browser)

View File

@ -28,7 +28,7 @@ from .service import wait_for_page_update
sys_modules = [
'avahi', 'backups', 'cockpit', 'config', 'datetime', 'diagnostics',
'dynamicdns', 'firewall', 'letsencrypt', 'monkeysphere', 'names',
'networks', 'power', 'snapshot', 'upgrades', 'users'
'networks', 'pagekite', 'power', 'snapshot', 'upgrades', 'users'
]
default_url = config['DEFAULT']['url']

View File

@ -170,9 +170,8 @@ def backup_create(browser, app_name):
def backup_export(browser, app_name):
browser.visit(default_url)
nav_to_module(browser, 'backups')
browser.find_link_by_href(
'/plinth/sys/backups/export/_functional_test_'
+ app_name + '/').first.click()
browser.find_link_by_href('/plinth/sys/backups/export/_functional_test_' +
app_name + '/').first.click()
browser.find_by_id('id_backups-disk_0').first.check()
submit(browser)
@ -181,6 +180,51 @@ def backup_restore(browser, app_name):
browser.visit(default_url)
nav_to_module(browser, 'backups')
browser.find_link_by_href(
'/plinth/sys/backups/restore/Root%2520Filesystem/_functional_test_'
+ app_name + '.tar.gz/').first.click()
'/plinth/sys/backups/restore/Root%2520Filesystem/_functional_test_' +
app_name + '.tar.gz/').first.click()
submit(browser)
def pagekite_enable(browser, should_enable):
"""Enable/disable pagekite service."""
nav_to_module(browser, 'pagekite')
browser.find_link_by_href('/plinth/sys/pagekite/configure/').first.click()
checkbox = browser.find_by_id('id_pagekite-enabled').first
if checkbox.checked == should_enable:
return
if should_enable:
checkbox.check()
else:
checkbox.uncheck()
submit(browser)
def pagekite_is_enabled(browser):
"""Return whether pagekite is enabled."""
nav_to_module(browser, 'pagekite')
browser.find_link_by_href('/plinth/sys/pagekite/configure/').first.click()
return browser.find_by_id('id_pagekite-enabled').value
def pagekite_configure(browser, host, port, kite_name, kite_secret):
"""Configure pagekite basic parameters."""
nav_to_module(browser, 'pagekite')
browser.find_link_by_href('/plinth/sys/pagekite/configure/').first.click()
#time.sleep(0.250) # Wait for 200ms show animation to complete
browser.fill('pagekite-server_domain', host)
browser.fill('pagekite-server_port', str(port))
browser.fill('pagekite-kite_name', kite_name)
browser.fill('pagekite-kite_secret', kite_secret)
submit(browser)
def pagekite_get_configuration(browser):
"""Return pagekite basic parameters."""
nav_to_module(browser, 'pagekite')
browser.find_link_by_href('/plinth/sys/pagekite/configure/').first.click()
return (browser.find_by_name('pagekite-server_domain').value,
int(browser.find_by_name('pagekite-server_port').value),
browser.find_by_name('pagekite-kite_name').value,
browser.find_by_name('pagekite-kite_secret').value)

View File

@ -51,9 +51,9 @@
$('#id_pagekite-enabled').change(function() {
if ($('#id_pagekite-enabled').prop('checked')) {
$('#pagekite-post-enabled-form').show('slow');
$('#pagekite-post-enabled-form').show('fast');
} else {
$('#pagekite-post-enabled-form').hide('slow');
$('#pagekite-post-enabled-form').hide('fast');
}
});