diff --git a/actions/upgrades b/actions/upgrades index ada24e019..69a5f3875 100755 --- a/actions/upgrades +++ b/actions/upgrades @@ -20,7 +20,6 @@ Configures or runs unattended-upgrades """ import argparse -import os import re import subprocess import sys diff --git a/functional_tests/features/upgrades.feature b/functional_tests/features/upgrades.feature new file mode 100644 index 000000000..d0bfa9550 --- /dev/null +++ b/functional_tests/features/upgrades.feature @@ -0,0 +1,33 @@ +# +# 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 . +# + +@essential @upgrades @system +Feature: Software Upgrades + Configure automatic software upgrades + +Background: + Given I'm a logged in user + +Scenario: Enable automatic upgrades + Given automatic upgrades are disabled + When I enable automatic upgrades + Then automatic upgrades should be enabled + +Scenario: Disable automatic upgrades + Given automatic upgrades are enabled + When I disable automatic upgrades + Then automatic upgrades should be disabled diff --git a/functional_tests/step_definitions/system.py b/functional_tests/step_definitions/system.py index a76cfdee9..c42395dde 100644 --- a/functional_tests/step_definitions/system.py +++ b/functional_tests/step_definitions/system.py @@ -277,3 +277,21 @@ def security_enable_restricted_logins(browser, enable): def security_assert_restricted_logins(browser, enabled): enabled = (enabled == 'enabled') assert system.security_get_restricted_logins(browser) == enabled + + +@given(parsers.parse('automatic upgrades are {enabled:w}')) +def upgrades_given_enable_automatic(browser, enabled): + should_enable = (enabled == 'enabled') + system.upgrades_enable_automatic(browser, should_enable) + + +@when(parsers.parse('I {enable:w} automatic upgrades')) +def upgrades_enable_automatic(browser, enable): + should_enable = (enable == 'enable') + system.upgrades_enable_automatic(browser, should_enable) + + +@then(parsers.parse('automatic upgrades should be {enabled:w}')) +def upgrades_assert_automatic(browser, enabled): + should_be_enabled = (enabled == 'enabled') + assert system.upgrades_get_automatic(browser) == should_be_enabled diff --git a/functional_tests/support/system.py b/functional_tests/support/system.py index 9efde69c5..e8b60a6d5 100644 --- a/functional_tests/support/system.py +++ b/functional_tests/support/system.py @@ -308,3 +308,24 @@ def security_get_restricted_logins(browser): """Return whether restricted console logins is enabled.""" nav_to_module(browser, 'security') return browser.find_by_name('security-restricted_access').first.checked + + +def upgrades_enable_automatic(browser, should_enable): + """Enable/disable automatic software upgrades.""" + nav_to_module(browser, 'upgrades') + checkbox_element = browser.find_by_name('auto_upgrades_enabled').first + if should_enable == checkbox_element.checked: + return + + if should_enable: + checkbox_element.check() + else: + checkbox_element.uncheck() + + submit(browser) + + +def upgrades_get_automatic(browser): + """Return whether automatic software upgrades is enabled.""" + nav_to_module(browser, 'upgrades') + return browser.find_by_name('auto_upgrades_enabled').first.checked