apikeytest

package
v0.3.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package apikeytest is the shared contract suite for core.APIKeyAdmin, the optional interface for listing every API key and deleting the expired ones. Each backend runs RunAdmin with a factory that returns a fresh, empty store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAdmin

func RunAdmin(t *testing.T, factory Factory)

RunAdmin runs every APIKeyAdmin contract test against factory.

func TestCleanupDeletesExpiredRevokedOrNot

func TestCleanupDeletesExpiredRevokedOrNot(t *testing.T, factory Factory)

TestCleanupDeletesExpiredRevokedOrNot: cleanup deletes every expired key, revoked or not, and keeps live keys and keys with no expiry, even a revoked one.

func TestCleanupHonorsNow

func TestCleanupHonorsNow(t *testing.T, factory Factory)

TestCleanupHonorsNow: cleanup measures expiry against req.Now, not the wall clock, and a key expiring exactly at Now is expired.

func TestCleanupIsRepeatable

func TestCleanupIsRepeatable(t *testing.T, factory Factory)

TestCleanupIsRepeatable: a second cleanup at the same Now removes 0.

func TestListDuringCleanup

func TestListDuringCleanup(t *testing.T, factory Factory)

TestListDuringCleanup: a cleanup on one handle deletes keys while another handle lists. No listing fails, and none returns a deleted key half-read. Agni hit an error here on fs (agni issue 1796).

func TestListEmpty

func TestListEmpty(t *testing.T, factory Factory)

TestListEmpty: an empty store lists no keys and no error.

func TestListEverySubjectWithoutHashes

func TestListEverySubjectWithoutHashes(t *testing.T, factory Factory)

TestListEverySubjectWithoutHashes: the listing covers every subject, and no listed key carries its bcrypt hash.

Types

type Backend

type Backend struct {
	Store  Store
	Reopen func() Store
}

Backend is one fresh, empty store. Reopen returns a second handle on the same data, the way another process would see it. For fs that's a store with its own mutex on the same directory.

type Factory

type Factory func(t *testing.T) Backend

Factory returns a fresh, empty backend for one subtest.

type Store

type Store interface {
	core.APIKeyStore
	core.APIKeyAdmin
}

Store is an APIKeyStore that also implements APIKeyAdmin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL