@@ -84,6 +84,168 @@ func Test_ingressClassParamsValidator_ValidateCreate(t *testing.T) {
84
84
},
85
85
wantErr : "spec.inboundCIDRs[0]: Invalid value: \" invalid.example.com\" : Could not be parsed as a CIDR" ,
86
86
},
87
+ {
88
+ name : "securityGroups is valid ID list" ,
89
+ obj : & elbv2api.IngressClassParams {
90
+ Spec : elbv2api.IngressClassParamsSpec {
91
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
92
+ IDs : []elbv2api.SecurityGroupID {"sg-1" , "sg-2" },
93
+ },
94
+ },
95
+ },
96
+ },
97
+ {
98
+ name : "securityGroups is valid managed" ,
99
+ obj : & elbv2api.IngressClassParams {
100
+ Spec : elbv2api.IngressClassParamsSpec {
101
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
102
+ ManagedInbound : true ,
103
+ },
104
+ },
105
+ },
106
+ },
107
+ {
108
+ name : "securityGroups is managedInbound with inboundCIDRs" ,
109
+ obj : & elbv2api.IngressClassParams {
110
+ Spec : elbv2api.IngressClassParamsSpec {
111
+ InboundCIDRs : []string {
112
+ "10.0.0.0/8" ,
113
+ "2001:DB8::/32" ,
114
+ },
115
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
116
+ ManagedInbound : true ,
117
+ },
118
+ },
119
+ },
120
+ },
121
+ {
122
+ name : "securityGroups is valid tag list" ,
123
+ obj : & elbv2api.IngressClassParams {
124
+ Spec : elbv2api.IngressClassParamsSpec {
125
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
126
+ Tags : map [string ][]string {
127
+ "key" : {"value1" , "value2" },
128
+ },
129
+ },
130
+ },
131
+ },
132
+ },
133
+ {
134
+ name : "securityGroups selector empty" ,
135
+ obj : & elbv2api.IngressClassParams {
136
+ Spec : elbv2api.IngressClassParamsSpec {
137
+ SecurityGroups : & elbv2api.SecurityGroupSelector {},
138
+ },
139
+ },
140
+ wantErr : "spec.securityGroups: Required value: must have `ids`, `managed`, or `tags`" ,
141
+ },
142
+ {
143
+ name : "securityGroups selector with both id and managedInbound" ,
144
+ obj : & elbv2api.IngressClassParams {
145
+ Spec : elbv2api.IngressClassParamsSpec {
146
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
147
+ IDs : []elbv2api.SecurityGroupID {"sg-1" , "sg-2" },
148
+ ManagedInbound : true ,
149
+ },
150
+ },
151
+ },
152
+ wantErr : "spec.securityGroups.managedInbound: Forbidden: may not have both `ids` and `managedInbound` set" ,
153
+ },
154
+ {
155
+ name : "securityGroups selector with both id and tag" ,
156
+ obj : & elbv2api.IngressClassParams {
157
+ Spec : elbv2api.IngressClassParamsSpec {
158
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
159
+ IDs : []elbv2api.SecurityGroupID {"sg-1" , "sg-2" },
160
+ Tags : map [string ][]string {
161
+ "Name" : {"named-subnet" },
162
+ },
163
+ },
164
+ },
165
+ },
166
+ wantErr : "spec.securityGroups.tags: Forbidden: may not have both `ids` and `tags` set" ,
167
+ },
168
+ {
169
+ name : "securityGroups selector with both managedInbound and tag" ,
170
+ obj : & elbv2api.IngressClassParams {
171
+ Spec : elbv2api.IngressClassParamsSpec {
172
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
173
+ ManagedInbound : true ,
174
+ Tags : map [string ][]string {
175
+ "Name" : {"named-subnet" },
176
+ },
177
+ },
178
+ },
179
+ },
180
+ wantErr : "spec.securityGroups.tags: Forbidden: may not have both `managedInbound` and `tags` set" ,
181
+ },
182
+ {
183
+ name : "securityGroups id with inboundCIDRs" ,
184
+ obj : & elbv2api.IngressClassParams {
185
+ Spec : elbv2api.IngressClassParamsSpec {
186
+ InboundCIDRs : []string {
187
+ "10.0.0.0/8" ,
188
+ },
189
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
190
+ IDs : []elbv2api.SecurityGroupID {"sg-1" },
191
+ },
192
+ },
193
+ },
194
+ wantErr : "spec.inboundCIDRs: Forbidden: May not have both `inboundCIDRs` and `securityGroups.ids`" ,
195
+ },
196
+ {
197
+ name : "securityGroups duplicate id" ,
198
+ obj : & elbv2api.IngressClassParams {
199
+ Spec : elbv2api.IngressClassParamsSpec {
200
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
201
+ IDs : []elbv2api.SecurityGroupID {"sg-1" , "sg-2" , "sg-1" },
202
+ },
203
+ },
204
+ },
205
+ wantErr : "spec.securityGroups.ids[2]: Duplicate value: \" sg-1\" " ,
206
+ },
207
+ {
208
+ name : "securityGroups tag with inboundCIDRs" ,
209
+ obj : & elbv2api.IngressClassParams {
210
+ Spec : elbv2api.IngressClassParamsSpec {
211
+ InboundCIDRs : []string {
212
+ "10.0.0.0/8" ,
213
+ },
214
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
215
+ Tags : map [string ][]string {
216
+ "Name" : {"name1" },
217
+ "Other" : {"other1" },
218
+ },
219
+ },
220
+ },
221
+ },
222
+ wantErr : "spec.inboundCIDRs: Forbidden: May not have both `inboundCIDRs` and `securityGroups.tags`" ,
223
+ },
224
+ {
225
+ name : "securityGroups duplicate tag value" ,
226
+ obj : & elbv2api.IngressClassParams {
227
+ Spec : elbv2api.IngressClassParamsSpec {
228
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
229
+ Tags : map [string ][]string {
230
+ "Name" : {"name1" },
231
+ "Other" : {"other1" , "other2" , "other1" },
232
+ },
233
+ },
234
+ },
235
+ },
236
+ wantErr : "spec.securityGroups.tags[Other][2]: Duplicate value: \" other1\" " ,
237
+ },
238
+ {
239
+ name : "securityGroups empty tags map" ,
240
+ obj : & elbv2api.IngressClassParams {
241
+ Spec : elbv2api.IngressClassParamsSpec {
242
+ SecurityGroups : & elbv2api.SecurityGroupSelector {
243
+ Tags : map [string ][]string {},
244
+ },
245
+ },
246
+ },
247
+ wantErr : "spec.securityGroups.tags: Required value: must have at least one tag key" ,
248
+ },
87
249
{
88
250
name : "subnet is valid ID list" ,
89
251
obj : & elbv2api.IngressClassParams {
0 commit comments