use super::{DiskFixture, Issuer, Lifecycle, TestResult, durable, pull_limits};
pub fn configure_sites(
disk: &DiskFixture,
issuer: &Issuer,
owners: &durable::ApprovalAgents,
lifecycle: &Lifecycle,
) -> TestResult {
use crate::services::lifecycle::site;
let pass_path = disk.directory.path().join("machine.pass");
std::fs::write(&pass_path, "connector-fixture")?;
let machine =
serde_json::from_value(serde_json::json!({"identity_path":"", "pass_path":pass_path}))?;
let effects = site::effects::LysSiteEffects::new(
std::sync::Arc::new(crate::services::lys_http::HttpLys::new(
&issuer.api,
tokio::runtime::Handle::current(),
)?),
Some(crate::link_pass::MachinePass::configured(&machine)?),
owners.agents().clone(),
site::effects::GrantSources {
plan: "fixture-plan".into(),
serve: "fixture-serve".into(),
credential_path: None,
placement: None,
},
pull_limits()?.metadata_bytes,
);
let capacity: site::SiteLimits = serde_json::from_value(
serde_json::json!({"sites":8,"subjects":8,"schema_bytes":1024,"text_bytes":1024,"steps":8,"transitions":8,"drafts":8,"approvers":2,"snapshot_bytes":1_048_576,"request_bytes":4096}),
)?;
lifecycle.configure_sites(
capacity,
disk.store.clone(),
None,
std::sync::Arc::new(effects),
owners.agents().retained().clone(),
)?;
Ok(())
}