Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
1591c90f
Commit
1591c90f
authored
Jan 02, 2017
by
Semyon Pupkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move admin users spinach tests to rspec
https://gitlab.com/gitlab-org/gitlab-ce/issues/23036
parent
8dc2163c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
255 deletions
+132
-255
features/admin/users.feature
features/admin/users.feature
+0
-65
features/steps/admin/users.rb
features/steps/admin/users.rb
+0
-167
spec/features/admin/admin_users_spec.rb
spec/features/admin/admin_users_spec.rb
+132
-23
No files found.
features/admin/users.feature
deleted
100644 → 0
View file @
8dc2163c
@admin
Feature
:
Admin Users
Background
:
Given
I sign in as an admin
And
system has users
Scenario
:
On Admin Users
Given
I visit admin users page
Then
I should see all users
Scenario
:
Edit user and change username to non ascii char
When
I visit admin users page
And
Click edit
And
Input non ascii char in username
And
Click save
Then
See username error message
And
Not changed form action url
Scenario
:
Show user attributes
Given
user
"Mike"
with groups and projects
Given
I visit admin users page
And
click on
"Mike"
link
Then
I should see user
"Mike"
details
Scenario
:
Edit my user attributes
Given
I visit admin users page
And
click edit on my user
When
I submit modified user
Then
I see user attributes changed
@javascript
Scenario
:
Remove users secondary email
Given
I visit admin users page
And
I view the user with secondary email
And
I see the secondary email
When
I click remove secondary email
Then
I should not see secondary email anymore
Scenario
:
Show user keys
Given
user
"Pete"
with ssh keys
And
I visit admin users page
And
click on user
"Pete"
And
click on ssh keys tab
Then
I should see key list
And
I click on the key title
Then
I should see key details
And
I click on remove key
Then
I should see the key removed
Scenario
:
Show user identities
Given
user
"Pete"
with twitter account
And
I visit
"Pete"
identities page in admin
Then
I should see twitter details
Scenario
:
Update user identities
Given
user
"Pete"
with twitter account
And
I visit
"Pete"
identities page in admin
And
I modify twitter identity
Then
I should see twitter details updated
Scenario
:
Remove user identities
Given
user
"Pete"
with twitter account
And
I visit
"Pete"
identities page in admin
And
I remove twitter identity
Then
I should not see twitter details
features/steps/admin/users.rb
deleted
100644 → 0
View file @
8dc2163c
class
Spinach::Features::AdminUsers
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedAdmin
before
do
allow
(
Gitlab
::
OAuth
::
Provider
).
to
receive
(
:providers
).
and_return
([
:twitter
,
:twitter_updated
])
allow_any_instance_of
(
ApplicationHelper
).
to
receive
(
:user_omniauth_authorize_path
).
and_return
(
root_path
)
end
after
do
allow
(
Gitlab
::
OAuth
::
Provider
).
to
receive
(
:providers
).
and_call_original
allow_any_instance_of
(
ApplicationHelper
).
to
receive
(
:user_omniauth_authorize_path
).
and_call_original
end
step
'I should see all users'
do
User
.
all
.
each
do
|
user
|
expect
(
page
).
to
have_content
user
.
name
end
end
step
'Click edit'
do
@user
=
User
.
first
find
(
"#edit_user_
#{
@user
.
id
}
"
).
click
end
step
'Input non ascii char in username'
do
fill_in
'user_username'
,
with:
"
\u
3042
\u
3044"
end
step
'Click save'
do
click_button
(
"Save"
)
end
step
'See username error message'
do
page
.
within
"#error_explanation"
do
expect
(
page
).
to
have_content
"Username"
end
end
step
'Not changed form action url'
do
expect
(
page
).
to
have_selector
%(form[action="/admin/users/#{@user.username}"])
end
step
'I submit modified user'
do
check
:user_can_create_group
click_button
'Save'
end
step
'I see user attributes changed'
do
expect
(
page
).
to
have_content
'Can create groups: Yes'
end
step
'click edit on my user'
do
find
(
"#edit_user_
#{
current_user
.
id
}
"
).
click
end
step
'I view the user with secondary email'
do
@user_with_secondary_email
=
User
.
last
@user_with_secondary_email
.
emails
.
new
(
email:
"secondary@example.com"
)
@user_with_secondary_email
.
save
visit
"/admin/users/
#{
@user_with_secondary_email
.
username
}
"
end
step
'I see the secondary email'
do
expect
(
page
).
to
have_content
"Secondary email:
#{
@user_with_secondary_email
.
emails
.
last
.
email
}
"
end
step
'I click remove secondary email'
do
find
(
"#remove_email_
#{
@user_with_secondary_email
.
emails
.
last
.
id
}
"
).
click
end
step
'I should not see secondary email anymore'
do
expect
(
page
).
not_to
have_content
"Secondary email:"
end
step
'user "Mike" with groups and projects'
do
user
=
create
(
:user
,
name:
'Mike'
)
project
=
create
(
:empty_project
)
project
.
team
<<
[
user
,
:developer
]
group
=
create
(
:group
)
group
.
add_developer
(
user
)
end
step
'click on "Mike" link'
do
click_link
"Mike"
end
step
'I should see user "Mike" details'
do
expect
(
page
).
to
have_content
'Account'
expect
(
page
).
to
have_content
'Personal projects limit'
end
step
'user "Pete" with ssh keys'
do
user
=
create
(
:user
,
name:
'Pete'
)
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key1"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1"
)
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key2"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2"
)
end
step
'click on user "Pete"'
do
click_link
'Pete'
end
step
'I should see key list'
do
expect
(
page
).
to
have_content
'ssh-rsa Key2'
expect
(
page
).
to
have_content
'ssh-rsa Key1'
end
step
'I click on the key title'
do
click_link
'ssh-rsa Key2'
end
step
'I should see key details'
do
expect
(
page
).
to
have_content
'ssh-rsa Key2'
expect
(
page
).
to
have_content
'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2'
end
step
'I click on remove key'
do
click_link
'Remove'
end
step
'I should see the key removed'
do
expect
(
page
).
not_to
have_content
'ssh-rsa Key2'
end
step
'user "Pete" with twitter account'
do
@user
=
create
(
:user
,
name:
'Pete'
)
@user
.
identities
.
create!
(
extern_uid:
'123456'
,
provider:
'twitter'
)
end
step
'I visit "Pete" identities page in admin'
do
visit
admin_user_identities_path
(
@user
)
end
step
'I should see twitter details'
do
expect
(
page
).
to
have_content
'Pete'
expect
(
page
).
to
have_content
'twitter'
end
step
'I modify twitter identity'
do
find
(
'.table'
).
find
(
:link
,
'Edit'
).
click
fill_in
'identity_extern_uid'
,
with:
'654321'
select
'twitter_updated'
,
from:
'identity_provider'
click_button
'Save changes'
end
step
'I should see twitter details updated'
do
expect
(
page
).
to
have_content
'Pete'
expect
(
page
).
to
have_content
'twitter_updated'
expect
(
page
).
to
have_content
'654321'
end
step
'I remove twitter identity'
do
click_link
'Delete'
end
step
'I should not see twitter details'
do
expect
(
page
).
to
have_content
'Pete'
expect
(
page
).
not_to
have_content
'twitter'
end
step
'click on ssh keys tab'
do
click_link
'SSH keys'
end
end
spec/features/admin/admin_users_spec.rb
View file @
1591c90f
require
'spec_helper'
describe
"Admin::Users"
,
feature:
true
do
describe
"Admin::Users"
,
feature:
true
do
include
WaitForAjax
before
{
login_as
:admin
}
let!
(
:user
)
do
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
end
let!
(
:current_user
)
{
login_as
:admin
}
describe
"GET /admin/users"
do
before
do
...
...
@@ -15,8 +19,10 @@ describe "Admin::Users", feature: true do
end
it
"has users list"
do
expect
(
page
).
to
have_content
(
@user
.
email
)
expect
(
page
).
to
have_content
(
@user
.
name
)
expect
(
page
).
to
have_content
(
current_user
.
email
)
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
user
.
name
)
end
describe
'Two-factor Authentication filters'
do
...
...
@@ -40,8 +46,6 @@ describe "Admin::Users", feature: true do
end
it
'counts users who have not enabled 2FA'
do
create
(
:user
)
visit
admin_users_path
page
.
within
(
'.filter-two-factor-disabled small'
)
do
...
...
@@ -50,8 +54,6 @@ describe "Admin::Users", feature: true do
end
it
'filters by users who have not enabled 2FA'
do
user
=
create
(
:user
)
visit
admin_users_path
click_link
'2FA Disabled'
...
...
@@ -110,10 +112,10 @@ describe "Admin::Users", feature: true do
describe
"GET /admin/users/:id"
do
it
"has user info"
do
visit
admin_users_path
click_link
@
user
.
name
click_link
user
.
name
expect
(
page
).
to
have_content
(
@
user
.
email
)
expect
(
page
).
to
have_content
(
@
user
.
name
)
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
user
.
name
)
end
describe
'Impersonation'
do
...
...
@@ -126,7 +128,7 @@ describe "Admin::Users", feature: true do
end
it
'does not show impersonate button for admin itself'
do
visit
admin_user_path
(
@
user
)
visit
admin_user_path
(
current_
user
)
expect
(
page
).
not_to
have_content
(
'Impersonate'
)
end
...
...
@@ -158,7 +160,7 @@ describe "Admin::Users", feature: true do
it
'logs out of impersonated user back to original user'
do
find
(
:css
,
'li.impersonation a'
).
click
expect
(
page
.
find
(
:css
,
'.header-user .profile-link'
)[
'data-user'
]).
to
eql
(
@
user
.
username
)
expect
(
page
.
find
(
:css
,
'.header-user .profile-link'
)[
'data-user'
]).
to
eql
(
current_
user
.
username
)
end
it
'is redirected back to the impersonated users page in the admin after stopping'
do
...
...
@@ -171,15 +173,15 @@ describe "Admin::Users", feature: true do
describe
'Two-factor Authentication status'
do
it
'shows when enabled'
do
@
user
.
update_attribute
(
:otp_required_for_login
,
true
)
user
.
update_attribute
(
:otp_required_for_login
,
true
)
visit
admin_user_path
(
@
user
)
visit
admin_user_path
(
user
)
expect_two_factor_status
(
'Enabled'
)
end
it
'shows when disabled'
do
visit
admin_user_path
(
@
user
)
visit
admin_user_path
(
user
)
expect_two_factor_status
(
'Disabled'
)
end
...
...
@@ -194,9 +196,8 @@ describe "Admin::Users", feature: true do
describe
"GET /admin/users/:id/edit"
do
before
do
@simple_user
=
create
(
:user
)
visit
admin_users_path
click_link
"edit_user_
#{
@simple_
user
.
id
}
"
click_link
"edit_user_
#{
user
.
id
}
"
end
it
"has user edit page"
do
...
...
@@ -214,16 +215,29 @@ describe "Admin::Users", feature: true do
click_button
"Save changes"
end
it
"shows page with
new data"
do
it
"shows page with new data"
do
expect
(
page
).
to
have_content
(
'bigbang@mail.com'
)
expect
(
page
).
to
have_content
(
'Big Bang'
)
end
it
"changes user entry"
do
@simple_user
.
reload
expect
(
@simple_user
.
name
).
to
eq
(
'Big Bang'
)
expect
(
@simple_user
.
is_admin?
).
to
be_truthy
expect
(
@simple_user
.
password_expires_at
).
to
be
<=
Time
.
now
user
.
reload
expect
(
user
.
name
).
to
eq
(
'Big Bang'
)
expect
(
user
.
is_admin?
).
to
be_truthy
expect
(
user
.
password_expires_at
).
to
be
<=
Time
.
now
end
end
describe
'update username to non ascii char'
do
it
do
fill_in
'user_username'
,
with:
'\u3042\u3044'
click_button
(
'Save'
)
page
.
within
'#error_explanation'
do
expect
(
page
).
to
have_content
(
'Username'
)
end
expect
(
page
).
to
have_selector
(
%(form[action="/admin/users/#{user.username}"])
)
end
end
end
...
...
@@ -270,4 +284,99 @@ describe "Admin::Users", feature: true do
expect
(
page
).
not_to
have_selector
(
'.group_member'
)
end
end
describe
'show user attributes'
do
it
do
visit
admin_users_path
click_link
user
.
name
expect
(
page
).
to
have_content
'Account'
expect
(
page
).
to
have_content
'Personal projects limit'
end
end
describe
'remove users secondary email'
,
js:
true
do
let!
(
:secondary_email
)
do
create
:email
,
email:
'secondary@example.com'
,
user:
user
end
it
do
visit
admin_user_path
(
user
.
username
)
expect
(
page
).
to
have_content
(
"Secondary email:
#{
secondary_email
.
email
}
"
)
find
(
"#remove_email_
#{
secondary_email
.
id
}
"
).
click
expect
(
page
).
not_to
have_content
(
secondary_email
.
email
)
end
end
describe
'show user keys'
do
let!
(
:key1
)
do
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key1"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1"
)
end
let!
(
:key2
)
do
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key2"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2"
)
end
it
do
visit
admin_users_path
click_link
user
.
name
click_link
'SSH keys'
expect
(
page
).
to
have_content
(
key1
.
title
)
expect
(
page
).
to
have_content
(
key2
.
title
)
click_link
key2
.
title
expect
(
page
).
to
have_content
(
key2
.
title
)
expect
(
page
).
to
have_content
(
key2
.
key
)
click_link
'Remove'
expect
(
page
).
not_to
have_content
(
key2
.
title
)
end
end
describe
'show user identities'
do
it
'shows user identities'
do
visit
admin_user_identities_path
(
user
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'twitter'
)
end
end
describe
'update user identities'
do
before
do
allow
(
Gitlab
::
OAuth
::
Provider
).
to
receive
(
:providers
).
and_return
([
:twitter
,
:twitter_updated
])
end
it
'modifies twitter identity'
do
visit
admin_user_identities_path
(
user
)
find
(
'.table'
).
find
(
:link
,
'Edit'
).
click
fill_in
'identity_extern_uid'
,
with:
'654321'
select
'twitter_updated'
,
from:
'identity_provider'
click_button
'Save changes'
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'twitter_updated'
)
expect
(
page
).
to
have_content
(
'654321'
)
end
end
describe
'remove user with identities'
do
it
'removes user with twitter identity'
do
visit
admin_user_identities_path
(
user
)
click_link
'Delete'
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
not_to
have_content
(
'twitter'
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment