am 457998d6: Correctly handle missing entry in DeactivateUsageEntry

* commit '457998d677f23cd46c0549abfde89abcd51d8d1b':
  Correctly handle missing entry in DeactivateUsageEntry
This commit is contained in:
Fred Gylys-Colwell
2014-09-05 23:04:28 +00:00
committed by Android Git Automerger
2 changed files with 15 additions and 2 deletions

View File

@@ -4478,6 +4478,7 @@ TEST_F(DISABLED_GenericDRMTest, KeyDurationVerify) {
TEST_F(OEMCryptoClientTest, SupportsUsageTable) {
if (OEMCrypto_SupportsUsageTable()) {
EXPECT_EQ(OEMCrypto_SUCCESS, OEMCrypto_UpdateUsageTable());
cout << " OEMCrypto supports usage tables." << endl;
} else {
cout << " OEMCrypto does not support usage tables." << endl;
@@ -4668,7 +4669,6 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
s1.LoadTestKeys(pst1, new_mac_keys_);
sleep(kShortSleep);
cout << "Making 49\n";
const size_t ENTRY_COUNT = 49;// API says should hold at least 50 entries.
Session sessions[ENTRY_COUNT];
for (int i=0; i<ENTRY_COUNT; i++) {
@@ -4685,7 +4685,6 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
sessions[i].GenerateReport(pst);
sessions[i].close();
}
cout << "Checking 49\n";
for (int i=0; i<ENTRY_COUNT; i++) {
Session s;
s.open();
@@ -4944,6 +4943,20 @@ TEST_P(DISABLED_UsageTableTest, DeleteEntryBadRange) {
}
}
TEST_P(DISABLED_UsageTableTest, DeactivateBadPST) {
if (OEMCrypto_SupportsUsageTable()) {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_UpdateUsageTable());
std::string pst = "nonexistant pst";
OEMCryptoResult sts = OEMCrypto_DeactivateUsageEntry(
reinterpret_cast<const uint8_t*>(pst.c_str()), pst.length());
EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, sts);
std::string null_pst = "";
sts = OEMCrypto_DeactivateUsageEntry(
reinterpret_cast<const uint8_t*>(null_pst.c_str()), null_pst.length());
EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, sts);
}
}
TEST_P(DISABLED_UsageTableTest, GenericEncrypt) {
if (OEMCrypto_SupportsUsageTable()) {
std::string pst = "A PST";