@@ -99,21 +99,17 @@ func TestValidateTokenGroups(t *testing.T) {
99
99
func TestValidateNodeRegistrationOptions (t * testing.T ) {
100
100
var tests = []struct {
101
101
nodeName string
102
- criSocket string
103
102
expectedErrors bool
104
103
}{
105
- {"" , "/some/path" , true }, // node name can't be empty
106
- {"INVALID-NODENAME" , "/some/path" , true }, // Upper cases is invalid
107
- {"invalid-nodename-" , "/some/path" , true }, // Can't have trailing dashes
108
- {"invalid-node?name" , "/some/path" , true }, // Unsupported characters
109
- {"valid-nodename" , "/some/path" , false }, // supported
110
- {"valid-nodename-with-numbers01234" , "/some/path/with/numbers/01234/" , false }, // supported, with numbers as well
111
- {"valid-nodename" , kubeadmapiv1beta2 .DefaultUrlScheme + "://" + "/some/path" , false }, // supported, with socket url
112
- {"valid-nodename" , "bla:///some/path" , true }, // unsupported url scheme
113
- {"valid-nodename" , ":::" , true }, // unparseable url
104
+ {"" , true }, // node name can't be empty
105
+ {"INVALID-NODENAME" , true }, // Upper cases is invalid
106
+ {"invalid-nodename-" , true }, // Can't have trailing dashes
107
+ {"invalid-node?name" , true }, // Unsupported characters
108
+ {"valid-nodename" , false }, // supported
109
+ // test cases for criSocket are covered in TestValidateSocketPath
114
110
}
115
111
for _ , rt := range tests {
116
- nro := kubeadm.NodeRegistrationOptions {Name : rt .nodeName , CRISocket : rt . criSocket }
112
+ nro := kubeadm.NodeRegistrationOptions {Name : rt .nodeName , CRISocket : "/some/path" }
117
113
actual := ValidateNodeRegistrationOptions (& nro , field .NewPath ("nodeRegistration" ))
118
114
actualErrors := len (actual ) > 0
119
115
if actualErrors != rt .expectedErrors {
@@ -896,3 +892,25 @@ func TestValidateDiscoveryKubeConfigPath(t *testing.T) {
896
892
}
897
893
}
898
894
}
895
+
896
+ func TestValidateSocketPath (t * testing.T ) {
897
+ var tests = []struct {
898
+ name string
899
+ criSocket string
900
+ expectedErrors bool
901
+ }{
902
+ {name : "valid path" , criSocket : "/some/path" , expectedErrors : false },
903
+ {name : "valid socket url" , criSocket : kubeadmapiv1beta2 .DefaultUrlScheme + "://" + "/some/path" , expectedErrors : false },
904
+ {name : "unsupported url scheme" , criSocket : "bla:///some/path" , expectedErrors : true },
905
+ {name : "unparseable url" , criSocket : ":::" , expectedErrors : true },
906
+ {name : "invalid CRISocket (path is not absolute)" , criSocket : "some/path" , expectedErrors : true },
907
+ {name : "empty CRISocket (path is not absolute)" , criSocket : "" , expectedErrors : true },
908
+ }
909
+ for _ , tc := range tests {
910
+ actual := ValidateSocketPath (tc .criSocket , field .NewPath ("criSocket" ))
911
+ actualErrors := len (actual ) > 0
912
+ if actualErrors != tc .expectedErrors {
913
+ t .Errorf ("error: socket path: %q\n \t expected: %t\n \t actual: %t" , tc .criSocket , tc .expectedErrors , actualErrors )
914
+ }
915
+ }
916
+ }
0 commit comments