From b7bc51a88ed9ba8e64a4906330181748d3e4705f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 10 Jan 2025 20:02:54 +0100 Subject: [PATCH] feat: expose crdvalidation testsuite types: TestCasesGroup and TestCases (#220) --- VERSION | 2 +- ...uration.konghq.com_kongcacertificates.yaml | 2 +- ...iguration.konghq.com_kongcertificates.yaml | 2 +- ...uration.konghq.com_kongconsumergroups.yaml | 2 +- ...onfiguration.konghq.com_kongconsumers.yaml | 2 +- ...uration.konghq.com_kongcredentialacls.yaml | 2 +- ...tion.konghq.com_kongcredentialapikeys.yaml | 2 +- ...n.konghq.com_kongcredentialbasicauths.yaml | 2 +- ...ration.konghq.com_kongcredentialhmacs.yaml | 2 +- ...uration.konghq.com_kongcredentialjwts.yaml | 2 +- ...q.com_kongdataplaneclientcertificates.yaml | 2 +- .../configuration.konghq.com_kongkeys.yaml | 2 +- .../configuration.konghq.com_kongkeysets.yaml | 2 +- ...configuration.konghq.com_konglicenses.yaml | 2 +- ...uration.konghq.com_kongpluginbindings.yaml | 2 +- .../configuration.konghq.com_kongplugins.yaml | 2 +- .../configuration.konghq.com_kongroutes.yaml | 2 +- ...configuration.konghq.com_kongservices.yaml | 2 +- .../configuration.konghq.com_kongsnis.yaml | 2 +- .../configuration.konghq.com_kongtargets.yaml | 2 +- ...onfiguration.konghq.com_kongupstreams.yaml | 2 +- .../configuration.konghq.com_kongvaults.yaml | 2 +- ...nghq.com_konnectapiauthconfigurations.yaml | 2 +- ...onghq.com_konnectgatewaycontrolplanes.yaml | 2 +- ...troller.konghq.com_kongservicefacades.yaml | 2 +- ...n.konghq.com_ingressclassparameterses.yaml | 2 +- ...uration.konghq.com_kongclusterplugins.yaml | 2 +- ...uration.konghq.com_kongconsumergroups.yaml | 2 +- ...onfiguration.konghq.com_kongconsumers.yaml | 2 +- ...uration.konghq.com_kongcustomentities.yaml | 2 +- ...onfiguration.konghq.com_kongingresses.yaml | 2 +- ...configuration.konghq.com_konglicenses.yaml | 2 +- .../configuration.konghq.com_kongplugins.yaml | 2 +- ...ation.konghq.com_kongupstreampolicies.yaml | 2 +- .../configuration.konghq.com_kongvaults.yaml | 2 +- ...configuration.konghq.com_tcpingresses.yaml | 2 +- ...configuration.konghq.com_udpingresses.yaml | 2 +- test/crdsvalidation/kongcacertificate_test.go | 3 +- test/crdsvalidation/kongcertificate_test.go | 5 ++- test/crdsvalidation/kongconsumer_test.go | 5 ++- test/crdsvalidation/kongconsumergroup_test.go | 7 ++-- test/crdsvalidation/kongcredentialacl_test.go | 7 ++-- .../kongcredentialapikey_test.go | 7 ++-- .../kongcredentialbasicauth_test.go | 7 ++-- .../crdsvalidation/kongcredentialhmac_test.go | 7 ++-- test/crdsvalidation/kongcredentialjwt_test.go | 7 ++-- test/crdsvalidation/kongcustomentity_test.go | 6 ++- .../kongdataplaneclientcertificate_test.go | 3 +- test/crdsvalidation/kongkey_test.go | 7 ++-- test/crdsvalidation/kongkeyset_test.go | 5 ++- .../crdsvalidation/kongpluginbindings_test.go | 9 +++-- test/crdsvalidation/kongroute_test.go | 9 +++-- test/crdsvalidation/kongservice_test.go | 3 +- test/crdsvalidation/kongsni_test.go | 7 ++-- test/crdsvalidation/kongtarget_test.go | 7 ++-- test/crdsvalidation/kongupstream_test.go | 5 ++- test/crdsvalidation/kongvault_test.go | 5 ++- .../konnectapiauthconfiguration_test.go | 3 +- .../konnectgatewaycontrolplane_test.go | 9 +++-- ...ite_crd_ref_change_kic_unsupported_test.go | 11 +++--- .../suite_crd_ref_change_test.go | 35 +++++++++--------- .../{suite_test.go => testcase.go} | 37 +++++++++++++------ 62 files changed, 165 insertions(+), 125 deletions(-) rename test/crdsvalidation/{suite_test.go => testcase.go} (78%) diff --git a/VERSION b/VERSION index 9f43ed7..fc3371e 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -v1.0.4 +v1.0.5 latest diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml index 4d2fa07..cf3a336 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcacertificates.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcacertificates.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml index 699b1be..5d02d86 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcertificates.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcertificates.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml index 52214c9..283fbbd 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongconsumergroups.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongconsumergroups.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml index 8d9651c..04b5bff 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongconsumers.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongconsumers.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialacls.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialacls.yaml index 06ab03e..19e070c 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialacls.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialacls.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcredentialacls.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialapikeys.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialapikeys.yaml index fd3ae32..ad3aadf 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialapikeys.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialapikeys.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcredentialapikeys.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialbasicauths.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialbasicauths.yaml index 0a278db..4975a1f 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialbasicauths.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialbasicauths.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcredentialbasicauths.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialhmacs.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialhmacs.yaml index 35d7f23..337912a 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialhmacs.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialhmacs.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcredentialhmacs.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialjwts.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialjwts.yaml index d1e0c4d..e2747b7 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongcredentialjwts.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongcredentialjwts.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcredentialjwts.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml index cd02f14..de50c20 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongdataplaneclientcertificates.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongdataplaneclientcertificates.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml index 69f04b9..f7a7850 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongkeys.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongkeys.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml index cf97148..f90ecc0 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongkeysets.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongkeysets.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_konglicenses.yaml b/config/crd/gateway-operator/configuration.konghq.com_konglicenses.yaml index d6a0bd7..8f50e79 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_konglicenses.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_konglicenses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: konglicenses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml index 2f4137d..c931e75 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongpluginbindings.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongpluginbindings.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongplugins.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongplugins.yaml index 6065c57..648b70e 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongplugins.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongplugins.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongplugins.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml index 7204cf3..b17be83 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongroutes.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongroutes.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml index 4f71c10..8836508 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongservices.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongservices.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongsnis.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongsnis.yaml index ee964d9..bacdf3a 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongsnis.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongsnis.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongsnis.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongtargets.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongtargets.yaml index 9319826..74e3350 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongtargets.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongtargets.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongtargets.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml index 26998eb..ce42b4a 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongupstreams.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongupstreams.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml b/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml index dea3e9e..b3816da 100644 --- a/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml +++ b/config/crd/gateway-operator/configuration.konghq.com_kongvaults.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongvaults.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/gateway-operator/konnect.konghq.com_konnectapiauthconfigurations.yaml b/config/crd/gateway-operator/konnect.konghq.com_konnectapiauthconfigurations.yaml index b1397f7..38cecff 100644 --- a/config/crd/gateway-operator/konnect.konghq.com_konnectapiauthconfigurations.yaml +++ b/config/crd/gateway-operator/konnect.konghq.com_konnectapiauthconfigurations.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: konnectapiauthconfigurations.konnect.konghq.com spec: group: konnect.konghq.com diff --git a/config/crd/gateway-operator/konnect.konghq.com_konnectgatewaycontrolplanes.yaml b/config/crd/gateway-operator/konnect.konghq.com_konnectgatewaycontrolplanes.yaml index db6e936..8b17004 100644 --- a/config/crd/gateway-operator/konnect.konghq.com_konnectgatewaycontrolplanes.yaml +++ b/config/crd/gateway-operator/konnect.konghq.com_konnectgatewaycontrolplanes.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: konnectgatewaycontrolplanes.konnect.konghq.com spec: group: konnect.konghq.com diff --git a/config/crd/ingress-controller-incubator/incubator.ingress-controller.konghq.com_kongservicefacades.yaml b/config/crd/ingress-controller-incubator/incubator.ingress-controller.konghq.com_kongservicefacades.yaml index 107bd59..3f489d1 100644 --- a/config/crd/ingress-controller-incubator/incubator.ingress-controller.konghq.com_kongservicefacades.yaml +++ b/config/crd/ingress-controller-incubator/incubator.ingress-controller.konghq.com_kongservicefacades.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller-incubator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongservicefacades.incubator.ingress-controller.konghq.com spec: group: incubator.ingress-controller.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_ingressclassparameterses.yaml b/config/crd/ingress-controller/configuration.konghq.com_ingressclassparameterses.yaml index 3afce3b..ba760d9 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_ingressclassparameterses.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_ingressclassparameterses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: ingressclassparameterses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongclusterplugins.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongclusterplugins.yaml index 7358640..d62aabf 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongclusterplugins.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongclusterplugins.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongclusterplugins.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml index 52214c9..283fbbd 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongconsumergroups.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongconsumergroups.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml index 8d9651c..04b5bff 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongconsumers.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongconsumers.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongcustomentities.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongcustomentities.yaml index e7d0644..14013b8 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongcustomentities.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongcustomentities.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongcustomentities.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongingresses.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongingresses.yaml index f33542c..f517883 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongingresses.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongingresses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongingresses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_konglicenses.yaml b/config/crd/ingress-controller/configuration.konghq.com_konglicenses.yaml index d6a0bd7..8f50e79 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_konglicenses.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_konglicenses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: konglicenses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongplugins.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongplugins.yaml index 6065c57..648b70e 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongplugins.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongplugins.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongplugins.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongupstreampolicies.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongupstreampolicies.yaml index e9546d5..be465fd 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongupstreampolicies.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongupstreampolicies.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 labels: gateway.networking.k8s.io/policy: direct name: kongupstreampolicies.configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml b/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml index dea3e9e..b3816da 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_kongvaults.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller,gateway-operator - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: kongvaults.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_tcpingresses.yaml b/config/crd/ingress-controller/configuration.konghq.com_tcpingresses.yaml index 23e1846..d2fe21a 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_tcpingresses.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_tcpingresses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: tcpingresses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/config/crd/ingress-controller/configuration.konghq.com_udpingresses.yaml b/config/crd/ingress-controller/configuration.konghq.com_udpingresses.yaml index ff5dd00..fbd4a49 100644 --- a/config/crd/ingress-controller/configuration.konghq.com_udpingresses.yaml +++ b/config/crd/ingress-controller/configuration.konghq.com_udpingresses.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: kubernetes-configuration.konghq.com/channels: ingress-controller - kubernetes-configuration.konghq.com/version: v1.0.4 + kubernetes-configuration.konghq.com/version: v1.0.5 name: udpingresses.configuration.konghq.com spec: group: configuration.konghq.com diff --git a/test/crdsvalidation/kongcacertificate_test.go b/test/crdsvalidation/kongcacertificate_test.go index eeebd29..96a9b5b 100644 --- a/test/crdsvalidation/kongcacertificate_test.go +++ b/test/crdsvalidation/kongcacertificate_test.go @@ -7,11 +7,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCACertificate(t *testing.T) { t.Run("required fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCACertificate]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCACertificate]{ { Name: "cert field is required", TestObject: &configurationv1alpha1.KongCACertificate{ diff --git a/test/crdsvalidation/kongcertificate_test.go b/test/crdsvalidation/kongcertificate_test.go index 2e49fbd..6c1706e 100644 --- a/test/crdsvalidation/kongcertificate_test.go +++ b/test/crdsvalidation/kongcertificate_test.go @@ -8,6 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCertificate(t *testing.T) { @@ -30,7 +31,7 @@ func TestKongCertificate(t *testing.T) { }) t.Run("required fields", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCertificate]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCertificate]{ { Name: "cert field is required", TestObject: &configurationv1alpha1.KongCertificate{ @@ -88,7 +89,7 @@ func TestKongCertificate(t *testing.T) { }.Run(t) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCertificate]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCertificate]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCertificate{ diff --git a/test/crdsvalidation/kongconsumer_test.go b/test/crdsvalidation/kongconsumer_test.go index 7cd34e6..b0df9a8 100644 --- a/test/crdsvalidation/kongconsumer_test.go +++ b/test/crdsvalidation/kongconsumer_test.go @@ -9,6 +9,7 @@ import ( configurationv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongConsumer(t *testing.T) { @@ -26,7 +27,7 @@ func TestKongConsumer(t *testing.T) { }) t.Run("required fields", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1.KongConsumer]{ + crdsvalidation.TestCasesGroup[*configurationv1.KongConsumer]{ { Name: "username or custom_id required (username provided)", TestObject: &configurationv1.KongConsumer{ @@ -76,7 +77,7 @@ func TestKongConsumer(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1.KongConsumer]{ + crdsvalidation.TestCasesGroup[*configurationv1.KongConsumer]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1.KongConsumer{ diff --git a/test/crdsvalidation/kongconsumergroup_test.go b/test/crdsvalidation/kongconsumergroup_test.go index b614850..677305c 100644 --- a/test/crdsvalidation/kongconsumergroup_test.go +++ b/test/crdsvalidation/kongconsumergroup_test.go @@ -10,6 +10,7 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" configurationv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongConsumerGroup(t *testing.T) { @@ -29,7 +30,7 @@ func TestKongConsumerGroup(t *testing.T) { }) t.Run("cp ref update", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ + crdsvalidation.TestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ { Name: "cpRef change is not allowed for Programmed=True", TestObject: &configurationv1beta1.KongConsumerGroup{ @@ -113,7 +114,7 @@ func TestKongConsumerGroup(t *testing.T) { }) t.Run("fields", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ + crdsvalidation.TestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ { Name: "name field can be set", TestObject: &configurationv1beta1.KongConsumerGroup{ @@ -133,7 +134,7 @@ func TestKongConsumerGroup(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ + crdsvalidation.TestCasesGroup[*configurationv1beta1.KongConsumerGroup]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1beta1.KongConsumerGroup{ diff --git a/test/crdsvalidation/kongcredentialacl_test.go b/test/crdsvalidation/kongcredentialacl_test.go index ddcae57..d0d3eb4 100644 --- a/test/crdsvalidation/kongcredentialacl_test.go +++ b/test/crdsvalidation/kongcredentialacl_test.go @@ -10,11 +10,12 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCredentialACL(t *testing.T) { t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ { Name: "consumerRef change is not allowed for Programmed=True", TestObject: &configurationv1alpha1.KongCredentialACL{ @@ -76,7 +77,7 @@ func TestKongCredentialACL(t *testing.T) { }) t.Run("required fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ { Name: "group is required", TestObject: &configurationv1alpha1.KongCredentialACL{ @@ -107,7 +108,7 @@ func TestKongCredentialACL(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialACL]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCredentialACL{ diff --git a/test/crdsvalidation/kongcredentialapikey_test.go b/test/crdsvalidation/kongcredentialapikey_test.go index 2869d05..f132b82 100644 --- a/test/crdsvalidation/kongcredentialapikey_test.go +++ b/test/crdsvalidation/kongcredentialapikey_test.go @@ -10,11 +10,12 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCredentialAPIKey(t *testing.T) { t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ { Name: "consumerRef change is not allowed for Programmed=True", TestObject: &configurationv1alpha1.KongCredentialAPIKey{ @@ -76,7 +77,7 @@ func TestKongCredentialAPIKey(t *testing.T) { }) t.Run("required fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ { Name: "key is required", TestObject: &configurationv1alpha1.KongCredentialAPIKey{ @@ -107,7 +108,7 @@ func TestKongCredentialAPIKey(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialAPIKey]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCredentialAPIKey{ diff --git a/test/crdsvalidation/kongcredentialbasicauth_test.go b/test/crdsvalidation/kongcredentialbasicauth_test.go index 6ef7ced..10799e6 100644 --- a/test/crdsvalidation/kongcredentialbasicauth_test.go +++ b/test/crdsvalidation/kongcredentialbasicauth_test.go @@ -10,11 +10,12 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCredentialBasicAuth(t *testing.T) { t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ { Name: "consumerRef change is not allowed for Programmed=True", TestObject: &configurationv1alpha1.KongCredentialBasicAuth{ @@ -78,7 +79,7 @@ func TestKongCredentialBasicAuth(t *testing.T) { }) t.Run("required fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ { Name: "password is required", TestObject: &configurationv1alpha1.KongCredentialBasicAuth{ @@ -128,7 +129,7 @@ func TestKongCredentialBasicAuth(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialBasicAuth]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCredentialBasicAuth{ diff --git a/test/crdsvalidation/kongcredentialhmac_test.go b/test/crdsvalidation/kongcredentialhmac_test.go index afeba25..0704119 100644 --- a/test/crdsvalidation/kongcredentialhmac_test.go +++ b/test/crdsvalidation/kongcredentialhmac_test.go @@ -10,11 +10,12 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCredentialHMAC(t *testing.T) { t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ { Name: "consumerRef change is not allowed for Programmed=True", TestObject: &configurationv1alpha1.KongCredentialHMAC{ @@ -78,7 +79,7 @@ func TestKongCredentialHMAC(t *testing.T) { }) t.Run("fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ { Name: "username is required", TestObject: &configurationv1alpha1.KongCredentialHMAC{ @@ -113,7 +114,7 @@ func TestKongCredentialHMAC(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialHMAC]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCredentialHMAC{ diff --git a/test/crdsvalidation/kongcredentialjwt_test.go b/test/crdsvalidation/kongcredentialjwt_test.go index 3c6511e..54357ed 100644 --- a/test/crdsvalidation/kongcredentialjwt_test.go +++ b/test/crdsvalidation/kongcredentialjwt_test.go @@ -12,11 +12,12 @@ import ( configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCredentialJWT(t *testing.T) { t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ { Name: "consumerRef change is not allowed for Programmed=True", TestObject: &configurationv1alpha1.KongCredentialJWT{ @@ -78,7 +79,7 @@ func TestKongCredentialJWT(t *testing.T) { }) t.Run("fields validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ { Name: "rsa_public_key is required when algorithm is RS256", TestObject: &configurationv1alpha1.KongCredentialJWT{ @@ -288,7 +289,7 @@ func TestKongCredentialJWT(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCredentialJWT]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongCredentialJWT{ diff --git a/test/crdsvalidation/kongcustomentity_test.go b/test/crdsvalidation/kongcustomentity_test.go index 2c3af05..9be361a 100644 --- a/test/crdsvalidation/kongcustomentity_test.go +++ b/test/crdsvalidation/kongcustomentity_test.go @@ -3,14 +3,16 @@ package crdsvalidation_test import ( "testing" - configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" "github.com/samber/lo" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongCustomEntity(t *testing.T) { t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongCustomEntity]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongCustomEntity]{ { Name: "basic allowed spec", TestObject: &configurationv1alpha1.KongCustomEntity{ diff --git a/test/crdsvalidation/kongdataplaneclientcertificate_test.go b/test/crdsvalidation/kongdataplaneclientcertificate_test.go index 6eccaa3..f7fff2d 100644 --- a/test/crdsvalidation/kongdataplaneclientcertificate_test.go +++ b/test/crdsvalidation/kongdataplaneclientcertificate_test.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongDataPlaneClientCertificate(t *testing.T) { @@ -32,7 +33,7 @@ func TestKongDataPlaneClientCertificate(t *testing.T) { }) t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongDataPlaneClientCertificate]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongDataPlaneClientCertificate]{ { Name: "valid KongDataPlaneClientCertificate", TestObject: &configurationv1alpha1.KongDataPlaneClientCertificate{ diff --git a/test/crdsvalidation/kongkey_test.go b/test/crdsvalidation/kongkey_test.go index 7163d17..68b8383 100644 --- a/test/crdsvalidation/kongkey_test.go +++ b/test/crdsvalidation/kongkey_test.go @@ -8,6 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongKey(t *testing.T) { @@ -71,7 +72,7 @@ func TestKongKey(t *testing.T) { }) t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongKey]{ { Name: "KID must be set", TestObject: &configurationv1alpha1.KongKey{ @@ -112,7 +113,7 @@ func TestKongKey(t *testing.T) { }) t.Run("key set ref", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongKey]{ { Name: "when type is 'namespacedRef', namespacedRef is required", TestObject: &configurationv1alpha1.KongKey{ @@ -199,7 +200,7 @@ func TestKongKey(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongKey]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongKey]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongKey{ diff --git a/test/crdsvalidation/kongkeyset_test.go b/test/crdsvalidation/kongkeyset_test.go index 6e370bb..13e78bc 100644 --- a/test/crdsvalidation/kongkeyset_test.go +++ b/test/crdsvalidation/kongkeyset_test.go @@ -8,6 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongKeySet(t *testing.T) { @@ -33,7 +34,7 @@ func TestKongKeySet(t *testing.T) { }) t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongKeySet]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongKeySet]{ { Name: "name must be set", TestObject: &configurationv1alpha1.KongKeySet{ @@ -48,7 +49,7 @@ func TestKongKeySet(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongKeySet]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongKeySet]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongKeySet{ diff --git a/test/crdsvalidation/kongpluginbindings_test.go b/test/crdsvalidation/kongpluginbindings_test.go index 2c293a1..a9e11d6 100644 --- a/test/crdsvalidation/kongpluginbindings_test.go +++ b/test/crdsvalidation/kongpluginbindings_test.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongPluginBindings(t *testing.T) { @@ -35,7 +36,7 @@ func TestKongPluginBindings(t *testing.T) { }) t.Run("plugin ref", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ { Name: "no plugin reference", TestObject: &configurationv1alpha1.KongPluginBinding{ @@ -131,7 +132,7 @@ func TestKongPluginBindings(t *testing.T) { }) t.Run("target combinations", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ { Name: "consumer, route, service targets", TestObject: &configurationv1alpha1.KongPluginBinding{ @@ -508,7 +509,7 @@ func TestKongPluginBindings(t *testing.T) { }) t.Run("targets group/kind", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ { Name: "networking.k8s.io/Ingress, as service target", TestObject: &configurationv1alpha1.KongPluginBinding{ @@ -553,7 +554,7 @@ func TestKongPluginBindings(t *testing.T) { }) t.Run("cross targets validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongPluginBinding]{ { Name: "core/Service, configuration.konghq.com/KongRoute targets", TestObject: &configurationv1alpha1.KongPluginBinding{ diff --git a/test/crdsvalidation/kongroute_test.go b/test/crdsvalidation/kongroute_test.go index 7491e23..7004338 100644 --- a/test/crdsvalidation/kongroute_test.go +++ b/test/crdsvalidation/kongroute_test.go @@ -10,6 +10,7 @@ import ( sdkkonnectcomp "github.com/Kong/sdk-konnect-go/models/components" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongRoute(t *testing.T) { @@ -32,7 +33,7 @@ func TestKongRoute(t *testing.T) { }) t.Run("protocols", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongRoute]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongRoute]{ { Name: "no http in protocols implies no other requirements", TestObject: &configurationv1alpha1.KongRoute{ @@ -84,7 +85,7 @@ func TestKongRoute(t *testing.T) { }) t.Run("no service ref and no cp ref provided", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongRoute]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongRoute]{ { Name: "have to provide either controlPlaneRef or serviceRef", TestObject: &configurationv1alpha1.KongRoute{ @@ -101,7 +102,7 @@ func TestKongRoute(t *testing.T) { }) t.Run("service ref", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongRoute]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongRoute]{ { Name: "NamespacedRef reference is valid", TestObject: &configurationv1alpha1.KongRoute{ @@ -233,7 +234,7 @@ func TestKongRoute(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongRoute]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongRoute]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongRoute{ diff --git a/test/crdsvalidation/kongservice_test.go b/test/crdsvalidation/kongservice_test.go index ece3949..f320ecb 100644 --- a/test/crdsvalidation/kongservice_test.go +++ b/test/crdsvalidation/kongservice_test.go @@ -8,6 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongService(t *testing.T) { @@ -28,7 +29,7 @@ func TestKongService(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongService]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongService]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongService{ diff --git a/test/crdsvalidation/kongsni_test.go b/test/crdsvalidation/kongsni_test.go index c4d0dba..874104f 100644 --- a/test/crdsvalidation/kongsni_test.go +++ b/test/crdsvalidation/kongsni_test.go @@ -8,11 +8,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongSNI(t *testing.T) { t.Run("certificate ref", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongSNI]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongSNI]{ { Name: "certificate ref name is required", TestObject: &configurationv1alpha1.KongSNI{ @@ -80,7 +81,7 @@ func TestKongSNI(t *testing.T) { }) t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongSNI]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongSNI]{ { Name: "spec.name must not be empty", TestObject: &configurationv1alpha1.KongSNI{ @@ -97,7 +98,7 @@ func TestKongSNI(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongSNI]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongSNI]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongSNI{ diff --git a/test/crdsvalidation/kongtarget_test.go b/test/crdsvalidation/kongtarget_test.go index 585b6b2..26606c4 100644 --- a/test/crdsvalidation/kongtarget_test.go +++ b/test/crdsvalidation/kongtarget_test.go @@ -7,11 +7,12 @@ import ( "github.com/samber/lo" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongTarget(t *testing.T) { t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongTarget]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongTarget]{ { Name: "weight must between 0 and 65535", TestObject: &configurationv1alpha1.KongTarget{ @@ -36,7 +37,7 @@ func TestKongTarget(t *testing.T) { }) t.Run("upstream ref", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongTarget]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongTarget]{ { Name: "upstream ref is immutable", TestObject: &configurationv1alpha1.KongTarget{ @@ -62,7 +63,7 @@ func TestKongTarget(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongTarget]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongTarget]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongTarget{ diff --git a/test/crdsvalidation/kongupstream_test.go b/test/crdsvalidation/kongupstream_test.go index 1b4dc25..6d66de2 100644 --- a/test/crdsvalidation/kongupstream_test.go +++ b/test/crdsvalidation/kongupstream_test.go @@ -10,6 +10,7 @@ import ( sdkkonnectcomp "github.com/Kong/sdk-konnect-go/models/components" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongUpstream(t *testing.T) { @@ -30,7 +31,7 @@ func TestKongUpstream(t *testing.T) { }) t.Run("required fields", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongUpstream]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongUpstream]{ { Name: "hash_fallback_header is required when hash_fallback is set to 'header'", TestObject: &configurationv1alpha1.KongUpstream{ @@ -383,7 +384,7 @@ func TestKongUpstream(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongUpstream]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongUpstream]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongUpstream{ diff --git a/test/crdsvalidation/kongvault_test.go b/test/crdsvalidation/kongvault_test.go index 094a829..b43f382 100644 --- a/test/crdsvalidation/kongvault_test.go +++ b/test/crdsvalidation/kongvault_test.go @@ -8,6 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKongVault(t *testing.T) { @@ -28,7 +29,7 @@ func TestKongVault(t *testing.T) { }) t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongVault]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongVault]{ { Name: "backend must be non-empty", TestObject: &configurationv1alpha1.KongVault{ @@ -67,7 +68,7 @@ func TestKongVault(t *testing.T) { }) t.Run("tags validation", func(t *testing.T) { - CRDValidationTestCasesGroup[*configurationv1alpha1.KongVault]{ + crdsvalidation.TestCasesGroup[*configurationv1alpha1.KongVault]{ { Name: "up to 20 tags are allowed", TestObject: &configurationv1alpha1.KongVault{ diff --git a/test/crdsvalidation/konnectapiauthconfiguration_test.go b/test/crdsvalidation/konnectapiauthconfiguration_test.go index 4a06d6f..7379790 100644 --- a/test/crdsvalidation/konnectapiauthconfiguration_test.go +++ b/test/crdsvalidation/konnectapiauthconfiguration_test.go @@ -7,11 +7,12 @@ import ( corev1 "k8s.io/api/core/v1" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKonnectAPIAuthConfiguration(t *testing.T) { t.Run("spec", func(t *testing.T) { - CRDValidationTestCasesGroup[*konnectv1alpha1.KonnectAPIAuthConfiguration]{ + crdsvalidation.TestCasesGroup[*konnectv1alpha1.KonnectAPIAuthConfiguration]{ { Name: "valid token type - spat prefix", TestObject: &konnectv1alpha1.KonnectAPIAuthConfiguration{ diff --git a/test/crdsvalidation/konnectgatewaycontrolplane_test.go b/test/crdsvalidation/konnectgatewaycontrolplane_test.go index eca5b4c..579eae7 100644 --- a/test/crdsvalidation/konnectgatewaycontrolplane_test.go +++ b/test/crdsvalidation/konnectgatewaycontrolplane_test.go @@ -11,11 +11,12 @@ import ( sdkkonnectcomp "github.com/Kong/sdk-konnect-go/models/components" konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) func TestKonnectGatewayControlPlane(t *testing.T) { t.Run("members can only be set on groups", func(t *testing.T) { - CRDValidationTestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ + crdsvalidation.TestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ { Name: "members can be set on control-plane group", TestObject: &konnectv1alpha1.KonnectGatewayControlPlane{ @@ -111,7 +112,7 @@ func TestKonnectGatewayControlPlane(t *testing.T) { }) t.Run("updates not allowed for status conditions", func(t *testing.T) { - CRDValidationTestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ + crdsvalidation.TestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ { Name: "konnect.authRef change is not allowed for Programmed=True", TestObject: &konnectv1alpha1.KonnectGatewayControlPlane{ @@ -235,7 +236,7 @@ func TestKonnectGatewayControlPlane(t *testing.T) { }) t.Run("labels constraints", func(t *testing.T) { - CRDValidationTestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ + crdsvalidation.TestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ { Name: "spec.labels of length 40 is allowed", TestObject: &konnectv1alpha1.KonnectGatewayControlPlane{ @@ -537,7 +538,7 @@ func TestKonnectGatewayControlPlane(t *testing.T) { }) t.Run("restriction on cluster types", func(t *testing.T) { - CRDValidationTestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ + crdsvalidation.TestCasesGroup[*konnectv1alpha1.KonnectGatewayControlPlane]{ { Name: "unspecified cluster type (defaulting to CLUSTR_TYPE_CONTROL_PLANE) is allowed", TestObject: &konnectv1alpha1.KonnectGatewayControlPlane{ diff --git a/test/crdsvalidation/suite_crd_ref_change_kic_unsupported_test.go b/test/crdsvalidation/suite_crd_ref_change_kic_unsupported_test.go index 2ea0eb6..121d23b 100644 --- a/test/crdsvalidation/suite_crd_ref_change_kic_unsupported_test.go +++ b/test/crdsvalidation/suite_crd_ref_change_kic_unsupported_test.go @@ -8,6 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) type EmptyControlPlaneRefAllowedT bool @@ -29,15 +30,15 @@ func NewCRDValidationTestCasesGroupCPRefChangeKICUnsupportedTypes[ t *testing.T, obj T, emptyControlPlaneRefAllowed EmptyControlPlaneRefAllowedT, -) CRDValidationTestCasesGroup[T] { - ret := CRDValidationTestCasesGroup[T]{} +) crdsvalidation.TestCasesGroup[T] { + ret := crdsvalidation.TestCasesGroup[T]{} { obj := obj.DeepCopy() obj.SetControlPlaneRef(&configurationv1alpha1.ControlPlaneRef{ Type: configurationv1alpha1.ControlPlaneRefKIC, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "kic control plane ref is not allowed", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("KIC is not supported as control plane"), @@ -48,13 +49,13 @@ func NewCRDValidationTestCasesGroupCPRefChangeKICUnsupportedTypes[ obj.SetControlPlaneRef(nil) switch emptyControlPlaneRefAllowed { case EmptyControlPlaneRefNotAllowed: - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: " control plane ref is not allowed", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("controlPlaneRef"), }) case EmptyControlPlaneRefAllowed: - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: " control plane ref is allowed", TestObject: obj, }) diff --git a/test/crdsvalidation/suite_crd_ref_change_test.go b/test/crdsvalidation/suite_crd_ref_change_test.go index 54494d2..8e65729 100644 --- a/test/crdsvalidation/suite_crd_ref_change_test.go +++ b/test/crdsvalidation/suite_crd_ref_change_test.go @@ -13,6 +13,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/config" configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1" + "github.com/kong/kubernetes-configuration/test/crdsvalidation" ) type Scope byte @@ -55,9 +56,9 @@ func NewCRDValidationTestCasesGroupCPRefChange[ t *testing.T, obj T, supportedByKIC SupportedByKicT, -) CRDValidationTestCasesGroup[T] { +) crdsvalidation.TestCasesGroup[T] { var ( - ret = CRDValidationTestCasesGroup[T]{} + ret = crdsvalidation.TestCasesGroup[T]{} programmedConditionTrue = metav1.Condition{ Type: "Programmed", @@ -80,7 +81,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ // object without spec.controlPlaneRef should be allowed. obj := obj.DeepCopy() obj.SetControlPlaneRef(nil) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "no cpRef is valid", TestObject: obj, }) @@ -96,7 +97,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Namespace: "another-namespace", }, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef (type=konnectNamespacedRef) cannot have namespace", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("spec.controlPlaneRef cannot specify namespace for namespaced resource"), @@ -109,7 +110,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Type: configurationv1alpha1.ControlPlaneRefKonnectNamespacedRef, KonnectID: lo.ToPtr("123456"), }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectID when type is konnectNamespacedRef yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is konnectNamespacedRef, konnectNamespacedRef must be set"), @@ -123,7 +124,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Name: "test-konnect-control-plane", }, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectNamespacedRef when type is konnectID yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectID must be set"), @@ -138,7 +139,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Name: "test-konnect-control-plane", }, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectNamespacedRef and konnectID when type is konnectID yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is konnectID, konnectNamespacedRef must not be set"), @@ -153,7 +154,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Name: "test-konnect-control-plane", }, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectID and konnectNamespacedRef when type is konnectNamespacedRef yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is konnectNamespacedRef, konnectID must not be set"), @@ -165,7 +166,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Type: configurationv1alpha1.ControlPlaneRefKIC, KonnectID: lo.ToPtr("123456"), }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectID when type is kic yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is kic, konnectID must not be set"), @@ -179,7 +180,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Name: "test-konnect-control-plane", }, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "providing konnectNamespaceRef when type is kic yields an error", TestObject: obj, ExpectedErrorMessage: lo.ToPtr("when type is kic, konnectNamespacedRef must not be set"), @@ -191,7 +192,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ obj.SetControlPlaneRef(&configurationv1alpha1.ControlPlaneRef{ Type: configurationv1alpha1.ControlPlaneRefKIC, }) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "kic control plane ref is allowed", TestObject: obj, }) @@ -208,7 +209,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ }, }) obj.SetConditions([]metav1.Condition{programmedConditionTrue}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=konnectNamespacedRef) is not allowed for Programmed=True", TestObject: obj, Update: func(obj T) { @@ -228,7 +229,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ }, }) obj.SetConditions([]metav1.Condition{programmedConditionFalse}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=konnectNamespacedRef) is allowed when object is Programmed=False", TestObject: obj, Update: func(obj T) { @@ -251,7 +252,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Type: configurationv1alpha1.ControlPlaneRefKIC, }) obj.SetConditions([]metav1.Condition{programmedConditionTrue}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=kic) is not allowed for Programmed=True", TestObject: obj, Update: func(obj T) { @@ -274,7 +275,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ Type: configurationv1alpha1.ControlPlaneRefKIC, }) obj.SetConditions([]metav1.Condition{programmedConditionFalse}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=kic) is allowed when object is not Programmed=True", TestObject: obj, Update: func(obj T) { @@ -295,7 +296,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ if supportedByKIC == SupportedByKIC { obj := obj.DeepCopy() obj.SetConditions([]metav1.Condition{programmedConditionFalse}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=) is allowed when object is Programmed=False", TestObject: obj, Update: func(obj T) { @@ -315,7 +316,7 @@ func NewCRDValidationTestCasesGroupCPRefChange[ obj := obj.DeepCopy() obj.SetControlPlaneRef(&configurationv1alpha1.ControlPlaneRef{}) obj.SetConditions([]metav1.Condition{programmedConditionTrue}) - ret = append(ret, CRDValidationTestCase[T]{ + ret = append(ret, crdsvalidation.TestCase[T]{ Name: "cpRef change (type=) is not allowed for Programmed=True", TestObject: obj, Update: func(obj T) { diff --git a/test/crdsvalidation/suite_test.go b/test/crdsvalidation/testcase.go similarity index 78% rename from test/crdsvalidation/suite_test.go rename to test/crdsvalidation/testcase.go index bd796c6..053db0a 100644 --- a/test/crdsvalidation/suite_test.go +++ b/test/crdsvalidation/testcase.go @@ -1,4 +1,4 @@ -package crdsvalidation_test +package crdsvalidation import ( "context" @@ -7,24 +7,32 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" "github.com/kong/kubernetes-configuration/pkg/clientset/scheme" ) -// CRDValidationTestCasesGroup is a group of test cases related to CRD validation. -type CRDValidationTestCasesGroup[T client.Object] []CRDValidationTestCase[T] +// TestCasesGroup is a group of test cases related to CRD validation. +type TestCasesGroup[T client.Object] []TestCase[T] -// Run runs all test cases in the group. -func (g CRDValidationTestCasesGroup[T]) Run(t *testing.T) { +// RunWithConfig runs all test cases in the group against the provided rest.Config's cluster. +func (g TestCasesGroup[T]) RunWithConfig(t *testing.T, cfg *rest.Config) { for _, tc := range g { - tc.Run(t) + tc.RunWithConfig(t, cfg) } } -// CRDValidationTestCase represents a test case for CRD validation. -type CRDValidationTestCase[T client.Object] struct { +// Run runs all test cases in the group. +func (g TestCasesGroup[T]) Run(t *testing.T) { + cfg, err := config.GetConfig() + require.NoError(t, err) + g.RunWithConfig(t, cfg) +} + +// TestCase represents a test case for CRD validation. +type TestCase[T client.Object] struct { // Name is the name of the test case. Name string @@ -42,15 +50,14 @@ type CRDValidationTestCase[T client.Object] struct { Update func(T) } -func (tc *CRDValidationTestCase[T]) Run(t *testing.T) { +// RunWithConfig runs the test case against the provided rest.Config's cluster. +func (tc *TestCase[T]) RunWithConfig(t *testing.T, cfg *rest.Config) { // Run the test case. t.Run(tc.Name, func(t *testing.T) { t.Parallel() ctx := context.Background() // Create a new controller-runtime client.Client. - cfg, err := config.GetConfig() - require.NoError(t, err) cl, err := client.New(cfg, client.Options{ Scheme: scheme.Scheme, }) @@ -110,3 +117,11 @@ func (tc *CRDValidationTestCase[T]) Run(t *testing.T) { } }) } + +// Run runs the test case. +func (tc *TestCase[T]) Run(t *testing.T) { + cfg, err := config.GetConfig() + require.NoError(t, err) + + tc.RunWithConfig(t, cfg) +}