@@ -817,6 +817,78 @@ func runTests(admissionReviewVersion string) {
817
817
svr .WebhookMux ().ServeHTTP (w , req )
818
818
ExpectWithOffset (1 , w .Code ).To (Equal (http .StatusNotFound ))
819
819
})
820
+
821
+ It ("should not scaffold a custom defaulting and a custom validating webhook with the same custom path" , func () {
822
+ By ("creating a controller manager" )
823
+ m , err := manager .New (cfg , manager.Options {})
824
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
825
+
826
+ By ("registering the type in the Scheme" )
827
+ builder := scheme.Builder {GroupVersion : testValidatorGVK .GroupVersion ()}
828
+ builder .Register (& TestDefaultValidator {}, & TestDefaultValidatorList {})
829
+ err = builder .AddToScheme (m .GetScheme ())
830
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
831
+
832
+ customPath := "/custom-path"
833
+ err = WebhookManagedBy (m ).
834
+ For (& TestDefaultValidator {}).
835
+ WithDefaulter (& TestCustomDefaultValidator {}).
836
+ WithValidator (& TestCustomDefaultValidator {}).
837
+ WithLogConstructor (func (base logr.Logger , req * admission.Request ) logr.Logger {
838
+ return admission .DefaultLogConstructor (testingLogger , req )
839
+ }).
840
+ WithCustomPath (customPath ).
841
+ Complete ()
842
+ ExpectWithOffset (1 , err ).To (HaveOccurred ())
843
+ })
844
+
845
+ It ("should not scaffold a custom defaulting when setting a custom path and a defaulting custom path" , func () {
846
+ By ("creating a controller manager" )
847
+ m , err := manager .New (cfg , manager.Options {})
848
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
849
+
850
+ By ("registering the type in the Scheme" )
851
+ builder := scheme.Builder {GroupVersion : testValidatorGVK .GroupVersion ()}
852
+ builder .Register (& TestDefaultValidator {}, & TestDefaultValidatorList {})
853
+ err = builder .AddToScheme (m .GetScheme ())
854
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
855
+
856
+ customPath := "/custom-path"
857
+ err = WebhookManagedBy (m ).
858
+ For (& TestDefaulter {}).
859
+ WithDefaulter (& TestCustomDefaulter {}).
860
+ WithLogConstructor (func (base logr.Logger , req * admission.Request ) logr.Logger {
861
+ return admission .DefaultLogConstructor (testingLogger , req )
862
+ }).
863
+ WithDefaultingCustomPath (customPath ).
864
+ WithCustomPath (customPath ).
865
+ Complete ()
866
+ ExpectWithOffset (1 , err ).To (HaveOccurred ())
867
+ })
868
+
869
+ It ("should not scaffold a custom defaulting when setting a custom path and a validating custom path" , func () {
870
+ By ("creating a controller manager" )
871
+ m , err := manager .New (cfg , manager.Options {})
872
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
873
+
874
+ By ("registering the type in the Scheme" )
875
+ builder := scheme.Builder {GroupVersion : testValidatorGVK .GroupVersion ()}
876
+ builder .Register (& TestDefaultValidator {}, & TestDefaultValidatorList {})
877
+ err = builder .AddToScheme (m .GetScheme ())
878
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
879
+
880
+ customPath := "/custom-path"
881
+ err = WebhookManagedBy (m ).
882
+ For (& TestValidator {}).
883
+ WithValidator (& TestCustomValidator {}).
884
+ WithLogConstructor (func (base logr.Logger , req * admission.Request ) logr.Logger {
885
+ return admission .DefaultLogConstructor (testingLogger , req )
886
+ }).
887
+ WithDefaultingCustomPath (customPath ).
888
+ WithCustomPath (customPath ).
889
+ Complete ()
890
+ ExpectWithOffset (1 , err ).To (HaveOccurred ())
891
+ })
820
892
}
821
893
822
894
// TestDefaulter.
0 commit comments