Skip to content

Commit

Permalink
remove the test
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Apr 1, 2024
1 parent 96a6347 commit 562fea5
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions xmtp_id/src/verified_key_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,75 +109,3 @@ fn extract_application_id(kp: &KeyPackage) -> Result<Address, KeyPackageVerifica
String::from_utf8(application_id_bytes)
.map_err(|_| KeyPackageVerificationError::InvalidApplicationId)
}

#[cfg(test)]
mod tests {
use openmls::{
credentials::CredentialWithKey,
extensions::{
ApplicationIdExtension, Extension, ExtensionType, Extensions, LastResortExtension,
},
group::config::CryptoConfig,
prelude::Capabilities,
prelude_test::KeyPackage,
versions::ProtocolVersion,
};
use xmtp_cryptography::utils::generate_local_wallet;

use xmtp_mls::{
builder::ClientBuilder,
configuration::CIPHERSUITE,
verified_key_package::{KeyPackageVerificationError, VerifiedKeyPackage},
};

#[tokio::test]
async fn test_invalid_application_id() {
let client = ClientBuilder::new_test_client(&generate_local_wallet()).await;
let conn = client.store.conn().unwrap();
let provider = client.mls_provider(&conn);

// Build a key package
let last_resort = Extension::LastResort(LastResortExtension::default());
// Make sure the application id doesn't match the account address
let invalid_application_id = "invalid application id".as_bytes();
let application_id =
Extension::ApplicationId(ApplicationIdExtension::new(invalid_application_id));
let leaf_node_extensions = Extensions::single(application_id);
let capabilities = Capabilities::new(
None,
Some(&[CIPHERSUITE]),
Some(&[ExtensionType::LastResort, ExtensionType::ApplicationId]),
None,
None,
);
// TODO: Set expiration
let kp = KeyPackage::builder()
.leaf_node_capabilities(capabilities)
.key_package_extensions(Extensions::single(last_resort))
.leaf_node_extensions(leaf_node_extensions)
.build(
CryptoConfig {
ciphersuite: CIPHERSUITE,
version: ProtocolVersion::default(),
},
&provider,
&client.identity.installation_keys,
CredentialWithKey {
credential: client.identity.credential().unwrap(),
signature_key: client.identity.installation_keys.to_public_vec().into(),
},
)
.unwrap();

let verified_kp_result = VerifiedKeyPackage::from_key_package(kp);
assert!(verified_kp_result.is_err());
assert_eq!(
KeyPackageVerificationError::ApplicationIdCredentialMismatch(
String::from_utf8(invalid_application_id.to_vec()).unwrap(),
client.account_address()
)
.to_string(),
verified_kp_result.err().unwrap().to_string()
);
}
}

0 comments on commit 562fea5

Please sign in to comment.