fix UTs
Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>
This commit is contained in:
parent
84d7dd4aed
commit
8d362439a8
@ -61,10 +61,10 @@ func int32Ptr(i int32) *int32 {
|
||||
func TestValidateCertificate(t *testing.T) {
|
||||
fldPath := field.NewPath("spec")
|
||||
scenarios := map[string]struct {
|
||||
cfg *internalcmapi.Certificate
|
||||
a *admissionv1.AdmissionRequest
|
||||
errs []*field.Error
|
||||
warnings []string
|
||||
cfg *internalcmapi.Certificate
|
||||
a *admissionv1.AdmissionRequest
|
||||
errs []*field.Error
|
||||
warnings []string
|
||||
useCertificateRequestNameConstraints bool
|
||||
}{
|
||||
"valid basic certificate": {
|
||||
@ -696,7 +696,7 @@ func TestValidateCertificate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
a: someAdmissionRequest,
|
||||
a: someAdmissionRequest,
|
||||
useCertificateRequestNameConstraints: true,
|
||||
},
|
||||
"invalid with name constraints": {
|
||||
|
||||
@ -85,7 +85,7 @@ func init() {
|
||||
var webhookFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
DisallowInsecureCSRUsageDefinition: {Default: true, PreRelease: featuregate.Beta},
|
||||
|
||||
AdditionalCertificateOutputFormats: {Default: false, PreRelease: featuregate.Alpha},
|
||||
LiteralCertificateSubject: {Default: false, PreRelease: featuregate.Alpha},
|
||||
AdditionalCertificateOutputFormats: {Default: false, PreRelease: featuregate.Alpha},
|
||||
LiteralCertificateSubject: {Default: false, PreRelease: featuregate.Alpha},
|
||||
UseCertificateRequestNameConstraints: {Default: false, PreRelease: featuregate.Alpha},
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ comma = ,
|
||||
# Helm's "--set" interprets commas, which means we want to escape commas
|
||||
# for "--set featureGates". That's why we have "\$(comma)".
|
||||
feature_gates_controller := $(subst $(space),\$(comma),$(filter AllAlpha=% AllBeta=% AdditionalCertificateOutputFormats=% ValidateCAA=% ExperimentalCertificateSigningRequestControllers=% ExperimentalGatewayAPISupport=% ServerSideApply=% LiteralCertificateSubject=% UseCertificateRequestBasicConstraints=% UseCertificateRequestNameConstraints=% SecretsFilteredCaching=%, $(subst $(comma),$(space),$(FEATURE_GATES))))
|
||||
feature_gates_webhook := $(subst $(space),\$(comma),$(filter AllAlpha=% AllBeta=% AdditionalCertificateOutputFormats=% LiteralCertificateSubject=%, $(subst $(comma),$(space),$(FEATURE_GATES))))
|
||||
feature_gates_webhook := $(subst $(space),\$(comma),$(filter AllAlpha=% AllBeta=% AdditionalCertificateOutputFormats=% LiteralCertificateSubject=%, UseCertificateRequestNameConstraints=% $(subst $(comma),$(space),$(FEATURE_GATES))))
|
||||
feature_gates_cainjector := $(subst $(space),\$(comma),$(filter AllAlpha=% AllBeta=% ServerSideApply=%, $(subst $(comma),$(space),$(FEATURE_GATES))))
|
||||
|
||||
# Install cert-manager with E2E specific images and deployment settings.
|
||||
|
||||
@ -37,12 +37,12 @@ func TestMarshalNameConstraints(t *testing.T) {
|
||||
{
|
||||
name: "Permitted constraints",
|
||||
input: &v1.NameConstraints{
|
||||
Critical: true,
|
||||
Critical: true,
|
||||
Permitted: &v1.NameConstraintItem{
|
||||
DNSDomains: []string{"example.com"},
|
||||
IPRanges: []string{"192.168.0.1/24"},
|
||||
EmailAddresses: []string{"user@example.com"},
|
||||
URIDomains: []string{"https://example.com"},
|
||||
DNSDomains: []string{"example.com"},
|
||||
IPRanges: []string{"192.168.0.1/24"},
|
||||
EmailAddresses: []string{"user@example.com"},
|
||||
URIDomains: []string{"https://example.com"},
|
||||
},
|
||||
},
|
||||
expectedErr: nil,
|
||||
@ -55,18 +55,18 @@ func TestMarshalNameConstraints(t *testing.T) {
|
||||
{
|
||||
name: "Mixed constraints",
|
||||
input: &v1.NameConstraints{
|
||||
Critical: true,
|
||||
Critical: true,
|
||||
Permitted: &v1.NameConstraintItem{
|
||||
DNSDomains: []string{"example.com"},
|
||||
IPRanges: []string{"192.168.0.1/24"},
|
||||
EmailAddresses: []string{"user@example.com"},
|
||||
URIDomains: []string{"https://example.com"},
|
||||
DNSDomains: []string{"example.com"},
|
||||
IPRanges: []string{"192.168.0.1/24"},
|
||||
EmailAddresses: []string{"user@example.com"},
|
||||
URIDomains: []string{"https://example.com"},
|
||||
},
|
||||
Excluded: &v1.NameConstraintItem{
|
||||
DNSDomains: []string{"excluded.com"},
|
||||
IPRanges: []string{"192.168.0.0/24"},
|
||||
EmailAddresses: []string{"user@excluded.com"},
|
||||
URIDomains: []string{"https://excluded.com"},
|
||||
DNSDomains: []string{"excluded.com"},
|
||||
IPRanges: []string{"192.168.0.0/24"},
|
||||
EmailAddresses: []string{"user@excluded.com"},
|
||||
URIDomains: []string{"https://excluded.com"},
|
||||
},
|
||||
},
|
||||
expectedErr: nil,
|
||||
@ -77,8 +77,8 @@ func TestMarshalNameConstraints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Empty constraints",
|
||||
input: &v1.NameConstraints{},
|
||||
name: "Empty constraints",
|
||||
input: &v1.NameConstraints{},
|
||||
expectedErr: nil,
|
||||
expectedResult: pkix.Extension{
|
||||
Id: OIDExtensionNameConstraints,
|
||||
@ -90,10 +90,10 @@ func TestMarshalNameConstraints(t *testing.T) {
|
||||
name: "Excluded constraints",
|
||||
input: &v1.NameConstraints{
|
||||
Excluded: &v1.NameConstraintItem{
|
||||
DNSDomains: []string{"excluded.com"},
|
||||
IPRanges: []string{"192.168.0.0/24"},
|
||||
EmailAddresses: []string{"user@excluded.com"},
|
||||
URIDomains: []string{"https://excluded.com"},
|
||||
DNSDomains: []string{"excluded.com"},
|
||||
IPRanges: []string{"192.168.0.0/24"},
|
||||
EmailAddresses: []string{"user@excluded.com"},
|
||||
URIDomains: []string{"https://excluded.com"},
|
||||
},
|
||||
},
|
||||
expectedErr: nil,
|
||||
@ -107,10 +107,10 @@ func TestMarshalNameConstraints(t *testing.T) {
|
||||
name: "Invalid NameConstraints",
|
||||
input: &v1.NameConstraints{
|
||||
Excluded: &v1.NameConstraintItem{
|
||||
IPRanges: []string{"invalidCIDR"},
|
||||
IPRanges: []string{"invalidCIDR"},
|
||||
},
|
||||
},
|
||||
expectedErr: fmt.Errorf("invalid CIDR address: invalidCIDR"),
|
||||
expectedErr: fmt.Errorf("invalid CIDR address: invalidCIDR"),
|
||||
expectedResult: pkix.Extension{},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user