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
36c9e1f4
Commit
36c9e1f4
authored
Jun 23, 2017
by
Daneyon Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds IPv6 test cases
parent
3fd593aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
5 deletions
+69
-5
validation_test.go
cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go
+27
-5
manifests_test.go
cmd/kubeadm/app/master/manifests_test.go
+37
-0
addons_test.go
cmd/kubeadm/app/phases/addons/addons_test.go
+5
-0
No files found.
cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go
View file @
36c9e1f4
...
@@ -32,6 +32,9 @@ func TestValidateTokenDiscovery(t *testing.T) {
...
@@ -32,6 +32,9 @@ func TestValidateTokenDiscovery(t *testing.T) {
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5.6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
true
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5.6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
true
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
".6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
false
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
".6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
false
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5."
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
false
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5."
,
DiscoveryTokenAPIServers
:
[]
string
{
"192.168.122.100:9898"
}},
nil
,
false
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5.6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"2001:db8::100:9898"
}},
nil
,
true
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
".6b6baab1d4a0a171"
,
DiscoveryTokenAPIServers
:
[]
string
{
"2001:db8::100:9898"
}},
nil
,
false
},
{
&
kubeadm
.
NodeConfiguration
{
Token
:
"772ef5."
,
DiscoveryTokenAPIServers
:
[]
string
{
"2001:db8::100:9898"
}},
nil
,
false
},
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
err
:=
ValidateToken
(
rt
.
c
.
Token
,
rt
.
f
)
.
ToAggregate
()
err
:=
ValidateToken
(
rt
.
c
.
Token
,
rt
.
f
)
.
ToAggregate
()
...
@@ -101,11 +104,13 @@ func TestValidateAPIServerCertSANs(t *testing.T) {
...
@@ -101,11 +104,13 @@ func TestValidateAPIServerCertSANs(t *testing.T) {
sans
[]
string
sans
[]
string
expected
bool
expected
bool
}{
}{
{[]
string
{},
true
},
// ok if not provided
{[]
string
{},
true
},
// ok if not provided
{[]
string
{
"1,2,,3"
},
false
},
// not a DNS label or IP
{[]
string
{
"1,2,,3"
},
false
},
// not a DNS label or IP
{[]
string
{
"my-hostname"
,
"???&?.garbage"
},
false
},
// not valid
{[]
string
{
"my-hostname"
,
"???&?.garbage"
},
false
},
// not valid
{[]
string
{
"my-hostname"
,
"my.subdomain"
,
"1.2.3.4"
},
true
},
// supported
{[]
string
{
"my-hostname"
,
"my.subdomain"
,
"1.2.3.4"
},
true
},
// supported
{[]
string
{
"my-hostname2"
,
"my.other.subdomain"
,
"10.0.0.10"
},
true
},
// supported
{[]
string
{
"my-hostname2"
,
"my.other.subdomain"
,
"10.0.0.10"
},
true
},
// supported
{[]
string
{
"my-hostname"
,
"my.subdomain"
,
"2001:db8::4"
},
true
},
// supported
{[]
string
{
"my-hostname2"
,
"my.other.subdomain"
,
"2001:db8::10"
},
true
},
// supported
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
actual
:=
ValidateAPIServerCertSANs
(
rt
.
sans
,
nil
)
actual
:=
ValidateAPIServerCertSANs
(
rt
.
sans
,
nil
)
...
@@ -191,6 +196,23 @@ func TestValidateMasterConfiguration(t *testing.T) {
...
@@ -191,6 +196,23 @@ func TestValidateMasterConfiguration(t *testing.T) {
CertificatesDir
:
"/some/other/cert/dir"
,
CertificatesDir
:
"/some/other/cert/dir"
,
Token
:
"abcdef.0123456789abcdef"
,
Token
:
"abcdef.0123456789abcdef"
,
},
true
},
},
true
},
{
&
kubeadm
.
MasterConfiguration
{
AuthorizationModes
:
[]
string
{
"RBAC"
},
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"2001:db8::/98"
,
DNSDomain
:
"cluster.local"
,
},
CertificatesDir
:
"/some/cert/dir"
,
},
false
},
{
&
kubeadm
.
MasterConfiguration
{
AuthorizationModes
:
[]
string
{
"RBAC"
},
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"2001:db8::/98"
,
DNSDomain
:
"cluster.local"
,
},
CertificatesDir
:
"/some/other/cert/dir"
,
Token
:
"abcdef.0123456789abcdef"
,
},
true
},
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
actual
:=
ValidateMasterConfiguration
(
rt
.
s
)
actual
:=
ValidateMasterConfiguration
(
rt
.
s
)
...
...
cmd/kubeadm/app/master/manifests_test.go
View file @
36c9e1f4
...
@@ -648,6 +648,43 @@ func TestGetAPIServerCommand(t *testing.T) {
...
@@ -648,6 +648,43 @@ func TestGetAPIServerCommand(t *testing.T) {
"--etcd-keyfile=faz"
,
"--etcd-keyfile=faz"
,
},
},
},
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
API
:
kubeadm
.
API
{
BindPort
:
123
,
AdvertiseAddress
:
"2001:db8::1"
},
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"bar"
},
Etcd
:
kubeadm
.
Etcd
{
CertFile
:
"fiz"
,
KeyFile
:
"faz"
},
CertificatesDir
:
testCertsDir
,
KubernetesVersion
:
"v1.7.0"
,
},
expected
:
[]
string
{
"kube-apiserver"
,
"--insecure-port=0"
,
"--admission-control=Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota"
,
"--service-cluster-ip-range=bar"
,
"--service-account-key-file="
+
testCertsDir
+
"/sa.pub"
,
"--client-ca-file="
+
testCertsDir
+
"/ca.crt"
,
"--tls-cert-file="
+
testCertsDir
+
"/apiserver.crt"
,
"--tls-private-key-file="
+
testCertsDir
+
"/apiserver.key"
,
"--kubelet-client-certificate="
+
testCertsDir
+
"/apiserver-kubelet-client.crt"
,
"--kubelet-client-key="
+
testCertsDir
+
"/apiserver-kubelet-client.key"
,
fmt
.
Sprintf
(
"--secure-port=%d"
,
123
),
"--allow-privileged=true"
,
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname"
,
"--experimental-bootstrap-token-auth=true"
,
"--proxy-client-cert-file=/var/lib/certs/front-proxy-client.crt"
,
"--proxy-client-key-file=/var/lib/certs/front-proxy-client.key"
,
"--requestheader-username-headers=X-Remote-User"
,
"--requestheader-group-headers=X-Remote-Group"
,
"--requestheader-extra-headers-prefix=X-Remote-Extra-"
,
"--requestheader-client-ca-file="
+
testCertsDir
+
"/front-proxy-ca.crt"
,
"--requestheader-allowed-names=front-proxy-client"
,
"--authorization-mode=RBAC"
,
"--advertise-address=2001:db8::1"
,
"--etcd-servers=http://127.0.0.1:2379"
,
"--etcd-certfile=fiz"
,
"--etcd-keyfile=faz"
,
},
},
}
}
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
...
...
cmd/kubeadm/app/phases/addons/addons_test.go
View file @
36c9e1f4
...
@@ -32,6 +32,11 @@ func TestGetClusterCIDR(t *testing.T) {
...
@@ -32,6 +32,11 @@ func TestGetClusterCIDR(t *testing.T) {
if
clusterCIDR
!=
"- --cluster-cidr=10.244.0.0/16"
{
if
clusterCIDR
!=
"- --cluster-cidr=10.244.0.0/16"
{
t
.
Errorf
(
"Invalid format: %s"
,
clusterCIDR
)
t
.
Errorf
(
"Invalid format: %s"
,
clusterCIDR
)
}
}
clusterIPv6CIDR
:=
getClusterCIDR
(
"2001:db8::/64"
)
if
clusterIPv6CIDR
!=
"- --cluster-cidr=2001:db8::/64"
{
t
.
Errorf
(
"Invalid format: %s"
,
clusterIPv6CIDR
)
}
}
}
func
TestCompileManifests
(
t
*
testing
.
T
)
{
func
TestCompileManifests
(
t
*
testing
.
T
)
{
...
...
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