1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
// Copyright 2020 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use tss_esapi::constants::CapabilityType;
use tss_esapi::structures::CapabilityData;
use crate::common::create_ctx_without_session;
#[test]
fn test_algorithms() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::Algorithms, 0, 80)
.unwrap();
if let CapabilityData::Algorithms(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_handles() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::Handles, 0, 80)
.unwrap();
if let CapabilityData::Handles(vec) = capabs {
assert!(!vec.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_command() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::Command, 0, 80)
.unwrap();
if let CapabilityData::Commands(vec) = capabs {
assert!(!vec.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_pp_commands() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::PpCommands, 0, 80)
.unwrap();
if let CapabilityData::PpCommands(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_audit_commands() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::AuditCommands, 0, 80)
.unwrap();
if let CapabilityData::AuditCommands(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_assigned_pcr() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::AssignedPcr, 0, 80)
.unwrap();
if let CapabilityData::AssignedPcr(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_tpm_properties() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::TpmProperties, 0, 80)
.unwrap();
if let CapabilityData::TpmProperties(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_pcr_properties() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::PcrProperties, 0, 80)
.unwrap();
if let CapabilityData::PcrProperties(list) = capabs {
assert!(!list.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
#[test]
fn test_ecc_curves() {
let mut context = create_ctx_without_session();
let (capabs, _more) = context
.get_capability(CapabilityType::EccCurves, 0, 80)
.unwrap();
if let CapabilityData::EccCurves(vec) = capabs {
assert!(!vec.is_empty());
} else {
panic!("Got wrong type of capability data: {:?}", capabs);
}
}
// For these tests to work the tpm2-tss library need to have the
// authPolicies field in the TPMU_CAPABILITIES union.
// #[test]
// fn test_auth_policies() {
// let mut context = create_ctx_without_session();
// let (capabs, _more) = context
// .get_capability(CapabilityType::AuthPolicies, 0, 80)
// .unwrap();
// if let CapabilityData::AuthPolicies(list) = capabs {
// assert!(!list.is_empty());
// } else {
// panic!("Got wrong type of capability data: {:?}", capabs);
// }
// }
// For these tests to work the tpm2-tss library need to have the
// actData field in the TPMU_CAPABILITIES union.
// #[test]
// fn test_act() {
// let mut context = create_ctx_without_session();
// let (capabs, _more) = context.get_capability(CapabilityType::Act, 0, 80).unwrap();
// if let CapabilityData::ActData(list) = capabs {
// assert!(!list.is_empty());
// } else {
// panic!("Got wrong type of capability data: {:?}", capabs);
// }
// }
|