Files
NLnetLabs-krill/tests/auth_check.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

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(_)
)
)
);
}