From a3288e34c5432708e15816fcf26a0719d86f9473 Mon Sep 17 00:00:00 2001 From: Sam Clark <3758302+goatgoose@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:20:19 -0400 Subject: [PATCH] test(bindings): Consolidate test pems --- .../examples => }/certs/cert.pem | 0 .../examples => }/certs/cert_rsa.pem | 0 .../examples => }/certs/generate.sh | 0 .../examples => }/certs/key.pem | 0 .../examples => }/certs/key_rsa.pem | 0 .../rust/s2n-tls-tokio/examples/client.rs | 2 +- .../rust/s2n-tls-tokio/examples/server.rs | 4 ++-- .../rust/s2n-tls-tokio/tests/common/mod.rs | 20 +++++++------------ bindings/rust/s2n-tls/src/callbacks/pkey.rs | 10 ++-------- bindings/rust/s2n-tls/src/testing/s2n_tls.rs | 12 +++++------ 10 files changed, 18 insertions(+), 30 deletions(-) rename bindings/rust/{s2n-tls-tokio/examples => }/certs/cert.pem (100%) rename bindings/rust/{s2n-tls-tokio/examples => }/certs/cert_rsa.pem (100%) rename bindings/rust/{s2n-tls-tokio/examples => }/certs/generate.sh (100%) rename bindings/rust/{s2n-tls-tokio/examples => }/certs/key.pem (100%) rename bindings/rust/{s2n-tls-tokio/examples => }/certs/key_rsa.pem (100%) diff --git a/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem b/bindings/rust/certs/cert.pem similarity index 100% rename from bindings/rust/s2n-tls-tokio/examples/certs/cert.pem rename to bindings/rust/certs/cert.pem diff --git a/bindings/rust/s2n-tls-tokio/examples/certs/cert_rsa.pem b/bindings/rust/certs/cert_rsa.pem similarity index 100% rename from bindings/rust/s2n-tls-tokio/examples/certs/cert_rsa.pem rename to bindings/rust/certs/cert_rsa.pem diff --git a/bindings/rust/s2n-tls-tokio/examples/certs/generate.sh b/bindings/rust/certs/generate.sh similarity index 100% rename from bindings/rust/s2n-tls-tokio/examples/certs/generate.sh rename to bindings/rust/certs/generate.sh diff --git a/bindings/rust/s2n-tls-tokio/examples/certs/key.pem b/bindings/rust/certs/key.pem similarity index 100% rename from bindings/rust/s2n-tls-tokio/examples/certs/key.pem rename to bindings/rust/certs/key.pem diff --git a/bindings/rust/s2n-tls-tokio/examples/certs/key_rsa.pem b/bindings/rust/certs/key_rsa.pem similarity index 100% rename from bindings/rust/s2n-tls-tokio/examples/certs/key_rsa.pem rename to bindings/rust/certs/key_rsa.pem diff --git a/bindings/rust/s2n-tls-tokio/examples/client.rs b/bindings/rust/s2n-tls-tokio/examples/client.rs index 5d3684d36ab..eebc3e115ac 100644 --- a/bindings/rust/s2n-tls-tokio/examples/client.rs +++ b/bindings/rust/s2n-tls-tokio/examples/client.rs @@ -8,7 +8,7 @@ use std::{error::Error, fs}; use tokio::{io::AsyncWriteExt, net::TcpStream}; /// NOTE: this certificate is to be used for demonstration purposes only! -const DEFAULT_CERT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/certs/cert.pem"); +const DEFAULT_CERT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/cert.pem"); #[derive(Parser, Debug)] struct Args { diff --git a/bindings/rust/s2n-tls-tokio/examples/server.rs b/bindings/rust/s2n-tls-tokio/examples/server.rs index 9b33553351b..3e549ef10e9 100644 --- a/bindings/rust/s2n-tls-tokio/examples/server.rs +++ b/bindings/rust/s2n-tls-tokio/examples/server.rs @@ -8,8 +8,8 @@ use std::{error::Error, fs}; use tokio::{io::AsyncWriteExt, net::TcpListener}; /// NOTE: this certificate and key are to be used for demonstration purposes only! -const DEFAULT_CERT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/certs/cert.pem"); -const DEFAULT_KEY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/certs/key.pem"); +const DEFAULT_CERT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/cert.pem"); +const DEFAULT_KEY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/key.pem"); #[derive(Parser, Debug)] struct Args { diff --git a/bindings/rust/s2n-tls-tokio/tests/common/mod.rs b/bindings/rust/s2n-tls-tokio/tests/common/mod.rs index fbcab0e1e06..5c587a46345 100644 --- a/bindings/rust/s2n-tls-tokio/tests/common/mod.rs +++ b/bindings/rust/s2n-tls-tokio/tests/common/mod.rs @@ -20,22 +20,16 @@ mod time; pub use time::*; /// NOTE: this certificate and key are used for testing purposes only! -pub static CERT_PEM: &[u8] = include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/examples/certs/cert.pem" -)); -pub static KEY_PEM: &[u8] = include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/examples/certs/key.pem" -)); +pub static CERT_PEM: &[u8] = + include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/cert.pem")); +pub static KEY_PEM: &[u8] = + include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/key.pem")); pub static RSA_CERT_PEM: &[u8] = include_bytes!(concat!( env!("CARGO_MANIFEST_DIR"), - "/examples/certs/cert_rsa.pem" -)); -pub static RSA_KEY_PEM: &[u8] = include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/examples/certs/key_rsa.pem" + "/../certs/cert_rsa.pem" )); +pub static RSA_KEY_PEM: &[u8] = + include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/key_rsa.pem")); pub const MIN_BLINDING_SECS: Duration = Duration::from_secs(10); pub const MAX_BLINDING_SECS: Duration = Duration::from_secs(30); diff --git a/bindings/rust/s2n-tls/src/callbacks/pkey.rs b/bindings/rust/s2n-tls/src/callbacks/pkey.rs index 1c9953e8d31..bbf44d6e8cf 100644 --- a/bindings/rust/s2n-tls/src/callbacks/pkey.rs +++ b/bindings/rust/s2n-tls/src/callbacks/pkey.rs @@ -133,14 +133,8 @@ mod tests { type Error = Box; - const KEY: &[u8] = include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../../tests/pems/ecdsa_p384_pkcs1_key.pem" - )); - const CERT: &[u8] = include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../../tests/pems/ecdsa_p384_pkcs1_cert.pem" - )); + const KEY: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/key.pem")); + const CERT: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/cert.pem")); fn new_pair(callback: T, waker: Waker) -> Result where diff --git a/bindings/rust/s2n-tls/src/testing/s2n_tls.rs b/bindings/rust/s2n-tls/src/testing/s2n_tls.rs index 1da872fa277..a641eb993f0 100644 --- a/bindings/rust/s2n-tls/src/testing/s2n_tls.rs +++ b/bindings/rust/s2n-tls/src/testing/s2n_tls.rs @@ -247,11 +247,11 @@ mod tests { #[test] fn trust_location() -> Result<(), Error> { - let pem_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../../tests/pems")); + let pem_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs")); let mut cert = pem_dir.to_path_buf(); - cert.push("rsa_4096_sha512_client_cert.pem"); + cert.push("cert.pem"); let mut key = pem_dir.to_path_buf(); - key.push("rsa_4096_sha512_client_key.pem"); + key.push("key.pem"); let mut builder = crate::config::Builder::new(); builder.set_security_policy(&security::DEFAULT_TLS13)?; @@ -269,11 +269,11 @@ mod tests { /// on OCSP explicitly still works when `trust_location()` is called. #[test] fn trust_location_does_not_change_ocsp_status() -> Result<(), Error> { - let pem_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../../tests/pems")); + let pem_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs")); let mut cert = pem_dir.to_path_buf(); - cert.push("rsa_4096_sha512_client_cert.pem"); + cert.push("cert.pem"); let mut key = pem_dir.to_path_buf(); - key.push("rsa_4096_sha512_client_key.pem"); + key.push("key.pem"); const OCSP_IANA_EXTENSION_ID: u16 = 5;