From 0a5c5e9a1041210b7be7146826253d1bcbb5b0b5 Mon Sep 17 00:00:00 2001 From: Mark <mark@openappstack.net> Date: Mon, 9 Dec 2019 16:03:54 +0100 Subject: [PATCH] Rename variables and steps --- test/login_logout/app.py | 2 +- .../test/behave/features/environment.py | 12 ++++++--- .../test/behave/features/login.feature | 27 ++++++------------- .../test/behave/features/steps/login.py | 4 +-- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/test/login_logout/app.py b/test/login_logout/app.py index 5f7366e..e58a728 100644 --- a/test/login_logout/app.py +++ b/test/login_logout/app.py @@ -48,7 +48,7 @@ def get_userinfo(): @app.route('/logout') def logout(): del session['sso_token'] - return redirect(LOGOUT_URL) + return redirect(url_for('login')) @app.route('/callback') def callback(): diff --git a/test/login_logout/test/behave/features/environment.py b/test/login_logout/test/behave/features/environment.py index 592d579..fe5e4cb 100644 --- a/test/login_logout/test/behave/features/environment.py +++ b/test/login_logout/test/behave/features/environment.py @@ -37,20 +37,24 @@ def before_all(context): def before_tag(context, tag): values = dict() userdata = context.config.userdata - values['url'] = userdata.get('url') - values['logout'] = userdata.get('logout_url') - values['userinfo'] = userdata.get('userinfo_url') + values['home'] = userdata.get('url') + values['logout'] = values['home'] + "/logout" + values['userinfo'] = values['home'] + "/userinfo" values['username'] = userdata.get('username') values['username2'] = userdata.get('username2') values['password'] = userdata.get('password') values['email'] = userdata.get('email') values['role'] = userdata.get('role') - assert values['url'], 'url variable missing in' \ + assert values['home'], 'url variable missing in' \ 'userdata. Provide it with "-D url".' assert values['username'], 'username variable missing in' \ 'userdata. Provide it with "-D username".' assert values['password'], 'password variable missing in' \ 'userdata. Provide it with "-D password".' + assert values['email'], 'email variable missing in' \ + 'userdata. Provide it with "-D email".' + assert values['role'], 'role variable missing in' \ + 'userdata. Provide it with "-D role".' context.oauth = values diff --git a/test/login_logout/test/behave/features/login.feature b/test/login_logout/test/behave/features/login.feature index 2fb598d..759b2ef 100644 --- a/test/login_logout/test/behave/features/login.feature +++ b/test/login_logout/test/behave/features/login.feature @@ -4,43 +4,32 @@ Feature: Test login-provider function I want to be able to login to an OAS App And verify my userdata that is provided by OpenID Connect -Scenario: Open the oAuth application - When I open the URL "url" - Then I wait on element "input#username" for 1000ms to be visible - -Scenario: Login with a valid user with access to application - Given the element "input#username" is visible +Scenario: Open the oAuth application and Login witha valid user + Given the oauth client "home" URL was opened + And the element "input#username" is visible When I enter the "username" in the inputfield "input#username" And I enter the "password" in the inputfield "input#password" And I click on the button "input#submit" Then I wait on element "input#password" for 1000ms to not exist - -Scenario: Wait for the oAuth flow to finish and check if access token is present - Given the element "input#password" does not exist - Then I expect that the path is "/callback" + And I expect that the path is "/callback" And I expect that element "body" contains the text "access_token" Scenario: Get OpenID Connect userdata for testuser - When I open the url "userinfo" + When I open the oauth client "userinfo" URL Then I expect that the "preferred_username" in the json output is "username" And I expect that the "email" in the json output is "email" And I expect that the "openappstack_roles" in the json output contains "role" And I expect that the "name" in the json output is "username" Scenario: Logout - When I open the URL "logout" - Then I wait on element "input#username" for 1000ms to be visible - And I expect that element "input#password" is visible - And I expect that element "input#submit" is visible - -Scenario: Navigate to Login page after logout - When I open the URL "url" + When I open the oauth client "logout" URL Then I wait on element "input#username" for 1000ms to be visible And I expect that element "input#password" is visible And I expect that element "input#submit" is visible Scenario: Login with a valid user without access to an application - Given the element "input#username" is visible + Given the oauth client "home" URL was opened + And the element "input#username" is visible When I enter the "username2" in the inputfield "input#username" And I enter the "password" in the inputfield "input#password" And I click on the button "input#submit" diff --git a/test/login_logout/test/behave/features/steps/login.py b/test/login_logout/test/behave/features/steps/login.py index fd631bf..ef1a5a5 100644 --- a/test/login_logout/test/behave/features/steps/login.py +++ b/test/login_logout/test/behave/features/steps/login.py @@ -10,8 +10,8 @@ from behave_webdriver.steps import * def before_all(context): pass # login and save cookies here -@when(u'I open the URL "{url}"') -@given(u'I open the URL "{url}"') +@when(u'I open the oauth client "{url}" URL') +@given(u'The oauth client "{url}" URL was opened') def step_impl(context, url): context.behave_driver.get(context.oauth[url]) -- GitLab