diff --git a/pkg/frontend/admin_openshiftcluster_approvecsr.go b/pkg/frontend/admin_openshiftcluster_approvecsr.go index d7da1a3c8..f1a8c6ede 100644 --- a/pkg/frontend/admin_openshiftcluster_approvecsr.go +++ b/pkg/frontend/admin_openshiftcluster_approvecsr.go @@ -30,7 +30,6 @@ func (f *frontend) postAdminOpenShiftClusterApproveCSR(w http.ResponseWriter, r func (f *frontend) _postAdminOpenShiftClusterApproveCSR(ctx context.Context, r *http.Request, log *logrus.Entry) error { vars := mux.Vars(r) - // Get csrName if provided csrName := r.URL.Query().Get("csrName") if csrName != "" { err := validateAdminKubernetesObjects(r.Method, "CertificateSigningRequest", "", csrName) @@ -39,16 +38,6 @@ func (f *frontend) _postAdminOpenShiftClusterApproveCSR(ctx context.Context, r * } } - // approveAll := strings.EqualFold(r.URL.Query().Get("approveAll"), "true") - // csrName := "" - // if !approveAll { - // csrName = r.URL.Query().Get("csrName") - // err := validateAdminKubernetesObjects(r.Method, "CertificateSigningRequest", "", csrName) - // if err != nil { - // return err - // } - // } - resourceID := strings.TrimPrefix(r.URL.Path, "/admin") doc, err := f.dbOpenShiftClusters.Get(ctx, resourceID) @@ -64,15 +53,9 @@ func (f *frontend) _postAdminOpenShiftClusterApproveCSR(ctx context.Context, r * return err } - // Swapped out to mass approve if no csrName is provided, otherwise approve single CSR if csrName != "" { return k.RunCertificateApprove(ctx, csrName) } return k.RunCertificateMassApprove(ctx) - - // if approveAll { - // return k.RunCertificateMassApprove(ctx) - // } - // return k.RunCertificateApprove(ctx, csrName) } diff --git a/pkg/frontend/admin_openshiftcluster_approvecsr_test.go b/pkg/frontend/admin_openshiftcluster_approvecsr_test.go index 3617ecb7f..df6ec1d22 100644 --- a/pkg/frontend/admin_openshiftcluster_approvecsr_test.go +++ b/pkg/frontend/admin_openshiftcluster_approvecsr_test.go @@ -26,10 +26,9 @@ func TestAdminApproveCSR(t *testing.T) { ctx := context.Background() type test struct { - name string - resourceID string - csrName string - // approveAll string + name string + resourceID string + csrName string mocks func(*test, *mock_adminactions.MockKubeActions) method string wantStatusCode int @@ -54,8 +53,6 @@ func TestAdminApproveCSR(t *testing.T) { method: http.MethodPost, name: "all csrs", resourceID: fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/Microsoft.RedHatOpenShift/openShiftClusters/resourceName", mockSubID), - //csrName: "aro-csr", - //approveAll: "true", mocks: func(tt *test, k *mock_adminactions.MockKubeActions) { k.EXPECT(). RunCertificateMassApprove(gomock.Any()). @@ -63,17 +60,6 @@ func TestAdminApproveCSR(t *testing.T) { }, wantStatusCode: http.StatusOK, }, - // { - // method: http.MethodPost, - // name: "invalid csr name", - // resourceID: fmt.Sprintf("/subscriptions/%s/resourcegroups/resourceGroup/providers/Microsoft.RedHatOpenShift/openShiftClusters/resourceName", mockSubID), - // csrName: "", - // // approveAll: "false", - // mocks: func(tt *test, k *mock_adminactions.MockKubeActions) { - // }, - // wantStatusCode: http.StatusBadRequest, - // wantError: "400: InvalidParameter: : The provided name '' is invalid.", - // }, } { t.Run(fmt.Sprintf("%s: %s", tt.method, tt.name), func(t *testing.T) { ti := newTestInfra(t).WithOpenShiftClusters().WithSubscriptions() @@ -115,7 +101,6 @@ func TestAdminApproveCSR(t *testing.T) { go f.Run(ctx, nil, nil) resp, b, err := ti.request(tt.method, - // fmt.Sprintf("https://server/admin%s/approvecsr?csrName=%s&approveAll=%s", tt.resourceID, tt.csrName, tt.approveAll), fmt.Sprintf("https://server/admin%s/approvecsr?csrName=%s", tt.resourceID, tt.csrName), nil, nil) if err != nil { diff --git a/test/e2e/adminapi_csr.go b/test/e2e/adminapi_csr.go index 4d364e513..214fde555 100644 --- a/test/e2e/adminapi_csr.go +++ b/test/e2e/adminapi_csr.go @@ -58,7 +58,6 @@ func testCSRApproveOK(objName, namespace string) { By("approving the CSR via RP admin API") params := url.Values{ "csrName": []string{objName}, - // "approveAll": []string{"false"}, } resp, err := adminRequest(context.Background(), http.MethodPost, "/admin"+resourceIDFromEnv()+"/approvecsr", params, nil, nil) Expect(err).NotTo(HaveOccurred()) @@ -82,10 +81,6 @@ func testCSRApproveOK(objName, namespace string) { func testCSRMassApproveOK(namePrefix, namespace string, csrCount int) { By("approving all CSRs via RP admin API") - // params := url.Values{ - // "approveAll": []string{"true"}, - // } - // resp, err := adminRequest(context.Background(), http.MethodPost, "/admin"+resourceIDFromEnv()+"/approvecsr", params, nil, nil) resp, err := adminRequest(context.Background(), http.MethodPost, "/admin"+resourceIDFromEnv()+"/approvecsr", nil, nil, nil) Expect(err).NotTo(HaveOccurred()) Expect(resp.StatusCode).To(Equal(http.StatusOK))