Skip to content

Commit daab991

Browse files
committed
fix(test): bootstrap the durable trust superuser identity in test harnesses
Replace ad-hoc create_user calls with bootstrap_trust_superuser / bootstrap_superuser so trust-mode listeners resolve the configured principal that configured_trust_identity expects on the first native frame, matching production bootstrap instead of fabricating an ephemeral identity.
1 parent 9e9cba3 commit daab991

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

  • nodedb-test-support/src/native_harness
  • nodedb/src/control/server/session

nodedb-test-support/src/native_harness/server.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ impl NativeTestServer {
5959
nodedb::control::security::credential::store::CredentialStore::open(&catalog_path)
6060
.expect("open credential store");
6161
let credentials = Arc::new(credential_store);
62-
// Provision the harness superuser `nodedb` so Trust-mode strict
63-
// identity resolution accepts the default test connection.
64-
let _ = credentials.create_user(
65-
"nodedb",
66-
"nodedb",
67-
nodedb::types::TenantId::new(1),
68-
vec![nodedb::control::security::identity::Role::Superuser],
69-
);
62+
// Mirror production bootstrap so trust-mode listeners resolve a durable
63+
// configured principal rather than fabricating an ephemeral identity.
64+
// The configured trust superuser is what `configured_trust_identity`
65+
// reads on the first native frame; `create_user` alone does not set it.
66+
match auth_mode {
67+
AuthMode::Trust => credentials
68+
.bootstrap_trust_superuser("nodedb")
69+
.expect("bootstrap trust superuser"),
70+
_ => credentials
71+
.bootstrap_superuser("nodedb", "nodedb")
72+
.expect("bootstrap password superuser"),
73+
}
7074
// Ensure the built-in `default` database (id 0) is present in the
7175
// catalog so the default connection database works in tests.
7276
let _ = credentials.catalog().bootstrap_default_database();

nodedb/src/control/server/session/tests.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ async fn full_request_response_roundtrip() {
2222

2323
let (dispatcher, data_sides) = Dispatcher::new(1, 64);
2424
let shared = SharedState::new(dispatcher, wal).unwrap();
25+
// Trust-mode sessions auto-authenticate as the configured durable principal
26+
// on the first frame; materialize it so `configured_trust_identity` resolves
27+
// instead of rejecting with "configured trust identity is unavailable".
28+
shared
29+
.credentials
30+
.bootstrap_trust_superuser("nodedb")
31+
.expect("bootstrap trust superuser");
2532

2633
// Start a Data Plane core in a background thread.
2734
let data_side = data_sides.into_iter().next().unwrap();

0 commit comments

Comments
 (0)