diff --git a/api/handler/v1beta1/grant.go b/api/handler/v1beta1/grant.go index 1450fb0c..be829996 100644 --- a/api/handler/v1beta1/grant.go +++ b/api/handler/v1beta1/grant.go @@ -133,8 +133,7 @@ func (s *GRPCServer) UpdateGrant(ctx context.Context, req *guardianv1beta1.Updat case errors.Is(err, grant.ErrGrantNotFound): return nil, status.Error(codes.NotFound, err.Error()) case errors.Is(err, grant.ErrEmptyOwner), - errors.Is(err, domain.ErrInvalidGrantUpdateRequest), - errors.Is(err, domain.ErrGrantUpdateNoChanges): + errors.Is(err, domain.ErrInvalidGrantUpdateRequest): return nil, status.Error(codes.InvalidArgument, err.Error()) default: return nil, s.internalError(ctx, "failed to update grant: %v", err) diff --git a/domain/grant.go b/domain/grant.go index 2885a34d..5d851f55 100644 --- a/domain/grant.go +++ b/domain/grant.go @@ -28,7 +28,6 @@ var ( ErrDuplicateActiveGrant = errors.New("grant already exists") ErrInvalidGrantRestoreParams = errors.New("invalid grant restore parameters") ErrInvalidGrantUpdateRequest = errors.New("invalid grant update request") - ErrGrantUpdateNoChanges = errors.New("no changes in grant update request") ) type Grant struct { @@ -175,15 +174,9 @@ func (gu *GrantUpdate) Validate(current Grant) error { return fmt.Errorf("can't update grant in status %q", current.Status) } - anyFieldUpdated := false - // owner - if gu.Owner != nil { - if *gu.Owner == "" { - return errors.New("owner should not be empty") - } else if *gu.Owner != current.Owner { - anyFieldUpdated = true - } + if gu.Owner != nil && *gu.Owner == "" { + return errors.New("owner should not be empty") } // expiration date @@ -200,14 +193,6 @@ func (gu *GrantUpdate) Validate(current Grant) error { if gu.ExpirationDateReason == nil || *gu.ExpirationDateReason == "" { return errors.New("expiration date reason is required") } - - if current.ExpirationDate == nil || (gu.ExpirationDate.Compare(*current.ExpirationDate) != 0) { - anyFieldUpdated = true - } - } - - if !anyFieldUpdated { - return ErrGrantUpdateNoChanges } return nil