Skip to content
Tracon

ApiKeyStoreContract

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

Behavior tests for the IApiKeyStore contract.

public abstract class ApiKeyStoreContract : TenantIsolationContract<IApiKeyStore>, IAsyncLifetime, IAsyncDisposable

objectTenantIsolationContract<IApiKeyStore>ApiKeyStoreContract

IAsyncLifetime, IAsyncDisposable

TenantIsolationContract<IApiKeyStore>.TenantA, TenantIsolationContract<IApiKeyStore>.TenantB, TenantIsolationContract<IApiKeyStore>.CreateStoreAsync(), TenantIsolationContract<IApiKeyStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<IApiKeyStore>.InitializeAsync(), TenantIsolationContract<IApiKeyStore>.DisposeAsync(), TenantIsolationContract<IApiKeyStore>.OnDisposeAsync(), TenantIsolationContract<IApiKeyStore>.SeedAsync(string, string), TenantIsolationContract<IApiKeyStore>.ExistsAsync(string, object), TenantIsolationContract<IApiKeyStore>.CountAsync(string), TenantIsolationContract<IApiKeyStore>.TryDeleteAsync(string, object), TenantIsolationContract<IApiKeyStore>.TryOverwriteAsync(string, string), TenantIsolationContract<IApiKeyStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<IApiKeyStore>.Tenant_reads_its_own_record(), TenantIsolationContract<IApiKeyStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<IApiKeyStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<IApiKeyStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<IApiKeyStore>.AmbientTenant, TenantIsolationContract<IApiKeyStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

In this contract, the raw key value is visible only in the ApiKeyCreationResult.PlaintextKey returned by IApiKeyStore.CreateAsync; no read path (IApiKeyStore.ListAsync, IApiKeyStore.FindByHashAsync) returns the raw value or its hash.

protected ApiKeyStoreContract()
[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 135)]
public Task Active_scope_is_found_system_wide()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 101)]
public Task Cannot_revoke_another_tenants_key()

Task

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

protected override ValueTask<int> CountAsync(string tenantId)

tenantId string

The reading tenant.

ValueTask<int>

The number of records seen.

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("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 124)]
public Task Expiration_is_read_back()

Task

Finding_another_tenants_key_by_hash_returns_the_correct_tenant()

Section titled “ Finding_another_tenants_key_by_hash_returns_the_correct_tenant()”
[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 155)]
public Task Finding_another_tenants_key_by_hash_returns_the_correct_tenant()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 57)]
public Task Found_by_hash_of_the_raw_value()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 112)]
public Task Last_used_timestamp_is_updated()

Task

Revoked_key_carries_RevokedAt_and_appears_inactive()

Section titled “ Revoked_key_carries_RevokedAt_and_appears_inactive()”
[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 79)]
public Task Revoked_key_carries_RevokedAt_and_appears_inactive()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 146)]
public Task Revoked_keys_scope_is_no_longer_active()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 92)]
public Task Same_key_cannot_be_revoked_twice()

Task

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 41)]
public Task Saved_key_is_read_back()

Task

Writes a sample record for the given tenant.

protected override ValueTask<object> SeedAsync(string tenantId, string name)

tenantId string

The tenant that owns the record.

name string

The name distinguishing the record. The same name may be used by two tenants.

ValueTask<object>

The key to use for reading the record back.

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("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/ApiKeyStoreContract.cs", 69)]
public Task Unknown_hash_is_not_found()

Task