From 544573ebce6e5f826daf2e7821d9c9ab0c1a858d Mon Sep 17 00:00:00 2001 From: Elim Tsiagbey Date: Wed, 24 Jul 2024 11:34:03 -0400 Subject: [PATCH] Set the `Read` permission state as `Unknown` if the response from the list calls does not find the expected key --- plugin/service/storage/plugin.go | 1 + plugin/service/storage/plugin_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/service/storage/plugin.go b/plugin/service/storage/plugin.go index 5e0862b..f973678 100644 --- a/plugin/service/storage/plugin.go +++ b/plugin/service/storage/plugin.go @@ -820,6 +820,7 @@ func dryRunValidation(ctx context.Context, state *awsStoragePersistedState, attr st, permissions.Read = errors.ParseAWSError(err, "failed to list object") errs = multierror.Append(errs, st.Err()) } else if res == nil || len(res.Contents) != 1 || *res.Contents[0].Key != objectKey { + permissions.Read = &pb.Permission{State: pb.StateType_STATE_TYPE_UNKNOWN, CheckedAt: timestamppb.Now()} errs = multierror.Append(errs, status.New(codes.Aborted, fmt.Sprintf("list response did not contain the expected key: %+v", res)).Err()) } diff --git a/plugin/service/storage/plugin_test.go b/plugin/service/storage/plugin_test.go index 0b689e5..108899e 100644 --- a/plugin/service/storage/plugin_test.go +++ b/plugin/service/storage/plugin_test.go @@ -2688,7 +2688,7 @@ func TestStoragePlugin_ValidatePermissions(t *testing.T) { expectedDetails: &pb.StorageBucketCredentialState{ State: &pb.Permissions{ Read: &pb.Permission{ - State: pb.StateType_STATE_TYPE_OK, + State: pb.StateType_STATE_TYPE_UNKNOWN, CheckedAt: timestamppb.Now(), }, Write: &pb.Permission{