FakeI1Guard class final

The I1 guard of the fake's rights changes (10 5.4, 11; BR-01, BR-07, BR-08).

run applies a change, checks I1 for every active personal agent of the world afterwards and restores everything on a violation; the request's resolve_i1 switches the listed agents to organization first. dryRun does the same for a preview and always restores.

Example:

final guard = FakeI1Guard(world, audit);
return guard.run(r, action: 'owner.add', resourceKind: 'user', apply: () {
  person.isOwner = true;
  return (response: FakeResponse(201, owner), resourceId: person.id, details: {});
});

Constructors

FakeI1Guard(FakeWorld world, FakeAuditLog audit)
Creates the guard over world; audit rows go to audit.

Properties

audit → FakeAuditLog
The audit log of the rows of every change.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
world → FakeWorld
The world.
final

Methods

conflictsJson(Map<String, List<String>> conflicts) → List<JsonMap>
The conflicts of a 409 i1_violation (InvariantViolation, 10 5.4).
dryRun(JsonMap body, void apply()) → Map<String, List<String>>
The I1 conflicts the request body would cause: switches its resolve_i1 agents, runs apply and checks, then restores everything (a preview writes nothing, 07 9.3).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
previewSentences(Map<String, List<String>> conflicts) → List<String>
One sentence per conflict for the preview text (10 11 point 2, English like the fake's other preview texts).
previewViolations(Map<String, List<String>> conflicts) → List<JsonMap>
The invariant_violations of a grant preview (10 11 point 1): the conflicts with organization_ready (the agent reports organization among billing_modes_supported) and the i1Hint.
resolveAgents(JsonMap body) → List<FakeAgent>
The agents of the resolve_i1 of body, in ascending ID (10 11: the server authorizes them in ascending id); none without resolve_i1.
run(FakeRequest r, {required String action, required String resourceKind, required FakeChange apply()}) → FakeResponse
Runs apply as one rights change of r with the audit row action on resourceKind.
setPolicy(FakeAgent a, String mode, String? holder) → void
Sets the policy of a to mode with holder, raises its version and the permission version and stamps billing_mode_changed_at.
switchToOrganization(FakeAgent a, {required String actor, required String reason, required String correlationId}) → void
Switches a to organization for resolve_i1 with one audit row agent.billing_mode.set (10 11: an agent already there keeps its row and gets a row with no_change).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

holderOf(FakeAgent a) → String?
The holder that counts for a: its credential_holder_id on personal, else null.
policyDetails(String fromMode, String? fromHolder, String toMode, String? toHolder, String reason) → JsonMap
The audit details of a policy switch of one agent, as the server writes them (policyAttrs of services/server/internal/agents/app/policy.go, 10 14).