Skip to content

Commit 6ba277a

Browse files
maurice-blattmannnilsb99
authored andcommitted
Added testing for get_time
Signed-off-by: Maurice Blattmann <maumoblattmann@gmail.com>
1 parent 4498248 commit 6ba277a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tss-esapi/tests/integration_tests/context_tests/tpm_commands/attestation_commands_tests.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,47 @@ mod test_quote {
6565
}
6666
}
6767

68+
#[test]
69+
fn time() {
70+
let mut context = create_ctx_with_session();
71+
// No qualifying data
72+
let qualifying_data = vec![0xff; 16];
73+
74+
let key_handle = context
75+
.create_primary(Hierarchy::Owner, signing_key_pub(), None, None, None, None)
76+
.unwrap()
77+
.key_handle;
78+
let (attest, _signature) = context
79+
.execute_with_sessions(
80+
(
81+
Some(AuthSession::Password),
82+
Some(AuthSession::Password),
83+
None,
84+
),
85+
|ctx| {
86+
ctx.get_time(
87+
key_handle,
88+
Data::try_from(qualifying_data).unwrap(),
89+
SignatureScheme::Null,
90+
)
91+
},
92+
)
93+
.expect("Failed to get time");
94+
95+
assert_eq!(
96+
AttestationType::Time,
97+
attest.attestation_type(),
98+
"Attestation type of the returned value is not indicating Time"
99+
);
100+
101+
match attest.attested() {
102+
AttestInfo::Time { info: _ } => {}
103+
_ => {
104+
panic!("Attested did not contain the expected variant.")
105+
}
106+
}
107+
}
108+
68109
#[test]
69110
fn certify() {
70111
let mut context = create_ctx_with_session();

0 commit comments

Comments
 (0)