Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Test for firstboot and creating administrator account #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/date_and_time.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

@essential @date-and-time
@essential @date-and-time @system
Feature: Date and Time
Configure time zone and network time service.

Expand Down
30 changes: 30 additions & 0 deletions features/first_boot.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# This file is part of Plinth-tester.
#
# 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/>.
#

@first-boot @setup
Feature: First Boot
Setup a new FreedomBox installation and create an admin user.

Scenario: Start Setup
Given I am on the firstboot welcome page
When I click on start setup
Then I should be taken to the firstboot page

Scenario: Create Administrator Account
Given I am on the firstboot page
When I create an administrator account
Then I should be taken to the firstboot complete page
2 changes: 1 addition & 1 deletion features/single_sign_on.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

@sso @essential
@sso @essential @system
Feature: Single Sign On
Test Single Sign On features.

Expand Down
35 changes: 31 additions & 4 deletions step_definitions/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,48 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from pytest_bdd import parsers, given, when, then
from pytest_bdd import given, parsers, then, when

from support import config, interface


default_url = config['DEFAULT']['url']


@given("I am on the firstboot welcome page")
def nav_to_firstboot_welcome(browser):
browser.visit(default_url + '/plinth/firstboot/welcome')


@when("I click on start setup")
def first_boot_setup(browser):
browser.find_by_value('Start Setup').click()


@then("I should be taken to the firstboot complete page")
def firstboot_complete_page(browser):
assert browser.url == default_url + '/plinth/firstboot/complete/'


@then("I should be taken to the firstboot page")
def firstboot_page(browser):
assert browser.url == default_url + '/plinth/users/firstboot/'


@given("I am on the firstboot page")
def nav_to_firstboot(browser):
browser.visit(default_url + '/plinth/users/firstboot')


@given("I'm a logged in user")
def logged_in_user(browser):
interface.login(browser, config['DEFAULT']['url'],
config['DEFAULT']['username'],
interface.login(browser, default_url, config['DEFAULT']['username'],
config['DEFAULT']['password'])


@given("I'm a logged out user")
def logged_out_user(browser):
browser.visit(config['DEFAULT']['url'] + '/plinth/accounts/logout/')
browser.visit(default_url + '/plinth/accounts/logout/')


@then(parsers.parse('I should be prompted for login'))
Expand Down
14 changes: 9 additions & 5 deletions step_definitions/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from pytest_bdd import parsers, when, then
from pytest_bdd import parsers, then, when

from support import system


language_codes = {
'Danish': 'da',
'German': 'de',
Expand Down Expand Up @@ -54,14 +53,19 @@ def change_language(browser, language):

@then(parsers.parse('the hostname should be {hostname:w}'))
def hostname_should_be(browser, hostname):
assert(system.get_hostname(browser) == hostname)
assert system.get_hostname(browser) == hostname


@then(parsers.parse('the domain name should be {domain:w}'))
def domain_name_should_be(browser, domain):
assert(system.get_domain_name(browser) == domain)
assert system.get_domain_name(browser) == domain


@then('Plinth language should be <language>')
def plinth_language_should_be(browser, language):
assert(system.check_language(browser, language_codes[language]))
assert system.check_language(browser, language_codes[language])


@when("I create an administrator account")
def create_admin_account(browser):
system.create_admin_account(browser, 'tester', 'testingtesting')
8 changes: 7 additions & 1 deletion support/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from .interface import nav_to_module, submit


config_page_title_language_map = {
'da': 'Generel Konfiguration',
'de': 'Allgemeine Konfiguration',
Expand Down Expand Up @@ -69,3 +68,10 @@ def set_language(browser, language_code):
def check_language(browser, language_code):
nav_to_module(browser, 'config')
return browser.title == config_page_title_language_map[language_code]


def create_admin_account(browser, username, password):
browser.find_by_id('id_username').fill(username)
browser.find_by_id('id_password1').fill(password)
browser.find_by_id('id_password2').fill(password)
browser.find_by_value('Create Account').click()