fix: retain Session domain in factory binding regression fixtures
This commit is contained in:
@@ -3,6 +3,9 @@ mod startup_binding_tests {
|
|||||||
//! real aggregate/Session stores and reopen. Only the Workspace response is
|
//! real aggregate/Session stores and reopen. Only the Workspace response is
|
||||||
//! synthetic; this suite does not test domain authorization or network transport.
|
//! synthetic; this suite does not test domain authorization or network transport.
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use protocol::session_failure::{
|
||||||
|
SessionPrincipal, SessionRegistrationCause, session_registration_attachment,
|
||||||
|
};
|
||||||
use protocol::startup_failure::{RuntimeStartupCause, StartupPersistenceOutcome};
|
use protocol::startup_failure::{RuntimeStartupCause, StartupPersistenceOutcome};
|
||||||
use session_store::worker_metadata::StartupFailureRead;
|
use session_store::worker_metadata::StartupFailureRead;
|
||||||
use worker::{WorkspaceClientError, WorkspaceRequest, WorkspaceResponse};
|
use worker::{WorkspaceClientError, WorkspaceRequest, WorkspaceResponse};
|
||||||
@@ -67,13 +70,27 @@ mod startup_binding_tests {
|
|||||||
_ => self.store.read_by_name(&self.name).unwrap().unwrap(),
|
_ => self.store.read_by_name(&self.name).unwrap().unwrap(),
|
||||||
};
|
};
|
||||||
if matches!(self.response, Response::Lost) {
|
if matches!(self.response, Response::Lost) {
|
||||||
return Err(WorkspaceClientError::Unavailable(
|
return Err(WorkspaceClientError::Request(
|
||||||
"response deliberately lost".into(),
|
"response deliberately lost".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Ok(WorkspaceResponse {
|
Ok(WorkspaceResponse {
|
||||||
status: 403,
|
status: 403,
|
||||||
body: "synthetic rejection with private token /internal/path".into(),
|
body: serde_json::to_string(
|
||||||
|
&server_api::RepositoryApiError::new(
|
||||||
|
403,
|
||||||
|
"PermissionDenied",
|
||||||
|
"synthetic rejection with private token /internal/path",
|
||||||
|
vec![],
|
||||||
|
)
|
||||||
|
.with_failure(
|
||||||
|
session_registration_attachment(SessionRegistrationCause::denied(
|
||||||
|
SessionPrincipal::Subject,
|
||||||
|
))
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,8 +155,25 @@ mod startup_binding_tests {
|
|||||||
.err()
|
.err()
|
||||||
.expect("failure must remain a failure");
|
.expect("failure must remain a failure");
|
||||||
let result = failure.execution_result(WorkerExecutionOperation::Spawn);
|
let result = failure.execution_result(WorkerExecutionOperation::Spawn);
|
||||||
let primary = result.startup_failure::<RuntimeStartupCause>().unwrap();
|
if matches!(response, Response::BeforeSession | Response::BeforeOwner) {
|
||||||
assert!(matches!(primary, error_contract::DecodeFailure::Known(_)));
|
let primary = result.startup_failure::<RuntimeStartupCause>().unwrap();
|
||||||
|
assert!(matches!(primary, error_contract::DecodeFailure::Known(_)));
|
||||||
|
} else {
|
||||||
|
let error_contract::DecodeFailure::Known(primary) = result
|
||||||
|
.startup_failure::<SessionRegistrationCause>()
|
||||||
|
.unwrap()
|
||||||
|
else {
|
||||||
|
panic!("a Session decision must not be relabeled as a generic Runtime failure");
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
*primary.facts().cause(),
|
||||||
|
if matches!(response, Response::Lost) {
|
||||||
|
SessionRegistrationCause::outcome_unknown()
|
||||||
|
} else {
|
||||||
|
SessionRegistrationCause::denied(SessionPrincipal::Subject)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
drop(worker);
|
drop(worker);
|
||||||
drop(store);
|
drop(store);
|
||||||
let reopened = WorkerAggregateStore::new(root.path(), name).unwrap();
|
let reopened = WorkerAggregateStore::new(root.path(), name).unwrap();
|
||||||
@@ -151,13 +185,17 @@ mod startup_binding_tests {
|
|||||||
Some(StartupPersistenceOutcome::Persisted)
|
Some(StartupPersistenceOutcome::Persisted)
|
||||||
);
|
);
|
||||||
let StartupFailureRead::Present(error_contract::DecodeFailure::Known(cause)) =
|
let StartupFailureRead::Present(error_contract::DecodeFailure::Known(cause)) =
|
||||||
metadata.decode_startup_failure::<RuntimeStartupCause>()
|
metadata.decode_startup_failure::<SessionRegistrationCause>()
|
||||||
else {
|
else {
|
||||||
panic!("same-Session failure must actually save a typed cause")
|
panic!("same-Session failure must actually save a typed cause")
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cause.facts().cause().reason,
|
*cause.facts().cause(),
|
||||||
protocol::startup_failure::RuntimeStartupReason::AttributionFailed
|
if matches!(response, Response::Lost) {
|
||||||
|
SessionRegistrationCause::outcome_unknown()
|
||||||
|
} else {
|
||||||
|
SessionRegistrationCause::denied(SessionPrincipal::Subject)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(metadata.active.unwrap().session_id, origin);
|
assert_eq!(metadata.active.unwrap().session_id, origin);
|
||||||
let saved = serde_json::to_string(&metadata.startup_failure).unwrap();
|
let saved = serde_json::to_string(&metadata.startup_failure).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user