Android CDM: Removed secure stop tests.

[ Merge of http://go/wvgerrit/158720 ]

Support for secure stop licenses have been dropped.  The MediaDRM
APIs have already documented their deprecation.  Before support can
be removed from the plugin and CDM core implementation, the tests
associated with them must be removed.

This CL removes secure stop tests from the Android CDM integration
test `request_license_test` and from the MediaDRM plugin test
`libwvdrmdrmplugin_hal_test` and `libwvdrmdrmplugin_hidl_test`.

Bug: 242289743
Test: libwvdrmdrmplugin_hal_test request_license_test
Change-Id: Idb7ee53ab8115ce9b9a173eaf0a00f54325863a2
This commit is contained in:
Alex Dale
2022-10-12 17:59:50 -07:00
parent 56ee5f052c
commit d027236719
4 changed files with 40 additions and 1681 deletions

View File

@@ -47,8 +47,6 @@ using ::aidl::android::hardware::drm::KeyValue;
using ::aidl::android::hardware::drm::OfflineLicenseState;
using ::aidl::android::hardware::drm::ProvideProvisionResponseResult;
using ::aidl::android::hardware::drm::ProvisionRequest;
using ::aidl::android::hardware::drm::SecureStop;
using ::aidl::android::hardware::drm::SecureStopId;
using ::aidl::android::hardware::drm::SecurityLevel;
using ::aidl::android::hardware::drm::Status;
@@ -91,10 +89,7 @@ using wvcdm::CdmOfflineLicenseState;
using wvcdm::CdmProvisioningRequest;
using wvcdm::CdmProvisioningResponse;
using wvcdm::CdmQueryMap;
using wvcdm::CdmSecureStopId;
using wvcdm::CdmSecurityLevel;
using wvcdm::CdmUsageInfo;
using wvcdm::CdmUsageInfoReleaseMessage;
using wvcdm::EMPTY_ORIGIN;
using wvcdm::kCertificateWidevine;
using wvcdm::KEY_ID_SIZE;
@@ -222,22 +217,6 @@ public:
bool),
(override));
MOCK_METHOD(CdmResponseType, GetUsageInfo,
(const std::string &, const CdmIdentifier &, CdmUsageInfo *),
(override));
MOCK_METHOD(CdmResponseType, GetUsageInfo,
(const std::string &, const CdmSecureStopId &,
const CdmIdentifier &, CdmUsageInfo *),
(override));
MOCK_METHOD(CdmResponseType, RemoveAllUsageInfo,
(const std::string &, const CdmIdentifier &), (override));
MOCK_METHOD(CdmResponseType, ReleaseUsageInfo,
(const CdmUsageInfoReleaseMessage &, const CdmIdentifier &),
(override));
MOCK_METHOD(bool, IsValidServiceCertificate, (const std::string &),
(override));
@@ -980,75 +959,6 @@ TEST_F(WVDrmPluginHalTest, RejectsAtscUnprovisionDeviceRequests) {
ASSERT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
}
TEST_F(WVDrmPluginHalTest, GetsSecureStops) {
static const uint32_t kStopSize = 53;
static const uint32_t kStopCount = 7;
uint8_t stopsRaw[kStopCount][kStopSize];
FILE *fp = fopen("/dev/urandom", "r");
ASSERT_NE(fp, nullptr) << "Failed to open /dev/urandom";
for (uint32_t i = 0; i < kStopCount; ++i) {
fread(stopsRaw[i], sizeof(uint8_t), kStopSize, fp);
}
fclose(fp);
CdmUsageInfo mCdmStops;
for (uint32_t i = 0; i < kStopCount; ++i) {
mCdmStops.push_back(std::string(stopsRaw[i], stopsRaw[i] + kStopSize));
}
const char *app_id = "my_app_id";
EXPECT_CALL(*mCdm, GetUsageInfo(StrEq(app_id), _, _))
.WillOnce(
DoAll(SetArgPointee<2>(mCdmStops), testing::Return(wvcdm::NO_ERROR)));
auto ret =
mPlugin->setPropertyString(std::string("appId"), std::string(app_id));
EXPECT_TRUE(ret.isOk());
std::vector<SecureStop> secureStops;
ret = mPlugin->getSecureStops(&secureStops);
EXPECT_TRUE(ret.isOk());
std::vector<std::vector<uint8_t>> stops;
for (const auto &stop : secureStops) {
stops.push_back(stop.opaqueData);
}
size_t index = 0;
for (const auto &stop : stops) {
EXPECT_THAT(stop, ElementsAreArray(stopsRaw[index++], kStopSize));
}
EXPECT_EQ(kStopCount, index);
}
TEST_F(WVDrmPluginHalTest, ReleasesAllSecureStops) {
EXPECT_CALL(*mCdm, RemoveAllUsageInfo(StrEq(""), _)).Times(1);
auto ret = mPlugin->setPropertyString(std::string("appId"), "");
EXPECT_TRUE(ret.isOk());
ret = mPlugin->releaseAllSecureStops();
EXPECT_TRUE(ret.isOk());
}
TEST_F(WVDrmPluginHalTest, ReleasesSecureStop) {
static const uint32_t kMessageSize = 128;
uint8_t messageRaw[kMessageSize];
FILE *fp = fopen("/dev/urandom", "r");
ASSERT_NE(fp, nullptr) << "Failed to open /dev/urandom";
fread(messageRaw, sizeof(uint8_t), kMessageSize, fp);
fclose(fp);
EXPECT_CALL(*mCdm,
ReleaseUsageInfo(ElementsAreArray(messageRaw, kMessageSize), _))
.Times(1);
SecureStopId stopId;
stopId.secureStopId.assign(messageRaw, messageRaw + kMessageSize);
auto ret = mPlugin->releaseSecureStop(stopId);
EXPECT_TRUE(ret.isOk());
}
TEST_F(WVDrmPluginHalTest, ReturnsExpectedPropertyValues) {
CdmQueryMap l1Map;
l1Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L1;

View File

@@ -59,16 +59,6 @@ using ::testing::Values;
using ::testing::WithParamInterface;
using ::testing::internal::ElementsAreArrayMatcher;
using wvcdm::kCertificateWidevine;
using wvcdm::kKeyRequestTypeInitial;
using wvcdm::kKeyRequestTypeRelease;
using wvcdm::kKeyRequestTypeRenewal;
using wvcdm::kLicenseTypeOffline;
using wvcdm::kLicenseTypeRelease;
using wvcdm::kLicenseTypeStreaming;
using wvcdm::kSecurityLevelL1;
using wvcdm::kSecurityLevelL3;
using wvutil::Base64Encode;
using wvcdm::CdmAppParameterMap;
using wvcdm::CdmCertificateType;
using wvcdm::CdmClientPropertySet;
@@ -84,10 +74,7 @@ using wvcdm::CdmOfflineLicenseState;
using wvcdm::CdmProvisioningRequest;
using wvcdm::CdmProvisioningResponse;
using wvcdm::CdmQueryMap;
using wvcdm::CdmSecureStopId;
using wvcdm::CdmSecurityLevel;
using wvcdm::CdmUsageInfo;
using wvcdm::CdmUsageInfoReleaseMessage;
using wvcdm::EMPTY_ORIGIN;
using wvcdm::kCertificateWidevine;
using wvcdm::KEY_ID_SIZE;
@@ -121,6 +108,7 @@ using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L1;
using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3;
using wvcdm::SESSION_ID_PREFIX;
using wvcdm::WvCdmEventListener;
using wvutil::Base64Encode;
namespace {
const std::string kEmptyString;
@@ -204,21 +192,6 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD(bool, IsProvisioned, (CdmSecurityLevel, const std::string&,
const std::string&, bool), (override));
MOCK_METHOD(CdmResponseType, GetUsageInfo, (const std::string&,
const CdmIdentifier&,
CdmUsageInfo*), (override));
MOCK_METHOD(CdmResponseType, GetUsageInfo, (const std::string&,
const CdmSecureStopId&,
const CdmIdentifier&,
CdmUsageInfo*), (override));
MOCK_METHOD(CdmResponseType, RemoveAllUsageInfo, (const std::string&,
const CdmIdentifier&), (override));
MOCK_METHOD(CdmResponseType, ReleaseUsageInfo,
(const CdmUsageInfoReleaseMessage&, const CdmIdentifier&), (override));
MOCK_METHOD(bool, IsValidServiceCertificate, (const std::string&), (override));
MOCK_METHOD(CdmResponseType, GetMetrics, (const CdmIdentifier&,
@@ -1144,96 +1117,6 @@ TEST_F(WVDrmPluginTest, RejectsAtscUnprovisionDeviceRequests) {
ASSERT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status);
}
TEST_F(WVDrmPluginTest, GetsSecureStops) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
StrictMock<MockCrypto> crypto;
std::string appPackageName;
static const uint32_t kStopSize = 53;
static const uint32_t kStopCount = 7;
uint8_t stopsRaw[kStopCount][kStopSize];
FILE* fp = fopen("/dev/urandom", "r");
for (uint32_t i = 0; i < kStopCount; ++i) {
fread(stopsRaw[i], sizeof(uint8_t), kStopSize, fp);
}
fclose(fp);
CdmUsageInfo cdmStops;
for (uint32_t i = 0; i < kStopCount; ++i) {
cdmStops.push_back(std::string(stopsRaw[i], stopsRaw[i] + kStopSize));
}
const char* app_id = "my_app_id";
EXPECT_CALL(*cdm, GetUsageInfo(StrEq(app_id), _, _))
.WillOnce(
DoAll(SetArgPointee<2>(cdmStops), testing::Return(wvcdm::NO_ERROR)));
std::vector<std::vector<uint8_t>> stops;
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
Status status =
plugin.setPropertyString(hidl_string("appId"), hidl_string(app_id));
ASSERT_EQ(Status::OK, status);
plugin.getSecureStops([&](Status status, hidl_vec<SecureStop> hSecureStops) {
ASSERT_EQ(Status::OK, status);
std::vector<SecureStop> secureStops(hSecureStops);
std::vector<SecureStop>::iterator iter = secureStops.begin();
std::vector<uint8_t> stop;
while (iter != secureStops.end()) {
stop = (*iter++).opaqueData;
stops.push_back(stop);
}
});
size_t index = 0;
for (auto stop : stops) {
EXPECT_THAT(stop, ElementsAreArray(stopsRaw[index++], kStopSize));
}
EXPECT_EQ(kStopCount, index);
}
TEST_F(WVDrmPluginTest, ReleasesAllSecureStops) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
StrictMock<MockCrypto> crypto;
std::string appPackageName;
EXPECT_CALL(*cdm, RemoveAllUsageInfo(StrEq(""), _)).Times(1);
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
Status status =
plugin.setPropertyString(hidl_string("appId"), hidl_string(""));
ASSERT_EQ(Status::OK, status);
status = plugin.releaseAllSecureStops();
ASSERT_EQ(Status::OK, status);
}
TEST_F(WVDrmPluginTest, ReleasesSecureStop) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
StrictMock<MockCrypto> crypto;
std::string appPackageName;
static const uint32_t kMessageSize = 128;
uint8_t messageRaw[kMessageSize];
FILE* fp = fopen("/dev/urandom", "r");
fread(messageRaw, sizeof(uint8_t), kMessageSize, fp);
fclose(fp);
std::vector<uint8_t> message;
message.assign(messageRaw, messageRaw + kMessageSize);
EXPECT_CALL(*cdm,
ReleaseUsageInfo(ElementsAreArray(messageRaw, kMessageSize), _))
.Times(1);
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
Status status = plugin.releaseSecureStop(toHidlVec(message));
ASSERT_EQ(Status::OK, status);
}
TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
StrictMock<MockCrypto> crypto;