Files
NLnetLabs-krill/tests/suspend.rs
T
Martin HoffmannandGitHub 6d253c22da Refactor cli to use clap’s derive. (#1228)
This PR changes how the clients -- krillc, krillta, as well as the
integration tests -- work to better fit the derive model provided by clap.
This results in basically everything in the cli module and all the
integration tests being different now.

The PR slightly changes the options for both krillc and krillta. For krillc,
the --server, --token, --format, and --api options are now before the first
subcommand (since they affect all commands). For krillta, those options are
now after krillta proxy but before the next subcommand, while --format is
now after krillta signer.

This PR also removes client support and integration tests for RTA.

This is a breaking change.
2024-08-20 14:05:06 +02:00

106 lines
3.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Test suspension and un-suspension logic.
use rpki::ca::idexchange::CaHandle;
use rpki::repository::resources::ResourceSet;
use krill::commons::api::UpdateChildRequest;
mod common;
//------------ Test Function -------------------------------------------------
/// Tests suspension and un-suspension.
///
/// Uses the following layout:
/// ```test
/// TA
/// |
/// testbed
/// |
/// CA
/// ```
#[tokio::test]
async fn test_suspension() {
let (config, _tmpdir) = common::TestConfig::mem_storage()
.enable_testbed().enable_suspend().finalize();
let server = common::KrillServer::start_with_config(config).await;
let testbed = common::ca_handle("testbed");
let ca = common::ca_handle("CA");
let ca_res = common::ipv4_resources("10.0.0.0/16");
// Wait for the *testbed* CA to get its certificate, this means
// that all CAs which are set up as part of krill_start under the
// testbed config have been set up.
assert!(
server.wait_for_ca_resources(&testbed, &ResourceSet::all()).await
);
eprintln!(">>>> Set up CA under testbed and its cert is published.");
server.create_ca_with_repo(&ca).await;
server.register_ca_with_parent(&ca, &testbed, &ca_res).await;
eprintln!(">>>> Verify that testbed publishes the cert and it is active");
server.expect_not_suspended(&testbed, &ca).await;
eprintln!(">>>> Wait a bit.");
common::sleep_seconds(15).await;
eprintln!(">>>> Refresh testbed only, check that CA is suspended.");
// This happens because CA isnt updating.
server.client().ca_sync_parents(&testbed).await.unwrap();
server.client().bulk_suspend().await.unwrap();
server.expect_suspended(&testbed, &ca).await;
eprintln!(">>>> Let CA refresh with testbed, this should un-suspend it.");
server.client().ca_sync_parents(&ca).await.unwrap();
server.client().bulk_suspend().await.unwrap();
server.expect_not_suspended(&testbed, &ca).await;
eprintln!(">>>> Explicitly suspend CA.");
server.client().child_update(
&testbed, &ca.convert(),
UpdateChildRequest::suspend()
).await.unwrap();
server.expect_suspended(&testbed, &ca).await;
eprintln!(">>>> Explicitly un-suspend CA.");
server.client().child_update(
&testbed, &ca.convert(),
UpdateChildRequest::unsuspend()
).await.unwrap();
server.expect_not_suspended(&testbed, &ca).await;
}
//------------ Extend KrillServer --------------------------------------------
impl common::KrillServer {
async fn expect_not_suspended(&self, ca: &CaHandle, child: &CaHandle) {
let rcn0 = common::rcn(0);
let child_handle = child.convert();
let mut files = self.expected_objects(ca);
files.push_mft_and_crl(&rcn0).await;
files.push_cer(child, &rcn0).await;
assert!(files.wait_for_published().await);
let ca_info = self.client().ca_details(ca).await.unwrap();
assert!(ca_info.children().contains(&child_handle));
assert!(!ca_info.suspended_children().contains(&child_handle));
}
async fn expect_suspended(&self, ca: &CaHandle, child: &CaHandle) {
let rcn0 = common::rcn(0);
let child_handle = child.convert();
let mut files = self.expected_objects(ca);
files.push_mft_and_crl(&rcn0).await;
assert!(files.wait_for_published().await);
let ca_info = self.client().ca_details(ca).await.unwrap();
assert!(ca_info.children().contains(&child_handle));
assert!(ca_info.suspended_children().contains(&child_handle));
}
}