Fix CanSetServiceCertificate Test
(This is a merge of http://go/wvgerrit/14783) When validation was added to the service certificate property, it broke the associated test, which sends random data. It also did not do any testing of the new validation itself. This fix makes the validation method on WvContentDecryptionModule non-static so that it can be mocked and handled appropriately in the test. Bug: 21923281 Change-Id: Id5d2315709fce35f9347b3545f594371810349f0
This commit is contained in:
@@ -92,6 +92,8 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
|
||||
MOCK_METHOD1(ReleaseUsageInfo,
|
||||
CdmResponseType(const CdmUsageInfoReleaseMessage&));
|
||||
|
||||
MOCK_METHOD1(IsValidServiceCertificate, bool(const std::string&));
|
||||
};
|
||||
|
||||
class MockCrypto : public WVGenericCryptoInterface {
|
||||
@@ -1702,6 +1704,8 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
|
||||
Vector<uint8_t> privacyCert;
|
||||
privacyCert.appendArray(privacyCertRaw, kPrivacyCertSize);
|
||||
std::string strPrivacyCert(reinterpret_cast<char*>(privacyCertRaw),
|
||||
kPrivacyCertSize);
|
||||
Vector<uint8_t> emptyVector;
|
||||
|
||||
// Provide expected mock behavior
|
||||
@@ -1721,6 +1725,13 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
.Times(AtLeast(0));
|
||||
}
|
||||
|
||||
// Validate that the certificate is validated. Accept it once and reject it
|
||||
// once. Note that there is no expected call for when the certificate is
|
||||
// cleared.
|
||||
EXPECT_CALL(*cdm, IsValidServiceCertificate(strPrivacyCert))
|
||||
.WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
plugin.openSession(sessionId);
|
||||
ASSERT_THAT(propertySet, NotNull());
|
||||
|
||||
@@ -1736,6 +1747,11 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
res = plugin.setPropertyByteArray(String8("serviceCertificate"), emptyVector);
|
||||
ASSERT_EQ(OK, res);
|
||||
EXPECT_EQ(0u, propertySet->service_certificate().size());
|
||||
|
||||
// Test setting a certificate and having it fail
|
||||
res = plugin.setPropertyByteArray(String8("serviceCertificate"), privacyCert);
|
||||
ASSERT_NE(OK, res);
|
||||
EXPECT_EQ(0u, propertySet->service_certificate().size());
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
|
||||
Reference in New Issue
Block a user