@@ -1006,12 +1006,14 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1006
1006
Raw : []byte (`{"kind": "foo", "apiVersion": "dra.example.com/v1"}` ),
1007
1007
},
1008
1008
NetworkData : & resource.NetworkDeviceData {
1009
- InterfaceName : "net-1" ,
1009
+ InterfaceName : strings .Repeat ("x" , 256 ),
1010
+ HardwareAddress : strings .Repeat ("x" , 128 ),
1010
1011
Addresses : []string {
1011
1012
"10.9.8.0/24" ,
1012
1013
"2001:db8::/64" ,
1014
+ "10.9.8.1/24" ,
1015
+ "2001:db8::1/64" ,
1013
1016
},
1014
- HardwareAddress : "ea:9f:cb:40:b1:7b" ,
1015
1017
},
1016
1018
},
1017
1019
}
@@ -1021,6 +1023,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1021
1023
},
1022
1024
"invalid-device-status-duplicate" : {
1023
1025
wantFailures : field.ErrorList {
1026
+ field .Duplicate (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "addresses" ).Index (1 ), "2001:db8::1/64" ),
1024
1027
field .Duplicate (field .NewPath ("status" , "devices" ).Index (1 ).Child ("deviceID" ), structured.DeviceID {Driver : goodName , Pool : goodName , Device : goodName }),
1025
1028
},
1026
1029
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1030,6 +1033,12 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1030
1033
Driver : goodName ,
1031
1034
Pool : goodName ,
1032
1035
Device : goodName ,
1036
+ NetworkData : & resource.NetworkDeviceData {
1037
+ Addresses : []string {
1038
+ "2001:db8::1/64" ,
1039
+ "2001:0db8::1/64" ,
1040
+ },
1041
+ },
1033
1042
},
1034
1043
{
1035
1044
Driver : goodName ,
@@ -1043,6 +1052,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1043
1052
},
1044
1053
"invalid-network-device-status" : {
1045
1054
wantFailures : field.ErrorList {
1055
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , interfaceNameMaxLength ),
1056
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , hardwareAddressMaxLength ),
1046
1057
field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "addresses" ).Index (0 ), "300.9.8.0/24" , "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)" ),
1047
1058
},
1048
1059
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1053,6 +1064,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1053
1064
Pool : goodName ,
1054
1065
Device : goodName ,
1055
1066
NetworkData : & resource.NetworkDeviceData {
1067
+ InterfaceName : strings .Repeat ("x" , interfaceNameMaxLength + 1 ),
1068
+ HardwareAddress : strings .Repeat ("x" , hardwareAddressMaxLength + 1 ),
1056
1069
Addresses : []string {
1057
1070
"300.9.8.0/24" ,
1058
1071
},
@@ -1065,7 +1078,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1065
1078
},
1066
1079
"invalid-data-device-status" : {
1067
1080
wantFailures : field.ErrorList {
1068
- field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "<value omitted>" , "error parsing data: invalid character 'o' in literal false (expecting 'a')" ),
1081
+ field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "<value omitted>" , "error parsing data as JSON : invalid character 'o' in literal false (expecting 'a')" ),
1069
1082
},
1070
1083
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
1071
1084
update : func (claim * resource.ResourceClaim ) * resource.ResourceClaim {
@@ -1102,6 +1115,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1102
1115
},
1103
1116
"invalid-device-status-duplicate-disabled-feature-gate" : {
1104
1117
wantFailures : field.ErrorList {
1118
+ field .Duplicate (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "addresses" ).Index (1 ), "2001:db8::1/64" ),
1105
1119
field .Duplicate (field .NewPath ("status" , "devices" ).Index (1 ).Child ("deviceID" ), structured.DeviceID {Driver : goodName , Pool : goodName , Device : goodName }),
1106
1120
},
1107
1121
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1111,6 +1125,12 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1111
1125
Driver : goodName ,
1112
1126
Pool : goodName ,
1113
1127
Device : goodName ,
1128
+ NetworkData : & resource.NetworkDeviceData {
1129
+ Addresses : []string {
1130
+ "2001:db8::1/64" ,
1131
+ "2001:0db8::1/64" ,
1132
+ },
1133
+ },
1114
1134
},
1115
1135
{
1116
1136
Driver : goodName ,
@@ -1124,6 +1144,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1124
1144
},
1125
1145
"invalid-network-device-status-disabled-feature-gate" : {
1126
1146
wantFailures : field.ErrorList {
1147
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , interfaceNameMaxLength ),
1148
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , hardwareAddressMaxLength ),
1127
1149
field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "addresses" ).Index (0 ), "300.9.8.0/24" , "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)" ),
1128
1150
},
1129
1151
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1134,6 +1156,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1134
1156
Pool : goodName ,
1135
1157
Device : goodName ,
1136
1158
NetworkData : & resource.NetworkDeviceData {
1159
+ InterfaceName : strings .Repeat ("x" , interfaceNameMaxLength + 1 ),
1160
+ HardwareAddress : strings .Repeat ("x" , hardwareAddressMaxLength + 1 ),
1137
1161
Addresses : []string {
1138
1162
"300.9.8.0/24" ,
1139
1163
},
@@ -1146,7 +1170,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1146
1170
},
1147
1171
"invalid-data-device-status-disabled-feature-gate" : {
1148
1172
wantFailures : field.ErrorList {
1149
- field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "<value omitted>" , "error parsing data: invalid character 'o' in literal false (expecting 'a')" ),
1173
+ field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "<value omitted>" , "error parsing data as JSON : invalid character 'o' in literal false (expecting 'a')" ),
1150
1174
},
1151
1175
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
1152
1176
update : func (claim * resource.ResourceClaim ) * resource.ResourceClaim {
0 commit comments