MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_auth_intermediate_ca

Function test_auth_intermediate_ca

src/environmentd/tests/auth.rs:2635–2693  ·  view source on GitHub ↗

unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`

()

Source from the content-addressed store, hash-verified

2633#[mz_ore::test(tokio::test(flavor = "multi_thread", worker_threads = 1))]
2634#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`
2635async fn test_auth_intermediate_ca() {
2636 // Create a CA, an intermediate CA, and a server key pair signed by the
2637 // intermediate CA.
2638 let ca = Ca::new_root("test ca").unwrap();
2639 let intermediate_ca = ca.request_ca("intermediary").unwrap();
2640 let (server_cert, server_key) = intermediate_ca
2641 .request_cert("server", vec![IpAddr::V4(Ipv4Addr::LOCALHOST)])
2642 .unwrap();
2643
2644 // Create a certificate chain bundle that contains the server's certificate
2645 // and the intermediate CA's certificate.
2646 let server_cert_chain = {
2647 let path = intermediate_ca.dir.path().join("server.chain.crt");
2648 let mut buf = vec![];
2649 File::open(server_cert)
2650 .unwrap()
2651 .read_to_end(&mut buf)
2652 .unwrap();
2653 File::open(intermediate_ca.ca_cert_path())
2654 .unwrap()
2655 .read_to_end(&mut buf)
2656 .unwrap();
2657 fs::write(&path, buf).unwrap();
2658 path
2659 };
2660
2661 // When the server is configured to present the entire certificate chain,
2662 // the client should be able to verify the chain even though it only knows
2663 // about the root CA.
2664 let server = test_util::TestHarness::default()
2665 .with_tls(server_cert_chain, server_key)
2666 .start()
2667 .await;
2668
2669 run_tests(
2670 "TlsMode::Require",
2671 &server,
2672 &[
2673 TestCase::Pgwire {
2674 user_to_auth_as: "materialize",
2675 user_reported_by_system: "materialize",
2676 password: None,
2677 ssl_mode: SslMode::Require,
2678 options: None,
2679 configure: Box::new(|b| b.set_ca_file(ca.ca_cert_path())),
2680 assert: Assert::Success,
2681 },
2682 TestCase::Http {
2683 user_to_auth_as: &*HTTP_DEFAULT_USER.name,
2684 user_reported_by_system: &*HTTP_DEFAULT_USER.name,
2685 scheme: Scheme::HTTPS,
2686 headers: &HeaderMap::new(),
2687 configure: Box::new(|b| b.set_ca_file(ca.ca_cert_path())),
2688 assert: Assert::Success,
2689 },
2690 ],
2691 )
2692 .await;

Callers

nothing calls this directly

Calls 10

writeFunction · 0.85
unwrapMethod · 0.80
request_caMethod · 0.80
request_certMethod · 0.80
ca_cert_pathMethod · 0.80
with_tlsMethod · 0.80
run_testsFunction · 0.70
joinMethod · 0.45
pathMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected