Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keystore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
id
keystore
Commits
73e4c61d
Commit
73e4c61d
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add a test for backwards compatibility with clients lacking session IDs
parent
98e45722
Branches
Branches containing commit
No related tags found
Loading
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/keystore_test.go
+40
-0
40 additions, 0 deletions
server/keystore_test.go
with
40 additions
and
0 deletions
server/keystore_test.go
+
40
−
0
View file @
73e4c61d
...
...
@@ -144,6 +144,46 @@ func TestKeystore_OpenAndGet(t *testing.T) {
}
}
func
TestKeystore_OpenAndGet_BackwardsCompatibility
(
t
*
testing
.
T
)
{
c
,
keystore
,
cleanup
:=
newTestContext
(
t
)
defer
cleanup
()
// Decrypt the private key with the right password. Do not set a session ID.
err
:=
keystore
.
Open
(
context
.
Background
(),
"testuser"
,
string
(
pw
),
""
,
60
)
if
err
!=
nil
{
t
.
Fatal
(
"keystore.Open():"
,
err
)
}
// Call expire() now to make sure we don't wipe data that is
// not expired yet.
keystore
.
expire
(
time
.
Now
())
// Sign a valid SSO ticket and use it to obtain the private
// key we just stored.
ssoTicket
:=
c
.
sign
(
"testuser"
,
"keystore/"
,
"domain"
)
result
,
err
:=
keystore
.
Get
(
"testuser"
,
ssoTicket
)
if
err
!=
nil
{
t
.
Fatal
(
"keystore.Get():"
,
err
)
}
expectedPEM
,
_
:=
privKey
.
PEM
()
if
!
bytes
.
Equal
(
result
,
expectedPEM
)
{
t
.
Fatalf
(
"keystore.Get() returned bad key: got %v, expected %v"
,
result
,
expectedPEM
)
}
// Verify user namespace isolation
keystore
.
Close
(
"otheruser"
,
""
)
if
_
,
err
:=
keystore
.
Get
(
"testuser"
,
ssoTicket
);
err
!=
nil
{
t
.
Fatalf
(
"keystore.Get() returned error after Close(otheruser): %v"
,
err
)
}
// Call Close() and forget the key.
keystore
.
Close
(
"testuser"
,
""
)
if
_
,
err
:=
keystore
.
Get
(
"testuser"
,
ssoTicket
);
err
==
nil
{
t
.
Fatal
(
"keystore.Get() returned no error after Close()"
)
}
}
func
TestKeystore_OpenAndGet_MultipleSessions
(
t
*
testing
.
T
)
{
c
,
keystore
,
cleanup
:=
newTestContext
(
t
)
defer
cleanup
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment