aboutsummaryrefslogtreecommitdiff
path: root/tests/certreq.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/certreq.rs')
-rw-r--r--tests/certreq.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/certreq.rs b/tests/certreq.rs
index 547524c..82ce41c 100644
--- a/tests/certreq.rs
+++ b/tests/certreq.rs
@@ -1,6 +1,7 @@
//! Certification request (`CertReq`) tests
-use der::{Encode, Tag, Tagged};
+use der::asn1::{PrintableStringRef, Utf8StringRef};
+use der::{Decode, Encode, Tag, Tagged};
use hex_literal::hex;
use x509_cert::request::{CertReq, Version};
@@ -28,7 +29,7 @@ const EXTENSIONS: &[(&str, &[u8])] = &[
#[test]
fn decode_rsa_2048_der() {
- let cr = CertReq::try_from(RSA_2048_DER_EXAMPLE).unwrap();
+ let cr = CertReq::from_der(RSA_2048_DER_EXAMPLE).unwrap();
// Check the version.
assert_eq!(cr.info.version, Version::V1);
@@ -38,8 +39,8 @@ fn decode_rsa_2048_der() {
for (name, (oid, val)) in cr.info.subject.0.iter().zip(NAMES) {
let kind = name.0.get(0).unwrap();
let value = match kind.value.tag() {
- Tag::Utf8String => kind.value.utf8_string().unwrap().as_str(),
- Tag::PrintableString => kind.value.printable_string().unwrap().as_str(),
+ Tag::Utf8String => Utf8StringRef::try_from(&kind.value).unwrap().as_str(),
+ Tag::PrintableString => PrintableStringRef::try_from(&kind.value).unwrap().as_str(),
_ => panic!("unexpected tag"),
};
@@ -52,7 +53,7 @@ fn decode_rsa_2048_der() {
let alg = cr.info.public_key.algorithm;
assert_eq!(alg.oid, "1.2.840.113549.1.1.1".parse().unwrap());
assert!(alg.parameters.unwrap().is_null());
- assert_eq!(cr.info.public_key.subject_public_key, RSA_KEY);
+ assert_eq!(cr.info.public_key.subject_public_key.raw_bytes(), RSA_KEY);
// Check the attributes (just one; contains extensions).
assert_eq!(cr.info.attributes.len(), 1);
@@ -62,10 +63,10 @@ fn decode_rsa_2048_der() {
// Check the extensions.
let extensions: x509_cert::ext::Extensions =
- attribute.values.get(0).unwrap().decode_into().unwrap();
+ attribute.values.get(0).unwrap().decode_as().unwrap();
for (ext, (oid, val)) in extensions.iter().zip(EXTENSIONS) {
assert_eq!(ext.extn_id, oid.parse().unwrap());
- assert_eq!(ext.extn_value, *val);
+ assert_eq!(ext.extn_value.as_bytes(), *val);
assert!(!ext.critical);
}
@@ -80,7 +81,7 @@ fn decode_rsa_2048_der() {
#[test]
fn encode_rsa_2048_der() {
- let cr = CertReq::try_from(RSA_2048_DER_EXAMPLE).unwrap();
- let cr_encoded = cr.to_vec().unwrap();
+ let cr = CertReq::from_der(RSA_2048_DER_EXAMPLE).unwrap();
+ let cr_encoded = cr.to_der().unwrap();
assert_eq!(RSA_2048_DER_EXAMPLE, cr_encoded.as_slice());
}