10 #include "AampVgdrmHelper.h"
11 #include "AampClearKeyHelper.h"
15 #include "aampMocks.h"
16 #include "opencdmMocks.h"
17 #include "curlMocks.h"
19 #include "drmTestUtils.h"
21 #include "CppUTest/TestHarness.h"
22 #include "CppUTestExt/MockSupport.h"
28 unsigned int callCount;
34 std::vector<std::string> getHeaders()
const
36 std::vector<std::string> headerList;
38 for (
int i = 0; i < opts.headerCount; ++i)
40 headerList.push_back(std::string(opts.headers[i]));
42 std::sort(headerList.begin(), headerList.end());
50 std::string challenge;
54 challenge(challenge) {}
57 TEST_GROUP(AampDrmSessionTests)
60 OpenCDMSession* mOcdmSession = (OpenCDMSession*)0x0CD12345;
61 OpenCDMSystem* mOcdmSystem = (OpenCDMSystem*)0x0CDACC12345;
62 std::map<std::string, TestCurlResponse> mCurlResponses;
66 int mMaxDrmSessions = 2;
69 const std::string mSessionTokenUrl =
"http://localhost:50050/authService/getSessionToken";
73 const std::string mSessionTokenResponse =
"{\"token\":\"SESSIONTOKEN\", \"status\":0}";
77 if (sessionManager ==
nullptr) {
80 return sessionManager;
83 AampDrmSession* createDrmSessionForHelper(std::shared_ptr<AampDrmHelper> drmHelper,
const char *keySystem)
86 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
88 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
89 .withParameter(
"keySystem", keySystem)
90 .andReturnValue(mOcdmSystem);
92 mock(
"OpenCDM").expectOneCall(
"opencdm_construct_session")
93 .withOutputParameterReturning(
"session", &mOcdmSession,
sizeof(mOcdmSession))
96 mock().checkExpectations();
97 CHECK_TEXT(drmSession != NULL,
"Session creation failed");
102 AampDrmSession* createDashDrmSession(
const std::string testKeyData,
const std::string psshStr, DrmMetaDataEventPtr& event)
104 std::vector<uint8_t> testKeyDataVec(testKeyData.begin(), testKeyData.end());
105 return createDashDrmSession(testKeyDataVec, psshStr, event);
108 AampDrmSession* createDashDrmSession(
const std::vector<uint8_t> testKeyData,
const std::string psshStr, DrmMetaDataEventPtr& event)
112 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
113 .withParameter(
"keySystem",
"com.microsoft.playready")
114 .andReturnValue(mOcdmSystem);
116 mock(
"OpenCDM").expectOneCall(
"opencdm_construct_session")
117 .withOutputParameterReturning(
"session", &mOcdmSession,
sizeof(mOcdmSession))
120 mock(
"OpenCDM").expectOneCall(
"opencdm_session_update")
121 .withMemoryBufferParameter(
"keyMessage", testKeyData.data(), testKeyData.size())
122 .withIntParameter(
"keyLength", testKeyData.size())
126 (
const unsigned char*)psshStr.c_str(), psshStr.length(),
eMEDIATYPE_VIDEO, mAamp, event);
127 CHECK_TEXT(drmSession != NULL,
"Session creation failed");
132 std::shared_ptr<AampHlsOcdmBridge> createBridgeForHelper(std::shared_ptr<AampVgdrmHelper> drmHelper)
134 return std::make_shared<AampHlsOcdmBridge>(&mLogging, createDrmSessionForHelper(drmHelper,
"net.vgdrm"));
137 DrmMetaDataEventPtr createDrmMetaDataEvent()
142 void setupCurlPerformResponse(std::string response)
144 static string responseStr = response;
146 MockCurlSetPerformCallback([](CURL *curl, MockCurlWriteCallback writeCallback,
void* writeData,
void* userData) {
147 writeCallback((
char*)responseStr.c_str(), 1, responseStr.size(), writeData);
151 void setupCurlPerformResponses(
const std::map<std::string, std::string>& responses)
153 for (
auto& response : responses)
158 MockCurlSetPerformCallback([](CURL *curl, MockCurlWriteCallback writeCallback,
void* writeData,
void* userData) {
159 const auto *responseMap = (
const std::map<std::string, TestCurlResponse>*)userData;
163 auto iter = responseMap->find(curlOpts->url);
164 if (iter != responseMap->end())
167 curlResponse->opts = *curlOpts;
168 curlResponse->callCount++;
170 writeCallback((
char*)curlResponse->response.c_str(), 1, curlResponse->response.size(), writeData);
177 auto iter = mCurlResponses.find(url);
178 if (iter != mCurlResponses.end())
180 return &iter->second;
193 mMockChallengeData = challengeData;
195 callbacks.constructSessionCallback = [](
const MockOpenCdmSessionInfo *mockSessionInfo,
void *mockUserData) {
199 const char* url = pChallengeData->url.c_str();
200 const std::string challenge = pChallengeData->challenge;
201 mockSessionInfo->callbacks.process_challenge_callback((OpenCDMSession*)mockSessionInfo->session,
202 mockSessionInfo->userData, url, (
const uint8_t*)challenge.c_str(), challenge.size());
205 callbacks.sessionUpdateCallback = [](
const MockOpenCdmSessionInfo *mockSessionInfo,
const uint8_t keyMessage[],
const uint16_t keyLength) {
206 mockSessionInfo->callbacks.key_update_callback((OpenCDMSession*)mockSessionInfo->session, mockSessionInfo->userData, keyMessage, keyLength);
207 mockSessionInfo->callbacks.keys_updated_callback((OpenCDMSession*)mockSessionInfo->session, mockSessionInfo->userData);
209 MockOpenCdmSetCallbacks(callbacks, &mMockChallengeData);
212 void setupChallengeCallbacksForExternalLicense()
215 callbacks.constructSessionCallback = [](
const MockOpenCdmSessionInfo *mockSessionInfo,
void *mockUserData) {
218 const char* url =
"test";
219 uint8_t challenge[] = {
'A'};
220 mockSessionInfo->callbacks.process_challenge_callback((OpenCDMSession*)mockSessionInfo->session, mockSessionInfo->userData, url, challenge, 1);
224 mockSessionInfo->callbacks.key_update_callback((OpenCDMSession*)mockSessionInfo->session, mockSessionInfo->userData,
nullptr, 0);
225 mockSessionInfo->callbacks.keys_updated_callback((OpenCDMSession*)mockSessionInfo->session, mockSessionInfo->userData);
228 MockOpenCdmSetCallbacks(callbacks, NULL);
241 if (sessionManager !=
nullptr)
244 SAFE_DELETE(sessionManager);
259 #ifndef USE_SECCLIENT
260 TEST(AampDrmSessionTests, TestVgdrmSessionDecrypt)
263 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
264 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
268 std::vector<uint8_t> expectedKeyId;
269 drmHelper->getKey(expectedKeyId);
270 LONGS_EQUAL(16, expectedKeyId.size());
272 setupChallengeCallbacksForExternalLicense();
274 AampDrmSession *drmSession = createDrmSessionForHelper(drmHelper,
"net.vgdrm");
275 STRCMP_EQUAL(
"net.vgdrm", drmSession->
getKeySystem().c_str());
277 const uint8_t testIv[] = {
'T',
'E',
'S',
'T',
'I',
'V'};
278 const uint8_t payloadData[] = {
'E',
'N',
'C',
'R',
'Y',
'P',
'T',
'E',
'D'};
279 const uint8_t decryptedData[] = {
'C',
'L',
'E',
'A',
'R',
'D',
'A',
'T',
'A',
'O',
'U',
'T'};
280 uint8_t *pOpaqueData = NULL;
284 uint32_t expectedDataIn =
sizeof(payloadData);
285 uint32_t expectedDataOut =
sizeof(decryptedData);
289 mock(
"OpenCDM").expectOneCall(
"opencdm_session_decrypt")
290 .withPointerParameter(
"session", mOcdmSession)
291 .withMemoryBufferParameter(
"encrypted", (
unsigned char*)&expectedDataIn,
sizeof(expectedDataIn))
292 .withOutputParameterReturning(
"encrypted", &expectedDataOut,
sizeof(expectedDataOut))
293 .withIntParameter(
"encryptedLength",
sizeof(expectedDataIn))
294 .withPointerParameter(
"iv", (
void*)testIv)
295 .withIntParameter(
"ivLength",
sizeof(testIv))
296 .withMemoryBufferParameter(
"keyId", (
unsigned char*)&expectedKeyId[0], expectedKeyId.size())
297 .withIntParameter(
"keyIdLength", expectedKeyId.size())
300 LONGS_EQUAL(0, drmSession->
decrypt(testIv,
sizeof(testIv), payloadData,
sizeof(payloadData), &pOpaqueData));
301 mock().checkExpectations();
304 TEST(AampDrmSessionTests, TestDecryptFromHlsOcdmBridgeNoKey)
307 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
308 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
310 setupChallengeCallbacksForExternalLicense();
312 shared_ptr<AampHlsOcdmBridge> hlsOcdmBridge = createBridgeForHelper(drmHelper);
314 uint8_t payloadData[] = {
'E',
'N',
'C',
'R',
'Y',
'P',
'T',
'E',
'D'};
318 mock(
"OpenCDM").expectNoCall(
"opencdm_session_decrypt");
320 mock().checkExpectations();
323 TEST(AampDrmSessionTests, TestDecryptFromHlsOcdmBridge)
326 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
327 std::string testIv =
"TESTIV0123456789";
328 drmInfo.
iv = (
unsigned char*)testIv.c_str();
330 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
331 std::vector<uint8_t> expectedKeyId;
332 drmHelper->getKey(expectedKeyId);
333 LONGS_EQUAL(16, expectedKeyId.size());
335 setupChallengeCallbacksForExternalLicense();
337 shared_ptr<AampHlsOcdmBridge> hlsOcdmBridge = createBridgeForHelper(drmHelper);
339 uint8_t payloadData[] = {
'E',
'N',
'C',
'R',
'Y',
'P',
'T',
'E',
'D'};
340 const uint8_t decryptedData[] = {
'C',
'L',
'E',
'A',
'R',
'D',
'A',
'T',
'A',
'O',
'U',
'T'};
342 hlsOcdmBridge->SetDecryptInfo(mAamp, &drmInfo);
346 uint32_t expectedDataIn =
sizeof(payloadData);
347 uint32_t expectedDataOut =
sizeof(decryptedData);
351 mock(
"OpenCDM").expectOneCall(
"opencdm_session_decrypt")
352 .withPointerParameter(
"session", mOcdmSession)
353 .withMemoryBufferParameter(
"encrypted", (
unsigned char*)&expectedDataIn,
sizeof(expectedDataIn))
354 .withOutputParameterReturning(
"encrypted", &expectedDataOut,
sizeof(expectedDataOut))
355 .withIntParameter(
"encryptedLength",
sizeof(expectedDataIn))
356 .withPointerParameter(
"iv", (
void*)drmInfo.
iv)
357 .withIntParameter(
"ivLength", testIv.size())
358 .withMemoryBufferParameter(
"keyId", (
unsigned char*)&expectedKeyId[0], expectedKeyId.size())
359 .withIntParameter(
"keyIdLength", expectedKeyId.size())
363 mock().checkExpectations();
366 TEST(AampDrmSessionTests, TestClearKeyLicenseAcquisition)
370 std::string testKeyData =
"TESTKEYDATA";
371 setupCurlPerformResponse(testKeyData);
372 setupChallengeCallbacks();
377 drmInfo.
manifestURL =
"http://example.com/assets/test.m3u8";
378 drmInfo.
keyURI =
"file.key";
379 std::shared_ptr<AampClearKeyHelper> drmHelper = std::make_shared<AampClearKeyHelper>(drmInfo, &mLogging);
385 const shared_ptr<DrmData> expectedDrmData = make_shared<DrmData>((
unsigned char *)testKeyData.c_str(), testKeyData.size());
386 drmHelper->transformLicenseResponse(expectedDrmData);
388 mock(
"OpenCDM").expectOneCall(
"opencdm_session_update")
389 .withMemoryBufferParameter(
"keyMessage", (
const unsigned char*) expectedDrmData->getData().c_str(), (
size_t)expectedDrmData->getDataLength())
390 .withIntParameter(
"keyLength", expectedDrmData->getDataLength())
393 AampDrmSession *drmSession = createDrmSessionForHelper(drmHelper,
"org.w3.clearkey");
394 STRCMP_EQUAL(
"org.w3.clearkey", drmSession->
getKeySystem().c_str());
398 STRCMP_EQUAL(
"http://example.com/assets/file.key", curlOpts->url);
400 LONGS_EQUAL(0L, curlOpts->httpGet);
403 TEST(AampDrmSessionTests, TestOcdmCreateSystemFailure)
406 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
407 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
408 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
411 mOcdmSystem =
nullptr;
412 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
413 .withParameter(
"keySystem",
"net.vgdrm")
414 .andReturnValue(mOcdmSystem);
415 mock(
"OpenCDM").expectNoCall(
"opencdm_construct_session");
417 mock().checkExpectations();
420 TEST(AampDrmSessionTests, TestOcdmConstructSessionFailure)
423 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
424 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
425 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
429 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
430 .withParameter(
"keySystem",
"net.vgdrm")
431 .andReturnValue(mOcdmSystem);
434 mOcdmSession =
nullptr;
435 mock(
"OpenCDM").expectOneCall(
"opencdm_construct_session")
436 .withOutputParameterReturning(
"session", &mOcdmSession,
sizeof(mOcdmSession))
437 .andReturnValue((
int)ERROR_KEYSYSTEM_NOT_SUPPORTED);
439 mock().checkExpectations();
440 CHECK_TEXT(drmSession == NULL,
"Session creation unexpectedly succeeded");
443 TEST(AampDrmSessionTests, TestMultipleSessionsDifferentKey)
445 std::string testKeyData =
"TESTKEYDATA";
446 setupCurlPerformResponse(testKeyData);
447 setupChallengeCallbacks();
450 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
451 std::shared_ptr<AampVgdrmHelper> drmHelper1 = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
453 const shared_ptr<DrmData> expectedDrmData = make_shared<DrmData>((
unsigned char *)testKeyData.c_str(), testKeyData.size());
454 drmHelper1->transformLicenseResponse(expectedDrmData);
456 setupChallengeCallbacksForExternalLicense();
459 AampDrmSession *drmSession1 = createDrmSessionForHelper(drmHelper1,
"net.vgdrm");
460 STRCMP_EQUAL(
"net.vgdrm", drmSession1->
getKeySystem().c_str());
463 drmInfo.
keyURI =
"81701500000811367b131dd025ab0a7bd8d20c1314151600";
464 std::shared_ptr<AampVgdrmHelper> drmHelper2 = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
465 AampDrmSession *drmSession2 = createDrmSessionForHelper(drmHelper2,
"net.vgdrm");
466 STRCMP_EQUAL(
"net.vgdrm", drmSession2->
getKeySystem().c_str());
467 CHECK_FALSE(drmSession1 == drmSession2);
470 TEST(AampDrmSessionTests, TestMultipleSessionsSameKey)
472 std::string testKeyData =
"TESTKEYDATA";
473 setupCurlPerformResponse(testKeyData);
474 setupChallengeCallbacks();
478 drmInfo.
manifestURL =
"http://example.com/assets/test.m3u8";
479 drmInfo.
keyURI =
"file.key";
480 std::shared_ptr<AampClearKeyHelper> drmHelper = std::make_shared<AampClearKeyHelper>(drmInfo, &mLogging);
482 const shared_ptr<DrmData> expectedDrmData = make_shared<DrmData>((
unsigned char *)testKeyData.c_str(), testKeyData.size());
483 drmHelper->transformLicenseResponse(expectedDrmData);
486 mock(
"OpenCDM").expectOneCall(
"opencdm_session_update")
487 .withMemoryBufferParameter(
"keyMessage", (
const unsigned char *)expectedDrmData->getData().c_str(), (
size_t)expectedDrmData->getDataLength())
488 .withIntParameter(
"keyLength", expectedDrmData->getDataLength())
492 AampDrmSession *drmSession1 = createDrmSessionForHelper(drmHelper,
"org.w3.clearkey");
493 STRCMP_EQUAL(
"org.w3.clearkey", drmSession1->
getKeySystem().c_str());
497 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
498 mock(
"OpenCDM").expectNoCall(
"opencdm_create_system");
499 mock(
"OpenCDM").expectNoCall(
"opencdm_construct_session");
501 CHECK_EQUAL(drmSession1, drmSession2);
506 mock(
"OpenCDM").expectOneCall(
"opencdm_session_update")
507 .withMemoryBufferParameter(
"keyMessage", (
const unsigned char *)expectedDrmData->getData().c_str(), (
size_t)expectedDrmData->getDataLength())
508 .withIntParameter(
"keyLength", expectedDrmData->getDataLength())
511 AampDrmSession *drmSession3 = createDrmSessionForHelper(drmHelper,
"org.w3.clearkey");
512 STRCMP_EQUAL(
"org.w3.clearkey", drmSession3->
getKeySystem().c_str());
515 TEST(AampDrmSessionTests, TestDashPlayReadySession)
517 string prLicenseServerURL =
"http://licenseserver.example/license";
518 const std::string testKeyData =
"TESTKEYDATA";
519 const std::string testChallengeData =
"PLAYREADY_CHALLENGE_DATA";
526 setupCurlPerformResponses({
527 {mSessionTokenUrl, mSessionTokenResponse},
528 {prLicenseServerURL, testKeyData}
531 setupChallengeCallbacks(
MockChallengeData(
"playready.example", testChallengeData));
534 const std::string psshStr =
535 "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
537 "<KID>16bytebase64enckeydata==</KID>"
541 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
542 AampDrmSession *drmSession = createDashDrmSession(testKeyData, psshStr, event);
543 STRCMP_EQUAL(
"com.microsoft.playready", drmSession->
getKeySystem().c_str());
545 const TestCurlResponse *licenseResponse = getCurlPerformResponse(prLicenseServerURL);
546 CHECK_EQUAL(1, licenseResponse->callCount);
549 CHECK_EQUAL(testChallengeData.size(), licenseResponse->opts.postFieldSize);
550 CHECK_EQUAL(testChallengeData, licenseResponse->opts.postFields);
553 TEST(AampDrmSessionTests, TestDashPlayReadySessionNoCkmPolicy)
555 string prLicenseServerURL =
"http://licenseserver.example/license";
556 std::string testKeyData =
"TESTKEYDATA";
563 setupCurlPerformResponses({
564 {mSessionTokenUrl, mSessionTokenResponse},
565 {prLicenseServerURL, testKeyData}
568 setupChallengeCallbacks();
571 const std::string psshStr =
572 "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
574 "<KID>16bytebase64enckeydata==</KID>"
578 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
579 AampDrmSession *drmSession = createDashDrmSession(testKeyData, psshStr, event);
580 CHECK_TEXT(drmSession != NULL,
"Session creation failed");
581 STRCMP_EQUAL(
"com.microsoft.playready", drmSession->
getKeySystem().c_str());
588 STRCMP_EQUAL(url.c_str(), curlOpts->url);
592 CHECK_TRUE(curlOpts->postFieldSize > 0);
593 STRNCMP_EQUAL(
"OCDM_CHALLENGE_DATA", curlOpts->postFields, curlOpts->postFieldSize);
596 TEST(AampDrmSessionTests, TestSessionBadChallenge)
600 drmInfo.
manifestURL =
"http://example.com/assets/test.m3u8";
601 drmInfo.
keyURI =
"file.key";
602 std::shared_ptr<AampClearKeyHelper> drmHelper = std::make_shared<AampClearKeyHelper>(drmInfo, &mLogging);
607 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
608 .withParameter(
"keySystem",
"org.w3.clearkey")
609 .andReturnValue(mOcdmSystem);
611 mock(
"OpenCDM").expectOneCall(
"opencdm_construct_session")
612 .withOutputParameterReturning(
"session", &mOcdmSession,
sizeof(mOcdmSession))
615 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
617 POINTERS_EQUAL(NULL, drmSession);
621 TEST(AampDrmSessionTests, TestSessionBadLicenseResponse)
625 drmInfo.
manifestURL =
"http://example.com/assets/test.m3u8";
626 drmInfo.
keyURI =
"file.key";
627 std::shared_ptr<AampClearKeyHelper> drmHelper = std::make_shared<AampClearKeyHelper>(drmInfo, &mLogging);
630 setupCurlPerformResponses({
631 {
"http://example.com/assets/file.key",
""}
634 mock(
"OpenCDM").expectOneCall(
"opencdm_create_system")
635 .withParameter(
"keySystem",
"org.w3.clearkey")
636 .andReturnValue(mOcdmSystem);
638 mock(
"OpenCDM").expectOneCall(
"opencdm_construct_session")
639 .withOutputParameterReturning(
"session", &mOcdmSession,
sizeof(mOcdmSession))
641 setupChallengeCallbacks();
643 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
645 POINTERS_EQUAL(NULL, drmSession);
649 TEST(AampDrmSessionTests, TestDashSessionBadPssh)
651 std::string testKeyData =
"TESTKEYDATA";
654 const std::string psshStr =
"bad data with no KID";
656 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
658 (
const unsigned char*)psshStr.c_str(), psshStr.length(),
eMEDIATYPE_VIDEO, mAamp, event);
659 POINTERS_EQUAL(NULL, drmSession);
663 TEST(AampDrmSessionTests, TestDrmMessageCallback)
666 drmInfo.
keyURI =
"81701500000810367b131dd025ab0a7bd8d20c1314151600";
667 std::shared_ptr<AampVgdrmHelper> drmHelper = std::make_shared<AampVgdrmHelper>(drmInfo, &mLogging);
668 setupChallengeCallbacksForExternalLicense();
669 AampDrmSession *drmSession = createDrmSessionForHelper(drmHelper,
"net.vgdrm");
670 STRCMP_EQUAL(
"net.vgdrm", drmSession->
getKeySystem().c_str());
672 struct DrmMessageTestData
676 bool callbackExpected;
679 const std::vector<DrmMessageTestData> testData = {
681 {
"individualization-request:Type:",
"{\"watermark\":{\"display\":false}}",
true},
682 {
"3:Type:",
"{\"watermark\":{\"display\":false}}",
true},
683 {
"individualization-request:Type:",
"payload is opaque so could be anything",
true},
686 {
"4:Type:",
"{\"watermark\":{\"display\":false}}",
false},
687 {
"",
"just a random string",
false},
690 for (
const auto& testCase : testData)
692 const std::string challengeData = testCase.prefix + testCase.payload;
694 if (testCase.callbackExpected)
696 mock(
"Aamp").expectOneCall(
"individualization").withStringParameter(
"payload", testCase.payload.c_str());
700 mock(
"Aamp").expectNoCall(
"individualization");
704 cdmInfo->callbacks.process_challenge_callback((OpenCDMSession*)cdmInfo->session,
707 (
const uint8_t*)challengeData.data(),
708 (
const uint16_t)challengeData.size());
713 TEST(AampDrmSessionTests, TestDashPlayReadySessionSecClient)
715 std::string prLicenseServerURL =
"http://licenseserver.example/license";
716 std::string expectedServiceHostUrl =
"licenseserver.example";
723 setupCurlPerformResponses({
724 {mSessionTokenUrl, mSessionTokenResponse}
727 setupChallengeCallbacks();
730 const std::string psshStr =
731 "<WRMHEADER xmlns=\"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader\" version=\"4.0.0.0\">"
733 "<KID>16bytebase64enckeydata==</KID>"
734 "<ckm:policy xmlns:ckm=\"urn:ccp:ckm\">policy</ckm:policy>"
738 std::string expectedKeyData =
"TESTSECKEYDATA";
739 size_t respLength = expectedKeyData.length();
740 const char *respPtr = expectedKeyData.c_str();
743 mock(
"SecClient").expectOneCall(
"AcquireLicense")
744 .withStringParameter(
"serviceHostUrl", expectedServiceHostUrl.c_str())
745 .withOutputParameterReturning(
"licenseResponse", &respPtr,
sizeof(respPtr))
746 .withOutputParameterReturning(
"licenseResponseLength", &respLength,
sizeof(respLength));
748 DrmMetaDataEventPtr
event = createDrmMetaDataEvent();
749 AampDrmSession *drmSession = createDashDrmSession(expectedKeyData, psshStr, event);
750 CHECK_TEXT(drmSession != NULL,
"Session creation failed");
751 STRCMP_EQUAL(
"com.microsoft.playready", drmSession->
getKeySystem().c_str());