@@ -32,6 +32,7 @@ func TestCreateSubnamespaces(t *testing.T) {
3232 {name : "for existing non-subns child" , pnm : "a" , cnm : "c" , fail : true },
3333 {name : "for existing subns" , pnm : "a" , cnm : "b" },
3434 {name : "for non DNS label compliant child" , pnm : "a" , cnm : "child.01" , fail : true },
35+ {name : "with name more than 63 characters" , pnm : "a" , cnm : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" , fail : true },
3536 }
3637 for _ , tc := range tests {
3738 t .Run (tc .name , func (t * testing.T ) {
@@ -55,6 +56,41 @@ func TestCreateSubnamespaces(t *testing.T) {
5556 }
5657}
5758
59+ func TestDeleteSubnamespaces (t * testing.T ) {
60+ f := foresttest .Create ("-Aa" )
61+ v := & Validator {Forest : f }
62+
63+ tests := []struct {
64+ name string
65+ pnm string
66+ cnm string
67+ fail bool
68+ }{
69+ {name : "for existing subns" , pnm : "a" , cnm : "b" },
70+ {name : "with name more than 63 characters" , pnm : "a" , cnm : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" },
71+ }
72+ for _ , tc := range tests {
73+ t .Run (tc .name , func (t * testing.T ) {
74+ // Setup
75+ g := NewWithT (t )
76+ anchor := & api.SubnamespaceAnchor {}
77+ anchor .ObjectMeta .Namespace = tc .pnm
78+ anchor .ObjectMeta .Name = tc .cnm
79+ req := & anchorRequest {
80+ anchor : anchor ,
81+ op : k8sadm .Delete ,
82+ }
83+
84+ // Test
85+ got := v .handle (req )
86+
87+ // Report
88+ logResult (t , got .AdmissionResponse .Result )
89+ g .Expect (got .AdmissionResponse .Allowed ).ShouldNot (Equal (tc .fail ))
90+ })
91+ }
92+ }
93+
5894func TestManagedMeta (t * testing.T ) {
5995 f := foresttest .Create ("-" ) // a
6096 v := & Validator {Forest : f }
0 commit comments