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
ce789a64
Commit
ce789a64
authored
Jul 09, 2021
by
Serena Fang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update auth spec
parent
a33ec9fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
23 deletions
+24
-23
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+3
-3
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+21
-20
No files found.
lib/gitlab/auth.rb
View file @
ce789a64
...
...
@@ -203,10 +203,10 @@ module Gitlab
if
project
&&
token
.
user
.
project_bot?
&&
!
project
.
bots
.
include?
(
token
.
user
)
return
unless
project
.
group
group_ids
=
project
.
group
.
self_and_ancestors
.
pluck
(
:id
)
user_groups
=
token
.
user
.
groups
.
pluck
(
:id
)
group_
ancestor_
ids
=
project
.
group
.
self_and_ancestors
.
pluck
(
:id
)
user_group
_id
s
=
token
.
user
.
groups
.
pluck
(
:id
)
return
if
(
group_
ids
&
user_group
s
).
empty?
return
if
(
group_
ancestor_ids
&
user_group_id
s
).
empty?
end
if
can_user_login_with_non_expired_password?
(
token
.
user
)
||
token
.
user
.
project_bot?
...
...
spec/lib/gitlab/auth_spec.rb
View file @
ce789a64
...
...
@@ -406,38 +406,39 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do
it_behaves_like
'with an invalid access token'
end
context
'when
using a group namespace project access token
'
do
context
'when
in a group namespace
'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:project_bot_user
)
{
create
(
:user
,
:project_bot
)
}
let_it_be
(
:access_token
)
{
create
(
:personal_access_token
,
user:
project_bot_user
)
}
context
'when the token belongs to the project'
do
before
do
project
.
add_maintainer
(
project_bot_user
)
context
'when using a project access token'
do
let_it_be
(
:project_bot_user
)
{
create
(
:user
,
:project_bot
)
}
let_it_be
(
:access_token
)
{
create
(
:personal_access_token
,
user:
project_bot_user
)
}
context
'when token user belongs to the project'
do
before
do
project
.
add_maintainer
(
project_bot_user
)
end
it_behaves_like
'with a valid access token'
end
it_behaves_like
'with a
valid access token'
it_behaves_like
'with a
n in
valid access token'
end
it_behaves_like
'with an invalid access token'
end
context
'when using a group access token'
do
let_it_be
(
:project_bot_user
)
{
create
(
:user
,
name:
'Group token bot'
,
email:
"group_
#{
group
.
id
}
_bot@example.com"
,
username:
"group_
#{
group
.
id
}
_bot"
,
user_type: :project_bot
)
}
let_it_be
(
:access_token
)
{
create
(
:personal_access_token
,
user:
project_bot_user
)
}
context
'when using a group access token'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:project_bot_user
)
{
create
(
:user
,
name:
'Group token bot'
,
email:
"group_
#{
group
.
id
}
_bot@example.com"
,
username:
"group_
#{
group
.
id
}
_bot"
,
user_type:
'project_bot'
.
to_sym
)
}
let_it_be
(
:access_token
)
{
create
(
:personal_access_token
,
user:
project_bot_user
)
}
context
'when the token belongs to the group'
do
before
do
group
.
add_maintainer
(
project_bot_user
)
end
context
'when the token belongs to the group'
do
before
do
group
.
add_maintainer
(
project_bot_user
)
it_behaves_like
'with a valid access token'
end
it_behaves_like
'with a
valid access token'
it_behaves_like
'with a
n in
valid access token'
end
it_behaves_like
'with an invalid access token'
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