BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e0fea696
Commit
e0fea696
authored
Aug 06, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip LDAP cache check when LDAP is disabled
parent
1118a6fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
user.rb
app/models/user.rb
+3
-1
user_spec.rb
spec/models/user_spec.rb
+21
-10
No files found.
app/models/user.rb
View file @
e0fea696
...
@@ -403,7 +403,9 @@ class User < ActiveRecord::Base
...
@@ -403,7 +403,9 @@ class User < ActiveRecord::Base
end
end
def
requires_ldap_check?
def
requires_ldap_check?
if
ldap_user?
if
!
Gitlab
.
config
.
ldap
.
enabled
false
elsif
ldap_user?
!
last_credential_check_at
||
(
last_credential_check_at
+
1
.
hour
)
<
Time
.
now
!
last_credential_check_at
||
(
last_credential_check_at
+
1
.
hour
)
<
Time
.
now
else
else
false
false
...
...
spec/models/user_spec.rb
View file @
e0fea696
...
@@ -315,22 +315,33 @@ describe User do
...
@@ -315,22 +315,33 @@ describe User do
describe
:requires_ldap_check?
do
describe
:requires_ldap_check?
do
let
(
:user
)
{
User
.
new
}
let
(
:user
)
{
User
.
new
}
it
'is false for non-LDAP users'
do
it
'is false when LDAP is disabled'
do
user
.
stub
(
ldap_user?:
false
)
# Create a condition which would otherwise cause 'true' to be returned
user
.
stub
(
ldap_user?:
true
)
user
.
last_credential_check_at
=
nil
expect
(
user
.
requires_ldap_check?
).
to
be_false
expect
(
user
.
requires_ldap_check?
).
to
be_false
end
end
context
'when
the user is an LDAP user
'
do
context
'when
LDAP is enabled
'
do
before
{
user
.
stub
(
ldap_user?
:
true
)
}
before
{
Gitlab
.
config
.
ldap
.
stub
(
enabled
:
true
)
}
it
'is
true when the user has never had an LDAP check before
'
do
it
'is
false for non-LDAP users
'
do
user
.
last_credential_check_at
=
nil
user
.
stub
(
ldap_user?:
false
)
expect
(
user
.
requires_ldap_check?
).
to
be_
tru
e
expect
(
user
.
requires_ldap_check?
).
to
be_
fals
e
end
end
it
'is true when the last LDAP check happened over 1 hour ago'
do
context
'and when the user is an LDAP user'
do
user
.
last_credential_check_at
=
2
.
hours
.
ago
before
{
user
.
stub
(
ldap_user?:
true
)
}
expect
(
user
.
requires_ldap_check?
).
to
be_true
it
'is true when the user has never had an LDAP check before'
do
user
.
last_credential_check_at
=
nil
expect
(
user
.
requires_ldap_check?
).
to
be_true
end
it
'is true when the last LDAP check happened over 1 hour ago'
do
user
.
last_credential_check_at
=
2
.
hours
.
ago
expect
(
user
.
requires_ldap_check?
).
to
be_true
end
end
end
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