Skip to content

Commit

Permalink
change to pass test
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioLangaritaBenitez committed Jan 9, 2025
1 parent 5676804 commit 3bce362
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/handlers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
)

var errInput = errors.New("unrecognized input (valid inputs are MinIO and dCache)")
var overlappingError = "An object key name filtering rule defined with overlapping prefixes"

// Custom logger
var createLogger = log.New(os.Stdout, "[CREATE-HANDLER] ", log.Flags())
Expand Down Expand Up @@ -654,7 +655,7 @@ func enableInputNotification(minIOClient *s3.S3, arnStr string, bucket string, p
// Enable the notification
_, err = minIOClient.PutBucketNotificationConfiguration(pbncInput)

if err != nil && !strings.Contains(err.Error(), "An object key name filtering rule defined with overlapping prefixes") {
if err != nil && !strings.Contains(err.Error(), overlappingError) {
return fmt.Errorf("error enabling bucket notification: %v", err)
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/handlers/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package handlers

import (
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -119,7 +118,6 @@ func TestMakeCreateHandler(t *testing.T) {
defer server.Close()

if w.Code != http.StatusCreated {
fmt.Println(w.Body)
t.Errorf("expecting code %d, got %d", http.StatusCreated, w.Code)
}
}
3 changes: 2 additions & 1 deletion pkg/handlers/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
)

var ALL_USERS_GROUP = "all_users_group"
var allUserGroupNotExist = "unable to remove bucket from policy \"" + ALL_USERS_GROUP + "\", policy '" + ALL_USERS_GROUP + "' does not exist"
var deleteLogger = log.New(os.Stdout, "[DELETE-HANDLER] ", log.Flags())

// MakeDeleteHandler makes a handler for deleting services
Expand Down Expand Up @@ -86,7 +87,7 @@ func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand

// Delete service buckets
err = deleteBuckets(service, cfg, minIOAdminClient)
if err != nil {
if err != nil && !strings.Contains(err.Error(), allUserGroupNotExist) {
c.String(http.StatusInternalServerError, "Error deleting service buckets: ", err)
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/utils/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ func (minIOAdminClient *MinIOAdminClient) CreateAddPolicy(bucketName string, pol
json.Unmarshal(policyInfo.Policy, actualPolicy)

// Add new resource and create policy
actualPolicy.Statement[0].Resource = append(actualPolicy.Statement[0].Resource, rs)
actualPolicy.Statement = []Statement{
{
Resource: []string{rs},
},
}

policy, jsonErr = json.Marshal(actualPolicy)
if jsonErr != nil {
Expand Down

0 comments on commit 3bce362

Please sign in to comment.