Bind the simulated Windows echo review to one persistent job scope
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -27,8 +27,8 @@ type Result<T> = std::result::Result<T, Error>;
|
||||
const CASE_AGENT: Uuid = Uuid::from_u128(0x63ea15b20643403db5b4cba1288dbea3);
|
||||
const CASE_ASSET: Uuid = Uuid::from_u128(0xa176520e8a914e93a78b8e7620f430e0);
|
||||
const CASE_TENANT: Uuid = Uuid::from_u128(0x11111111111141118111111111111111);
|
||||
const FIRST: Uuid = Uuid::from_u128(0xb6a3101f68ad41c8be4e4c7c2bc963d6);
|
||||
const DENIED: Uuid = Uuid::from_u128(0x0633a4de7e524e5da2a159fb134817fe);
|
||||
pub(super) const FIRST: Uuid = Uuid::from_u128(0xb6a3101f68ad41c8be4e4c7c2bc963d6);
|
||||
pub(super) const DENIED: Uuid = Uuid::from_u128(0x0633a4de7e524e5da2a159fb134817fe);
|
||||
const CERTIFICATE: &str = "c55aa8214cb8d60382fe453bddd56c6e46fa79b61ccefda502e001be56bb5075";
|
||||
|
||||
fn changed() -> Error {
|
||||
@@ -54,7 +54,12 @@ pub fn routes(r: Router<crate::State>) -> Router<crate::State> {
|
||||
get(download),
|
||||
)
|
||||
}
|
||||
async fn access(s: &crate::State, h: &HeaderMap, t: Uuid, write: bool) -> Result<Principal> {
|
||||
pub(super) async fn access(
|
||||
s: &crate::State,
|
||||
h: &HeaderMap,
|
||||
t: Uuid,
|
||||
write: bool,
|
||||
) -> Result<Principal> {
|
||||
let p = s
|
||||
.auth
|
||||
.principal(s, h, write)
|
||||
@@ -181,6 +186,23 @@ async fn verify_case(
|
||||
s: &crate::State,
|
||||
w: &Value,
|
||||
promoted: bool,
|
||||
) -> Result<()> {
|
||||
verify_case_state(tx, s, w, promoted, false).await
|
||||
}
|
||||
pub(super) async fn verify_probe_case(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
s: &crate::State,
|
||||
w: &Value,
|
||||
promoted: bool,
|
||||
) -> Result<()> {
|
||||
verify_case_state(tx, s, w, promoted, true).await
|
||||
}
|
||||
async fn verify_case_state(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
s: &crate::State,
|
||||
w: &Value,
|
||||
promoted: bool,
|
||||
probe: bool,
|
||||
) -> Result<()> {
|
||||
crate::agent_service::control_lock(tx, CASE_TENANT, CASE_AGENT).await?;
|
||||
let dev=sqlx::query("SELECT asset_id,certificate_sha256,enrollment_generation,assignment_version,connection_generation,connection_boot_id,capabilities,revoked_at IS NULL AS active,restore_blocked,sequence_regressed,sync_recovery_required,sync_required
|
||||
@@ -201,8 +223,36 @@ async fn verify_case(
|
||||
|| !dev.get::<bool, _>("restore_blocked")
|
||||
|| dev.get::<bool, _>("sequence_regressed")
|
||||
|| dev.get::<bool, _>("sync_recovery_required")
|
||||
|| dev.get::<bool, _>("sync_required")
|
||||
|| caps != ["agent.update/1", "heartbeat/1", "windows.base/1"]
|
||||
|| if probe {
|
||||
!dev.get::<bool, _>("sync_required")
|
||||
|| ![
|
||||
"windows.base/1",
|
||||
"windows.echo-probe/1",
|
||||
"run_script",
|
||||
"rmm.sync.v1",
|
||||
"script.powershell/1",
|
||||
"script.powershell.process_remote_signed/1",
|
||||
]
|
||||
.iter()
|
||||
.all(|k| caps.iter().any(|c| c == k))
|
||||
|| caps.iter().any(|k| {
|
||||
![
|
||||
"windows.base/1",
|
||||
"windows.echo-probe/1",
|
||||
"run_script",
|
||||
"rmm.sync.v1",
|
||||
"script.powershell/1",
|
||||
"script.powershell.process_remote_signed/1",
|
||||
"heartbeat/1",
|
||||
"agent.update/1",
|
||||
"refresh_inventory",
|
||||
]
|
||||
.contains(&k.as_str())
|
||||
})
|
||||
} else {
|
||||
dev.get::<bool, _>("sync_required")
|
||||
|| caps != ["agent.update/1", "heartbeat/1", "windows.base/1"]
|
||||
}
|
||||
{
|
||||
return Err(changed());
|
||||
}
|
||||
@@ -441,13 +491,21 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "requires a fresh isolated PostgreSQL database"]
|
||||
async fn isolated_windows_checkpoint_human_review() {
|
||||
let admin = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_ADMIN_URL").unwrap())
|
||||
async fn fixture(
|
||||
admin_var: &str,
|
||||
app_var: &str,
|
||||
) -> (
|
||||
sqlx::PgPool,
|
||||
crate::State,
|
||||
Principal,
|
||||
Value,
|
||||
Uuid,
|
||||
std::path::PathBuf,
|
||||
) {
|
||||
let admin = sqlx::PgPool::connect(&std::env::var(admin_var).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
let pool = sqlx::PgPool::connect(&std::env::var("RMM_TEST_REPAIR_APP_URL").unwrap())
|
||||
let pool = sqlx::PgPool::connect(&std::env::var(app_var).unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
rmm_persistence::verify_application_role(&pool)
|
||||
@@ -529,6 +587,22 @@ mod tests {
|
||||
.bind(CASE_TENANT).bind(&p.name).execute(&admin).await.unwrap();
|
||||
sqlx::query("INSERT INTO windows_checkpoint_reviews(tenant_id,request_id,asset_id,agent_id,witness,witness_sha256,requested_by) VALUES($1,$2,$3,$4,$5,$6,'fixture-submitter')")
|
||||
.bind(CASE_TENANT).bind(request).bind(CASE_ASSET).bind(CASE_AGENT).bind(&w).bind(&digest).execute(&admin).await.unwrap();
|
||||
(admin, s, p, w, request, tmp)
|
||||
}
|
||||
#[tokio::test]
|
||||
#[ignore = "requires a fresh isolated PostgreSQL database"]
|
||||
async fn isolated_windows_echo_scope() {
|
||||
let (admin, s, p, w, _, tmp) =
|
||||
fixture("RMM_TEST_ECHO_ADMIN_URL", "RMM_TEST_ECHO_APP_URL").await;
|
||||
crate::windows_echo_probe::test_fixed_echo(&admin, &s, p, w).await;
|
||||
std::fs::remove_dir_all(tmp).unwrap();
|
||||
}
|
||||
#[tokio::test]
|
||||
#[ignore = "requires a fresh isolated PostgreSQL database"]
|
||||
async fn isolated_windows_checkpoint_human_review() {
|
||||
let (admin, s, p, w, request, tmp) =
|
||||
fixture("RMM_TEST_REPAIR_ADMIN_URL", "RMM_TEST_REPAIR_APP_URL").await;
|
||||
let digest = inventory_sha256(&w).unwrap();
|
||||
let confirmation = || Confirmation {
|
||||
reviewed: true,
|
||||
witness_sha256: digest.clone(),
|
||||
|
||||
Reference in New Issue
Block a user