Support Per-Origin Provisioning
This is a merge of several Widevine-side commits that, cumulatively,
allow callers to specify an origin to be used to isolate data storage
as specified in the W3C Encrypted Media Extension specification.
Separate origins have separate certificates, and consequently cannot
share device identifiers with each other.
The changes included in this are:
Add Ability to Check for Existing Certificates
http://go/wvgerrit/13974
Add Ability to Remove the Certificate
http://go/wvgerrit/13975
Make CDM Origin-Aware
http://go/wvgerrit/13977
Add Per-Origin Storage to Widevine CDM on Android
http://go/wvgerrit/14026
Remove Automatic Origin Generation
http://go/wvgerrit/14031
Bug: 19771858
Change-Id: I6a01c705d9b6b4887a9c7e6ff4399a125f781569
This commit is contained in:
@@ -252,6 +252,8 @@ class WVDrmPlugin : public android::DrmPlugin,
|
||||
|
||||
WvContentDecryptionModule* mCDM;
|
||||
WVGenericCryptoInterface* mCrypto;
|
||||
std::string mOrigin;
|
||||
|
||||
Mutex mCryptoSessionsMutex;
|
||||
map<CdmSessionId, CryptoSession> mCryptoSessions;
|
||||
|
||||
@@ -273,6 +275,8 @@ class WVDrmPlugin : public android::DrmPlugin,
|
||||
status_t mapOEMCryptoResult(OEMCryptoResult res);
|
||||
|
||||
bool InitDataResemblesPSSH(const Vector<uint8_t>& initData);
|
||||
|
||||
const char* determineOrigin() const;
|
||||
};
|
||||
|
||||
} // namespace wvdrm
|
||||
|
||||
@@ -74,7 +74,8 @@ DrmPlugin::KeyStatusType ConvertFromCdmKeyStatus(CdmKeyStatus keyStatus) {
|
||||
|
||||
WVDrmPlugin::WVDrmPlugin(WvContentDecryptionModule* cdm,
|
||||
WVGenericCryptoInterface* crypto)
|
||||
: mCDM(cdm), mCrypto(crypto), mCryptoSessionsMutex(), mCryptoSessions() {}
|
||||
: mCDM(cdm), mCrypto(crypto), mOrigin(), mCryptoSessionsMutex(),
|
||||
mCryptoSessions() {}
|
||||
|
||||
WVDrmPlugin::~WVDrmPlugin() {
|
||||
typedef map<CdmSessionId, CryptoSession>::iterator mapIterator;
|
||||
@@ -93,7 +94,8 @@ WVDrmPlugin::~WVDrmPlugin() {
|
||||
status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
|
||||
CdmSessionId cdmSessionId;
|
||||
CdmResponseType res =
|
||||
mCDM->OpenSession("com.widevine", &mPropertySet, this, &cdmSessionId);
|
||||
mCDM->OpenSession("com.widevine", &mPropertySet, determineOrigin(), this,
|
||||
&cdmSessionId);
|
||||
|
||||
if (!isCdmResponseTypeSuccess(res)) {
|
||||
return mapAndNotifyOfCdmResponseType(sessionId, res);
|
||||
@@ -234,8 +236,8 @@ status_t WVDrmPlugin::getKeyRequest(
|
||||
string cdmDefaultUrl;
|
||||
CdmResponseType res = mCDM->GenerateKeyRequest(
|
||||
cdmSessionId, cdmKeySetId, cdmInitDataType, processedInitData,
|
||||
cdmLicenseType, cdmParameters, &mPropertySet, &keyRequest,
|
||||
&cdmKeyRequestType, &cdmDefaultUrl);
|
||||
cdmLicenseType, cdmParameters, &mPropertySet, determineOrigin(),
|
||||
&keyRequest, &cdmKeyRequestType, &cdmDefaultUrl);
|
||||
*keyRequestType = ConvertFromCdmKeyRequestType(cdmKeyRequestType);
|
||||
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
@@ -361,6 +363,7 @@ status_t WVDrmPlugin::getProvisionRequest(const String8& cert_type,
|
||||
|
||||
CdmResponseType res = mCDM->GetProvisioningRequest(cdmCertType,
|
||||
cdmCertAuthority,
|
||||
determineOrigin(),
|
||||
&cdmProvisionRequest,
|
||||
&cdmDefaultUrl);
|
||||
|
||||
@@ -384,7 +387,8 @@ status_t WVDrmPlugin::provideProvisionResponse(
|
||||
CdmProvisioningResponse cdmResponse(response.begin(), response.end());
|
||||
string cdmCertificate;
|
||||
string cdmWrappedKey;
|
||||
CdmResponseType res = mCDM->HandleProvisioningResponse(cdmResponse,
|
||||
CdmResponseType res = mCDM->HandleProvisioningResponse(determineOrigin(),
|
||||
cdmResponse,
|
||||
&cdmCertificate,
|
||||
&cdmWrappedKey);
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
@@ -403,8 +407,8 @@ status_t WVDrmPlugin::provideProvisionResponse(
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::unprovisionDevice() {
|
||||
CdmResponseType res1 = mCDM->Unprovision(kSecurityLevelL1);
|
||||
CdmResponseType res3 = mCDM->Unprovision(kSecurityLevelL3);
|
||||
CdmResponseType res1 = mCDM->Unprovision(kSecurityLevelL1, determineOrigin());
|
||||
CdmResponseType res3 = mCDM->Unprovision(kSecurityLevelL3, determineOrigin());
|
||||
if (!isCdmResponseTypeSuccess(res1))
|
||||
{
|
||||
return mapCdmResponseType(res1);
|
||||
@@ -511,6 +515,8 @@ status_t WVDrmPlugin::getPropertyString(const String8& name,
|
||||
return queryProperty(QUERY_KEY_MAX_NUMBER_OF_SESSIONS, value);
|
||||
} else if (name == "appId") {
|
||||
value = mPropertySet.app_id().c_str();
|
||||
} else if (name == "origin") {
|
||||
value = mOrigin.c_str();
|
||||
} else {
|
||||
ALOGE("App requested unknown string property %s", name.string());
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
@@ -609,6 +615,18 @@ status_t WVDrmPlugin::setPropertyString(const String8& name,
|
||||
ALOGE("App tried to set the application id while sessions are opened.");
|
||||
return kErrorSessionIsOpen;
|
||||
}
|
||||
} else if (name == "origin") {
|
||||
size_t sessionCount = 0;
|
||||
{
|
||||
Mutex::Autolock lock(mCryptoSessionsMutex);
|
||||
sessionCount = mCryptoSessions.size();
|
||||
}
|
||||
if (sessionCount == 0) {
|
||||
mOrigin = value.string();
|
||||
} else {
|
||||
ALOGE("App tried to set the origin while sessions are opened.");
|
||||
return kErrorSessionIsOpen;
|
||||
}
|
||||
} else {
|
||||
ALOGE("App set unknown string property %s", name.string());
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
@@ -1009,4 +1027,8 @@ bool WVDrmPlugin::InitDataResemblesPSSH(const Vector<uint8_t>& initData) {
|
||||
return id == kPsshTag;
|
||||
}
|
||||
|
||||
const char* WVDrmPlugin::determineOrigin() const {
|
||||
return mOrigin.empty() ? EMPTY_ORIGIN : mOrigin.c_str();
|
||||
}
|
||||
|
||||
} // namespace wvdrm
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "cdm_client_property_set.h"
|
||||
@@ -24,21 +25,28 @@ using namespace testing;
|
||||
using namespace wvcdm;
|
||||
using namespace wvdrm;
|
||||
|
||||
namespace {
|
||||
const String8 kEmptyString;
|
||||
const String8 kOrigin("widevine.com");
|
||||
const String8 kAppId("com.unittest.mock.app.id");
|
||||
}
|
||||
|
||||
class MockCDM : public WvContentDecryptionModule {
|
||||
public:
|
||||
MOCK_METHOD4(OpenSession, CdmResponseType(const CdmKeySystem&,
|
||||
MOCK_METHOD5(OpenSession, CdmResponseType(const CdmKeySystem&,
|
||||
CdmClientPropertySet*,
|
||||
const std::string&,
|
||||
WvCdmEventListener*,
|
||||
CdmSessionId*));
|
||||
|
||||
MOCK_METHOD1(CloseSession, CdmResponseType(const CdmSessionId&));
|
||||
|
||||
MOCK_METHOD10(GenerateKeyRequest,
|
||||
MOCK_METHOD11(GenerateKeyRequest,
|
||||
CdmResponseType(const CdmSessionId&, const CdmKeySetId&,
|
||||
const std::string&, const CdmInitData&,
|
||||
const CdmLicenseType, CdmAppParameterMap&,
|
||||
CdmClientPropertySet*, CdmKeyMessage*,
|
||||
CdmKeyRequestType*, string*));
|
||||
CdmClientPropertySet*, const std::string&,
|
||||
CdmKeyMessage*, CdmKeyRequestType*, string*));
|
||||
|
||||
MOCK_METHOD3(AddKey, CdmResponseType(const CdmSessionId&,
|
||||
const CdmKeyResponse&,
|
||||
@@ -57,13 +65,18 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
MOCK_METHOD2(QueryKeyControlInfo, CdmResponseType(const CdmSessionId&,
|
||||
CdmQueryMap*));
|
||||
|
||||
MOCK_METHOD4(GetProvisioningRequest, CdmResponseType(CdmCertificateType,
|
||||
MOCK_METHOD5(GetProvisioningRequest, CdmResponseType(CdmCertificateType,
|
||||
const std::string&,
|
||||
const std::string&,
|
||||
CdmProvisioningRequest*,
|
||||
std::string*));
|
||||
|
||||
MOCK_METHOD3(HandleProvisioningResponse,
|
||||
CdmResponseType(CdmProvisioningResponse&, std::string*, std::string*));
|
||||
MOCK_METHOD4(HandleProvisioningResponse,
|
||||
CdmResponseType(const std::string&, CdmProvisioningResponse&,
|
||||
std::string*, std::string*));
|
||||
|
||||
MOCK_METHOD2(Unprovision, CdmResponseType(CdmSecurityLevel,
|
||||
const std::string&));
|
||||
|
||||
MOCK_METHOD2(GetUsageInfo, CdmResponseType(const std::string&,
|
||||
CdmUsageInfo*));
|
||||
@@ -72,8 +85,6 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
const CdmSecureStopId&,
|
||||
CdmUsageInfo*));
|
||||
|
||||
MOCK_METHOD1(Unprovision, CdmResponseType(CdmSecurityLevel));
|
||||
|
||||
MOCK_METHOD1(ReleaseAllUsageInfo, CdmResponseType(const std::string&));
|
||||
|
||||
MOCK_METHOD1(ReleaseUsageInfo,
|
||||
@@ -149,14 +160,35 @@ class WVDrmPluginTest : public Test {
|
||||
}
|
||||
};
|
||||
|
||||
struct OriginTestVariant {
|
||||
// For a test that does not expect any follow-up queries
|
||||
OriginTestVariant(const std::string& nameValue, const String8& originValue,
|
||||
const std::string& expectedOriginValue)
|
||||
: name(nameValue), origin(originValue),
|
||||
expectedOrigin(expectedOriginValue) {}
|
||||
|
||||
const std::string name;
|
||||
const String8 origin;
|
||||
const std::string expectedOrigin;
|
||||
};
|
||||
|
||||
void PrintTo(const OriginTestVariant& param, ::std::ostream* os) {
|
||||
*os << param.name << " Variant";
|
||||
|
||||
}
|
||||
|
||||
class WVDrmPluginOriginTest : public WVDrmPluginTest,
|
||||
public WithParamInterface<OriginTestVariant> {};
|
||||
|
||||
TEST_F(WVDrmPluginTest, OpensSessions) {
|
||||
StrictMock<MockCDM> cdm;
|
||||
StrictMock<MockCrypto> crypto;
|
||||
WVDrmPlugin plugin(&cdm, &crypto);
|
||||
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm,
|
||||
OpenSession(StrEq("com.widevine"), _, StrEq(EMPTY_ORIGIN), _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -270,26 +302,27 @@ TEST_F(WVDrmPluginTest, GeneratesKeyRequests) {
|
||||
|
||||
EXPECT_CALL(cdm, GenerateKeyRequest(cdmSessionId, "", mimeType, initData,
|
||||
kLicenseTypeOffline, cdmParameters, _,
|
||||
_, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<7>(cdmRequest),
|
||||
SetArgPointee<8>(kKeyRequestTypeInitial),
|
||||
SetArgPointee<9>(kDefaultUrl),
|
||||
_, _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<8>(cdmRequest),
|
||||
SetArgPointee<9>(kKeyRequestTypeInitial),
|
||||
SetArgPointee<10>(kDefaultUrl),
|
||||
Return(wvcdm::KEY_MESSAGE)));
|
||||
|
||||
EXPECT_CALL(cdm, GenerateKeyRequest(cdmSessionId, "", mimeType, initData,
|
||||
kLicenseTypeStreaming, cdmParameters,
|
||||
_, _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<7>(cdmRequest),
|
||||
SetArgPointee<8>(kKeyRequestTypeRenewal),
|
||||
SetArgPointee<9>(kDefaultUrl),
|
||||
_, _, _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<8>(cdmRequest),
|
||||
SetArgPointee<9>(kKeyRequestTypeRenewal),
|
||||
SetArgPointee<10>(kDefaultUrl),
|
||||
Return(wvcdm::KEY_MESSAGE)));
|
||||
|
||||
EXPECT_CALL(cdm, GenerateKeyRequest("", cdmKeySetId, mimeType, initData,
|
||||
kLicenseTypeRelease, cdmParameters,
|
||||
NotNull(), _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<7>(cdmRequest),
|
||||
SetArgPointee<8>(kKeyRequestTypeRelease),
|
||||
SetArgPointee<9>(kDefaultUrl),
|
||||
NotNull(), StrEq(EMPTY_ORIGIN), _, _,
|
||||
_))
|
||||
.WillOnce(DoAll(SetArgPointee<8>(cdmRequest),
|
||||
SetArgPointee<9>(kKeyRequestTypeRelease),
|
||||
SetArgPointee<10>(kDefaultUrl),
|
||||
Return(wvcdm::KEY_MESSAGE)));
|
||||
}
|
||||
}
|
||||
@@ -384,10 +417,10 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
|
||||
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -512,9 +545,9 @@ TEST_F(WVDrmPluginTest, GetsProvisioningRequests) {
|
||||
static const char* kDefaultUrl = "http://google.com/";
|
||||
|
||||
EXPECT_CALL(cdm, GetProvisioningRequest(kCertificateWidevine, IsEmpty(),
|
||||
_, _))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmRequest),
|
||||
SetArgPointee<3>(kDefaultUrl),
|
||||
EMPTY_ORIGIN, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<3>(cdmRequest),
|
||||
SetArgPointee<4>(kDefaultUrl),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Vector<uint8_t> request;
|
||||
@@ -542,7 +575,8 @@ TEST_F(WVDrmPluginTest, HandlesProvisioningResponses) {
|
||||
Vector<uint8_t> response;
|
||||
response.appendArray(responseRaw, kResponseSize);
|
||||
|
||||
EXPECT_CALL(cdm, HandleProvisioningResponse(ElementsAreArray(responseRaw,
|
||||
EXPECT_CALL(cdm, HandleProvisioningResponse(EMPTY_ORIGIN,
|
||||
ElementsAreArray(responseRaw,
|
||||
kResponseSize),
|
||||
_, _))
|
||||
.Times(1);
|
||||
@@ -560,9 +594,9 @@ TEST_F(WVDrmPluginTest, UnprovisionsDevice) {
|
||||
StrictMock<MockCrypto> crypto;
|
||||
WVDrmPlugin plugin(&cdm, &crypto);
|
||||
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL1))
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL1, EMPTY_ORIGIN))
|
||||
.Times(1);
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL3))
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL3, EMPTY_ORIGIN))
|
||||
.Times(1);
|
||||
|
||||
status_t res = plugin.unprovisionDevice();
|
||||
@@ -576,11 +610,11 @@ TEST_F(WVDrmPluginTest, MuxesUnprovisioningErrors) {
|
||||
|
||||
// Tests that both Unprovisions are called even if one fails. Also tests that
|
||||
// no matter which fails, the function always propagates the error.
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL1))
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL1, EMPTY_ORIGIN))
|
||||
.WillOnce(Return(wvcdm::UNKNOWN_ERROR))
|
||||
.WillOnce(Return(wvcdm::NO_ERROR))
|
||||
.WillOnce(Return(wvcdm::UNKNOWN_ERROR));
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL3))
|
||||
EXPECT_CALL(cdm, Unprovision(kSecurityLevelL3, EMPTY_ORIGIN))
|
||||
.WillOnce(Return(wvcdm::NO_ERROR))
|
||||
.WillOnce(Return(wvcdm::UNKNOWN_ERROR))
|
||||
.WillOnce(Return(wvcdm::UNKNOWN_ERROR));
|
||||
@@ -824,9 +858,9 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
|
||||
bool match;
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -903,9 +937,9 @@ TEST_F(WVDrmPluginTest, CallsGenericEncrypt) {
|
||||
}
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -963,9 +997,9 @@ TEST_F(WVDrmPluginTest, CallsGenericDecrypt) {
|
||||
}
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1025,9 +1059,9 @@ TEST_F(WVDrmPluginTest, CallsGenericSign) {
|
||||
}
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1097,9 +1131,9 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
|
||||
}
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1130,9 +1164,9 @@ TEST_F(WVDrmPluginTest, RegistersForEvents) {
|
||||
WVDrmPlugin plugin(&cdm, &crypto);
|
||||
|
||||
// Provide expected behavior to support session creation
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, &plugin, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, &plugin, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1163,10 +1197,10 @@ TEST_F(WVDrmPluginTest, UnregistersForAllEventsOnDestruction) {
|
||||
CdmSessionId cdmSessionId1(sessionIdRaw1, sessionIdRaw1 + kSessionIdSize);
|
||||
CdmSessionId cdmSessionId2(sessionIdRaw2, sessionIdRaw2 + kSessionIdSize);
|
||||
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<3>(cdmSessionId1),
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId1),
|
||||
Return(wvcdm::NO_ERROR)))
|
||||
.WillOnce(DoAll(SetArgPointee<3>(cdmSessionId2),
|
||||
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId2),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId1, _))
|
||||
@@ -1281,9 +1315,9 @@ TEST_F(WVDrmPluginTest, GeneratesProvisioningNeededEvent) {
|
||||
NULL))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
|
||||
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NEED_PROVISIONING)));
|
||||
|
||||
EXPECT_CALL(cdm, CloseSession(_))
|
||||
@@ -1307,10 +1341,10 @@ TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1330,6 +1364,7 @@ TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
|
||||
EXPECT_EQ(0u, propertySet->session_sharing_id());
|
||||
EXPECT_STREQ("", propertySet->app_id().c_str());
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
StrictMock<MockCDM> cdm;
|
||||
StrictMock<MockCrypto> crypto;
|
||||
@@ -1337,14 +1372,22 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
|
||||
const CdmClientPropertySet* propertySet = NULL;
|
||||
|
||||
CdmQueryMap l3Map;
|
||||
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
|
||||
|
||||
// Provide expected mock behavior
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin queries for the security level
|
||||
EXPECT_CALL(cdm, QueryStatus(_))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<0>(l3Map),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1361,7 +1404,6 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
ASSERT_EQ(OK, res);
|
||||
|
||||
// Test setting an application id before a session is opened.
|
||||
const String8 kAppId("com.unittest.mock.app.id");
|
||||
res = plugin.setPropertyString(String8("appId"), kAppId);
|
||||
ASSERT_EQ(OK, res);
|
||||
|
||||
@@ -1376,6 +1418,42 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
ASSERT_EQ(kErrorSessionIsOpen, res);
|
||||
}
|
||||
|
||||
TEST_P(WVDrmPluginOriginTest, CanSetOrigin) {
|
||||
StrictMock<MockCDM> cdm;
|
||||
StrictMock<MockCrypto> crypto;
|
||||
WVDrmPlugin plugin(&cdm, &crypto);
|
||||
OriginTestVariant params = GetParam();
|
||||
|
||||
// Provide expected mock behavior
|
||||
{
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
// Provide expected behavior when plugin closes a session
|
||||
EXPECT_CALL(cdm, CloseSession(_))
|
||||
.Times(AtLeast(0));
|
||||
}
|
||||
|
||||
// Note which mock calls we expect
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, StrEq(params.expectedOrigin), _, _))
|
||||
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Set the properties & run the test
|
||||
if (!params.origin.isEmpty()) {
|
||||
ASSERT_EQ(OK, plugin.setPropertyString(String8("origin"), params.origin));
|
||||
}
|
||||
EXPECT_EQ(OK, plugin.openSession(sessionId));
|
||||
// Test setting an origin while sessions are opened. This should fail.
|
||||
EXPECT_NE(OK, plugin.setPropertyString(String8("origin"), kOrigin));
|
||||
EXPECT_EQ(OK, plugin.closeSession(sessionId));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OriginTests, WVDrmPluginOriginTest, Values(
|
||||
OriginTestVariant("No Origin", kEmptyString, EMPTY_ORIGIN),
|
||||
OriginTestVariant("With an Origin", kOrigin, kOrigin.string())));
|
||||
|
||||
TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
StrictMock<MockCDM> cdm;
|
||||
StrictMock<MockCrypto> crypto;
|
||||
@@ -1399,10 +1477,10 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1484,10 +1562,10 @@ TEST_F(WVDrmPluginTest, CanSetPrivacyMode) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1539,10 +1617,10 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1580,10 +1658,10 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
@@ -1639,10 +1717,10 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
|
||||
{
|
||||
// Provide expected behavior in response to OpenSession and store the
|
||||
// property set
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(cdm, OpenSession(_, _, _, _, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
SaveArg<1>(&propertySet),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
|
||||
Reference in New Issue
Block a user