@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- package validation
17+ package webhook_test
1818
1919import (
2020 "bytes"
@@ -30,10 +30,20 @@ import (
3030 "k8s.io/apimachinery/pkg/types"
3131
3232 enterpriseApi "github.com/splunk/splunk-operator/api/v4"
33+ "github.com/splunk/splunk-operator/pkg/splunk/enterprise/validation"
3334 "github.com/stretchr/testify/assert"
3435 "github.com/stretchr/testify/require"
3536)
3637
38+ func mustMarshal (t * testing.T , obj interface {}) []byte {
39+ t .Helper ()
40+ data , err := json .Marshal (obj )
41+ if err != nil {
42+ t .Fatalf ("failed to marshal object: %v" , err )
43+ }
44+ return data
45+ }
46+
3747func newPostgresClusterAdmissionReview (t * testing.T , uid string , op admissionv1.Operation , obj * enterpriseApi.PostgresCluster , oldObj * enterpriseApi.PostgresCluster ) * admissionv1.AdmissionReview {
3848 t .Helper ()
3949 ar := & admissionv1.AdmissionReview {
@@ -105,7 +115,7 @@ func newPostgresClusterClassAdmissionReview(t *testing.T, uid string, op admissi
105115 return ar
106116}
107117
108- func sendAdmissionReview (t * testing.T , server * WebhookServer , ar * admissionv1.AdmissionReview ) * admissionv1.AdmissionResponse {
118+ func sendAdmissionReview (t * testing.T , server * validation. WebhookServer , ar * admissionv1.AdmissionReview ) * admissionv1.AdmissionResponse {
109119 t .Helper ()
110120 body , err := json .Marshal (ar )
111121 require .NoError (t , err )
@@ -114,7 +124,7 @@ func sendAdmissionReview(t *testing.T, server *WebhookServer, ar *admissionv1.Ad
114124 req .Header .Set ("Content-Type" , "application/json" )
115125 rr := httptest .NewRecorder ()
116126
117- server .handleValidate (rr , req )
127+ server .HandleValidate (rr , req )
118128 require .Equal (t , http .StatusOK , rr .Code )
119129
120130 var response admissionv1.AdmissionReview
@@ -124,9 +134,9 @@ func sendAdmissionReview(t *testing.T, server *WebhookServer, ar *admissionv1.Ad
124134}
125135
126136func TestPostgresClusterPgHBAIntegration (t * testing.T ) {
127- server := NewWebhookServer (WebhookServerOptions {
137+ server := validation . NewWebhookServer (validation. WebhookServerOptions {
128138 Port : 9443 ,
129- Validators : DefaultValidators ,
139+ Validators : validation . DefaultValidators ,
130140 })
131141
132142 tests := []struct {
@@ -324,9 +334,9 @@ func TestPostgresClusterPgHBAIntegration(t *testing.T) {
324334}
325335
326336func TestPostgresClusterPgHBAUpdateIntegration (t * testing.T ) {
327- server := NewWebhookServer (WebhookServerOptions {
337+ server := validation . NewWebhookServer (validation. WebhookServerOptions {
328338 Port : 9443 ,
329- Validators : DefaultValidators ,
339+ Validators : validation . DefaultValidators ,
330340 })
331341
332342 oldObj := & enterpriseApi.PostgresCluster {
@@ -370,9 +380,9 @@ func TestPostgresClusterPgHBAUpdateIntegration(t *testing.T) {
370380}
371381
372382func TestPostgresClusterClassPgHBAIntegration (t * testing.T ) {
373- server := NewWebhookServer (WebhookServerOptions {
383+ server := validation . NewWebhookServer (validation. WebhookServerOptions {
374384 Port : 9443 ,
375- Validators : DefaultValidators ,
385+ Validators : validation . DefaultValidators ,
376386 })
377387
378388 tests := []struct {
@@ -502,9 +512,9 @@ func TestPostgresClusterClassPgHBAIntegration(t *testing.T) {
502512}
503513
504514func TestPostgresClusterClassPgHBAUpdateIntegration (t * testing.T ) {
505- server := NewWebhookServer (WebhookServerOptions {
515+ server := validation . NewWebhookServer (validation. WebhookServerOptions {
506516 Port : 9443 ,
507- Validators : DefaultValidators ,
517+ Validators : validation . DefaultValidators ,
508518 })
509519
510520 oldObj := & enterpriseApi.PostgresClusterClass {
0 commit comments