|
9 | 9 | //! backends behind `dyn` with no enum over concrete state, and that one driver |
10 | 10 | //! runs both unchanged. |
11 | 11 |
|
| 12 | +use std::collections::BTreeMap; |
12 | 13 | use std::marker::PhantomData; |
13 | | -use std::sync::Mutex; |
| 14 | +use std::path::PathBuf; |
14 | 15 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 16 | +use std::sync::{Arc, Mutex}; |
15 | 17 |
|
16 | | -use super::*; |
| 18 | +use async_trait::async_trait; |
| 19 | +use openshell_isolation_interface::contract::*; |
| 20 | +use tokio::sync::oneshot; |
17 | 21 |
|
18 | 22 | // --------------------------------------------------------------------------- |
19 | 23 | // Marker kinds: two materially different backends. |
@@ -211,10 +215,11 @@ impl<K: MockKind> BoundBoundary for MockBound<K> { |
211 | 215 | self.source.clone() |
212 | 216 | } |
213 | 217 | async fn confirm(self: Box<Self>) -> Result<ConfirmedBoundary, BackendError> { |
214 | | - Ok(ConfirmedBoundary::new( |
| 218 | + ConfirmedBoundary::try_new( |
215 | 219 | Box::new(MockReady::<K> { _k: PhantomData }), |
216 | 220 | confirmation_evidence(), |
217 | | - )) |
| 221 | + &workload_identity(), |
| 222 | + ) |
218 | 223 | } |
219 | 224 | } |
220 | 225 |
|
@@ -389,8 +394,8 @@ async fn drive( |
389 | 394 | let _ingress = bound.network_mediation_source(); |
390 | 395 | assert_eq!(bound.host_gateway_ip(), None); |
391 | 396 | let confirmed = bound.confirm().await?; |
392 | | - confirmed.evidence.validate(&sandbox_ctx().identity)?; |
393 | | - confirmed.boundary.start_agent().await |
| 397 | + confirmed.evidence().validate(&sandbox_ctx().identity)?; |
| 398 | + confirmed.into_boundary().start_agent().await |
394 | 399 | } |
395 | 400 |
|
396 | 401 | // --------------------------------------------------------------------------- |
@@ -466,6 +471,36 @@ async fn one_driver_runs_both_backends() { |
466 | 471 | ); |
467 | 472 | } |
468 | 473 |
|
| 474 | +#[test] |
| 475 | +fn confirmation_constructor_rejects_incomplete_evidence() { |
| 476 | + let mut evidence = confirmation_evidence(); |
| 477 | + evidence.seccomp.cancellation = false; |
| 478 | + let result = ConfirmedBoundary::try_new( |
| 479 | + Box::new(MockReady::<Primary> { _k: PhantomData }), |
| 480 | + evidence, |
| 481 | + &workload_identity(), |
| 482 | + ); |
| 483 | + assert!(matches!(result, Err(BackendError::Confirm(_)))); |
| 484 | +} |
| 485 | + |
| 486 | +#[test] |
| 487 | +fn confirmation_constructor_rejects_another_workload_identity() { |
| 488 | + let expected = ResolvedWorkloadIdentity::new( |
| 489 | + 1001, |
| 490 | + 1001, |
| 491 | + vec![1001], |
| 492 | + "policy".to_string(), |
| 493 | + "sha256:test".to_string(), |
| 494 | + ) |
| 495 | + .unwrap(); |
| 496 | + let result = ConfirmedBoundary::try_new( |
| 497 | + Box::new(MockReady::<Primary> { _k: PhantomData }), |
| 498 | + confirmation_evidence(), |
| 499 | + &expected, |
| 500 | + ); |
| 501 | + assert!(matches!(result, Err(BackendError::Confirm(_)))); |
| 502 | +} |
| 503 | + |
469 | 504 | #[tokio::test] |
470 | 505 | async fn one_boundary_termination_does_not_change_another_boundary() { |
471 | 506 | let reg = registry(); |
@@ -519,7 +554,11 @@ async fn runtime_interfaces_survive_lifecycle_consumption() { |
519 | 554 | // The retained Arc must remain usable afterward. |
520 | 555 | let source = bound.network_mediation_source(); |
521 | 556 | let confirmed = bound.confirm().await.expect("confirm"); |
522 | | - let _running = confirmed.boundary.start_agent().await.expect("start"); |
| 557 | + let _running = confirmed |
| 558 | + .into_boundary() |
| 559 | + .start_agent() |
| 560 | + .await |
| 561 | + .expect("start"); |
523 | 562 |
|
524 | 563 | let conn = source.accept().await.expect("accept after consumption"); |
525 | 564 | let identity = conn.binary_identity.expect("identity resolves"); |
|
0 commit comments