Source release v3.5.0
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <string>
|
||||
#include "crypto_session.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
@@ -42,25 +41,9 @@ const std::string kTestSignedCertificate = a2bs_hex(
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
class MockCryptoSession : public CryptoSession {
|
||||
public:
|
||||
MOCK_METHOD2(GetRandom, bool(size_t, uint8_t*));
|
||||
};
|
||||
|
||||
class ServiceCertificateTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() { crypto_session_ = new MockCryptoSession(); }
|
||||
|
||||
virtual void TearDown() {
|
||||
if (crypto_session_) delete crypto_session_;
|
||||
}
|
||||
|
||||
void CreateServiceCertificate() {
|
||||
service_certificate_ = new ServiceCertificate();
|
||||
}
|
||||
|
||||
ServiceCertificate* service_certificate_;
|
||||
MockCryptoSession* crypto_session_;
|
||||
ServiceCertificate service_certificate_;
|
||||
};
|
||||
|
||||
class StubCdmClientPropertySet : public CdmClientPropertySet {
|
||||
@@ -77,11 +60,11 @@ class StubCdmClientPropertySet : public CdmClientPropertySet {
|
||||
virtual bool use_privacy_mode() const { return use_privacy_mode_; }
|
||||
|
||||
virtual const std::string& service_certificate() const {
|
||||
return service_certificate_;
|
||||
return raw_service_certificate_;
|
||||
}
|
||||
|
||||
virtual void set_service_certificate(const std::string& cert) {
|
||||
service_certificate_ = cert;
|
||||
raw_service_certificate_ = cert;
|
||||
}
|
||||
|
||||
virtual bool is_session_sharing_enabled() const {
|
||||
@@ -98,7 +81,7 @@ class StubCdmClientPropertySet : public CdmClientPropertySet {
|
||||
|
||||
private:
|
||||
std::string security_level_;
|
||||
std::string service_certificate_;
|
||||
std::string raw_service_certificate_;
|
||||
bool use_privacy_mode_;
|
||||
bool is_session_sharing_enabled_;
|
||||
uint32_t session_sharing_id_;
|
||||
@@ -106,11 +89,8 @@ class StubCdmClientPropertySet : public CdmClientPropertySet {
|
||||
};
|
||||
|
||||
TEST_F(ServiceCertificateTest, InitSuccess) {
|
||||
MockCryptoSession crypto_session;
|
||||
|
||||
CreateServiceCertificate();
|
||||
service_certificate_->Init(kTestSessionId1);
|
||||
EXPECT_FALSE(service_certificate_->HasCertificate());
|
||||
service_certificate_.Init(kTestSessionId1);
|
||||
EXPECT_FALSE(service_certificate_.has_certificate());
|
||||
}
|
||||
|
||||
TEST_F(ServiceCertificateTest, InitPrivacyModeRequired) {
|
||||
@@ -121,9 +101,8 @@ TEST_F(ServiceCertificateTest, InitPrivacyModeRequired) {
|
||||
Properties::Init();
|
||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
||||
|
||||
CreateServiceCertificate();
|
||||
service_certificate_->Init(kTestSessionId1);
|
||||
EXPECT_FALSE(service_certificate_->HasCertificate());
|
||||
service_certificate_.Init(kTestSessionId1);
|
||||
EXPECT_FALSE(service_certificate_.has_certificate());
|
||||
}
|
||||
|
||||
TEST_F(ServiceCertificateTest, InitServiceCertificatePresent) {
|
||||
@@ -135,13 +114,12 @@ TEST_F(ServiceCertificateTest, InitServiceCertificatePresent) {
|
||||
Properties::Init();
|
||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
||||
|
||||
CreateServiceCertificate();
|
||||
std::string service_certificate;
|
||||
std::string raw_service_certificate;
|
||||
EXPECT_TRUE(Properties::GetServiceCertificate(kTestSessionId1,
|
||||
&service_certificate));
|
||||
&raw_service_certificate));
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
service_certificate_->Init(service_certificate));
|
||||
EXPECT_TRUE(service_certificate_->HasCertificate());
|
||||
service_certificate_.Init(raw_service_certificate));
|
||||
EXPECT_TRUE(service_certificate_.has_certificate());
|
||||
}
|
||||
|
||||
TEST_F(ServiceCertificateTest, SetServiceCertificate) {
|
||||
@@ -152,9 +130,8 @@ TEST_F(ServiceCertificateTest, SetServiceCertificate) {
|
||||
Properties::Init();
|
||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
||||
|
||||
CreateServiceCertificate();
|
||||
EXPECT_EQ(NO_ERROR, service_certificate_->Init(kTestSignedCertificate));
|
||||
EXPECT_TRUE(service_certificate_->HasCertificate());
|
||||
EXPECT_EQ(NO_ERROR, service_certificate_.Init(kTestSignedCertificate));
|
||||
EXPECT_TRUE(service_certificate_.has_certificate());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user