зеркало из https://github.com/Azure/ARO-RP.git
Changed to approve all if no name arg is present
This commit is contained in:
Родитель
5d9c3253c6
Коммит
37dda4d44b
|
@ -30,16 +30,25 @@ 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)
|
||||
|
||||
approveAll := strings.EqualFold(r.URL.Query().Get("approveAll"), "true")
|
||||
csrName := ""
|
||||
if !approveAll {
|
||||
csrName = r.URL.Query().Get("csrName")
|
||||
// Get csrName if provided
|
||||
csrName := r.URL.Query().Get("csrName")
|
||||
if csrName != "" {
|
||||
err := validateAdminKubernetesObjects(r.Method, "CertificateSigningRequest", "", csrName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
@ -55,8 +64,15 @@ func (f *frontend) _postAdminOpenShiftClusterApproveCSR(ctx context.Context, r *
|
|||
return err
|
||||
}
|
||||
|
||||
if approveAll {
|
||||
return k.RunCertificateMassApprove(ctx)
|
||||
// Swapped out to mass approve if no csrName is provided, otherwise approve single CSR
|
||||
if csrName != "" {
|
||||
return k.RunCertificateApprove(ctx, csrName)
|
||||
}
|
||||
return k.RunCertificateApprove(ctx, csrName)
|
||||
|
||||
return k.RunCertificateMassApprove(ctx)
|
||||
|
||||
// if approveAll {
|
||||
// return k.RunCertificateMassApprove(ctx)
|
||||
// }
|
||||
// return k.RunCertificateApprove(ctx, csrName)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ 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
|
||||
// approveAll string
|
||||
mocks func(*test, *mock_adminactions.MockKubeActions)
|
||||
method string
|
||||
wantStatusCode int
|
||||
|
|
|
@ -57,8 +57,8 @@ var _ = Describe("[Admin API] CertificateSigningRequest action", func() {
|
|||
func testCSRApproveOK(objName, namespace string) {
|
||||
By("approving the CSR via RP admin API")
|
||||
params := url.Values{
|
||||
"csrName": []string{objName},
|
||||
"approveAll": []string{"false"},
|
||||
"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 +82,11 @@ 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)
|
||||
// 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))
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче