7 #include<cjson/cJSON.h>
12 #include "CppUTest/TestHarness.h"
13 #include "CppUTestExt/MockSupport.h"
15 #include "aampMocks.h"
16 #include "curlMocks.h"
18 TEST_GROUP(AampLegacyDrmSessionTests)
23 int mMaxDrmSessions = 1;
27 if (sessionManager ==
nullptr)
32 return sessionManager;
35 void setupCurlPerformResponse(std::string response)
37 static string responseStr = response;
39 MockCurlSetPerformCallback([](CURL *curl, MockCurlWriteCallback writeCallback,
void* writeData,
void* userData) {
40 writeCallback((
char*)responseStr.c_str(), 1, responseStr.size(), writeData);
53 if (sessionManager !=
nullptr)
56 SAFE_DELETE(sessionManager);
70 TEST(AampLegacyDrmSessionTests, TestCreateClearkeySession)
74 cJSON *keysObj = cJSON_CreateObject();
75 cJSON *keyInstanceObj = cJSON_CreateObject();
76 cJSON_AddStringToObject(keyInstanceObj,
"alg",
"cbc");
77 cJSON_AddStringToObject(keyInstanceObj,
"k",
"_u3wDe7erb7v8Lqt8A3QDQ");
78 cJSON_AddStringToObject(keyInstanceObj,
"kid",
"_u3wDe7erb7v8Lqt8A3QDQ");
79 cJSON *keysArr = cJSON_AddArrayToObject(keysObj,
"keys");
80 cJSON_AddItemToArray(keysArr, keyInstanceObj);
82 char *keyResponse = cJSON_PrintUnformatted(keysObj);
83 setupCurlPerformResponse(keyResponse);
84 cJSON_free(keyResponse);
85 cJSON_Delete(keysObj);
87 const unsigned char initData[] = {
88 0x00, 0x00, 0x00, 0x34, 0x70, 0x73, 0x73, 0x68, 0x01, 0x00, 0x00, 0x00, 0x10, 0x77, 0xef, 0xec,
89 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00, 0x00, 0x00, 0x01,
90 0xfe, 0xed, 0xf0, 0x0d, 0xee, 0xde, 0xad, 0xbe, 0xef, 0xf0, 0xba, 0xad, 0xf0, 0x0d, 0xd0, 0x0d,
91 0x00, 0x00, 0x00, 0x00};
95 "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b",
104 CHECK_TEXT(drmSession != NULL,
"Session creation failed");