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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a40898af
Commit
a40898af
authored
Apr 13, 2022
by
John Mason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow unconfirmed users in non-admin searches
Changelog: changed EE: true
parent
d8652e92
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
app/models/user.rb
app/models/user.rb
+1
-1
ee/spec/finders/users_finder_spec.rb
ee/spec/finders/users_finder_spec.rb
+3
-3
spec/finders/users_finder_spec.rb
spec/finders/users_finder_spec.rb
+6
-6
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-2
No files found.
app/models/user.rb
View file @
a40898af
...
@@ -471,7 +471,7 @@ class User < ApplicationRecord
...
@@ -471,7 +471,7 @@ class User < ApplicationRecord
scope
:with_no_activity
,
->
{
with_state
(
:active
).
human_or_service_user
.
where
(
last_activity_on:
nil
)
}
scope
:with_no_activity
,
->
{
with_state
(
:active
).
human_or_service_user
.
where
(
last_activity_on:
nil
)
}
scope
:by_provider_and_extern_uid
,
->
(
provider
,
extern_uid
)
{
joins
(
:identities
).
merge
(
Identity
.
with_extern_uid
(
provider
,
extern_uid
))
}
scope
:by_provider_and_extern_uid
,
->
(
provider
,
extern_uid
)
{
joins
(
:identities
).
merge
(
Identity
.
with_extern_uid
(
provider
,
extern_uid
))
}
scope
:by_ids_or_usernames
,
->
(
ids
,
usernames
)
{
where
(
username:
usernames
).
or
(
where
(
id:
ids
))
}
scope
:by_ids_or_usernames
,
->
(
ids
,
usernames
)
{
where
(
username:
usernames
).
or
(
where
(
id:
ids
))
}
scope
:without_forbidden_states
,
->
{
confirmed
.
where
.
not
(
state:
FORBIDDEN_SEARCH_STATES
)
}
scope
:without_forbidden_states
,
->
{
where
.
not
(
state:
FORBIDDEN_SEARCH_STATES
)
}
strip_attributes!
:name
strip_attributes!
:name
...
...
ee/spec/finders/users_finder_spec.rb
View file @
a40898af
...
@@ -13,13 +13,13 @@ RSpec.describe UsersFinder do
...
@@ -13,13 +13,13 @@ RSpec.describe UsersFinder do
it
'returns ldap users by default'
do
it
'returns ldap users by default'
do
users
=
described_class
.
new
(
normal_user
).
execute
users
=
described_class
.
new
(
normal_user
).
execute
expect
(
users
).
to
contain_exactly
(
normal_user
,
omniauth_user
,
external_user
,
ldap_user
,
internal_user
,
admin_user
)
expect
(
users
).
to
contain_exactly
(
normal_user
,
unconfirmed_user
,
omniauth_user
,
external_user
,
ldap_user
,
internal_user
,
admin_user
)
end
end
it
'returns only non-ldap users with skip_ldap: true'
do
it
'returns only non-ldap users with skip_ldap: true'
do
users
=
described_class
.
new
(
normal_user
,
skip_ldap:
true
).
execute
users
=
described_class
.
new
(
normal_user
,
skip_ldap:
true
).
execute
expect
(
users
).
to
contain_exactly
(
normal_user
,
omniauth_user
,
external_user
,
internal_user
,
admin_user
)
expect
(
users
).
to
contain_exactly
(
normal_user
,
unconfirmed_user
,
omniauth_user
,
external_user
,
internal_user
,
admin_user
)
end
end
end
end
...
@@ -36,7 +36,7 @@ RSpec.describe UsersFinder do
...
@@ -36,7 +36,7 @@ RSpec.describe UsersFinder do
it
'returns all users by default'
do
it
'returns all users by default'
do
users
=
described_class
.
new
(
normal_user
).
execute
users
=
described_class
.
new
(
normal_user
).
execute
expect
(
users
).
to
contain_exactly
(
normal_user
,
omniauth_user
,
external_user
,
internal_user
,
admin_user
,
saml_user
,
non_saml_user
)
expect
(
users
).
to
contain_exactly
(
normal_user
,
unconfirmed_user
,
omniauth_user
,
external_user
,
internal_user
,
admin_user
,
saml_user
,
non_saml_user
)
end
end
it
'returns only saml users from the provided saml_provider_id'
do
it
'returns only saml users from the provided saml_provider_id'
do
...
...
spec/finders/users_finder_spec.rb
View file @
a40898af
...
@@ -14,7 +14,7 @@ RSpec.describe UsersFinder do
...
@@ -14,7 +14,7 @@ RSpec.describe UsersFinder do
it
'returns searchable users'
do
it
'returns searchable users'
do
users
=
described_class
.
new
(
user
).
execute
users
=
described_class
.
new
(
user
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
end
end
it
'filters by username'
do
it
'filters by username'
do
...
@@ -56,7 +56,7 @@ RSpec.describe UsersFinder do
...
@@ -56,7 +56,7 @@ RSpec.describe UsersFinder do
it
'filters by non external users'
do
it
'filters by non external users'
do
users
=
described_class
.
new
(
user
,
non_external:
true
).
execute
users
=
described_class
.
new
(
user
,
non_external:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
end
end
it
'filters by created_at'
do
it
'filters by created_at'
do
...
@@ -73,7 +73,7 @@ RSpec.describe UsersFinder do
...
@@ -73,7 +73,7 @@ RSpec.describe UsersFinder do
it
'filters by non internal users'
do
it
'filters by non internal users'
do
users
=
described_class
.
new
(
user
,
non_internal:
true
).
execute
users
=
described_class
.
new
(
user
,
non_internal:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
omniauth_user
,
admin_user
,
project_bot
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
unconfirmed_user
,
external_user
,
omniauth_user
,
admin_user
,
project_bot
)
end
end
it
'does not filter by custom attributes'
do
it
'does not filter by custom attributes'
do
...
@@ -82,18 +82,18 @@ RSpec.describe UsersFinder do
...
@@ -82,18 +82,18 @@ RSpec.describe UsersFinder do
custom_attributes:
{
foo:
'bar'
}
custom_attributes:
{
foo:
'bar'
}
).
execute
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
,
admin_user
,
project_bot
)
end
end
it
'orders returned results'
do
it
'orders returned results'
do
users
=
described_class
.
new
(
user
,
sort:
'id_asc'
).
execute
users
=
described_class
.
new
(
user
,
sort:
'id_asc'
).
execute
expect
(
users
).
to
eq
([
normal_user
,
admin_user
,
external_user
,
omniauth_user
,
internal_user
,
project_bot
,
user
])
expect
(
users
).
to
eq
([
normal_user
,
admin_user
,
external_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
,
project_bot
,
user
])
end
end
it
'does not filter by admins'
do
it
'does not filter by admins'
do
users
=
described_class
.
new
(
user
,
admins:
true
).
execute
users
=
described_class
.
new
(
user
,
admins:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
admin_user
,
omniauth_user
,
internal_user
,
project_bot
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
external_user
,
admin_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
,
project_bot
)
end
end
end
end
...
...
spec/models/user_spec.rb
View file @
a40898af
...
@@ -6660,9 +6660,9 @@ RSpec.describe User do
...
@@ -6660,9 +6660,9 @@ RSpec.describe User do
let_it_be
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
let_it_be
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
let_it_be
(
:internal_user
)
{
User
.
alert_bot
.
tap
{
|
u
|
u
.
confirm
}
}
let_it_be
(
:internal_user
)
{
User
.
alert_bot
.
tap
{
|
u
|
u
.
confirm
}
}
it
'does not return blocked
, banned or unconfirm
ed users'
do
it
'does not return blocked
or bann
ed users'
do
expect
(
described_class
.
without_forbidden_states
).
to
match_array
([
expect
(
described_class
.
without_forbidden_states
).
to
match_array
([
normal_user
,
admin_user
,
external_user
,
omniauth_user
,
internal_user
normal_user
,
admin_user
,
external_user
,
unconfirmed_user
,
omniauth_user
,
internal_user
])
])
end
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