Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Run rust e2e tests against pglite via a shared test-support crate

Manav Rathi3962cd32481a
diff --git a/.github/workflows/rust-e2e-test.yml b/.github/workflows/rust-e2e-test.yml
index 03b88c4858..a87f7021b8 100644
--- a/.github/workflows/rust-e2e-test.yml
+++ b/.github/workflows/rust-e2e-test.yml
@@ -4,11 +4,7 @@ on:
pull_request:
paths:
- ".github/workflows/rust-e2e-test.yml"
- - "rust/Cargo.lock"
- - "rust/Cargo.toml"
- - "rust/apps/cli/**"
- - "rust/crates/**"
- - "rust/e2e/**"
+ - "rust/**"
- "server/**"
permissions:
@@ -22,11 +18,12 @@ env:
RUSTFLAGS: -D warnings
jobs:
- cli-integration:
+ integration:
runs-on: ubuntu-latest
+ timeout-minutes: 30
defaults:
run:
- working-directory: rust/apps/cli
+ working-directory: rust
steps:
- name: Checkout
@@ -51,21 +48,10 @@ jobs:
save-if: false
- name: Install PGlite test dependency
- run: npm ci --prefix tests/pglite
+ run: npm ci --prefix crates/test-support/pglite
- name: Run CLI integration tests
- run: cargo test --features museum,pglite --locked
-
- docker-e2e:
- runs-on: ubuntu-latest
- timeout-minutes: 30
-
- steps:
- - name: Checkout
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ run: cargo test -p ente-rs --features museum,pglite --locked
- - name: Run Docker E2E suite
- env:
- ENTE_E2E_DOCKER_PROJECT: ente-rust-e2e-${{ github.run_id }}-${{ github.run_attempt }}
- ENTE_E2E_ENDPOINT: http://localhost:18080
- run: rust/e2e/scripts/run.sh
+ - name: Run E2E suite
+ run: cargo test -p ente-e2e --features museum,pglite --locked
diff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.yml
index f1dd0155bb..5be9a92aef 100644
--- a/.github/workflows/warm-caches.yml
+++ b/.github/workflows/warm-caches.yml
@@ -104,11 +104,11 @@ jobs:
- run: npm run build:wasm
rust-cli:
- # For rust-e2e-test.yml's cli-integration job.
+ # For rust-e2e-test.yml.
runs-on: ubuntu-latest
defaults:
run:
- working-directory: rust/apps/cli
+ working-directory: rust
env:
RUSTFLAGS: -D warnings
steps:
@@ -127,7 +127,9 @@ jobs:
workspaces: rust
shared-key: rust-cli
- - run: cargo test --features museum,pglite --locked --no-run
+ - run: cargo test -p ente-rs --features museum,pglite --locked --no-run
+
+ - run: cargo test -p ente-e2e --features museum,pglite --locked --no-run
ensu-android:
# For ensu-android-build.yml.
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index a2a096fe12..2b3f5a31db 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2489,6 +2489,7 @@ dependencies = [
"ente-contacts",
"ente-core",
"ente-rs",
+ "ente-test-support",
"hmac 0.13.0",
"reqwest 0.12.28",
"serde",
@@ -2510,6 +2511,7 @@ dependencies = [
"dirs 5.0.1",
"ente-accounts",
"ente-core",
+ "ente-test-support",
"env_logger 0.11.10",
"futures",
"indicatif",
@@ -2530,6 +2532,14 @@ dependencies = [
"zip 2.4.2",
]
+[[package]]
+name = "ente-test-support"
+version = "0.0.0"
+dependencies = [
+ "serde_json",
+ "uuid",
+]
+
[[package]]
name = "ente-wasm"
version = "0.0.0"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 8b03dfe417..6ca19b8951 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -22,6 +22,7 @@ members = [
"crates/ensu/transcription",
"crates/image",
"crates/photos",
+ "crates/test-support",
"e2e",
]
@@ -33,6 +34,7 @@ ente-accounts = { path = "crates/accounts" }
ente-contacts = { path = "crates/contacts" }
ente-core = { path = "crates/core" }
ente-rs = { path = "apps/cli" }
+ente-test-support = { path = "crates/test-support" }
ente_image = { path = "crates/image" }
ente_photos = { path = "crates/photos" }
inference_rs = { path = "crates/ensu/inference" }
diff --git a/rust/README.md b/rust/README.md
index 50e615d7c5..2316339d58 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -21,7 +21,6 @@ Other useful commands:
cargo codegen native # Regenerate bindings used by native apps
cargo codegen frb # Regenerate bindings used by Flutter apps
-# Starts Docker + runs the E2E tests (ignored by default)
-./e2e/scripts/run.sh
-cargo test -p ente-e2e -- --ignored --nocapture
+# E2E tests against a local Museum + pglite (see e2e/README.md for setup)
+cargo test -p ente-e2e --features museum,pglite
```
diff --git a/rust/apps/cli/Cargo.toml b/rust/apps/cli/Cargo.toml
index 66322afe92..7d5586341f 100644
--- a/rust/apps/cli/Cargo.toml
+++ b/rust/apps/cli/Cargo.toml
@@ -51,6 +51,7 @@ open = "5.0"
zip = "2.2"
[dev-dependencies]
+ente-test-support.workspace = true
mockito = "1.6"
sha2 = "0.11"
# Pinned to upstream commit that includes the padded-u interop fix for
diff --git a/rust/apps/cli/README.md b/rust/apps/cli/README.md
index 2854dff77b..72e0d02d62 100644
--- a/rust/apps/cli/README.md
+++ b/rust/apps/cli/README.md
@@ -8,15 +8,10 @@ cargo run --bin ente-rs -- --help
## Integration tests
-The integration tests spin up a local Museum server backed by an in-memory Postgres using [pglite](https://pglite.dev). These are gated behind Cargo features, so a plain `cargo test -p ente-rs` skips them.
-
-One-time setup:
-
-```sh
-npm ci --prefix rust/apps/cli/tests/pglite
-```
-
-Run the tests from the `rust/` directory:
+The integration tests run against a live Museum spun up by
+[ente-test-support](../../crates/test-support) (see its README for setup). They
+are gated behind Cargo features, so a plain `cargo test -p ente-rs` skips them.
+To run them:
```sh
cargo test -p ente-rs --features museum,pglite
diff --git a/rust/apps/cli/tests/paste.rs b/rust/apps/cli/tests/paste.rs
index 8edb88db39..bdc43464fc 100644
--- a/rust/apps/cli/tests/paste.rs
+++ b/rust/apps/cli/tests/paste.rs
@@ -19,7 +19,7 @@ fn paste() -> TestResult {
}
fn full_link_roundtrip(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("full-link")?;
+ let cli = support::cli_session(fixture, "full-link")?;
let text = unique_text("full-link");
let link = create_paste(&cli, fixture, &text)?;
@@ -54,7 +54,7 @@ fn full_link_roundtrip(fixture: &Fixture) -> TestResult {
}
fn token_and_key_roundtrip(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("token-key")?;
+ let cli = support::cli_session(fixture, "token-key")?;
let text = unique_text("token-key");
let link = create_paste(&cli, fixture, &text)?;
@@ -73,7 +73,7 @@ fn token_and_key_roundtrip(fixture: &Fixture) -> TestResult {
}
fn stdin_roundtrip(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("stdin")?;
+ let cli = support::cli_session(fixture, "stdin")?;
let text = format!(
"paste stdin scenario {}\n\nsecond line stays intact\n",
Uuid::new_v4()
@@ -104,7 +104,7 @@ fn stdin_roundtrip(fixture: &Fixture) -> TestResult {
}
fn password_protected_roundtrip(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("password-protected")?;
+ let cli = support::cli_session(fixture, "password-protected")?;
let text = unique_text("password-protected");
let password = format!("password {}", Uuid::new_v4());
let link = create_password_paste(&cli, fixture, &text, &password)?;
@@ -127,7 +127,7 @@ fn password_protected_roundtrip(fixture: &Fixture) -> TestResult {
}
fn wrong_password_consumes_password_protected_paste(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("wrong-password")?;
+ let cli = support::cli_session(fixture, "wrong-password")?;
let text = unique_text("wrong-password");
let password = format!("password {}", Uuid::new_v4());
let link = create_password_paste(&cli, fixture, &text, &password)?;
@@ -179,7 +179,7 @@ fn wrong_password_consumes_password_protected_paste(fixture: &Fixture) -> TestRe
}
fn consumed_password_paste_checks_availability_before_password(fixture: &Fixture) -> TestResult {
- let cli = fixture.cli_session("consumed-password")?;
+ let cli = support::cli_session(fixture, "consumed-password")?;
let text = unique_text("consumed-password");
let password = format!("password {}", Uuid::new_v4());
let link = create_password_paste(&cli, fixture, &text, &password)?;
diff --git a/rust/apps/cli/tests/support/mod.rs b/rust/apps/cli/tests/support/mod.rs
index d052f693f2..4a19de5a0e 100644
--- a/rust/apps/cli/tests/support/mod.rs
+++ b/rust/apps/cli/tests/support/mod.rs
@@ -1,12 +1,10 @@
mod cli;
-mod fixture;
-mod museum;
-mod pglite;
-mod process;
pub use cli::Cli;
-pub use fixture::Fixture;
+pub use ente_test_support::{Fixture, TestResult};
-pub type TestResult<T = ()> = Result<T, Box<dyn std::error::Error>>;
-
-const LOCAL_HOST: &str = "127.0.0.1";
+pub fn cli_session(fixture: &Fixture, scenario: &str) -> TestResult<Cli> {
+ let config_dir = fixture.temp_dir().join("cli").join(scenario);
+ std::fs::create_dir_all(&config_dir)?;
+ Ok(Cli::new(config_dir))
+}
diff --git a/rust/crates/test-support/Cargo.toml b/rust/crates/test-support/Cargo.toml
new file mode 100644
index 0000000000..3f74bf815b
--- /dev/null
+++ b/rust/crates/test-support/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "ente-test-support"
+edition = "2024"
+description = "Shared integration test fixture that runs a local Museum backed by PGlite"
+publish = false
+
+[dependencies]
+serde_json = "1.0"
+uuid = { version = "1.11", features = ["v4"] }
diff --git a/rust/crates/test-support/README.md b/rust/crates/test-support/README.md
new file mode 100644
index 0000000000..dcbbc4f7ed
--- /dev/null
+++ b/rust/crates/test-support/README.md
@@ -0,0 +1,22 @@
+# ente-test-support
+
+A test fixture that runs a local Museum backed by in-memory Postgres
+([pglite](https://pglite.dev)), used by the `ente-rs` and `ente-e2e` integration
+tests.
+
+## Setup
+
+Requires `go` and `node` on PATH. Install the pglite dependency once:
+
+```sh
+npm ci --prefix rust/crates/test-support/pglite
+```
+
+## Usage
+
+Tests that use the fixture are gated behind the `museum` and `pglite` Cargo
+features, so a plain `cargo test` skips them:
+
+```sh
+cargo test -p ente-e2e --features museum,pglite
+```
diff --git a/rust/apps/cli/tests/pglite/.npmrc b/rust/crates/test-support/pglite/.npmrc
similarity index 100%
rename from rust/apps/cli/tests/pglite/.npmrc
rename to rust/crates/test-support/pglite/.npmrc
diff --git a/rust/apps/cli/tests/pglite/package-lock.json b/rust/crates/test-support/pglite/package-lock.json
similarity index 100%
rename from rust/apps/cli/tests/pglite/package-lock.json
rename to rust/crates/test-support/pglite/package-lock.json
diff --git a/rust/apps/cli/tests/pglite/package.json b/rust/crates/test-support/pglite/package.json
similarity index 100%
rename from rust/apps/cli/tests/pglite/package.json
rename to rust/crates/test-support/pglite/package.json
diff --git a/rust/apps/cli/tests/support/fixture.rs b/rust/crates/test-support/src/fixture.rs
similarity index 81%
rename from rust/apps/cli/tests/support/fixture.rs
rename to rust/crates/test-support/src/fixture.rs
index c09d5895e4..4de6ac8095 100644
--- a/rust/apps/cli/tests/support/fixture.rs
+++ b/rust/crates/test-support/src/fixture.rs
@@ -6,7 +6,7 @@ use std::{
use uuid::Uuid;
-use super::{Cli, LOCAL_HOST, TestResult, museum, pglite, process::ChildProcess};
+use crate::{LOCAL_HOST, TestResult, museum, pglite, process::ChildProcess};
pub struct Fixture {
_museum: ChildProcess,
@@ -28,7 +28,7 @@ impl Fixture {
pub fn start() -> TestResult<Self> {
let paths = Paths::discover()?;
- let mut temp_dir = TempDir::new("ente-cli-test")?;
+ let mut temp_dir = TempDir::new("ente-test")?;
let log_dir = temp_dir.path().join("logs");
let pglite_port = free_port()?;
let museum_port = free_port()?;
@@ -73,10 +73,8 @@ impl Fixture {
&self.paste_origin
}
- pub fn cli_session(&self, scenario: &str) -> TestResult<Cli> {
- let config_dir = self.temp_dir.path().join("cli").join(scenario);
- fs::create_dir_all(&config_dir)?;
- Ok(Cli::new(config_dir))
+ pub fn temp_dir(&self) -> &Path {
+ self.temp_dir.path()
}
pub fn retain_temp_dir(&mut self) {
@@ -91,18 +89,16 @@ struct Paths {
impl Paths {
fn discover() -> TestResult<Self> {
- let cli_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
- let rust_dir = cli_dir
+ let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let repo_dir = crate_dir
.parent()
.and_then(Path::parent)
- .ok_or("failed to resolve rust directory")?;
- let repo_dir = rust_dir
- .parent()
+ .and_then(Path::parent)
.ok_or("failed to resolve repository directory")?;
Ok(Self {
server_dir: repo_dir.join("server"),
- pglite_dir: cli_dir.join("tests").join("pglite"),
+ pglite_dir: crate_dir.join("pglite"),
})
}
}
@@ -128,7 +124,7 @@ impl TempDir {
fn retain(&mut self) {
eprintln!(
- "retaining CLI integration test temp dir: {}",
+ "retaining integration test temp dir: {}",
self.path.display()
);
self.retained = true;
diff --git a/rust/crates/test-support/src/lib.rs b/rust/crates/test-support/src/lib.rs
new file mode 100644
index 0000000000..ddcfb3a2a4
--- /dev/null
+++ b/rust/crates/test-support/src/lib.rs
@@ -0,0 +1,21 @@
+//! Shared fixture for integration tests that need a live Museum.
+//!
+//! [`Fixture`] spins up a local Museum server backed by an in-memory Postgres
+//! using [pglite](https://pglite.dev). See the crate README for requirements
+//! and the one-time npm setup.
+
+mod fixture;
+mod museum;
+mod pglite;
+mod process;
+
+pub use fixture::Fixture;
+
+pub type TestResult<T = ()> = Result<T, Box<dyn std::error::Error>>;
+
+const LOCAL_HOST: &str = "127.0.0.1";
+
+/// Museum is configured to accept this OTT for `HARDCODED_OTT_EMAIL_SUFFIX`
+/// addresses, letting tests verify emails without an email inbox.
+pub const HARDCODED_OTT: &str = "123456";
+pub const HARDCODED_OTT_EMAIL_SUFFIX: &str = "@ente-rust-test.org";
diff --git a/rust/apps/cli/tests/support/museum.rs b/rust/crates/test-support/src/museum.rs
similarity index 91%
rename from rust/apps/cli/tests/support/museum.rs
rename to rust/crates/test-support/src/museum.rs
index 52ec34fb51..672c0c327f 100644
--- a/rust/apps/cli/tests/support/museum.rs
+++ b/rust/crates/test-support/src/museum.rs
@@ -7,7 +7,9 @@ use std::{
time::{Duration, Instant},
};
-use super::{LOCAL_HOST, TestResult, process::ChildProcess};
+use crate::{
+ HARDCODED_OTT, HARDCODED_OTT_EMAIL_SUFFIX, LOCAL_HOST, TestResult, process::ChildProcess,
+};
pub fn start(
server_dir: &Path,
@@ -61,6 +63,11 @@ s3:
region: eu-central-2
bucket: b2-eu-cen
+internal:
+ hardcoded-ott:
+ local-domain-suffix: "{HARDCODED_OTT_EMAIL_SUFFIX}"
+ local-domain-value: {HARDCODED_OTT}
+
jobs:
cron:
skip: true
diff --git a/rust/apps/cli/tests/support/pglite.rs b/rust/crates/test-support/src/pglite.rs
similarity index 93%
rename from rust/apps/cli/tests/support/pglite.rs
rename to rust/crates/test-support/src/pglite.rs
index 8e062ea34a..576e134381 100644
--- a/rust/apps/cli/tests/support/pglite.rs
+++ b/rust/crates/test-support/src/pglite.rs
@@ -8,7 +8,7 @@ use std::{
use serde_json::Value;
-use super::{LOCAL_HOST, TestResult, process::ChildProcess};
+use crate::{LOCAL_HOST, TestResult, process::ChildProcess};
pub fn start(package_dir: &Path, log_dir: &Path, port: u16) -> TestResult<ChildProcess> {
let bin = pglite_server_bin(package_dir)?;
@@ -62,7 +62,7 @@ fn package_version(path: impl AsRef<Path>) -> TestResult<String> {
}
fn install_error() -> Box<dyn std::error::Error> {
- "PGlite is not installed. Run `npm ci --prefix rust/apps/cli/tests/pglite` from the repository root.".into()
+ "PGlite is not installed. Run `npm ci --prefix rust/crates/test-support/pglite` from the repository root.".into()
}
fn wait_for_pglite(process: &mut ChildProcess, port: u16) -> TestResult {
diff --git a/rust/apps/cli/tests/support/process.rs b/rust/crates/test-support/src/process.rs
similarity index 98%
rename from rust/apps/cli/tests/support/process.rs
rename to rust/crates/test-support/src/process.rs
index 71063b09e0..28bed6322f 100644
--- a/rust/apps/cli/tests/support/process.rs
+++ b/rust/crates/test-support/src/process.rs
@@ -4,7 +4,7 @@ use std::{
process::{Child, Command, Stdio},
};
-use super::TestResult;
+use crate::TestResult;
pub struct ChildProcess {
name: &'static str,
diff --git a/rust/e2e/COVERAGE.md b/rust/e2e/COVERAGE.md
deleted file mode 100644
index 55e972729f..0000000000
--- a/rust/e2e/COVERAGE.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# Rust E2E Coverage
-
-Current suite entrypoint:
-
-- [`auth_contacts_e2e`](tests/full_e2e.rs)
-- [`legacy_contact_recovery_e2e`](tests/full_e2e.rs)
-- [`legacy_kit_recovery_e2e`](tests/full_e2e.rs)
-
-Shared setup and helpers:
-
-- owner/trusted pair creation and legacy-contact bootstrap: [`tests/support/legacy.rs`](tests/support/legacy.rs)
-- auth helpers: [`tests/support/auth.rs`](tests/support/auth.rs)
-- contacts and legacy-info helpers: [`tests/support/contacts.rs`](tests/support/contacts.rs)
-- local/CI runner: [`scripts/run.sh`](scripts/run.sh)
-- CI workflow: [`../../.github/workflows/rust-e2e-test.yml`](../../.github/workflows/rust-e2e-test.yml)
-
-## Covered Scenarios
-
-| Area | Covered behavior | Source |
-| -------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
-| Auth | fresh account creation for owner and trusted contact | [`tests/support/legacy.rs`](tests/support/legacy.rs), [`tests/support/auth.rs`](tests/support/auth.rs) |
-| Auth | login with the initial password | [`run_auth_stage`](tests/full_e2e.rs), [`tests/support/auth.rs`](tests/support/auth.rs) |
-| Auth | enable TOTP and login with TOTP | [`run_auth_stage`](tests/full_e2e.rs), [`tests/support/auth.rs`](tests/support/auth.rs) |
-| Contacts | create a contact record | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Contacts | read back the contact record | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Contacts | update contact name and birth date | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Contacts | diff includes the created contact | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Contacts | contact isolation across accounts (`404` from trusted account) | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Contacts | delete the contact record | [`run_contacts_stage`](tests/full_e2e.rs) |
-| Legacy | establish owner/trusted legacy relationship with accepted state | [`tests/support/legacy.rs`](tests/support/legacy.rs), [`tests/support/contacts.rs`](tests/support/contacts.rs) |
-| Legacy | start recovery, owner rejects, recovery session disappears, accepted contact remains | [`run_legacy_reject_stage`](tests/full_e2e.rs) |
-| Legacy | trusted contact stops recovery and both recovery-session views clear | [`run_legacy_stop_stage`](tests/full_e2e.rs) |
-| Legacy | revoke and re-invite trusted contact back to accepted state | [`run_legacy_reinvite_stage`](tests/full_e2e.rs) |
-| Legacy | full recovery flow to `READY` after owner approval | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | recovered contact changes password through legacy recovery | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | old password login fails after recovery | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | new password login succeeds after recovery | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | recovered login keeps the same `user_id` and master key | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | TOTP is cleared by recovery | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | recovery session is cleared after password reset | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-| Recovery | legacy trusted contact remains configured after recovery | [`run_legacy_reset_stage`](tests/full_e2e.rs) |
-
-## Not Covered Yet
-
-- contact profile-picture / attachment flows
-- object-store-backed scenarios
-- passkey flows
-- recovery via elapsed notice period without explicit owner approval
-- multi-process shared fixtures; current reuse is scoped to one test binary
diff --git a/rust/e2e/Cargo.toml b/rust/e2e/Cargo.toml
index 8ab26e02e8..2e3c6611b2 100644
--- a/rust/e2e/Cargo.toml
+++ b/rust/e2e/Cargo.toml
@@ -2,12 +2,21 @@
name = "ente-e2e"
edition = "2024"
+[features]
+museum = []
+pglite = []
+
+[[test]]
+name = "full_e2e"
+required-features = ["museum", "pglite"]
+
[dependencies]
ente-accounts.workspace = true
ente-contacts.workspace = true
ente-core = { workspace = true, features = ["srp"] }
ente-rs.workspace = true
-tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
+ente-test-support.workspace = true
+tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
reqwest = { version = "0.12", features = ["json", "rustls-tls-native-roots"] }
zeroize = { version = "1.8", features = ["derive"] }
uuid = { version = "1.11", features = ["v4"] }
diff --git a/rust/e2e/README.md b/rust/e2e/README.md
index ad5dc67aba..f97b397b8f 100644
--- a/rust/e2e/README.md
+++ b/rust/e2e/README.md
@@ -2,51 +2,28 @@
Rust end-to-end tests that require a live Museum instance belong here.
-Current server-backed coverage in this crate:
+The single `full_e2e` test runs these stages in sequence:
+`auth_contacts_e2e`, `legacy_contact_recovery_e2e`, and
+`legacy_kit_recovery_e2e`.
-- ignored stage tests that reuse shared fixtures inside one test binary: `auth_contacts_e2e`, `legacy_contact_recovery_e2e`, and `legacy_kit_recovery_e2e`
-
-Detailed scenario coverage lives in [`COVERAGE.md`](COVERAGE.md).
-
-Preferred local runner:
-
-```sh
-rust/e2e/scripts/run.sh
-```
-
-GitHub Actions uses the same runner via `.github/workflows/rust-e2e-test.yml`.
-
-That runner:
-
-- starts Museum in Docker with Postgres only
-- enables deterministic OTT for `@ente-rust-test.org`
-- defaults to `http://localhost:18080` to avoid colliding with an already running local Museum on `8080`
-- waits for `GET /ping`
-- runs this crate's ignored tests
-
-For a compile-only sanity check that does not hit a live server:
+Like the CLI integration tests, the suite runs against a live Museum spun up by
+[ente-test-support](../crates/test-support) (see its README for setup). It is
+gated behind Cargo features, so a plain `cargo test -p ente-e2e` skips it. To
+run it:
```sh
-cargo test --manifest-path rust/Cargo.toml -p ente-e2e
+cargo test -p ente-e2e --features museum,pglite
```
-For ad hoc runs against an already-running server:
+For ad hoc runs against an already-running server (skips the fixture):
```sh
-ENTE_E2E_ENDPOINT=http://localhost:8080 cargo test --manifest-path rust/Cargo.toml -p ente-e2e -- --ignored --nocapture
+ENTE_E2E_ENDPOINT=http://localhost:8080 cargo test -p ente-e2e --features museum,pglite -- --nocapture
```
-To run only one ignored stage:
+To skip or select stages:
```sh
-ENTE_E2E_ENDPOINT=http://localhost:8080 cargo test --manifest-path rust/Cargo.toml -p ente-e2e legacy_kit_recovery_e2e -- --ignored --nocapture
+ENTE_E2E_SKIP=legacy_kit_recovery_e2e cargo test -p ente-e2e --features museum,pglite
+ENTE_E2E_ONLY=legacy_contact_recovery_e2e cargo test -p ente-e2e --features museum,pglite
```
-
-To skip or select stages during a full ignored run:
-
-```sh
-ENTE_E2E_SKIP=legacy_kit_recovery_e2e rust/e2e/scripts/run.sh
-ENTE_E2E_ONLY=legacy_contact_recovery_e2e rust/e2e/scripts/run.sh
-```
-
-Attachment/object-store coverage can be added as a separate fixture later, but it is intentionally not part of the baseline auth/recovery suite.
diff --git a/rust/e2e/fixtures/server/.gitignore b/rust/e2e/fixtures/server/.gitignore
deleted file mode 100644
index 75bafd08b2..0000000000
--- a/rust/e2e/fixtures/server/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-museum.yaml
diff --git a/rust/e2e/fixtures/server/compose.auth.yaml b/rust/e2e/fixtures/server/compose.auth.yaml
deleted file mode 100644
index 21cd96ede0..0000000000
--- a/rust/e2e/fixtures/server/compose.auth.yaml
+++ /dev/null
@@ -1,71 +0,0 @@
-# Auth/recovery-only Docker fixture for rust/e2e.
-
-services:
- museum:
- build:
- context: ../../../../server
- args:
- GIT_COMMIT: development-cluster
- ports:
- - ${ENTE_MUSEUM_PORT:-18080}:8080
- depends_on:
- postgres:
- condition: service_healthy
- environment:
- ENTE_CREDENTIALS_FILE: /credentials.yaml
- configs:
- - source: credentials_yaml
- target: /credentials.yaml
- volumes:
- - ./museum.yaml:/museum.yaml:ro
- - ../../../../server/data:/data:ro
-
- postgres:
- image: postgres:15
- environment:
- POSTGRES_USER: pguser
- POSTGRES_PASSWORD: pgpass
- POSTGRES_DB: ente_db
- healthcheck:
- test: pg_isready -q -d ente_db -U pguser
- start_period: 40s
- start_interval: 1s
- volumes:
- - postgres-data:/var/lib/postgresql/data
-
-configs:
- credentials_yaml:
- content: |
- db:
- host: postgres
- port: 5432
- name: ente_db
- user: pguser
- password: pgpass
-
- # Museum bootstrap still expects S3 credentials in the config even though
- # the baseline rust/e2e suite does not exercise object storage.
- s3:
- are_local_buckets: true
- b2-eu-cen:
- key: changeme
- secret: changeme1234
- endpoint: localhost:3200
- region: eu-central-2
- bucket: b2-eu-cen
- wasabi-eu-central-2-v3:
- key: changeme
- secret: changeme1234
- endpoint: localhost:3200
- region: eu-central-2
- bucket: wasabi-eu-central-2-v3
- compliance: false
- scw-eu-fr-v3:
- key: changeme
- secret: changeme1234
- endpoint: localhost:3200
- region: eu-central-2
- bucket: scw-eu-fr-v3
-
-volumes:
- postgres-data:
diff --git a/rust/e2e/scripts/run.sh b/rust/e2e/scripts/run.sh
deleted file mode 100755
index 80dabb6e7a..0000000000
--- a/rust/e2e/scripts/run.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
-e2e_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
-repo_dir=$(CDPATH= cd -- "$e2e_dir/../.." && pwd)
-fixture_dir="$e2e_dir/fixtures/server"
-compose_file="$fixture_dir/compose.auth.yaml"
-museum_yaml="$fixture_dir/museum.yaml"
-endpoint="${ENTE_E2E_ENDPOINT:-http://localhost:18080}"
-project_name="${ENTE_E2E_DOCKER_PROJECT:-ente-rust-e2e}"
-endpoint_port=$(printf '%s' "$endpoint" | sed -E 's#^https?://[^:]+:([0-9]+).*$#\1#')
-
-compose() {
- docker compose -p "$project_name" -f "$compose_file" "$@"
-}
-
-dump_logs() {
- compose logs --no-color >&2 || true
-}
-
-if [ -z "$endpoint_port" ] || [ "$endpoint_port" = "$endpoint" ]; then
- echo "ENTE_E2E_ENDPOINT must include an explicit host port, got: $endpoint" >&2
- exit 1
-fi
-
-cleanup() {
- compose down -v --remove-orphans >/dev/null 2>&1 || true
- rm -f "$museum_yaml"
-}
-
-trap cleanup EXIT INT TERM
-
-cat >"$museum_yaml" <<'EOF'
-internal:
- hardcoded-ott:
- local-domain-suffix: "@ente-rust-test.org"
- local-domain-value: 123456
-EOF
-
-export ENTE_MUSEUM_PORT="$endpoint_port"
-if ! compose up -d --build postgres museum; then
- dump_logs
- exit 1
-fi
-
-attempt=0
-until curl -fsS "$endpoint/ping" >/dev/null 2>&1; do
- attempt=$((attempt + 1))
- if [ "$attempt" -ge 60 ]; then
- echo "Museum did not become ready at $endpoint/ping" >&2
- dump_logs
- exit 1
- fi
- sleep 2
-done
-
-cd "$repo_dir/rust"
-export ENTE_E2E_ENDPOINT="$endpoint"
-
-if ! cargo test -p ente-e2e "$@" -- --ignored --nocapture; then
- dump_logs
- exit 1
-fi
diff --git a/rust/e2e/tests/full_e2e.rs b/rust/e2e/tests/full_e2e.rs
index d5a2f477db..79acf6564f 100644
--- a/rust/e2e/tests/full_e2e.rs
+++ b/rust/e2e/tests/full_e2e.rs
@@ -8,6 +8,7 @@ use ente_contacts::{
};
use ente_core::http::Error as CoreHttpError;
use ente_rs::models::account::App;
+use ente_test_support::{Fixture, TestResult};
use serde::{Deserialize, Serialize};
use serde_json::json;
use uuid::Uuid;
@@ -53,62 +54,48 @@ struct CreateLegacyKitRequest {
encrypted_owner_blob: String,
}
-#[tokio::test]
-#[ignore = "requires local Museum at ENTE_E2E_ENDPOINT or http://localhost:8080"]
-async fn auth_contacts_e2e() {
- let endpoint = support::endpoint();
- if !support::assert_stage_enabled_or_skip(STAGE_AUTH_CONTACTS) {
- return;
- }
- if !support::assert_server_or_skip(&endpoint, STAGE_AUTH_CONTACTS).await {
- return;
+#[test]
+fn full_e2e() -> TestResult {
+ match std::env::var("ENTE_E2E_ENDPOINT") {
+ Ok(endpoint) => run_stages(&endpoint),
+ Err(_) => Fixture::run(|fixture| run_stages(fixture.endpoint())),
}
-
- let suite = support::suite::lock_suite(&endpoint).await;
- let pair = legacy::open_pair(&endpoint, &suite.legacy_pair).await;
-
- run_auth_stage(&endpoint, &pair.owner).await;
- run_contacts_stage(&pair).await;
}
-#[tokio::test]
-#[ignore = "requires local Museum at ENTE_E2E_ENDPOINT or http://localhost:8080"]
-async fn legacy_contact_recovery_e2e() {
- let endpoint = support::endpoint();
- if !support::assert_stage_enabled_or_skip(STAGE_LEGACY_CONTACT_RECOVERY) {
- return;
- }
- if !support::assert_server_or_skip(&endpoint, STAGE_LEGACY_CONTACT_RECOVERY).await {
- return;
- }
-
- let mut suite = support::suite::lock_suite(&endpoint).await;
- let mut pair = legacy::open_pair(&endpoint, &suite.legacy_pair).await;
+fn run_stages(endpoint: &str) -> TestResult {
+ tokio::runtime::Runtime::new()?.block_on(async {
+ let auth_contacts = support::stage_enabled(STAGE_AUTH_CONTACTS);
+ let legacy_recovery = support::stage_enabled(STAGE_LEGACY_CONTACT_RECOVERY);
+
+ let pair_state = if auth_contacts || legacy_recovery {
+ Some(legacy::create_accepted_pair_state(endpoint, 14).await)
+ } else {
+ None
+ };
+
+ if auth_contacts {
+ let pair = legacy::open_pair(endpoint, pair_state.as_ref().unwrap()).await;
+ run_auth_stage(endpoint, &pair.owner).await;
+ run_contacts_stage(&pair).await;
+ }
- ensure_totp_enabled(&endpoint, &pair.owner).await;
- run_legacy_reject_stage(&pair).await;
- run_legacy_stop_stage(&pair).await;
- run_legacy_reinvite_stage(&pair).await;
- run_legacy_reset_stage(&endpoint, &mut pair).await;
- legacy::persist_pair_state(&mut suite.legacy_pair, &pair);
-}
+ if legacy_recovery {
+ let mut pair = legacy::open_pair(endpoint, pair_state.as_ref().unwrap()).await;
+ ensure_totp_enabled(endpoint, &pair.owner).await;
+ run_legacy_reject_stage(&pair).await;
+ run_legacy_stop_stage(&pair).await;
+ run_legacy_reinvite_stage(&pair).await;
+ run_legacy_reset_stage(endpoint, &mut pair).await;
+ }
-#[tokio::test]
-#[ignore = "requires local Museum at ENTE_E2E_ENDPOINT or http://localhost:8080"]
-async fn legacy_kit_recovery_e2e() {
- let endpoint = support::endpoint();
- if !support::assert_stage_enabled_or_skip(STAGE_LEGACY_KIT_RECOVERY) {
- return;
- }
- if !support::assert_server_or_skip(&endpoint, STAGE_LEGACY_KIT_RECOVERY).await {
- return;
- }
+ if support::stage_enabled(STAGE_LEGACY_KIT_RECOVERY) {
+ let mut owner = legacy_kit::create_owner(endpoint).await;
+ ensure_totp_enabled(endpoint, &owner.owner).await;
+ run_legacy_kit_stage(endpoint, &mut owner).await;
+ }
- let mut suite = support::suite::lock_suite(&endpoint).await;
- let mut owner = legacy_kit::open_owner(&endpoint, &suite.legacy_kit_owner).await;
- ensure_totp_enabled(&endpoint, &owner.owner).await;
- run_legacy_kit_stage(&endpoint, &mut owner).await;
- legacy_kit::persist_owner_state(&mut suite.legacy_kit_owner, &owner);
+ Ok(())
+ })
}
async fn run_auth_stage(endpoint: &str, owner: &auth::TestAccount) {
diff --git a/rust/e2e/tests/support/auth.rs b/rust/e2e/tests/support/auth.rs
index bb962804b3..92949c2ffa 100644
--- a/rust/e2e/tests/support/auth.rs
+++ b/rust/e2e/tests/support/auth.rs
@@ -8,6 +8,7 @@ use ente_accounts::{
};
use ente_core::crypto::SecretVec;
use ente_rs::models::account::App;
+use ente_test_support::HARDCODED_OTT;
use hmac::{Hmac, KeyInit, Mac};
use sha1::Sha1;
use zeroize::Zeroizing;
@@ -33,7 +34,7 @@ struct TestUi {
impl TestUi {
fn otp_only() -> Self {
Self {
- otp: "123456".into(),
+ otp: HARDCODED_OTT.into(),
totp_secret: None,
allow_totp: false,
}
@@ -41,7 +42,7 @@ impl TestUi {
fn with_totp(secret: Option<String>) -> Self {
Self {
- otp: "123456".into(),
+ otp: HARDCODED_OTT.into(),
totp_secret: secret,
allow_totp: true,
}
diff --git a/rust/e2e/tests/support/legacy.rs b/rust/e2e/tests/support/legacy.rs
index f2a5c0e39a..d5a66a9b56 100644
--- a/rust/e2e/tests/support/legacy.rs
+++ b/rust/e2e/tests/support/legacy.rs
@@ -4,7 +4,6 @@ use crate::support::{
};
use ente_contacts::client::ContactsCtx;
-#[derive(Clone)]
pub struct LegacyPairState {
pub owner: TestAccount,
pub trusted: TestAccount,
@@ -56,8 +55,3 @@ pub async fn open_pair(endpoint: &str, state: &LegacyPairState) -> LegacyPair {
trusted_ctx,
}
}
-
-pub fn persist_pair_state(state: &mut LegacyPairState, runtime: &LegacyPair) {
- state.owner = runtime.owner.clone();
- state.trusted = runtime.trusted.clone();
-}
diff --git a/rust/e2e/tests/support/legacy_kit.rs b/rust/e2e/tests/support/legacy_kit.rs
index 90e0ac50df..19c6ddec05 100644
--- a/rust/e2e/tests/support/legacy_kit.rs
+++ b/rust/e2e/tests/support/legacy_kit.rs
@@ -5,29 +5,13 @@ use crate::support::{
contacts,
};
-#[derive(Clone)]
-pub struct LegacyKitOwnerState {
- pub owner: TestAccount,
-}
-
pub struct LegacyKitOwner {
pub owner: TestAccount,
pub owner_ctx: ContactsCtx,
}
-pub async fn create_owner_state(endpoint: &str) -> LegacyKitOwnerState {
+pub async fn create_owner(endpoint: &str) -> LegacyKitOwner {
let owner = auth::create_account_strict(endpoint, "legacy-kit-owner", "LegacyKitOwner").await;
let owner_ctx = contacts::open_ctx(endpoint, &owner).await;
- drop(owner_ctx);
- LegacyKitOwnerState { owner }
-}
-
-pub async fn open_owner(endpoint: &str, state: &LegacyKitOwnerState) -> LegacyKitOwner {
- let owner = state.owner.clone();
- let owner_ctx = contacts::open_ctx(endpoint, &owner).await;
LegacyKitOwner { owner, owner_ctx }
}
-
-pub fn persist_owner_state(state: &mut LegacyKitOwnerState, runtime: &LegacyKitOwner) {
- state.owner = runtime.owner.clone();
-}
diff --git a/rust/e2e/tests/support/mod.rs b/rust/e2e/tests/support/mod.rs
index 12d2e2d161..bd79095276 100644
--- a/rust/e2e/tests/support/mod.rs
+++ b/rust/e2e/tests/support/mod.rs
@@ -2,34 +2,12 @@ pub mod auth;
pub mod contacts;
pub mod legacy;
pub mod legacy_kit;
-pub mod suite;
+use ente_test_support::HARDCODED_OTT_EMAIL_SUFFIX;
use std::collections::HashSet;
use uuid::Uuid;
-pub fn endpoint() -> String {
- std::env::var("ENTE_E2E_ENDPOINT").unwrap_or_else(|_| "http://localhost:8080".to_string())
-}
-
-pub async fn assert_server_or_skip(endpoint: &str, test_name: &str) -> bool {
- let ping_url = format!("{endpoint}/ping");
- match reqwest::get(&ping_url).await {
- Ok(response) if response.status().is_success() => true,
- Ok(response) => {
- eprintln!(
- "skipping {test_name}: {ping_url} returned {}",
- response.status()
- );
- false
- }
- Err(error) => {
- eprintln!("skipping {test_name}: could not reach {ping_url}: {error}");
- false
- }
- }
-}
-
-pub fn assert_stage_enabled_or_skip(stage_name: &str) -> bool {
+pub fn stage_enabled(stage_name: &str) -> bool {
let normalized_stage = stage_name.trim().to_ascii_lowercase();
if let Some(only) = env_list("ENTE_E2E_ONLY")
&& !only.contains(&normalized_stage)
@@ -67,7 +45,7 @@ fn env_list(name: &str) -> Option<HashSet<String>> {
}
pub fn unique_test_email(prefix: &str) -> String {
- format!("{prefix}-{}@ente-rust-test.org", Uuid::new_v4())
+ format!("{prefix}-{}{HARDCODED_OTT_EMAIL_SUFFIX}", Uuid::new_v4())
}
pub fn unique_password(prefix: &str) -> String {
diff --git a/rust/e2e/tests/support/suite.rs b/rust/e2e/tests/support/suite.rs
deleted file mode 100644
index a6b7697fd3..0000000000
--- a/rust/e2e/tests/support/suite.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-use tokio::sync::{Mutex, MutexGuard, OnceCell};
-
-use crate::support::{legacy, legacy_kit};
-
-pub struct SuiteState {
- pub legacy_pair: legacy::LegacyPairState,
- pub legacy_kit_owner: legacy_kit::LegacyKitOwnerState,
-}
-
-static SUITE: OnceCell<Mutex<SuiteState>> = OnceCell::const_new();
-
-pub async fn lock_suite(endpoint: &str) -> MutexGuard<'static, SuiteState> {
- let endpoint = endpoint.to_string();
- let suite = SUITE
- .get_or_init(|| async move {
- Mutex::new(SuiteState {
- legacy_pair: legacy::create_accepted_pair_state(&endpoint, 14).await,
- legacy_kit_owner: legacy_kit::create_owner_state(&endpoint).await,
- })
- })
- .await;
- suite.lock().await
-}