Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove previous JWS validation and structs #34

Merged
merged 1 commit into from
Oct 8, 2024
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
114 changes: 0 additions & 114 deletions schema/v2/pgxn-jws.schema.json

This file was deleted.

26 changes: 0 additions & 26 deletions src/release/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,6 @@ impl ReleasePayload {
}
}

/// ReleaseJws represents JSON Web Signature release metadata populated by
/// PGXN.
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct ReleaseJws {
headers: Vec<String>,
signatures: Vec<String>,
payload: ReleasePayload,
}

impl ReleaseJws {
/// Borrows the signature headers.
pub fn headers(&self) -> &[String] {
self.headers.as_slice()
}

/// Borrows the signatures.
pub fn signatures(&self) -> &[String] {
self.signatures.as_slice()
}

/// Borrows the release payload.
pub fn payload(&self) -> &ReleasePayload {
self.payload.borrow()
}
}

/**

Represents metadata for a PGXN release, which is the same as [`Distribution`]
Expand Down
36 changes: 0 additions & 36 deletions src/release/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ use std::{error::Error, fs::File, io::Write, path::PathBuf};
use tempfile::NamedTempFile;
use wax::Glob;

fn release_meta() -> Value {
json!({"release": {
"headers": ["eyJhbGciOiJFUzI1NiJ9"],
"signatures": [
"DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
],
"payload": {
"user": "theory",
"date": "2024-07-20T20:34:34Z",
"uri": "dist/semver/0.40.0/semver-0.40.0.zip",
"digests": {
"sha1": "fe8c013f991b5f537c39fb0c0b04bc955457675a"
}
}
}})
}

fn certs() -> Value {
json!({
"certs": {
Expand Down Expand Up @@ -438,25 +421,6 @@ fn release_payload() {
)
}

#[test]
fn release_jws() {
let release = release_meta();
let json = release.get("release").unwrap();
let pay: ReleasePayload = serde_json::from_value(json.get("payload").unwrap().clone()).unwrap();
let jws: ReleaseJws = serde_json::from_value(json.clone()).unwrap();
assert_eq!(
json.get("headers").unwrap().as_array().unwrap(),
jws.headers(),
"headers"
);
assert_eq!(
json.get("signatures").unwrap().as_array().unwrap(),
jws.signatures(),
"signatures"
);
assert_eq!(&pay, jws.payload(), "payload");
}

#[test]
fn release() -> Result<(), Box<dyn Error>> {
let dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "corpus", "v2"]
Expand Down
Loading