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
b9b3ec83
Commit
b9b3ec83
authored
Jul 05, 2019
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CE port of "Require session with smartcard login for Git access"
parent
f845a081
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
13 deletions
+32
-13
lib/gitlab/namespaced_session_store.rb
lib/gitlab/namespaced_session_store.rb
+10
-5
spec/lib/gitlab/namespaced_session_store_spec.rb
spec/lib/gitlab/namespaced_session_store_spec.rb
+22
-8
No files found.
lib/gitlab/namespaced_session_store.rb
View file @
b9b3ec83
...
...
@@ -4,19 +4,24 @@ module Gitlab
class
NamespacedSessionStore
delegate
:[]
,
:[]=
,
to: :store
def
initialize
(
key
)
def
initialize
(
key
,
session
=
Session
.
current
)
@key
=
key
@session
=
session
end
def
initiated?
!
Session
.
current
.
nil?
!
session
.
nil?
end
def
store
return
unless
Session
.
current
return
unless
session
Session
.
current
[
@key
]
||=
{}
Session
.
current
[
@key
]
session
[
@key
]
||=
{}
session
[
@key
]
end
private
attr_reader
:session
end
end
spec/lib/gitlab/namespaced_session_store_spec.rb
View file @
b9b3ec83
...
...
@@ -4,19 +4,33 @@ require 'spec_helper'
describe
Gitlab
::
NamespacedSessionStore
do
let
(
:key
)
{
:some_key
}
subject
{
described_class
.
new
(
key
)
}
it
'stores data under the specified key'
do
Gitlab
::
Session
.
with_session
({})
do
subject
[
:new_data
]
=
123
context
'current session'
do
subject
{
described_class
.
new
(
key
)
}
expect
(
Thread
.
current
[
:session_storage
][
key
]).
to
eq
(
new_data:
123
)
it
'stores data under the specified key'
do
Gitlab
::
Session
.
with_session
({})
do
subject
[
:new_data
]
=
123
expect
(
Thread
.
current
[
:session_storage
][
key
]).
to
eq
(
new_data:
123
)
end
end
it
'retrieves data from the given key'
do
Thread
.
current
[
:session_storage
]
=
{
key
=>
{
existing_data:
123
}
}
expect
(
subject
[
:existing_data
]).
to
eq
123
end
end
it
'retrieves data from the given key'
do
Thread
.
current
[
:session_storage
]
=
{
key
=>
{
existing_data:
123
}
}
context
'passed in session'
do
let
(
:data
)
{
{
'data'
=>
42
}
}
let
(
:session
)
{
{
'some_key'
=>
data
}
}
subject
{
described_class
.
new
(
key
,
session
.
with_indifferent_access
)
}
expect
(
subject
[
:existing_data
]).
to
eq
123
it
'retrieves data from the given key'
do
expect
(
subject
[
'data'
]).
to
eq
42
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