Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
96fb797a
Commit
96fb797a
authored
Feb 21, 2017
by
Derek McQuay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: update token separator to '.'
parent
fcb234e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
token_test.go
cmd/kubeadm/app/cmd/token_test.go
+1
-1
tokens.go
cmd/kubeadm/app/util/token/tokens.go
+3
-3
tokens_test.go
cmd/kubeadm/app/util/token/tokens_test.go
+7
-7
token_test.go
cmd/kubeadm/test/cmd/token_test.go
+1
-1
No files found.
cmd/kubeadm/app/cmd/token_test.go
View file @
96fb797a
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
)
)
const
(
const
(
TokenExpectedRegex
=
"^
\\
S{6}
\\
:
\\
S{16}
\n
$"
TokenExpectedRegex
=
"^
\\
S{6}
\\
.
\\
S{16}
\n
$"
)
)
func
TestRunGenerateToken
(
t
*
testing
.
T
)
{
func
TestRunGenerateToken
(
t
*
testing
.
T
)
{
...
...
cmd/kubeadm/app/util/token/tokens.go
View file @
96fb797a
...
@@ -34,7 +34,7 @@ const (
...
@@ -34,7 +34,7 @@ const (
var
(
var
(
tokenIDRegexpString
=
"^([a-z0-9]{6})$"
tokenIDRegexpString
=
"^([a-z0-9]{6})$"
tokenIDRegexp
=
regexp
.
MustCompile
(
tokenIDRegexpString
)
tokenIDRegexp
=
regexp
.
MustCompile
(
tokenIDRegexpString
)
tokenRegexpString
=
"^([a-z0-9]{6})
\\
:
([a-z0-9]{16})$"
tokenRegexpString
=
"^([a-z0-9]{6})
\\
.
([a-z0-9]{16})$"
tokenRegexp
=
regexp
.
MustCompile
(
tokenRegexpString
)
tokenRegexp
=
regexp
.
MustCompile
(
tokenRegexpString
)
)
)
...
@@ -87,13 +87,13 @@ func ParseToken(s string) (string, string, error) {
...
@@ -87,13 +87,13 @@ func ParseToken(s string) (string, string, error) {
// BearerToken returns a string representation of the passed token.
// BearerToken returns a string representation of the passed token.
func
BearerToken
(
d
*
kubeadmapi
.
TokenDiscovery
)
string
{
func
BearerToken
(
d
*
kubeadmapi
.
TokenDiscovery
)
string
{
return
fmt
.
Sprintf
(
"%s
:
%s"
,
d
.
ID
,
d
.
Secret
)
return
fmt
.
Sprintf
(
"%s
.
%s"
,
d
.
ID
,
d
.
Secret
)
}
}
// ValidateToken validates whether a token is well-formed.
// ValidateToken validates whether a token is well-formed.
// In case it's not, the corresponding error is returned as well.
// In case it's not, the corresponding error is returned as well.
func
ValidateToken
(
d
*
kubeadmapi
.
TokenDiscovery
)
(
bool
,
error
)
{
func
ValidateToken
(
d
*
kubeadmapi
.
TokenDiscovery
)
(
bool
,
error
)
{
if
_
,
_
,
err
:=
ParseToken
(
d
.
ID
+
"
:
"
+
d
.
Secret
);
err
!=
nil
{
if
_
,
_
,
err
:=
ParseToken
(
d
.
ID
+
"
.
"
+
d
.
Secret
);
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
return
true
,
nil
return
true
,
nil
...
...
cmd/kubeadm/app/util/token/tokens_test.go
View file @
96fb797a
...
@@ -28,14 +28,14 @@ func TestTokenParse(t *testing.T) {
...
@@ -28,14 +28,14 @@ func TestTokenParse(t *testing.T) {
expected
bool
expected
bool
}{
}{
{
token
:
"1234567890123456789012"
,
expected
:
false
},
// invalid parcel size
{
token
:
"1234567890123456789012"
,
expected
:
false
},
// invalid parcel size
{
token
:
"12345
:
1234567890123456"
,
expected
:
false
},
// invalid parcel size
{
token
:
"12345
.
1234567890123456"
,
expected
:
false
},
// invalid parcel size
{
token
:
".1234567890123456"
,
expected
:
false
},
// invalid parcel size
{
token
:
".1234567890123456"
,
expected
:
false
},
// invalid parcel size
{
token
:
"123456:1234567890.123456"
,
expected
:
false
},
// invalid separation
{
token
:
"123456:1234567890.123456"
,
expected
:
false
},
// invalid separation
{
token
:
"abcdef
.
1234567890123456"
,
expected
:
false
},
// invalid separation
{
token
:
"abcdef
:
1234567890123456"
,
expected
:
false
},
// invalid separation
{
token
:
"Abcdef
:
1234567890123456"
,
expected
:
false
},
// invalid token id
{
token
:
"Abcdef
.
1234567890123456"
,
expected
:
false
},
// invalid token id
{
token
:
"123456
:
AABBCCDDEEFFGGHH"
,
expected
:
false
},
// invalid token secret
{
token
:
"123456
.
AABBCCDDEEFFGGHH"
,
expected
:
false
},
// invalid token secret
{
token
:
"abcdef
:
1234567890123456"
,
expected
:
true
},
{
token
:
"abcdef
.
1234567890123456"
,
expected
:
true
},
{
token
:
"123456
:
aabbccddeeffgghh"
,
expected
:
true
},
{
token
:
"123456
.
aabbccddeeffgghh"
,
expected
:
true
},
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
...
@@ -154,7 +154,7 @@ func TestBearerToken(t *testing.T) {
...
@@ -154,7 +154,7 @@ func TestBearerToken(t *testing.T) {
token
*
kubeadmapi
.
TokenDiscovery
token
*
kubeadmapi
.
TokenDiscovery
expected
string
expected
string
}{
}{
{
token
:
&
kubeadmapi
.
TokenDiscovery
{
ID
:
"foo"
,
Secret
:
"bar"
},
expected
:
"foo
:
bar"
},
// should use default
{
token
:
&
kubeadmapi
.
TokenDiscovery
{
ID
:
"foo"
,
Secret
:
"bar"
},
expected
:
"foo
.
bar"
},
// should use default
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
actual
:=
BearerToken
(
rt
.
token
)
actual
:=
BearerToken
(
rt
.
token
)
...
...
cmd/kubeadm/test/cmd/token_test.go
View file @
96fb797a
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
)
)
const
(
const
(
TokenExpectedRegex
=
"^
\\
S{6}
\\
:
\\
S{16}
\n
$"
TokenExpectedRegex
=
"^
\\
S{6}
\\
.
\\
S{16}
\n
$"
)
)
var
kubeadmPath
=
flag
.
String
(
"kubeadm-path"
,
filepath
.
Join
(
os
.
Getenv
(
"KUBE_ROOT"
),
"cluster/kubeadm.sh"
),
"Location of kubeadm"
)
var
kubeadmPath
=
flag
.
String
(
"kubeadm-path"
,
filepath
.
Join
(
os
.
Getenv
(
"KUBE_ROOT"
),
"cluster/kubeadm.sh"
),
"Location of kubeadm"
)
...
...
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