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
72422996
Commit
72422996
authored
Oct 24, 2019
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a spec for the TTL on sessions
parent
8ccdaf33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
spec/features/users/anonymous_sessions_spec.rb
spec/features/users/anonymous_sessions_spec.rb
+41
-0
No files found.
spec/features/users/anonymous_sessions_spec.rb
0 → 100644
View file @
72422996
# frozen_string_literal: true
require
'spec_helper'
describe
'Session TTLs'
,
:clean_gitlab_redis_shared_state
do
it
'creates a session with a short TTL when login fails'
do
visit
new_user_session_path
# The session key only gets created after a post
fill_in
'user_login'
,
with:
'non-existant@gitlab.org'
fill_in
'user_password'
,
with:
'12345678'
click_button
'Sign in'
expect
(
page
).
to
have_content
(
'Invalid Login or password'
)
expect_single_session_with_expiration
(
Settings
.
gitlab
[
'unauthenticated_session_expire_delay'
])
end
it
'increases the TTL when the login succeeds'
do
user
=
create
(
:user
)
gitlab_sign_in
(
user
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect_single_session_with_expiration
(
Settings
.
gitlab
[
'session_expire_delay'
]
*
60
)
end
def
expect_single_session_with_expiration
(
expiration
)
session_keys
=
get_session_keys
expect
(
session_keys
.
size
).
to
eq
(
1
)
expect
(
get_ttl
(
session_keys
.
first
)).
to
eq
expiration
end
def
get_session_keys
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
scan_each
(
match:
'session:gitlab:*'
).
to_a
}
end
def
get_ttl
(
key
)
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
ttl
(
key
)
}
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