Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: check list permissions for replay #3873

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion warehouse/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,12 @@ func (g *GRPC) validateObjectStorage(ctx context.Context, request validateObject
return fmt.Errorf("unable to create file manager: \n%s", err.Error())
}

it := filemanager.IterateFilesWithPrefix(ctx, fileManager.Prefix(), "", 1, fileManager)
_ = it.Next()
if err = it.Err(); err != nil {
return invalidDestinationCredErr{Base: err, Operation: "list"}
}

tempFilePath, err := validations.CreateTempLoadFile(&backendconfig.DestinationT{
DestinationDefinition: backendconfig.DestinationDefinitionT{
Name: request.Type,
Expand Down Expand Up @@ -757,7 +763,6 @@ func (g *GRPC) validateObjectStorage(ctx context.Context, request validateObject
if err = f.Close(); err != nil {
return fmt.Errorf("unable to close file: \n%w", err)
}

return nil
}

Expand Down
40 changes: 39 additions & 1 deletion warehouse/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,45 @@ func TestGRPC(t *testing.T) {
})
require.NoError(t, err)
require.NotEmpty(t, res)
require.Equal(t, "Invalid destination creds, failed for operation: upload with err: \nEndpoint: does not follow ip address or domain name standards.", res.GetError())
require.Equal(t, "Invalid destination creds, failed for operation: list with err: \nEndpoint: does not follow ip address or domain name standards.", res.GetError())
require.False(t, res.GetIsValid())
})
t.Run("list permissions missing", func(t *testing.T) {
res, err := grpcClient.ValidateObjectStorageDestination(ctx, &proto.ValidateObjectStorageRequest{
Type: whutils.MINIO,
Config: &structpb.Struct{
Fields: map[string]*structpb.Value{
"region": {
Kind: &structpb.Value_StringValue{
StringValue: minioResource.SiteRegion,
},
},
"bucketName": {
Kind: &structpb.Value_StringValue{
StringValue: minioResource.BucketName,
},
},
"secretAccessKey": {
Kind: &structpb.Value_StringValue{
StringValue: "wrongSecretKey",
},
},
"accessKeyID": {
Kind: &structpb.Value_StringValue{
StringValue: "wrongAccessKey",
},
},
"endPoint": {
Kind: &structpb.Value_StringValue{
StringValue: minioResource.Endpoint,
},
},
},
},
})
require.NoError(t, err)
require.NotEmpty(t, res)
require.Equal(t, "Invalid destination creds, failed for operation: list with err: \nThe Access Key Id you provided does not exist in our records.", res.GetError())
require.False(t, res.GetIsValid())
})
t.Run("checkMapForValidKey", func(t *testing.T) {
Expand Down
Loading