Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nexus/tests/integration_tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! This is used for various authz-related tests.
//! THERE ARE NO TESTS IN THIS FILE.

use crate::integration_tests::unauthorized::HTTP_SERVER;
use http::method::Method;
use lazy_static::lazy_static;
use nexus_test_utils::RACK_UUID;
Expand Down Expand Up @@ -234,7 +235,7 @@ lazy_static! {
name: DEMO_IMAGE_NAME.clone(),
description: String::from(""),
},
source: params::ImageSource::Url(String::from("http://127.0.0.1:5555/image.raw")),
source: params::ImageSource::Url(HTTP_SERVER.url("/image.raw").to_string()),
block_size: params::BlockSize::try_from(4096).unwrap(),
};

Expand Down
39 changes: 20 additions & 19 deletions nexus/tests/integration_tests/unauthorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ async fn test_unauthorized(cptestctx: &ControlPlaneTestContext) {
let client = &cptestctx.external_client;
let log = &cptestctx.logctx.log;

// Run a httptest server
let server = ServerBuilder::new()
.bind_addr("127.0.0.1:5555".parse().unwrap())
.run()
.unwrap();

// Fake some data
server.expect(
Expectation::matching(request::method_path("HEAD", "/image.raw"))
.times(1..)
.respond_with(
status_code(200).append_header(
"Content-Length",
format!("{}", 4096 * 1000),
),
),
);

// Create test data.
info!(log, "setting up resource hierarchy");
for request in &*SETUP_REQUESTS {
Expand Down Expand Up @@ -118,7 +100,7 @@ EXAMPLE: 0 3111 5555 3111 5555 5555 0 /organizations
The number in each cell is the last digit of the 400-level response
that was expected for this test case.

In this case, an unauthenthicated request to "GET /organizations" returned
In this case, an unauthenticated request to "GET /organizations" returned
401. All requests to "PUT /organizations" returned 405.

G GET PUT POST DEL TRCE G URL
Expand All @@ -141,6 +123,25 @@ struct SetupReq {
}

lazy_static! {
pub static ref HTTP_SERVER: httptest::Server = {
// Run a httptest server
let server = ServerBuilder::new().run().unwrap();

// Fake some data
server.expect(
Expectation::matching(request::method_path("HEAD", "/image.raw"))
.times(1..)
.respond_with(
status_code(200).append_header(
"Content-Length",
format!("{}", 4096 * 1000),
),
),
);

server
};

/// List of requests to execute at setup time
static ref SETUP_REQUESTS: Vec<SetupReq> = vec![
// Create a separate Silo (not used for anything else)
Expand Down