security: Add check for success of TPM signing
Change-Id: I5c0fc958f4d359354391a30c62791e877052b97e
Refs: #4585, #5086
diff --git a/tests/unit/security/v2/key-chain.t.cpp b/tests/unit/security/v2/key-chain.t.cpp
index ee19346..7f6abb0 100644
--- a/tests/unit/security/v2/key-chain.t.cpp
+++ b/tests/unit/security/v2/key-chain.t.cpp
@@ -210,6 +210,20 @@
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-memory:");
}
+BOOST_FIXTURE_TEST_CASE(SigningWithCorruptedPibTpm, IdentityManagementFixture)
+{
+ Identity id = m_keyChain.createIdentity("/test");
+
+ Data data("/foobar");
+ BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(id)));
+
+ // now, "corrupting TPM"
+ const_cast<Tpm&>(m_keyChain.getTpm()).deleteKey(id.getDefaultKey().getName());
+
+ BOOST_CHECK_NO_THROW(id.getDefaultKey());
+ BOOST_CHECK_THROW(m_keyChain.sign(data, signingByIdentity(id)), KeyChain::InvalidSigningInfoError);
+}
+
BOOST_FIXTURE_TEST_CASE(Management, IdentityManagementFixture)
{
Name identityName("/test/id");