Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 201 additions & 201 deletions benchmarking/locust/common/ateapi_pb2.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/ateapi/internal/controlapi/egress_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func ValidateCustom_EgressRuleEffects_InjectStaticHeaders(_ context.Context, _ o
return errs
}

func ValidateCustom_IPBlockRule_Cidrs(_ context.Context, _ operation.Operation, p *field.Path, cidrs, _ []string) field.ErrorList {
func ValidateCustom_CIDRRule_Cidrs(_ context.Context, _ operation.Operation, p *field.Path, cidrs, _ []string) field.ErrorList {
var errs field.ErrorList
for i, cidr := range cidrs {
errs = append(errs, validation.IsValidCIDR(p.Index(i), cidr)...)
Expand Down
28 changes: 14 additions & 14 deletions cmd/ateapi/internal/controlapi/egress_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,18 @@ func TestValidateEgressPolicyRules(t *testing.T) {
}, {
name: "canonical IPv4 CIDR",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{Cidrs: []string{"192.0.2.0/24"}}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{Cidrs: []string{"192.0.2.0/24"}}}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now both EgressRule and CIDRRule has a field named cidrs, which seems a little duplicate.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do CIDRRange if we wanted a little less duplication, but it's purely subjective at this point. Up to you 🙂

},
}, {
name: "canonical IPv6 CIDR",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{Cidrs: []string{"2001:db8::/32"}}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{Cidrs: []string{"2001:db8::/32"}}}
},
}, {
name: "mixed IPv4 and IPv6 CIDRs",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{
IpBlocks: &ateapipb.IPBlockRule{
Cidrs: &ateapipb.CIDRRule{
Cidrs: []string{"192.0.2.0/24", "2001:db8::/32"},
},
}
Expand All @@ -593,7 +593,7 @@ func TestValidateEgressPolicyRules(t *testing.T) {
cidrs = append(cidrs, fmt.Sprintf("192.0.2.%d/32", i))
}
p.Rules[0] = &ateapipb.EgressRule{
IpBlocks: &ateapipb.IPBlockRule{
Cidrs: &ateapipb.CIDRRule{
Cidrs: cidrs,
},
}
Expand All @@ -606,45 +606,45 @@ func TestValidateEgressPolicyRules(t *testing.T) {
cidrs = append(cidrs, fmt.Sprintf("192.0.2.%d/32", i))
}
p.Rules[0] = &ateapipb.EgressRule{
IpBlocks: &ateapipb.IPBlockRule{
Cidrs: &ateapipb.CIDRRule{
Cidrs: cidrs,
},
}
},
want: field.ErrorList{
field.TooMany(rule.Child("ip_blocks", "cidrs"), 257, 256).WithOrigin("maxItems"),
field.TooMany(rule.Child("cidrs", "cidrs"), 257, 256).WithOrigin("maxItems"),
},
}, {
name: "missing CIDR",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{Cidrs: []string{""}}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{Cidrs: []string{""}}}
},
want: field.ErrorList{
field.Invalid(rule.Child("ip_blocks", "cidrs").Index(0), "", "must be a canonical IPv4 or IPv6 prefix"),
field.Invalid(rule.Child("cidrs", "cidrs").Index(0), "", "must be a canonical IPv4 or IPv6 prefix"),
},
}, {
name: "empty CIDR list",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{}}
},
want: field.ErrorList{
field.Required(rule.Child("ip_blocks", "cidrs"), ""),
field.Required(rule.Child("cidrs", "cidrs"), ""),
},
}, {
name: "noncanonical CIDR",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{Cidrs: []string{"192.0.2.1/24"}}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{Cidrs: []string{"192.0.2.1/24"}}}
},
want: field.ErrorList{
field.Invalid(rule.Child("ip_blocks", "cidrs").Index(0), "192.0.2.1/24", "must be a canonical IPv4 or IPv6 prefix"),
field.Invalid(rule.Child("cidrs", "cidrs").Index(0), "192.0.2.1/24", "must be a canonical IPv4 or IPv6 prefix"),
},
}, {
name: "duplicate CIDR",
mutate: func(p *ateapipb.EgressPolicy) {
p.Rules[0] = &ateapipb.EgressRule{IpBlocks: &ateapipb.IPBlockRule{Cidrs: []string{"192.0.2.0/24", "192.0.2.0/24"}}}
p.Rules[0] = &ateapipb.EgressRule{Cidrs: &ateapipb.CIDRRule{Cidrs: []string{"192.0.2.0/24", "192.0.2.0/24"}}}
},
want: field.ErrorList{
field.Duplicate(rule.Child("ip_blocks", "cidrs").Index(1), "192.0.2.0/24"),
field.Duplicate(rule.Child("cidrs", "cidrs").Index(1), "192.0.2.0/24"),
},
}, {
name: "missing static header",
Expand Down
116 changes: 58 additions & 58 deletions cmd/ateapi/internal/controlapi/zz_generated.validation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions pkg/proto/ateapipb/ateapi.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading