Skip to content

Commit

Permalink
Rework logic to focus on the positive case, as per review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Nov 23, 2023
1 parent 96bdc06 commit 9206a77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ops/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2486,10 +2486,13 @@ def _ensure_secret_owner(self, secret: _Secret):
# secrets, the leader has manage permissions and other units only have
# view permissions.
# https://discourse.charmhub.io/t/secret-access-permissions/12627
if (secret.owner_name != self.unit_name
and (secret.owner_name != self.app_name or not self.is_leader())):
raise model.SecretNotFoundError(
f'You must own secret {secret.id!r} to perform this operation')
unit_secret = secret.owner_name == self.unit_name
app_secret = secret.owner_name == self.app_name

if unit_secret or (app_secret and self.is_leader()):
return
raise model.SecretNotFoundError(
f'You must own secret {secret.id!r} to perform this operation')

def secret_info_get(self, *,
id: Optional[str] = None,
Expand Down

0 comments on commit 9206a77

Please sign in to comment.