From edfcfb7ac743de46342389dd473941d44eb7af58 Mon Sep 17 00:00:00 2001 From: Chris Roche Date: Mon, 12 Feb 2024 11:26:35 -0800 Subject: [PATCH] Temporarily remove host_and_port conformance tests until protos make it into buf (#165) Conformance tests depend on the protos making it into buf first. Will reapply these changes once I can update that dependency for the tools module. --- .../validate/conformance/cases/strings.proto | 12 -- .../validate/conformance/cases/strings.pb.go | 176 +++--------------- .../internal/cases/cases_strings.go | 91 --------- 3 files changed, 21 insertions(+), 258 deletions(-) diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/strings.proto b/proto/protovalidate-testing/buf/validate/conformance/cases/strings.proto index e5ad5e02..a29859c6 100644 --- a/proto/protovalidate-testing/buf/validate/conformance/cases/strings.proto +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/strings.proto @@ -180,15 +180,3 @@ message StringInOneof { }]; } } - -message StringHostAndPort { - string val = 1 [(buf.validate.field).string.host_and_port = true]; -} - -message StringHostAndOptionalPort { - string val = 1 [(field).cel = { - id: "string.host_and_port.optional_port", - message: "value must be a host and (optional) port pair", - expression: "this.isHostAndPort(false)", - }]; -} diff --git a/tools/internal/gen/buf/validate/conformance/cases/strings.pb.go b/tools/internal/gen/buf/validate/conformance/cases/strings.pb.go index e74843b2..69df6f7e 100644 --- a/tools/internal/gen/buf/validate/conformance/cases/strings.pb.go +++ b/tools/internal/gen/buf/validate/conformance/cases/strings.pb.go @@ -1982,100 +1982,6 @@ type StringInOneof_Bar struct { func (*StringInOneof_Bar) isStringInOneof_Foo() {} -type StringHostAndPort struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` -} - -func (x *StringHostAndPort) Reset() { - *x = StringHostAndPort{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_validate_conformance_cases_strings_proto_msgTypes[41] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StringHostAndPort) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StringHostAndPort) ProtoMessage() {} - -func (x *StringHostAndPort) ProtoReflect() protoreflect.Message { - mi := &file_buf_validate_conformance_cases_strings_proto_msgTypes[41] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StringHostAndPort.ProtoReflect.Descriptor instead. -func (*StringHostAndPort) Descriptor() ([]byte, []int) { - return file_buf_validate_conformance_cases_strings_proto_rawDescGZIP(), []int{41} -} - -func (x *StringHostAndPort) GetVal() string { - if x != nil { - return x.Val - } - return "" -} - -type StringHostAndOptionalPort struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` -} - -func (x *StringHostAndOptionalPort) Reset() { - *x = StringHostAndOptionalPort{} - if protoimpl.UnsafeEnabled { - mi := &file_buf_validate_conformance_cases_strings_proto_msgTypes[42] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StringHostAndOptionalPort) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StringHostAndOptionalPort) ProtoMessage() {} - -func (x *StringHostAndOptionalPort) ProtoReflect() protoreflect.Message { - mi := &file_buf_validate_conformance_cases_strings_proto_msgTypes[42] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StringHostAndOptionalPort.ProtoReflect.Descriptor instead. -func (*StringHostAndOptionalPort) Descriptor() ([]byte, []int) { - return file_buf_validate_conformance_cases_strings_proto_rawDescGZIP(), []int{42} -} - -func (x *StringHostAndOptionalPort) GetVal() string { - if x != nil { - return x.Val - } - return "" -} - var File_buf_validate_conformance_cases_strings_proto protoreflect.FileDescriptor var file_buf_validate_conformance_cases_strings_proto_rawDesc = []byte{ @@ -2209,39 +2115,25 @@ var file_buf_validate_conformance_cases_strings_proto_rawDesc = []byte{ 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x12, 0x1f, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x72, 0x06, 0x52, 0x01, 0x61, 0x52, 0x01, 0x62, 0x48, 0x00, 0x52, 0x03, 0x62, 0x61, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x66, - 0x6f, 0x6f, 0x22, 0x2f, 0x0a, 0x11, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x6f, 0x73, 0x74, - 0x41, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1a, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xba, 0x48, 0x05, 0x72, 0x03, 0x80, 0x02, 0x01, 0x52, 0x03, - 0x76, 0x61, 0x6c, 0x22, 0xa4, 0x01, 0x0a, 0x19, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x6f, - 0x73, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x6f, 0x72, - 0x74, 0x12, 0x86, 0x01, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x74, 0xba, 0x48, 0x71, 0xba, 0x01, 0x6e, 0x0a, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, - 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x2d, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x61, 0x20, 0x68, 0x6f, 0x73, - 0x74, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x28, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x29, - 0x20, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x70, 0x61, 0x69, 0x72, 0x1a, 0x19, 0x74, 0x68, 0x69, 0x73, - 0x2e, 0x69, 0x73, 0x48, 0x6f, 0x73, 0x74, 0x41, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x28, 0x66, - 0x61, 0x6c, 0x73, 0x65, 0x29, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0xa3, 0x02, 0x0a, 0x22, 0x63, - 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, - 0x73, 0x42, 0x0c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, - 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, - 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0xa2, 0x02, 0x04, 0x42, 0x56, 0x43, 0x43, 0xaa, 0x02, 0x1e, - 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, - 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0xca, 0x02, - 0x1e, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, - 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0xe2, - 0x02, 0x2a, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, - 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x42, - 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, - 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6f, 0x42, 0xa3, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x42, 0x0c, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, 0x6f, + 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6e, + 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0xa2, 0x02, + 0x04, 0x42, 0x56, 0x43, 0x43, 0xaa, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, + 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0xca, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, + 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0xe2, 0x02, 0x2a, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, + 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, + 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2256,7 +2148,7 @@ func file_buf_validate_conformance_cases_strings_proto_rawDescGZIP() []byte { return file_buf_validate_conformance_cases_strings_proto_rawDescData } -var file_buf_validate_conformance_cases_strings_proto_msgTypes = make([]protoimpl.MessageInfo, 43) +var file_buf_validate_conformance_cases_strings_proto_msgTypes = make([]protoimpl.MessageInfo, 41) var file_buf_validate_conformance_cases_strings_proto_goTypes = []interface{}{ (*StringNone)(nil), // 0: buf.validate.conformance.cases.StringNone (*StringConst)(nil), // 1: buf.validate.conformance.cases.StringConst @@ -2299,8 +2191,6 @@ var file_buf_validate_conformance_cases_strings_proto_goTypes = []interface{}{ (*StringHttpHeaderValueLoose)(nil), // 38: buf.validate.conformance.cases.StringHttpHeaderValueLoose (*StringUUIDIgnore)(nil), // 39: buf.validate.conformance.cases.StringUUIDIgnore (*StringInOneof)(nil), // 40: buf.validate.conformance.cases.StringInOneof - (*StringHostAndPort)(nil), // 41: buf.validate.conformance.cases.StringHostAndPort - (*StringHostAndOptionalPort)(nil), // 42: buf.validate.conformance.cases.StringHostAndOptionalPort } var file_buf_validate_conformance_cases_strings_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -2808,30 +2698,6 @@ func file_buf_validate_conformance_cases_strings_proto_init() { return nil } } - file_buf_validate_conformance_cases_strings_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StringHostAndPort); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_buf_validate_conformance_cases_strings_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StringHostAndOptionalPort); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } file_buf_validate_conformance_cases_strings_proto_msgTypes[40].OneofWrappers = []interface{}{ (*StringInOneof_Bar)(nil), @@ -2842,7 +2708,7 @@ func file_buf_validate_conformance_cases_strings_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_validate_conformance_cases_strings_proto_rawDesc, NumEnums: 0, - NumMessages: 43, + NumMessages: 41, NumExtensions: 0, NumServices: 0, }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_strings.go b/tools/protovalidate-conformance/internal/cases/cases_strings.go index ce4acc38..2feeb4b3 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_strings.go +++ b/tools/protovalidate-conformance/internal/cases/cases_strings.go @@ -852,96 +852,5 @@ func stringSuite() suites.Suite { Expected: results.Violations( &validate.Violation{FieldPath: "val", ConstraintId: "string.well_known_regex.header_value"}), }, - "host_and_port/valid/hostname": { - Message: &cases.StringHostAndPort{Val: "localhost:1234"}, - Expected: results.Success(true), - }, - "host_and_port/valid/ipv4": { - Message: &cases.StringHostAndPort{Val: "127.0.0.1:12345"}, - Expected: results.Success(true), - }, - "host_and_port/valid/ipv6": { - Message: &cases.StringHostAndPort{Val: "[::1]:8080"}, - Expected: results.Success(true), - }, - "host_and_port/invalid/empty": { - Message: &cases.StringHostAndPort{Val: ""}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port_empty"}), - }, - "host_and_port/invalid/missing_port": { - Message: &cases.StringHostAndPort{Val: "localhost"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/whitespace": { - Message: &cases.StringHostAndPort{Val: " localhost:8080 "}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/malformed_hostname": { - Message: &cases.StringHostAndPort{Val: "abc#123:456"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/malformed_ipv4": { - Message: &cases.StringHostAndPort{Val: "123.456.789.100:8080"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/malformed_ipv6": { - Message: &cases.StringHostAndPort{Val: "[1::jk::3]:8080"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/unbracketed_ipv6": { - Message: &cases.StringHostAndPort{Val: "::1:8080"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/invalid/port_out_of_range": { - Message: &cases.StringHostAndPort{Val: "localhost:99999"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port"}), - }, - "host_and_port/optional_port/valid/hostname": { - Message: &cases.StringHostAndOptionalPort{Val: "localhost"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/valid/ipv4": { - Message: &cases.StringHostAndOptionalPort{Val: "192.168.0.1"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/valid/ipv6": { - Message: &cases.StringHostAndOptionalPort{Val: "[838e:3861:529f:0e68:2c40:906a:d7b6:4006]"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/valid/hostname_and_port": { - Message: &cases.StringHostAndOptionalPort{Val: "localhost:1234"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/valid/ipv4_and_port": { - Message: &cases.StringHostAndOptionalPort{Val: "127.0.0.1:12345"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/valid/ipv6_and_port": { - Message: &cases.StringHostAndOptionalPort{Val: "[::1]:8080"}, - Expected: results.Success(true), - }, - "host_and_port/optional_port/invalid/malformed_hostname": { - Message: &cases.StringHostAndOptionalPort{Val: "abc#123"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port.optional_port"}), - }, - "host_and_port/optional_port/invalid/malformed_ipv4": { - Message: &cases.StringHostAndOptionalPort{Val: "123.456.789.100"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port.optional_port"}), - }, - "host_and_port/optional_port/invalid/malformed_ipv6": { - Message: &cases.StringHostAndOptionalPort{Val: "[1::jk::3]"}, - Expected: results.Violations( - &validate.Violation{FieldPath: "val", ConstraintId: "string.host_and_port.optional_port"}), - }, } }