Skip to content
Tracon

TenantEgressPolicyStoreContract

Namespace Tracon.Testing.Contracts.Storage · Assembly Tracon.Testing.Contracts.Xunit.dll

Behavior tests for the ITenantEgressPolicyStore contract.

public abstract class TenantEgressPolicyStoreContract : TenantIsolationContract<ITenantEgressPolicyStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<ITenantEgressPolicyStore> ← TenantIsolationContract<ITenantEgressPolicyStore> ← TenantEgressPolicyStoreContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
TenantIsolationContract<ITenantEgressPolicyStore>.TenantA, TenantIsolationContract<ITenantEgressPolicyStore>.TenantB, TenantIsolationContract<ITenantEgressPolicyStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<ITenantEgressPolicyStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<ITenantEgressPolicyStore>.ExistsAsync(string, object), TenantIsolationContract<ITenantEgressPolicyStore>.CountAsync(string, CancellationToken), TenantIsolationContract<ITenantEgressPolicyStore>.TryDeleteAsync(string, object), TenantIsolationContract<ITenantEgressPolicyStore>.TryOverwriteAsync(string, string), TenantIsolationContract<ITenantEgressPolicyStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<ITenantEgressPolicyStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<ITenantEgressPolicyStore>.WroteAnythingAsync(), TenantIsolationContract<ITenantEgressPolicyStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<ITenantEgressPolicyStore>.Tenant_reads_its_own_record(), TenantIsolationContract<ITenantEgressPolicyStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<ITenantEgressPolicyStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<ITenantEgressPolicyStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<ITenantEgressPolicyStore>.AmbientTenant, StoreCancellationContract<ITenantEgressPolicyStore>.CreateStoreAsync(), StoreCancellationContract<ITenantEgressPolicyStore>.InitializeAsync(), StoreCancellationContract<ITenantEgressPolicyStore>.DisposeAsync(), StoreCancellationContract<ITenantEgressPolicyStore>.OnDisposeAsync(), StoreCancellationContract<ITenantEgressPolicyStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<ITenantEgressPolicyStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<ITenantEgressPolicyStore>.WroteAnythingAsync(), StoreCancellationContract<ITenantEgressPolicyStore>.Canceled_token_throws_on_read(), StoreCancellationContract<ITenantEgressPolicyStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<ITenantEgressPolicyStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<ITenantEgressPolicyStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

A tenant carries at most ONE policy (there is no “name” dimension), so the isolation base’s generic name parameter is ignored here; every scenario still proves the SAME thing the other store contracts do: tenant A’s policy is invisible to and unwritable by tenant B.

protected TenantEgressPolicyStoreContract()

A_policy_is_deleted_whatever_case_the_caller_uses()

Section titled “ A_policy_is_deleted_whatever_case_the_caller_uses()”
[Fact]
public Task A_policy_is_deleted_whatever_case_the_caller_uses()

Task

A_policy_saved_under_a_different_case_replaces_the_existing_one()

Section titled “ A_policy_saved_under_a_different_case_replaces_the_existing_one()”
[Fact]
public Task A_policy_saved_under_a_different_case_replaces_the_existing_one()

Task

A_tenant_is_matched_case_insensitively(string, string)

Section titled “ A_tenant_is_matched_case_insensitively(string, string)”
[Theory]
[InlineData(new object?[] { "acme", "Acme" })]
[InlineData(new object?[] { "Acme", "acme" })]
[InlineData(new object?[] { "ACME", "acme" })]
public Task A_tenant_is_matched_case_insensitively(string savedAs, string requestedAs)

savedAs string

requestedAs string

Task

Reports how many records the given tenant sees through the listing endpoint.

protected override ValueTask<int> CountAsync(string tenantId, CancellationToken cancellationToken)

tenantId string

The reading tenant.

cancellationToken CancellationToken

The token every store call inside the hook must be handed; see TenantIsolationContract.SeedAsync.

ValueTask<int>

The number of records seen.

Deleting_the_policy_makes_the_tenant_unrestricted_again()

Section titled “ Deleting_the_policy_makes_the_tenant_unrestricted_again()”
[Fact]
public Task Deleting_the_policy_makes_the_tenant_unrestricted_again()

Task

Reports whether the record is visible from the given tenant’s viewpoint.

protected override ValueTask<bool> ExistsAsync(string tenantId, object key)

tenantId string

The reading tenant.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool>

true if the record is visible.

[Fact]
public Task Saved_policy_is_read_back()

Task

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)

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.

ValueTask<object>

The key to use for reading the record back.

Tenant_with_no_saved_policy_is_unrestricted()

Section titled “ Tenant_with_no_saved_policy_is_unrestricted()”
[Fact]
public Task Tenant_with_no_saved_policy_is_unrestricted()

Task

Attempts to delete the record on behalf of the given tenant.

protected override ValueTask<bool?> TryDeleteAsync(string tenantId, object key)

tenantId string

The tenant attempting the delete.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool?>

true if the delete succeeded, false if the record was not found; null if the store does not offer deletion.

[Fact]
public Task Upsert_replaces_the_existing_policy()

Task