Skip to content

Commit

Permalink
test(bindings): Consolidate test pems (aws#4858)
Browse files Browse the repository at this point in the history
  • Loading branch information
goatgoose authored Oct 24, 2024
1 parent c0f971c commit d640c74
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 30 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bindings/rust/s2n-tls-tokio/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions bindings/rust/s2n-tls-tokio/examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 7 additions & 13 deletions bindings/rust/s2n-tls-tokio/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 2 additions & 8 deletions bindings/rust/s2n-tls/src/callbacks/pkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,8 @@ mod tests {

type Error = Box<dyn std::error::Error>;

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<T>(callback: T, waker: Waker) -> Result<TestPair, Error>
where
Expand Down
12 changes: 6 additions & 6 deletions bindings/rust/s2n-tls/src/testing/s2n_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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;

Expand Down

0 comments on commit d640c74

Please sign in to comment.