Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
hdacloud
dex
Commits
2cfcdfb8
Commit
2cfcdfb8
authored
8 years ago
by
Eric Chiang
Committed by
rithu john
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
storage/kubernetes: fix hash initialization bug
parent
f8aec4c1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/kubernetes/client.go
+4
-3
4 additions, 3 deletions
storage/kubernetes/client.go
storage/kubernetes/client_test.go
+13
-0
13 additions, 0 deletions
storage/kubernetes/client_test.go
with
17 additions
and
3 deletions
storage/kubernetes/client.go
+
4
−
3
View file @
2cfcdfb8
...
@@ -72,9 +72,10 @@ func idToName(s string, h func() hash.Hash) string {
...
@@ -72,9 +72,10 @@ func idToName(s string, h func() hash.Hash) string {
}
}
func
offlineTokenName
(
userID
string
,
connID
string
,
h
func
()
hash
.
Hash
)
string
{
func
offlineTokenName
(
userID
string
,
connID
string
,
h
func
()
hash
.
Hash
)
string
{
h
()
.
Write
([]
byte
(
userID
))
hash
:=
h
()
h
()
.
Write
([]
byte
(
connID
))
hash
.
Write
([]
byte
(
userID
))
return
strings
.
TrimRight
(
encoding
.
EncodeToString
(
h
()
.
Sum
(
nil
)),
"="
)
hash
.
Write
([]
byte
(
connID
))
return
strings
.
TrimRight
(
encoding
.
EncodeToString
(
hash
.
Sum
(
nil
)),
"="
)
}
}
func
(
c
*
client
)
urlFor
(
apiVersion
,
namespace
,
resource
,
name
string
)
string
{
func
(
c
*
client
)
urlFor
(
apiVersion
,
namespace
,
resource
,
name
string
)
string
{
...
...
This diff is collapsed.
Click to expand it.
storage/kubernetes/client_test.go
+
13
−
0
View file @
2cfcdfb8
...
@@ -29,6 +29,19 @@ func TestIDToName(t *testing.T) {
...
@@ -29,6 +29,19 @@ func TestIDToName(t *testing.T) {
wg
.
Wait
()
wg
.
Wait
()
}
}
func
TestOfflineTokenName
(
t
*
testing
.
T
)
{
h
:=
func
()
hash
.
Hash
{
return
fnv
.
New64
()
}
userID1
:=
"john"
userID2
:=
"jane"
id1
:=
offlineTokenName
(
userID1
,
"local"
,
h
)
id2
:=
offlineTokenName
(
userID2
,
"local"
,
h
)
if
id1
==
id2
{
t
.
Errorf
(
"expected offlineTokenName to produce different hashes"
)
}
}
func
TestNamespaceFromServiceAccountJWT
(
t
*
testing
.
T
)
{
func
TestNamespaceFromServiceAccountJWT
(
t
*
testing
.
T
)
{
namespace
,
err
:=
namespaceFromServiceAccountJWT
(
serviceAccountToken
)
namespace
,
err
:=
namespaceFromServiceAccountJWT
(
serviceAccountToken
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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