Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/auth-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ webauthn-rs-proto.workspace = true
piquel-auth = { workspace = true, features = ["axum", "test-util"] }
rcgen.workspace = true
tokio-rustls.workspace = true
piquel-repository = { workspace = true, features = ["test-support"] }
piquel-repository = { workspace = true, features = ["test-util"] }
piquel-telemetry = { workspace = true, features = ["test-util"] }
serde_urlencoded.workspace = true
tower.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ uuid.workspace = true
[features]
# Helpers that let other crates' tests observe stored state, and move a
# recovery's clock.
test-support = []
test-util = []

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/database/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Database {
}
}

#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
impl Database {
/// Connects to `config`'s database in a schema of its own, created and migrated
/// for this call, so a test can change history that the whole database shares,
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/exclusive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub enum LockKey {
/// overlapping `migrate` runs take turns.
Migrations = 7,
/// The job runner panic test; no release takes it.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
Test = -1,
/// The job runner exclusivity test, apart from [`Self::Test`] since tests
/// sharing a database run at once; no release takes it.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
ExclusivityTest = -2,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Applications receive typed repositories and never a pool, executor, row, or
//! `SQLx` error. Repositories expose only the operations used by the service, plus
//! read-only helpers behind the `test-support` feature for other crates' tests.
//! read-only helpers behind the `test-util` feature for other crates' tests.
/// Validated `PostgreSQL` transport and bounded connection pools.
mod connection;
/// Typed persistence and connection failures.
Expand All @@ -20,7 +20,7 @@ pub use connection::{Database, DatabaseConfig, RuntimeRole};
pub(crate) use connection::{Limit, Scope};
pub use error::{DatabaseConnectionError, DatabaseError};
pub use exclusive::{ExclusiveConnection, LockKey};
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub use repositories::audit::Tamper;
pub use repositories::{
AccountDeletionRepository, AdministratorRepository, AuditRepository, DashboardRepository,
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/repositories/audit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl DatabaseTransaction<'_> {
/// A change an attacker with database access could make, for verification tests.
/// [`AuditRepository::tamper`] applies it with the guard triggers disabled, so run
/// it only on a database of its own (see `Database::isolated`).
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
#[derive(Clone, Debug)]
pub enum Tamper {
/// Replaces the payload of the event at a position.
Expand All @@ -516,7 +516,7 @@ pub enum Tamper {
ErasePersonalData(u64),
}

#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
impl AuditRepository<'_> {
/// Applies `tamper` with the guard triggers disabled.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/repositories/deliveries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl DeliveryRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn payloads(
&mut self,
destination: &str,
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/repositories/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl EventRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails or a stored event does not decode.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn history_for_client(
&mut self,
client_id: &ClientId,
Expand Down Expand Up @@ -529,7 +529,7 @@ impl EventRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails.
#[cfg(any(test, feature = "test-support"))]
#[cfg(any(test, feature = "test-util"))]
pub async fn insert_written_elsewhere(
&mut self,
subject: UserId,
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/repositories/recoveries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl RecoveryRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the update fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn expire(&mut self, id: RecoveryId) -> Result<(), DatabaseError> {
run!(
self,
Expand All @@ -439,7 +439,7 @@ impl RecoveryRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the update fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn backdate_completion(
&mut self,
id: RecoveryId,
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/repositories/tokens/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl TokenRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn lock_family(&mut self, id: TokenId) -> Result<(), DatabaseError> {
run!(
self,
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/repositories/users/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct InsertUser {
pub display_name: String,
}

#[cfg(any(test, feature = "test-support"))]
#[cfg(any(test, feature = "test-util"))]
impl InsertUser {
/// An account whose handle is `prefix` and a random suffix, for tests.
///
Expand Down Expand Up @@ -259,7 +259,7 @@ impl UserRepository<'_> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn age_handle_change(&mut self, id: UserId, days: i32) -> Result<(), DatabaseError> {
run!(
self,
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'a> DatabaseTransaction<'a> {
/// # Errors
///
/// Returns [`DatabaseError`] if the query fails.
#[cfg(feature = "test-support")]
#[cfg(feature = "test-util")]
pub async fn blocked_transactions(&mut self) -> Result<i64, DatabaseError> {
sqlx::query_scalar!(
// `pg_locks` is read afresh by every query; `pg_stat_activity` would
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/database-crate.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ The purge's queries use indexes, including the actor's user ID in
`domain_events`, so its cost does not grow with everyone's history.
Tests that use `TEST_DATABASE_URL` are explicitly
marked ignored by the ordinary unit test runner; other crates' tests read stored state
through helpers behind the `test-support` feature. `just db test` runs them in a
through helpers behind the `test-util` feature. `just db test` runs them in a
throwaway PostgreSQL cluster, or against an explicit, disposable `TEST_DATABASE_URL`.

## Time limits
Expand Down Expand Up @@ -476,7 +476,7 @@ one that would move it back fails. Personal data is not covered, so retention
keeps deleting `event_personal_data` freely.

Verification tests need history no other test shares: `Database::isolated` (behind
`test-support`) migrates a schema of its own, and `audit().tamper` applies the
`test-util`) migrates a schema of its own, and `audit().tamper` applies the
changes an attacker could make, with the trigger disabled.

### Security history
Expand Down
2 changes: 1 addition & 1 deletion just/db.just
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prepare-check:
prepare:
@just db scratch just db _prepare

# Test targets and the `test-support` feature are included so checked queries
# Test targets and the `test-util` feature are included so checked queries
# compiled only for tests are cached too.
[positional-arguments]
_prepare *ARGS:
Expand Down
Loading