mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-20 16:37:43 +02:00
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.
33 lines
876 B
Rust
33 lines
876 B
Rust
//! Rust integration test to verify that invoking the restricted create CA
|
|
//! REST API requires a valid bearer token.
|
|
|
|
use hyper::StatusCode;
|
|
use krill::commons::util::httpclient;
|
|
|
|
mod common;
|
|
|
|
|
|
#[tokio::test]
|
|
async fn auth_check() {
|
|
let (server, _tempdir) = common::KrillServer::start().await;
|
|
|
|
// Get a client and change its auth token.
|
|
let mut client = server.client().clone();
|
|
client.set_token("wrong secret".into());
|
|
|
|
// Now try and create a CA. This should fail with a “Forbidden” error.
|
|
let res = client.ca_add(common::ca_handle("dummy_ca")).await;
|
|
dbg!(&res);
|
|
assert!(
|
|
matches!(
|
|
res,
|
|
Err(
|
|
httpclient::Error::ErrorResponseWithJson(
|
|
_, StatusCode::UNAUTHORIZED, _
|
|
)
|
|
| httpclient::Error::Forbidden(_)
|
|
)
|
|
)
|
|
);
|
|
}
|