Skip to content

Commit

Permalink
Remove previous JWS validation and structs
Browse files Browse the repository at this point in the history
With the switch from the old `release` field to the new `certs` and
`release` fields as defined in [RFC 5] and implemented in 0773ad7 and
acb0d22, the previously-defined JSON schemas and data structure are no
longer used. So remove them and their tests.

  [RFC 5]: pgxn/rfcs#5
  • Loading branch information
theory committed Oct 8, 2024
1 parent acb0d22 commit 156d314
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 1,053 deletions.
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

0 comments on commit 156d314

Please sign in to comment.