From 27a158fd62366d98db204b5a4f3806b003586000 Mon Sep 17 00:00:00 2001 From: "michal.kempski@sap.com" Date: Tue, 14 Jul 2020 19:59:08 +0200 Subject: [PATCH] fix units --- .../servicebinding/mutation/handler_test.go | 68 --------------- .../serviceinstance/mutation/handler_test.go | 83 +------------------ 2 files changed, 4 insertions(+), 147 deletions(-) diff --git a/pkg/webhook/servicecatalog/servicebinding/mutation/handler_test.go b/pkg/webhook/servicecatalog/servicebinding/mutation/handler_test.go index 52905429cf3..32764cc95e8 100644 --- a/pkg/webhook/servicecatalog/servicebinding/mutation/handler_test.go +++ b/pkg/webhook/servicecatalog/servicebinding/mutation/handler_test.go @@ -104,37 +104,6 @@ func TestCreateUpdateHandlerHandleCreateSuccess(t *testing.T) { }, }, }, - "Should clear out the manually set UserInfo field": { - givenRawObj: []byte(`{ - "apiVersion": "servicecatalog.k8s.io/v1beta1", - "kind": "ServiceBinding", - "metadata": { - "creationTimestamp": null, - "name": "test-binding" - }, - "spec": { - "instanceRef": { - "name": "some-instance" - }, - "externalID": "my-external-id-123", - "secretName": "overridden-name", - "userInfo": { - "username": "foo@bar.com", - "uid": "123-123", - "groups": ["val1", "val2"] - } - } - }`), - expPatches: []jsonpatch.Operation{ - { - Operation: "add", - Path: "/metadata/finalizers", - Value: []interface{}{ - "kubernetes-incubator/service-catalog", - }, - }, - }, - }, } for tn, tc := range tests { @@ -327,43 +296,6 @@ func TestCreateUpdateHandlerHandleSetUserInfoIfOriginatingIdentityIsEnabled(t *t }, }, }, - "Should clear out the ClusterServicePlanRef2": { - reqOperation: admissionv1beta1.Delete, - givenRawObj: []byte(`{ - "apiVersion": "servicecatalog.k8s.io/v1beta1", - "kind": "ServiceBinding", - "metadata": { - "finalizers": ["kubernetes-incubator/service-catalog"], - "creationTimestamp": null, - "name": "test-binding" - }, - "spec": { - "instanceRef": { - "name": "some-instance" - }, - "externalID": "123-abc", - "secretName": "test-binding" - } - }`), - expPatches: []jsonpatch.Operation{ - { - Operation: "add", - Path: "/spec/userInfo", - Value: map[string]interface{}{ - "username": "minikube", - "uid": "123", - "groups": []interface{}{ - "unauthorized", - }, - "extra": map[string]interface{}{ - "extra": []interface{}{ - "val1", "val2", - }, - }, - }, - }, - }, - }, } for tn, tc := range tests { diff --git a/pkg/webhook/servicecatalog/serviceinstance/mutation/handler_test.go b/pkg/webhook/servicecatalog/serviceinstance/mutation/handler_test.go index 631e01fd3ac..beb3d5e2f96 100644 --- a/pkg/webhook/servicecatalog/serviceinstance/mutation/handler_test.go +++ b/pkg/webhook/servicecatalog/serviceinstance/mutation/handler_test.go @@ -127,6 +127,10 @@ func TestCreateUpdateHandlerHandleCreateSuccess(t *testing.T) { "kubernetes-incubator/service-catalog", }, }, + { + Operation: "remove", + Path: "/spec/userInfo", + }, }, }, } @@ -228,49 +232,6 @@ func TestCreateUpdateHandlerHandleUpdateSuccess(t *testing.T) { }, }, }, - "Should clear out the manually set UserInfo field": { - givenOldRawObj: []byte(`{ - "apiVersion": "servicecatalog.k8s.io/v1beta1", - "kind": "ServiceInstance", - "metadata": { - "creationTimestamp": null, - "name": "test-instance", - "generation": 1 - }, - "spec": { - "updateRequests": 1, - "clusterServiceClassExternalName": "some-class", - "clusterServicePlanExternalName": "some-plan", - "externalID": "external-id-001" - } - }`), - givenNewRawObj: []byte(`{ - "apiVersion": "servicecatalog.k8s.io/v1beta1", - "kind": "ServiceInstance", - "metadata": { - "creationTimestamp": null, - "name": "test-instance", - "generation": 1 - }, - "spec": { - "updateRequests": 1, - "clusterServiceClassExternalName": "some-class", - "clusterServicePlanExternalName": "some-plan", - "externalID": "external-id-001", - "userInfo": { - "username": "foo@bar.com", - "uid": "123-123", - "groups": ["val1", "val2"] - } - } - }`), - expPatches: []jsonpatch.Operation{ - { - Operation: "remove", - Path: "/spec/userInfo", - }, - }, - }, } for tn, tc := range tests { @@ -366,42 +327,6 @@ func TestCreateUpdateHandlerHandleSetUserInfoIfOriginatingIdentityIsEnabled(t *t }, }, }, - "Should clear out the ClusterServicePlanRef2": { - reqOperation: admissionv1beta1.Delete, - givenRawObj: []byte(`{ - "apiVersion": "servicecatalog.k8s.io/v1beta1", - "kind": "ServiceInstance", - "metadata": { - "finalizers": [ "kubernetes-incubator/service-catalog" ], - "creationTimestamp": null, - "name": "test-instance" - }, - "spec": { - "updateRequests": 1, - "clusterServiceClassExternalName": "some-class", - "clusterServicePlanExternalName": "some-plan", - "externalID": "my-external-id-123" - } - }`), - expPatches: []jsonpatch.Operation{ - { - Operation: "add", - Path: "/spec/userInfo", - Value: map[string]interface{}{ - "username": "minikube", - "uid": "123", - "groups": []interface{}{ - "unauthorized", - }, - "extra": map[string]interface{}{ - "extra": []interface{}{ - "val1", "val2", - }, - }, - }, - }, - }, - }, } for tn, tc := range tests {