fix: assert typed registration causes separately from attribution lifecycle
This commit is contained in:
+44
-10
@@ -13152,8 +13152,24 @@ mod build_summary_prompt_tests {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
}),
|
}),
|
||||||
AttributionOutcome::Rejected => Ok(WorkspaceResponse {
|
AttributionOutcome::Rejected => Ok(WorkspaceResponse {
|
||||||
status: 503,
|
status: 403,
|
||||||
body: "temporarily unavailable".to_string(),
|
body: serde_json::to_string(
|
||||||
|
&server_api::RepositoryApiError::new(
|
||||||
|
403,
|
||||||
|
"PermissionDenied",
|
||||||
|
"Session registration permission denied.",
|
||||||
|
Vec::new(),
|
||||||
|
)
|
||||||
|
.with_failure(
|
||||||
|
protocol::session_failure::session_registration_attachment(
|
||||||
|
protocol::session_failure::SessionRegistrationCause::denied(
|
||||||
|
protocol::session_failure::SessionPrincipal::Subject,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
}),
|
}),
|
||||||
AttributionOutcome::Success => {
|
AttributionOutcome::Success => {
|
||||||
let input: server_api::SubjektivRecordSessionRequest =
|
let input: server_api::SubjektivRecordSessionRequest =
|
||||||
@@ -13484,10 +13500,23 @@ mod build_summary_prompt_tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn unknown_and_failed_attribution_remain_incomplete_until_lifecycle_retry() {
|
async fn unknown_and_failed_attribution_remain_incomplete_until_lifecycle_retry() {
|
||||||
for (first, expected_state) in [
|
use protocol::session_failure::{SessionPrincipal, SessionRegistrationCause};
|
||||||
(AttributionOutcome::TransportUnknown, "outcome_unknown"),
|
for (first, expected_state, expected_cause) in [
|
||||||
(AttributionOutcome::Rejected, "failed"),
|
(
|
||||||
(AttributionOutcome::Unauthorized, "failed"),
|
AttributionOutcome::TransportUnknown,
|
||||||
|
"outcome_unknown",
|
||||||
|
SessionRegistrationCause::outcome_unknown(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
AttributionOutcome::Rejected,
|
||||||
|
"failed",
|
||||||
|
SessionRegistrationCause::denied(SessionPrincipal::Subject),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
AttributionOutcome::Unauthorized,
|
||||||
|
"outcome_unknown",
|
||||||
|
SessionRegistrationCause::outcome_unknown(),
|
||||||
|
),
|
||||||
] {
|
] {
|
||||||
let client = Arc::new(AttributionLifecycleClient::new([
|
let client = Arc::new(AttributionLifecycleClient::new([
|
||||||
first,
|
first,
|
||||||
@@ -13500,10 +13529,10 @@ mod build_summary_prompt_tests {
|
|||||||
SubjektivSessionAttributionLifecycle::NewSession,
|
SubjektivSessionAttributionLifecycle::NewSession,
|
||||||
)
|
)
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
assert!(error.to_string().contains(expected_state));
|
assert_eq!(error.session_registration_cause(), Some(expected_cause));
|
||||||
if matches!(first, AttributionOutcome::Unauthorized) {
|
if matches!(first, AttributionOutcome::Unauthorized) {
|
||||||
assert!(error.to_string().contains("rejected with HTTP 401"));
|
// A legacy HTTP status is not a domain authorization attestation.
|
||||||
assert!(!error.to_string().contains("outcome_unknown"));
|
// Attribution remains incomplete and no implicit retry is issued.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client.requests.lock().unwrap().len(),
|
client.requests.lock().unwrap().len(),
|
||||||
1,
|
1,
|
||||||
@@ -13672,7 +13701,12 @@ mod build_summary_prompt_tests {
|
|||||||
)
|
)
|
||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
|
|
||||||
assert!(error.to_string().contains("legacy_unknown"));
|
assert_eq!(
|
||||||
|
error.session_registration_cause(),
|
||||||
|
Some(protocol::session_failure::SessionRegistrationCause::denied(
|
||||||
|
protocol::session_failure::SessionPrincipal::Subject,
|
||||||
|
)),
|
||||||
|
);
|
||||||
let requests = client.requests.lock().unwrap();
|
let requests = client.requests.lock().unwrap();
|
||||||
assert_eq!(requests.len(), 1);
|
assert_eq!(requests.len(), 1);
|
||||||
let request: server_api::SubjektivRecordSessionRequest =
|
let request: server_api::SubjektivRecordSessionRequest =
|
||||||
|
|||||||
Reference in New Issue
Block a user