removed unnecessary commented code

This commit is contained in:
Damian Miller 2022-08-22 13:28:11 -04:00 коммит произвёл Zach Jones
Родитель 397b6fbcd7
Коммит 087f675451
3 изменённых файлов: 3 добавлений и 40 удалений

Просмотреть файл

@ -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)
}

Просмотреть файл

@ -29,7 +29,6 @@ func TestAdminApproveCSR(t *testing.T) {
name string
resourceID string
csrName string
// approveAll 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 {

Просмотреть файл

@ -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))