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 13, 2023
1 parent 8ea6aee commit cec75b8
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 44 deletions.
14 changes: 2 additions & 12 deletions testsuite/features/core/srv_docker.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@ Feature: Prepare server for using Docker
Given I am authorized for the "Admin" section

Scenario: Create a Docker user with image administrators rights
When I follow the left menu "Users > User List > Active"
And I follow "Create User"
And I enter "docker" as "login"
And I enter "docker" as "desiredpassword"
And I enter "docker" as "desiredpasswordConfirm"
And I select "Mr." from "prefix"
And I enter "TestDocky" as "firstNames"
And I enter "TestDocky" as "lastName"
And I enter "gino-ginae@susy.de" as "email"
And I click on "Create Login"
Then I should see a "Account docker created" text
And I should see a "docker" link
When I create or enable user "docker" with first names "TestDocky" and last name "TestDocky"
Then I should see a "docker" link
And I should see a "normal user" text
And I follow "docker"
And I check "role_image_admin"
Expand Down
10 changes: 5 additions & 5 deletions testsuite/features/secondary/min_timezone.feature
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,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 @@ -58,13 +58,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"
12 changes: 6 additions & 6 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 Down Expand Up @@ -186,13 +186,13 @@ Feature: Manage users
When I follow "Deactivated"
Then I should not see a "user1" link

Scenario: Delete user
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
36 changes: 36 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,39 @@
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|
step %(When I make sure "#{user}" is not active )
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 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 "user1"
Then I should see a "Reactivate User" link
When I follow "Reactivate User"
)
if (product == 'Uyuni')
step %(Then I should see a "This action will allow this user to access Uyuni. This user will retain all permissions, roles, and data that he or she had before being deactivated." text)
else
step %(Then I should see a "This action will allow this user to access SUSE Manager. This user will retain all permissions, roles, and data that he or she had before being deactivated." text)
end
steps %(When I click on "Reactivate User"
Then I should see a "Active Users" text
And I should see a "user1" link
When I follow "Deactivated"
Then I should not see a "user1" link
)
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 cec75b8

Please sign in to comment.