Skip to content

Commit

Permalink
testsuite changes
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Arlt <parlt@suse.com>
  • Loading branch information
parlt91 committed Sep 15, 2023
1 parent ae0d792 commit cddd512
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 70 deletions.
24 changes: 8 additions & 16 deletions testsuite/features/secondary/min_timezone.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ Feature: Correct timezone display
Given I am authorized for the "Admin" section

Scenario: Create a new user in a timezone different than server's timezone
When I follow the left menu "Users > User List > Active"
And I follow "Create User"
And I enter "MalaysianUser" as "login"
And I enter "MalaysianUser" as "desiredpassword"
And I enter "MalaysianUser" as "desiredpasswordConfirm"
And I select "Mr." from "prefix"
And I enter "Test" as "firstNames"
And I enter "User" as "lastName"
And I enter "galaxy-noise@suse.de" as "email"
And I select "(GMT+0800) Malaysia" from "timezone"
And I click on "Create Login"
When I make sure "MalaysianUser" is not active
And I create or enable user "MalaysianUser" with first names "Test" and last name "User"
Then I should see a "MalaysianUser" link

Scenario: Add roles for the Malaysian user
When I follow the left menu "Users > User List > Active"
Expand Down Expand Up @@ -96,12 +88,12 @@ Feature: Correct timezone display
And I should see "role_activation_key_admin" as checked
And I should see "role_config_admin" as checked

Scenario: Cleanup: Delete user
Scenario: Cleanup: Disable user
When I follow the left menu "Users > User List > Active"
And I follow "MalaysianUser"
And I follow "Delete User"
Then I should see a "Confirm User Deletion" text
And I should see a "This will delete this user permanently." text
When I click on "Delete User"
And I follow "Deactivate User"
Then I should see a "Confirm User Deactivation" text
And I should see a "This action will deactivate this user." text
When I click on "Deactivate User"
Then I should see a "Active Users" text
And I should not see a "MalaysianUser" link
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,9 @@ Feature: Advanced content management

Scenario: Create a user without rights nor roles
Given I am authorized for the "Admin" section
When I follow the left menu "Users > User List > Active"
And I follow "Create User"
And I enter "norole" as "login"
And I enter "norole" as "desiredpassword"
And I enter "norole" as "desiredpasswordConfirm"
And I select "Mr." from "prefix"
And I enter "norole" as "firstNames"
And I enter "norole" as "lastName"
And I enter "norole-ginae@susy.de" as "email"
And I click on "Create Login"
Then I should see a "Account norole created" text
And I should see a "norole" link
When I make sure "norole" is not active
And I create or enable user "norole" with first names "norole" and last name "norole"
Then I should see a "norole" link
And I should see a "normal user" text

Scenario: Log in as docker user
Expand All @@ -58,13 +49,13 @@ Feature: Advanced content management
And I click on the red confirmation button
And I should see a "Image store has been deleted." text

Scenario: Cleanup: delete no role user
Scenario: Cleanup: disable no role user
Given I am authorized for the "Admin" section
When I follow the left menu "Users > User List > Active"
And I follow "norole"
And I follow "Delete User"
Then I should see a "Confirm User Deletion" text
And I should see a "This will delete this user permanently." text
When I click on "Delete User"
And I follow "Deactivate User"
Then I should see a "Confirm User Deactivation" text
And I should see a "This action will deactivate this user." text
When I click on "Deactivate User"
Then I should see a "Active Users" text
And I should not see a "norole" link
8 changes: 4 additions & 4 deletions testsuite/features/secondary/srv_user_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Feature: API "user" namespace
When I call user.list_roles() on user "admin"
Then I should get at least one role that matches "_admin" suffix

Scenario: Create user
When I make sure "testuser" is not present
And I call user.create() with login "testuser"
Scenario: Create or enable user
When I make sure "testuser" is not active
And I create or enable user with login "testuser"
And I call user.list_users()
Then I should get at least user "testuser"

Expand All @@ -27,4 +27,4 @@ Feature: API "user" namespace
Then I should not get role "org_admin"

Scenario: Cleanup: user tests
When I delete user "testuser"
When I disable user "testuser"
45 changes: 24 additions & 21 deletions testsuite/features/secondary/srv_users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the terms of the MIT license.
#
# 1) check users page
# 2) create and delete users
# 2) create and deactivate users
# 3) Change permissions and roles in web UI

@scope_visualization
Expand All @@ -23,18 +23,9 @@ Feature: Manage users
And I should see a "Download CSV" link

Scenario: Create a new user
When I follow the left menu "Users > User List > Active"
And I follow "Create User"
And I enter "user1" as "login"
And I enter "user1" as "desiredpassword"
And I enter "user1" as "desiredpasswordConfirm"
And I select "Mr." from "prefix"
And I enter "Test" as "firstNames"
And I enter "User" as "lastName"
And I enter "galaxy-noise@suse.de" as "email"
And I click on "Create Login"
Then I should see a "Account user1 created, login information sent to galaxy-noise@suse.de" text
And I should see a "user1" link
When I make sure "user1" is not active
And I create or enable user "user1" with first names "Test" and last name "User"
Then I should see a "user1" link
And I should see a "normal user" text

