Skip to main content

Tests: internal/credential

internal/credential · 9 tests

Each test is named for the property it holds, and runs against a real deployment: there is no mock of the database and no arm that skips when it is absent. The sentence is the test's name read back; the name is what go test -run takes.

access_test.go

credential_test.go

  • A credential resolves to its projects and nothing elseTestACredentialResolvesToItsProjectsAndNothingElse. A credential resolves to the projects it was granted, and carries nothing else.
  • A credential without a project is refusedTestACredentialWithoutAProjectIsRefused. A credential with no project is refused at minting rather than issued and useless.
  • Every way of failing to resolve gives the same answerTestEveryWayOfFailingToResolveGivesTheSameAnswer. Absent, malformed, unknown and revoked are one answer, because telling them apart tells a stranger whether a token they hold is real.
  • The token is not recoverable from the databaseTestTheTokenIsNotRecoverableFromTheDatabase. The token is returned once and is not recoverable from what is stored.
  • The memory service cannot read a credentialTestTheMemoryServiceCannotReadACredential. ── The structural claim ────────────────────────────────────────────────────────────────────── The memory service cannot read a credential.
  • Revoking an unknown or already revoked credential is refusedTestRevokingAnUnknownOrAlreadyRevokedCredentialIsRefused. Revoking something that is not there, or is already revoked, is refused with the same answer as resolving one.
  • A credential without a name is refusedTestACredentialWithoutANameIsRefused. A credential has to be nameable, because a list of anonymous keys is a list nobody can safely revoke from.
  • A credential opens one door by its kind and the registry holds the kindTestACredentialOpensOneDoorByItsKindAndTheRegistryHoldsTheKind. A credential is one of two kinds, and each kind opens one door: the memory resolver refuses an operator credential and the operator resolver refuses a project credential, both with the answer a stranger gets; an operator credential names no project; and the registry refuses a row that is both or neither.