use super::{
StoredAttachAllocation, StoredAttachRequest, StoredBindingEpoch, StoredDetachRequest,
StoredEnrollmentAllocation, StoredEnrollmentRequest, StoredU128,
};
use crate::credential_debug_tests::{shows_none_of, token_shaped};
const EPOCH: StoredBindingEpoch = StoredBindingEpoch {
server_incarnation: 1,
connection_ordinal: 2,
capability_generation: 3,
};
fn token() -> [u8; 16] {
token_shaped::<16>(16)
}
fn secret() -> [u8; 32] {
token_shaped::<32>(32)
}
#[test]
fn a_detach_repository_enrollment_request_debug_shows_no_token_byte() {
let request = StoredEnrollmentRequest {
conversation_id: 1,
token: token(),
};
shows_none_of(&request, &token());
}
#[test]
fn a_detach_repository_detach_request_debug_shows_no_token_byte() {
let request = StoredDetachRequest {
conversation_id: 1,
participant_id: 2,
capability_generation: 3,
token: token(),
};
shows_none_of(&request, &token());
}
#[test]
fn a_detach_repository_attach_request_debug_shows_no_secret_or_token_byte() {
let request = StoredAttachRequest {
conversation_id: 1,
participant_id: 2,
capability_generation: 3,
attach_secret: secret(),
token: token(),
accept_marker_delivery_seq: Some(4),
};
shows_none_of(&request, &secret());
shows_none_of(&request, &token());
}
#[test]
fn a_detach_repository_enrollment_allocation_debug_shows_no_secret_byte() {
let allocation = StoredEnrollmentAllocation {
attach_secret: secret(),
origin_binding_epoch: EPOCH,
attached_transaction_order: 4,
attached_delivery_seq: 5,
receipt_expires_at: StoredU128([6; 16]),
provenance_expires_at: StoredU128([7; 16]),
enrollment_fingerprint: [8; 32],
};
shows_none_of(&allocation, &secret());
}
#[test]
fn a_detach_repository_attach_allocation_debug_shows_no_secret_byte() {
let allocation = StoredAttachAllocation {
binding_epoch: EPOCH,
attach_secret: secret(),
attached_transaction_order: 4,
attached_delivery_seq: 5,
receipt_expires_at: StoredU128([6; 16]),
provenance_expires_at: StoredU128([7; 16]),
};
shows_none_of(&allocation, &secret());
}