Scenario: Login as the new user
Expand All @@ -46,7 +37,6 @@ Feature: Manage users
When I follow the left menu "Users > User List > Active"
And I follow "user1"
Then I should see a "User Details" text
And I should see a "Delete User" link
And I should see a "Deactivate User" link
And I should see a "Details" link
And I should see a "System Groups" link
Expand Down Expand Up @@ -130,9 +120,9 @@ Feature: Manage users
When I click on "Deactivate User"
Then I should see a "You cannot deactivate another organization administrator. Please remove the 'Organization Administrator' role from this user before attempting to deactivate their account." text
When I follow "Deactivated"
Then I should see a "No deactivated users." text
Then I should not see a "user1" link

Scenario: Remove role
Scenario: Remove org admin role
When I follow the left menu "Users > User List > Active"
And I follow "user1"
When I uncheck "role_org_admin"
Expand Down Expand Up @@ -186,13 +176,26 @@ Feature: Manage users
When I follow "Deactivated"
Then I should not see a "user1" link

Scenario: Delete user
Scenario: Remove other admin roles
When I follow the left menu "Users > User List > Active"
And I follow "user1"
When I uncheck "role_system_group_admin"
And I uncheck "role_channel_admin"
And I uncheck "role_activation_key_admin"
And I uncheck "role_config_admin"
And I click on "Update"
Then I should see "role_system_group_admin" as unchecked
And I should see "role_channel_admin" as unchecked
And I should see "role_activation_key_admin" as unchecked
And I should see "role_config_admin" as unchecked

Scenario: Deactivate user
When I follow the left menu "Users > User List > Active"
And I follow "user1"
When I follow "Delete User"
Then I should see a "Confirm User Deletion" text
And I should see a "This will delete this user permanently." text
When I click on "Delete User"
When I follow "Deactivate User"
Then I should see a "Confirm User Deactivation" text
And I should see a "This action will deactivate this user." text
When I click on "Deactivate User"
Then I should see a "Active Users" text
And I should not see a "user1" link

Expand Down
20 changes: 12 additions & 8 deletions testsuite/features/step_definitions/api_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,27 @@
refute_includes(@roles, rolename)
end

When(/^I call user\.create\(\) with login "([^"]*)"$/) do |user|
refute($api_test.user.create(user, 'JamesBond007', 'Hans', 'Mustermann', 'hans.mustermann@suse.com') != 1)
end

When(/^I call user\.add_role\(\) on "([^"]*)" with the role "([^"]*)"$/) do |user, role|
refute($api_test.user.add_role(user, role) != 1)
end

When(/^I delete user "([^"]*)"$/) do |user|
$api_test.user.delete(user)
When(/^I create or enable user with login "([^"]*)"$/) do |user|
if $api_test.user.list_users.map { |u| u['login'] }.select { |l| l == user }.empty?
refute($api_test.user.create(user, 'JamesBond007', 'Hans', 'Mustermann', 'hans.mustermann@suse.com') != 1)
else
$api_test.user.enable(user)
end
end

When(/^I disable user "([^"]*)"$/) do |user|
$api_test.user.disable(user)
end

When(/^I make sure "([^"]*)" is not present$/) do |user|
When(/^I make sure "([^"]*)" is not active$/) do |user|
$api_test.user.list_users
.map { |u| u['login'] }
.select { |l| l == user }
.each { $api_test.user.delete(user) }
.each { $api_test.user.disable(user) }
end

When(/^I call user\.remove_role\(\) on "([^"]*)" with the role "([^"]*)"$/) do |luser, rolename|
Expand Down
27 changes: 27 additions & 0 deletions testsuite/features/step_definitions/common_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,30 @@
And I wait until the table contains "FINISHED" or "SKIPPED" followed by "FINISHED" in its first rows
'
end

When(/^I create or enable user "([^"]*)" with first names "([^"]*)" and last name "([^"]*)" */) do |user, first, last|
if $api_test.user.list_users.map { |u| u['login'] }.select { |l| l == user }.empty?
steps %(And I follow the left menu "Users > User List > Active"
And I follow "Create User"
And I enter "#{user}" as "login"
And I enter "#{user}" as "desiredpassword"
And I enter "#{user}" as "desiredpasswordConfirm"
And I select "Mr." from "prefix"
And I enter "#{first}" as "firstNames"
And I enter "#{last}" as "lastName"
And I enter "galaxy-noise@suse.de" as "email"
And I select "(GMT+0800) Malaysia" from "timezone"
And I click on "Create Login"
Then I should see a "Account #{user} created" text
)
else
steps %(When I follow the left menu "Users > User List > Active"
And I follow "Deactivated"
And I follow "#{user}"
Then I should see a "Reactivate User" link
When I follow "Reactivate User"
Then I click on "Reactivate User"
Then I should see a "Active Users" text
)
end
end
17 changes: 13 additions & 4 deletions testsuite/features/support/namespaces/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ def create(user, password, first, last, email)
end

##
# Deletes a user from the system.
# Disables a user on the system.
#
# Args:
# user: The username of the user you want to delete.
def delete(user)
@test.call('user.delete', sessionKey: @test.token, login: user)
# user: The username of the user you want to disable.
def disable(user)
@test.call('user.disable', sessionKey: @test.token, login: user)
end

##
# Enables a user on the system.
#
# Args:
# user: The username of the user you want to enable.
def enable(user)
@test.call('user.enable', sessionKey: @test.token, login: user)
end

##
Expand Down

0 comments on commit cddd512

Please sign in to comment.