diff --git a/test/behave/README.md b/test/behave/README.md index c7e083c0cce2cc074c8625917d2c37183750c7c8..b43f0fe22c00f8ef8f05f339b232e17a0686a11c 100644 --- a/test/behave/README.md +++ b/test/behave/README.md @@ -5,3 +5,5 @@ apk --no-cache add git git clone https://code.greenhost.net/openappstack/bootstrap.git cd bootstrap/test/behave + behave -D nextcloud.url=https://files.ci-20410.ci.openappstack.net \ + -D nextcloud.admin.password=… diff --git a/test/behave/features/environment.py b/test/behave/features/environment.py index eb9cac121b913cf7a9c43880c944e63dfc21dac1..bc3dae74c87096e7eebcd137ec3441acf4ee5168 100644 --- a/test/behave/features/environment.py +++ b/test/behave/features/environment.py @@ -22,6 +22,16 @@ def save_screenshot(context, step): def before_all(context): """Run at the very beginning.""" userdata = context.config.userdata + context.nextcloud = {} + context.nextcloud['url'] = userdata.get('nextcloud.url') + context.nextcloud['username'] = \ + userdata.get('nextcloud.username', 'admin') + context.nextcloud['password'] = \ + userdata.get('nextcloud.password') + + assert context.nextcloud['url'], 'Nextcloud url variable missing in userdata!' + assert context.nextcloud['username'], 'Nextcloud username variable missing in userdata!' + assert context.nextcloud['password'], 'Nextcloud password variable missing in userdata!' headless = userdata.get('headless', 'False') diff --git a/test/behave/features/nextcloud.feature b/test/behave/features/nextcloud.feature new file mode 100644 index 0000000000000000000000000000000000000000..f010b4b82ce0cca52b70a5e11abe84064aaa4866 --- /dev/null +++ b/test/behave/features/nextcloud.feature @@ -0,0 +1,15 @@ +Feature: Test nextcloud admin login + As an OAS admin + I want to be able to login to nextcloud as the user admin + +Scenario: Open nextcloud + When I open the nextcloud URL + Then I wait on element "input#user" for 25000ms to be visible + And I expect that element "input#user" is visible + +Scenario: Login to nextcloud + Given the element "input#user" is visible + When I enter the "nextcloud" "username" in the inputfield "input#user" + When I enter the "nextcloud" "password" in the inputfield "input#password" + And I click on the button "input#submit" + Then I expect that the title is "Files - Nextcloud" diff --git a/test/behave/features/steps/login.py b/test/behave/features/steps/login.py index 4eec789c80a60c5a613d9fae05b3fd4cae9f3429..77ce58c6ba852408c2461295262cb2f6b03d450c 100644 --- a/test/behave/features/steps/login.py +++ b/test/behave/features/steps/login.py @@ -3,13 +3,20 @@ from behave import given, when from behave_webdriver.steps import * +@when(u'I open the nextcloud URL') +@given(u'I open the nextcloud URL') +def step_impl(context): + """Login to nextcloud.""" + context.behave_driver.get(context.nextcloud['url']) -@when(u'I enter the "{section}" "{user}" "{cred_type}" in the inputfield "{element}"') -def step_impl(context, section, user, cred_type, element): + +@when(u'I enter the "{section}" "{cred_type}" in the inputfield "{element}"') +def step_impl(context, section, cred_type, element): """Enter username/password into login inputfields.""" elem = context.behave_driver.get_element(element) elem.clear() context_section = getattr(context, section) - value = context_section[user][cred_type] + print(context_section) + value = context_section[cred_type] elem.send_keys(value) diff --git a/test/ci-bootstrap.py b/test/ci-bootstrap.py index 0133bafc00d8303f8dba0d58fc417e4c63cc846a..ed8a881bf5f1cc7eb45e42e561679a1d6f8344c5 100755 --- a/test/ci-bootstrap.py +++ b/test/ci-bootstrap.py @@ -268,9 +268,19 @@ def write_behave_config(settings=None): if settings is None: with open(SETTINGS_FILE) as stream: settings = yaml.safe_load(stream) + + with open('./secrets/nextcloud_admin_password', 'r') as stream: + nextcloud_admin_password = yaml.safe_load(stream) + behave_config = configparser.ConfigParser() behave_config['behave'] = {'stop': True} behave_config['behave.userdata'] = {} + behave_config['behave.userdata']['nextcloud.url'] = \ + 'https://files.{}'.format(settings['domain']) + behave_config['behave.userdata']['nextcloud.username'] = 'admin' + behave_config['behave.userdata']['nextcloud.password'] = \ + nextcloud_admin_password + with open('./behave/behave.ini', 'w') as configfile: behave_config.write(configfile)