Address CDM request license unit test failures

UAT issues fixed PSTs for each piece of content. This requires the usage
table to be cleared (or usage records released) between tests. If not
PST collisions occur and OEMCrypto fails with
OEMCrypto_ERROR_INVALID_CONTEXT (0x29).

b/17318063

[ Merge of https://widevine-internal-review.googlesource.com/#/c/11061/
  from wv cdm repo ]

Change-Id: I7758e5444637583a171edafcd4fb18315bfa8395
This commit is contained in:
Rahul Frias
2014-08-29 11:14:29 -07:00
parent fa3098ad07
commit d2ad6d7f13

View File

@@ -586,9 +586,17 @@ class WvCdmRequestLicenseTest : public testing::Test {
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3));
}
void Provision() {
void Provision(SecurityLevel level) {
TestWvCdmClientPropertySet property_set_L3;
TestWvCdmClientPropertySet* property_set = NULL;
if (kLevel3 == level) {
property_set_L3.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
property_set = &property_set_L3;
}
CdmResponseType status =
decryptor_.OpenSession(g_key_system, NULL, &session_id_);
decryptor_.OpenSession(g_key_system, property_set, &session_id_);
switch (status) {
case NO_ERROR:
decryptor_.CloseSession(session_id_);
@@ -906,7 +914,7 @@ TEST_F(WvCdmRequestLicenseTest, AddStreamingKeyTest) {
TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
Unprovision();
Provision();
Provision(kLevelDefault);
// override default settings unless configured through the command line
std::string key_id;
@@ -921,7 +929,7 @@ TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
Unprovision();
Provision();
Provision(kLevelDefault);
// override default settings unless configured through the command line
std::string key_id;
@@ -944,7 +952,7 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
Unprovision();
Provision();
Provision(kLevelDefault);
// override default settings unless configured through the command line
std::string key_id;
@@ -974,7 +982,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
Unprovision();
Provision();
Provision(kLevelDefault);
// override default settings unless configured through the command line
std::string key_id;
@@ -1013,7 +1021,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
Unprovision();
Provision();
Provision(kLevelDefault);
// override default settings unless configured through the command line
std::string key_id;
@@ -1091,6 +1099,8 @@ class WvCdmUsageInfoTest
public ::testing::WithParamInterface<UsageInfoSubSampleInfo*> {};
TEST_P(WvCdmUsageInfoTest, UsageInfo) {
Unprovision();
Provision(kLevelDefault);
CdmSecurityLevel security_level = GetDefaultSecurityLevel();
DeviceFiles handle;
EXPECT_TRUE(handle.Init(security_level));
@@ -1167,6 +1177,7 @@ TEST_F(WvCdmRequestLicenseTest, QueryUnmodifiedSessionStatus) {
TEST_F(WvCdmRequestLicenseTest, QueryModifiedSessionStatus) {
// Test that L3 is returned when properties downgrade security.
Provision(kLevel3);
TestWvCdmClientPropertySet property_set_L3;
property_set_L3.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
@@ -1264,15 +1275,14 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) {
}
TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
// override default settings unless configured through the command line
std::string key_id = g_key_id;
std::string client_auth = g_client_auth;
Unprovision();
Provision(kLevelDefault);
ConfigTestEnv config(g_license_server_id, false);
if (g_key_id.compare(a2bs_hex(g_config->key_id())) == 0)
key_id.assign(wvcdm::a2bs_hex(config.key_id()));
if (g_client_auth.compare(g_config->client_auth()) == 0)
client_auth.assign(config.client_auth());
// override default settings unless configured through the command line
std::string key_id;
std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth);
CdmQueryMap query_info;
CdmQueryMap::iterator itr;
@@ -1322,6 +1332,10 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
response, &cert, &wrapped_key));
decryptor_.CloseSession(session_id_);
std::vector<std::string> files;
EXPECT_TRUE(file.List(base_path, &files));
size_t number_of_files = files.size();
decryptor_.OpenSession(g_key_system, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1329,9 +1343,10 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
EXPECT_FALSE(key_set_id_.empty());
decryptor_.CloseSession(session_id_);
std::vector<std::string> files;
EXPECT_TRUE(file.List(base_path, &files));
EXPECT_TRUE(2u == files.size() || 3u == files.size());
int number_of_new_files = files.size() - number_of_files;
EXPECT_LE(1, number_of_new_files);
EXPECT_GE(2, number_of_new_files);
for (size_t i = 0; i < files.size(); ++i) {
std::string from = base_path + files[i];
@@ -1350,7 +1365,7 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
decryptor_.CloseSession(session_id_);
decryptor_.OpenSession(g_key_system, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeStreaming);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, client_auth, false);
decryptor_.CloseSession(session_id_);