Skip to content

ops.testing: revoking a previously-granted secret fails on 3.8.0 (worked on 3.7.1) #2613

Description

@sinanawad

While evaluating the upgrade to ops 3.8.0, one of my charm unit tests started failing.
The test is a charm revoking a secret grant when a relation goes away.
The same test passes on ops 3.7.1 and fails on ops 3.8.0
(which pulls in ops-scenario 8.8.0 via the testing extra).

I've asked Claude to reduce it to the minimal self-contained reproduction below.

Let me know what you think.

This is the output I get AttributeError: 'frozenset' object has no attribute 'remove'

# repro_revoke.py
import ops
from ops import testing


class RevokeCharm(ops.CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        framework.observe(self.on["db"].relation_broken, self._on_broken)

    def _on_broken(self, event):
        # Revoke the secret's grant to the relation that is going away.
        secret = self.model.get_secret(label="my-secret")
        secret.revoke(event.relation)


def test_revoke_on_relation_broken():
    ctx = testing.Context(
        RevokeCharm,
        meta={"name": "revoke-charm", "provides": {"db": {"interface": "x"}}},
    )
    secret = testing.Secret(
        {"token": "s3cret"},
        owner="app",
        label="my-secret",
        remote_grants={1: {"remote-app"}},  # relation 1 was previously granted
    )

Metadata

Metadata

Labels

next releaseTo be done before shipping the next releasesmall itemA small item, for some value of 'small'testsRelated to tests or testing

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions