Skip to content

Commit

Permalink
Add a rustls-webpki harness (#105)
Browse files Browse the repository at this point in the history
* add a rustls-webpki harness

Signed-off-by: William Woodruff <[email protected]>

* fix harness name

Signed-off-by: William Woodruff <[email protected]>

* Makefile, CI wiring

Signed-off-by: William Woodruff <[email protected]>

---------

Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Nov 27, 2023
1 parent b230187 commit 1f05d51
Show file tree
Hide file tree
Showing 15 changed files with 967 additions and 68 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test-harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,22 @@ jobs:
python ./harness/render-summary.py \
limbo.json \
harness/rust-webpki/results.json
rustls-webpki:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: ">=3.12"

- name: run tests
run: make test-rustls-webpki

- name: render summary
run: |
python ./harness/render-summary.py \
limbo.json \
harness/rust-rustls/results.json
33 changes: 31 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["harness/rust-webpki"]
members = ["harness-support/rust", "harness/rust-webpki", "harness/rust-rustls"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@ test-openssl:
test-rust-webpki:
@cargo run --bin rust-webpki-harness

.PHONY: test-rustls-webpki
test-rustls-webpki:
@cargo run --bin rust-rustls-harness

.PHONY: test
test: test-go test-openssl test-rust-webpki
test: test-go test-openssl test-rust-webpki test-rustls-webpki
11 changes: 11 additions & 0 deletions harness-support/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "limbo-harness-support"
version = "0.1.0"
edition = "2021"

[dependencies]
# TODO: Replace with upstream once merged:
# https://github.com/Marwes/schemafy/pull/76
schemafy = { git = "https://github.com/woodruffw-forks/schemafy", rev = "de28e87" }
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
4 changes: 4 additions & 0 deletions harness-support/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
limbo-harness-support
=====================

Shared behavior between Rust-based Limbo test harnesses.
11 changes: 11 additions & 0 deletions harness-support/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use models::Limbo;

pub mod models;

// `cargo run` runs from the workspace root, so this is relative to
// the root.
const LIMBO_JSON: &str = "limbo.json";

pub fn load_limbo() -> Limbo {
serde_json::from_str::<Limbo>(&std::fs::read_to_string(LIMBO_JSON).unwrap()).unwrap()
}
51 changes: 51 additions & 0 deletions harness-support/rust/src/models.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use serde::{Deserialize, Serialize};

schemafy::schemafy!("../../limbo-schema.json");

#[derive(Serialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum ActualResult {
Success,
Failure,
Skipped,
}

#[derive(Serialize)]
pub struct TestcaseResult {
pub id: String,
pub actual_result: ActualResult,
pub context: Option<String>,
}

impl TestcaseResult {
pub fn fail(tc: &Testcase, reason: &str) -> Self {
TestcaseResult {
id: tc.id.clone(),
actual_result: ActualResult::Failure,
context: Some(reason.into()),
}
}

pub fn success(tc: &Testcase) -> Self {
TestcaseResult {
id: tc.id.clone(),
actual_result: ActualResult::Success,
context: None,
}
}

pub fn skip(tc: &Testcase, reason: &str) -> Self {
TestcaseResult {
id: tc.id.clone(),
actual_result: ActualResult::Skipped,
context: Some(reason.into()),
}
}
}

#[derive(Serialize)]
pub struct LimboResult {
pub version: u8,
pub harness: String,
pub results: Vec<TestcaseResult>,
}
11 changes: 11 additions & 0 deletions harness/rust-rustls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "rust-rustls-harness"
version = "0.1.0"
edition = "2021"

[dependencies]
limbo-harness-support = { path = "../../harness-support/rust" }
chrono = "0.4.31"
pem = "3.0.2"
serde_json = "1.0.108"
rustls-webpki = { version = "0.101.7", features = ["std"] }
10 changes: 10 additions & 0 deletions harness/rust-rustls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `rustls-webpki` test harness for x509-limbo

This directory contains a basic test harness for running the x509-limbo
testsuite against the Rust [`rustls-webpki` crate].

[`webpki` crate]: https://docs.rs/rustls-webpki/latest/rustls-webpki/index.html

## Building

Just `cargo build`.
Loading

0 comments on commit 1f05d51

Please sign in to comment.