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
b3164346
Commit
b3164346
authored
May 27, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move LB call in Auth to Core
parent
7ff1e6f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
28 deletions
+25
-28
ee/lib/ee/gitlab/auth.rb
ee/lib/ee/gitlab/auth.rb
+0
-7
ee/spec/lib/gitlab/auth_spec.rb
ee/spec/lib/gitlab/auth_spec.rb
+0
-20
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+3
-1
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+22
-0
No files found.
ee/lib/ee/gitlab/auth.rb
View file @
b3164346
...
...
@@ -14,13 +14,6 @@ module EE
super
end
override
:find_build_by_token
def
find_build_by_token
(
token
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary
do
super
end
end
end
end
end
ee/spec/lib/gitlab/auth_spec.rb
View file @
b3164346
...
...
@@ -25,24 +25,4 @@ RSpec.describe Gitlab::Auth do
expect
(
gl_auth
.
find_with_user_password
(
username
,
password
)
).
to
eql
user
end
end
describe
'#build_access_token_check'
do
subject
{
gl_auth
.
find_for_git_client
(
'gitlab-ci-token'
,
build
.
token
,
project:
build
.
project
,
ip:
'1.2.3.4'
)
}
context
'for running build'
do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
user:
user
)
}
it
'executes query using primary database'
do
expect
(
Ci
::
Build
).
to
receive
(
:find_by_token
).
with
(
build
.
token
).
and_wrap_original
do
|
m
,
*
args
|
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary?
).
to
eq
(
true
)
m
.
call
(
*
args
)
end
expect
(
subject
).
to
be_a
(
Gitlab
::
Auth
::
Result
)
expect
(
subject
.
actor
).
to
eq
(
user
)
expect
(
subject
.
project
).
to
eq
(
build
.
project
)
expect
(
subject
.
type
).
to
eq
(
:build
)
end
end
end
end
lib/gitlab/auth.rb
View file @
b3164346
...
...
@@ -371,7 +371,9 @@ module Gitlab
end
def
find_build_by_token
(
token
)
::
Ci
::
AuthJobFinder
.
new
(
token:
token
).
execute
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary
do
::
Ci
::
AuthJobFinder
.
new
(
token:
token
).
execute
end
end
def
user_auth_attempt!
(
user
,
success
:)
...
...
spec/lib/gitlab/auth_spec.rb
View file @
b3164346
...
...
@@ -683,6 +683,28 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do
end
end
describe
'#build_access_token_check'
do
subject
{
gl_auth
.
find_for_git_client
(
'gitlab-ci-token'
,
build
.
token
,
project:
build
.
project
,
ip:
'1.2.3.4'
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
context
'for running build'
do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
user:
user
)
}
it
'executes query using primary database'
do
expect
(
Ci
::
Build
).
to
receive
(
:find_by_token
).
with
(
build
.
token
).
and_wrap_original
do
|
m
,
*
args
|
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary?
).
to
eq
(
true
)
m
.
call
(
*
args
)
end
expect
(
subject
).
to
be_a
(
Gitlab
::
Auth
::
Result
)
expect
(
subject
.
actor
).
to
eq
(
user
)
expect
(
subject
.
project
).
to
eq
(
build
.
project
)
expect
(
subject
.
type
).
to
eq
(
:build
)
end
end
end
describe
'find_with_user_password'
do
let!
(
:user
)
do
create
(
:user
,
...
...
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