.NET API
SkillScriptGrantContract
Tracon.Testing.Contracts.Xunit.dllBehavior tests for the ISkillScriptGrantStore contract.
public abstract class SkillScriptGrantContract : TenantIsolationContract<ISkillScriptGrantStore>, IAsyncLifetime, IAsyncDisposable- Inheritance
- object ← StoreCancellationContract<ISkillScriptGrantStore> ← TenantIsolationContract<ISkillScriptGrantStore> ← SkillScriptGrantContract
- Implements
- IAsyncLifetime, IAsyncDisposable
- Inherited Members
- TenantIsolationContract<ISkillScriptGrantStore>.TenantA, TenantIsolationContract<ISkillScriptGrantStore>.TenantB, TenantIsolationContract<ISkillScriptGrantStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<ISkillScriptGrantStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<ISkillScriptGrantStore>.ExistsAsync(string, object), TenantIsolationContract<ISkillScriptGrantStore>.CountAsync(string, CancellationToken), TenantIsolationContract<ISkillScriptGrantStore>.TryDeleteAsync(string, object), TenantIsolationContract<ISkillScriptGrantStore>.TryOverwriteAsync(string, string), TenantIsolationContract<ISkillScriptGrantStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<ISkillScriptGrantStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<ISkillScriptGrantStore>.WroteAnythingAsync(), TenantIsolationContract<ISkillScriptGrantStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<ISkillScriptGrantStore>.Tenant_reads_its_own_record(), TenantIsolationContract<ISkillScriptGrantStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<ISkillScriptGrantStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<ISkillScriptGrantStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<ISkillScriptGrantStore>.AmbientTenant, StoreCancellationContract<ISkillScriptGrantStore>.CreateStoreAsync(), StoreCancellationContract<ISkillScriptGrantStore>.InitializeAsync(), StoreCancellationContract<ISkillScriptGrantStore>.DisposeAsync(), StoreCancellationContract<ISkillScriptGrantStore>.OnDisposeAsync(), StoreCancellationContract<ISkillScriptGrantStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<ISkillScriptGrantStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<ISkillScriptGrantStore>.WroteAnythingAsync(), StoreCancellationContract<ISkillScriptGrantStore>.Canceled_token_throws_on_read(), StoreCancellationContract<ISkillScriptGrantStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<ISkillScriptGrantStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<ISkillScriptGrantStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Every implementation must pass the same scenarios; in particular, the “the narrower grant wins over the broader one” rule and the fact that a revoked grant never comes back must behave identically.
Constructors
Section titled “Constructors”SkillScriptGrantContract()
Section titled “ SkillScriptGrantContract()”protected SkillScriptGrantContract()Methods
Section titled “Methods”Content_hash_round_trips()
Section titled “ Content_hash_round_trips()”A grant pins the content it authorizes; every read returns the pinned hash.
[Fact]public Task Content_hash_round_trips()Returns
Section titled “Returns”CountAsync(string, CancellationToken)
Section titled “ CountAsync(string, CancellationToken)”Reports how many records the given tenant sees through the listing endpoint.
protected override ValueTask<int> CountAsync(string tenantId, CancellationToken cancellationToken)Parameters
Section titled “Parameters”tenantId string
The reading tenant.
cancellationToken CancellationToken
The token every store call inside the hook must be handed; see TenantIsolationContract.SeedAsync.
Returns
Section titled “Returns”The number of records seen.
ExistsAsync(string, object)
Section titled “ ExistsAsync(string, object)”Reports whether the record is visible from the given tenant’s viewpoint.
protected override ValueTask<bool> ExistsAsync(string tenantId, object key)Parameters
Section titled “Parameters”tenantId string
The reading tenant.
key object
The key returned by TenantIsolationContract.SeedAsync.
Returns
Section titled “Returns”true if the record is visible.
Expired_grant_is_not_returned()
Section titled “ Expired_grant_is_not_returned()”[Fact]public Task Expired_grant_is_not_returned()Returns
Section titled “Returns”Grant_does_not_leak_across_tenants()
Section titled “ Grant_does_not_leak_across_tenants()”[Fact]public Task Grant_does_not_leak_across_tenants()Returns
Section titled “Returns”Granting_again_replaces_the_content_hash()
Section titled “ Granting_again_replaces_the_content_hash()”Granting the same skill and script again pins the new content. An upsert whose update branch forgot the hash would keep authorizing the previous content.
[Fact]public Task Granting_again_replaces_the_content_hash()Returns
Section titled “Returns”Granting_the_same_grant_twice_leaves_a_single_record()
Section titled “ Granting_the_same_grant_twice_leaves_a_single_record()”[Fact]public Task Granting_the_same_grant_twice_leaves_a_single_record()Returns
Section titled “Returns”Null_content_hash_round_trips()
Section titled “ Null_content_hash_round_trips()”A grant that pins nothing stays that way: it authorizes scripts on disk only, and a store must not invent a value for it.
[Fact]public Task Null_content_hash_round_trips()Returns
Section titled “Returns”Racing_grants_and_revocations_leave_one_record_for_the_key()
Section titled “ Racing_grants_and_revocations_leave_one_record_for_the_key()”Grants and revocations of one key racing each other never leave two records for the key, and a grant written after the race is the one in force.
[Fact]public Task Racing_grants_and_revocations_leave_one_record_for_the_key()Returns
Section titled “Returns”Revoked_grant_can_be_granted_again()
Section titled “ Revoked_grant_can_be_granted_again()”[Fact]public Task Revoked_grant_can_be_granted_again()Returns
Section titled “Returns”Revoked_grant_is_invalid()
Section titled “ Revoked_grant_is_invalid()”[Fact]public Task Revoked_grant_is_invalid()Returns
Section titled “Returns”Revoked_grant_stays_listed()
Section titled “ Revoked_grant_stays_listed()”A grant is never deleted: revoking stamps the revocation time and the record stays listed, so who granted what and when it was withdrawn stays answerable.
[Fact]public Task Revoked_grant_stays_listed()Returns
Section titled “Returns”Script_specific_grant_wins_over_the_skill_wide_grant()
Section titled “ Script_specific_grant_wins_over_the_skill_wide_grant()”[Fact]public Task Script_specific_grant_wins_over_the_skill_wide_grant()Returns
Section titled “Returns”SeedAsync(string, string, CancellationToken)
Section titled “ SeedAsync(string, string, CancellationToken)”Writes a sample record for the given tenant.
protected override ValueTask<object> SeedAsync(string tenantId, string name, CancellationToken cancellationToken)Parameters
Section titled “Parameters”tenantId string
The tenant that owns the record.
name string
The name distinguishing the record. The same name may be used by two tenants.
cancellationToken CancellationToken
The token every store call inside the hook must be handed. The cancellation contract calls this hook with a token that is already cancelled, so a hook that drops the token reports a store as sound when it is not.
Returns
Section titled “Returns”The key to use for reading the record back.
Skill_wide_grant_covers_every_script()
Section titled “ Skill_wide_grant_covers_every_script()”[Fact]public Task Skill_wide_grant_covers_every_script()Returns
Section titled “Returns”TryDeleteAsync(string, object)
Section titled “ TryDeleteAsync(string, object)”Attempts to delete the record on behalf of the given tenant.
protected override ValueTask<bool?> TryDeleteAsync(string tenantId, object key)Parameters
Section titled “Parameters”tenantId string
The tenant attempting the delete.
key object
The key returned by TenantIsolationContract.SeedAsync.
Returns
Section titled “Returns”true if the delete succeeded, false if the record was not found; null if the store does not offer deletion.
Remarks
Section titled “Remarks”A grant is not deleted, it is revoked.