open-standards/smart-byte/smart-byte-rs/crates/smart-byte-oidc4vc/tests/status_list.rs
Transaction Science 0155cbea85 ingest wave G (final): smart-byte-oidc4vc · OpenID for Verifiable Credentials
Smart Byte (1 crate, ~4370 LOC, 82 tests)
  smart-byte-oidc4vc   OID4VCI 13 (issuer/AS metadata, pre-auth + auth-code
                       offers, deep-link encode/decode, token endpoint,
                       c_nonce + nonce endpoint, credential endpoint with
                       single + batch proofs + deferred + encryption hooks,
                       notification endpoint). OID4VP 23 (VpAuthRequest/
                       VpAuthResponse with DCQL + PE 2.0 +
                       presentation_definition_uri, client_id_scheme
                       constants, response_mode constants). SIOPv2 (request
                       + ID-token with sub_jwk). DCQL (path walker, value
                       constraints, claim_sets, credential_sets).
                       Presentation Exchange 2.0 (definition + submission
                       validation). DPoP (RFC 9449 with htm/htu/iat/ath/
                       nonce + skew validator). Bitstring Status List 2021
                       + IETF Token Status List (1/2/4/8-bit slots,
                       GZIP+base64url). HAIP + EUDI Wallet ARF profile
                       evaluators (PID + mDL vct/doctype constants).

This closes the planned ingest run for batches 4-7. The open-standards
monorepo now contains 22 net-new crates from this session across the
three workspaces.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 17:45:05 -04:00

48 lines
1.8 KiB
Rust

//! Status list round-trips: Token Status List (IETF) + Bitstring (W3C).
use smart_byte_oidc4vc::{
BitstringStatusList, STATUS_INVALID, STATUS_SUSPENDED, STATUS_VALID,
TokenStatusList, TokenStatusListBytes, check_bitstring_status,
};
#[test]
fn token_status_list_one_bit() {
let mut l = TokenStatusListBytes::new(1, 8192).expect("list");
l.set(0, STATUS_INVALID).unwrap();
l.set(4095, STATUS_INVALID).unwrap();
l.set(8191, STATUS_INVALID).unwrap();
let encoded = TokenStatusList::encode(&l).unwrap();
let decoded = encoded.decode(Some(l.bytes.len())).unwrap();
assert_eq!(decoded.get(0).unwrap(), STATUS_INVALID);
assert_eq!(decoded.get(4095).unwrap(), STATUS_INVALID);
assert_eq!(decoded.get(8191).unwrap(), STATUS_INVALID);
assert_eq!(decoded.get(1).unwrap(), STATUS_VALID);
assert_eq!(decoded.get(123).unwrap(), STATUS_VALID);
}
#[test]
fn token_status_list_two_bit_values() {
let mut l = TokenStatusListBytes::new(2, 64).unwrap();
l.set(0, STATUS_INVALID).unwrap();
l.set(1, STATUS_SUSPENDED).unwrap();
let enc = TokenStatusList::encode(&l).unwrap();
let back = enc.decode(Some(l.bytes.len())).unwrap();
assert_eq!(back.get(0).unwrap(), STATUS_INVALID);
assert_eq!(back.get(1).unwrap(), STATUS_SUSPENDED);
assert_eq!(back.get(2).unwrap(), STATUS_VALID);
}
#[test]
fn token_status_list_rejects_overflow() {
let mut l = TokenStatusListBytes::new(1, 8).unwrap();
assert!(l.set(0, 2).is_err());
}
#[test]
fn bitstring_status_list_passthrough() {
let mut bs = BitstringStatusList::new(1024);
bs.set(42, true).unwrap();
let encoded = bs.to_encoded().unwrap();
assert!(check_bitstring_status(&encoded, 1024, 42).unwrap());
assert!(!check_bitstring_status(&encoded, 1024, 41).unwrap());
}