Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Jun 27, 2024
1 parent 4658715 commit d760bd6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ mod tests {
use json_syntax::UnorderedPartialEq;
use ssi_data_integrity_core::DataIntegrity;
use ssi_di_sd_primitives::select::select_json_ld;
use ssi_json_ld::JsonLdEnvironment;
use ssi_verification_methods::Multikey;
use static_iref::{iri, uri};

Expand Down Expand Up @@ -328,10 +327,10 @@ mod tests {
&*PUBLIC_KEY,
);

let mut context = JsonLdEnvironment::default();
let loader = ssi_json_ld::ContextLoader::default();

let data = create_disclosure_data(
&mut context,
&loader,
&signed_base.claims,
&verification_method,
&signed_base.proofs.first().unwrap().signature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ use lazy_static::lazy_static;
use rdf_types::{BlankIdBuf, VocabularyMut};
use serde::{Deserialize, Serialize};
use ssi_bbs::{BBSplusPublicKey, BBSplusSecretKey};
use ssi_claims_core::{ClaimsValidity, Proof, Validate};
use ssi_claims_core::{ClaimsValidity, Validate};
use ssi_di_sd_primitives::JsonPointerBuf;
use ssi_json_ld::{AnyJsonLdEnvironment, JsonLdError, JsonLdNodeObject, JsonLdObject, JsonLdTypes};
use ssi_json_ld::{JsonLdError, JsonLdNodeObject, JsonLdObject, JsonLdTypes};
use ssi_rdf::{Interpretation, LdEnvironment, LinkedDataResource, LinkedDataSubject};
use static_iref::iri;

/// JSON Credential.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JsonCredential {
/// JSON-LD context.
#[serde(rename = "@context")]
pub context: json_ld::syntax::Context,
pub context: ssi_json_ld::syntax::Context,

/// Credential type.
#[serde(rename = "type")]
Expand All @@ -31,7 +32,7 @@ pub struct JsonCredential {
}

impl JsonLdObject for JsonCredential {
fn json_ld_context(&self) -> Option<Cow<json_ld::syntax::Context>> {
fn json_ld_context(&self) -> Option<Cow<ssi_json_ld::syntax::Context>> {
Some(Cow::Borrowed(&self.context))
}
}
Expand All @@ -42,28 +43,36 @@ impl JsonLdNodeObject for JsonCredential {
}
}

impl<E, P: Proof> Validate<E, P> for JsonCredential {
fn validate(&self, _env: &E, _proof: &P::Prepared) -> ClaimsValidity {
impl<E, P> Validate<E, P> for JsonCredential {
fn validate(&self, _env: &E, _proof: &P) -> ClaimsValidity {
Ok(())
}
}

impl<V, L, E> ssi_rdf::Expandable<E> for JsonCredential
where
E: AnyJsonLdEnvironment<Vocabulary = V, Loader = L>,
V: VocabularyMut,
V::Iri: Clone + Eq + Hash,
V::BlankId: Clone + Eq + Hash,
L: json_ld::Loader<V::Iri>,
L::Error: std::fmt::Display,
{
type Error = JsonLdError<L::Error>;

type Expanded = json_ld::ExpandedDocument<V::Iri, V::BlankId>;

async fn expand(&self, environment: &mut E) -> Result<Self::Expanded, Self::Error> {
impl ssi_json_ld::Expandable for JsonCredential {
type Error = JsonLdError;

type Expanded<I, V> = ssi_json_ld::ExpandedDocument<V::Iri, V::BlankId>
where
I: Interpretation,
V: VocabularyMut,
V::Iri: LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
V::BlankId: LinkedDataResource<I, V> + LinkedDataSubject<I, V>;

#[allow(async_fn_in_trait)]
async fn expand_with<I, V>(
&self,
ld: &mut LdEnvironment<V, I>,
loader: &impl ssi_json_ld::Loader,
) -> Result<Self::Expanded<I, V>, Self::Error>
where
I: Interpretation,
V: VocabularyMut,
V::Iri: Clone + Eq + Hash + LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
V::BlankId: Clone + Eq + Hash + LinkedDataResource<I, V> + LinkedDataSubject<I, V>,
{
let json = ssi_json_ld::CompactJsonLd(json_syntax::to_value(self).unwrap());
json.expand(environment).await
json.expand_with(ld, loader).await
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {
use ssi_data_integrity_core::{
suite::standard::TypedTransformationAlgorithm, ProofConfiguration,
};
use ssi_di_sd_primitives::{group::canonicalize_and_group, JsonPointerBuf};
use ssi_di_sd_primitives::group::canonicalize_and_group;
use ssi_rdf::IntoNQuads;
use ssi_verification_methods::{ProofPurpose, ReferenceOrOwned};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ mod tests {
let mut methods = HashMap::new();
methods.insert(VERIFICATION_METHOD_IRI.to_owned(), verification_method);

let vc = document.into_verifiable().await.unwrap();
assert!(vc.verify(&methods).await.unwrap().is_ok())
assert!(document.verify(&methods).await.unwrap().is_ok())
}
}
1 change: 1 addition & 0 deletions crates/jwk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ pub fn secp256k1_parse(data: &[u8]) -> Result<JWK, Error> {
Ok(pk.into())
}

#[cfg(feature = "secp256k1")]
impl From<k256::PublicKey> for JWK {
fn from(value: k256::PublicKey) -> Self {
JWK {
Expand Down

0 comments on commit d760bd6

Please sign in to comment.