Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
cd939309
Commit
cd939309
authored
Feb 24, 2017
by
Eric Chiang
Committed by
GitHub
Feb 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #817 from ericchiang/fix-hash-bug
storage/kubernetes: fix hash initialization bug
parents
25b902b0
1da2ae27
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
client.go
storage/kubernetes/client.go
+4
-3
client_test.go
storage/kubernetes/client_test.go
+13
-0
No files found.
storage/kubernetes/client.go
View file @
cd939309
...
@@ -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
{
...
...
storage/kubernetes/client_test.go
View file @
cd939309
...
@@ -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
{
...
...
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