From d4d46195ed2209ac4329779560b89da956709648 Mon Sep 17 00:00:00 2001 From: pkumar251_comcast Date: Tue, 27 Oct 2026 18:20:47 +0530 Subject: [PATCH] RDKEMW-16544 [AAMP]Change sessionID from uint32 to string when invoking ContentProtection APIs --- drm/DrmSessionManager.cpp | 12 +- .../ContentSecurityManager.cpp | 9 +- .../ContentSecurityManager.h | 24 +-- .../ContentSecurityManagerSession.cpp | 35 ++-- .../ContentSecurityManagerSession.h | 15 +- .../IFirebolt/ContentProtectionFirebolt.cpp | 44 ++--- .../IFirebolt/ContentProtectionFirebolt.h | 12 +- .../SecManagerThunder.cpp | 107 +++++++++--- .../SecManagerThunder.h | 8 +- .../fakes/FakeContentProtectionFireBolt.cpp | 15 +- .../fakes/FakeContentSecurityManager.cpp | 8 +- .../FakeContentSecurityManagerSession.cpp | 10 +- .../ContentSecurityManagerSessionTests.cpp | 98 +++++------ .../ContentSecurityManagerTests.cpp | 160 +++++++++--------- .../PlayerContentSecurityManagerFun.cpp | 120 ++++++------- .../PlayerContentSecurityManagerSes.cpp | 59 +++---- .../tests/FireBoltTests/FireBoltFun.cpp | 56 +++--- 17 files changed, 419 insertions(+), 373 deletions(-) diff --git a/drm/DrmSessionManager.cpp b/drm/DrmSessionManager.cpp index 8c3da56b..1ab5ae6b 100755 --- a/drm/DrmSessionManager.cpp +++ b/drm/DrmSessionManager.cpp @@ -226,7 +226,7 @@ void DrmSessionManager::clearDrmSession(bool forceClearSession) void DrmSessionManager::setVideoWindowSize(int width, int height) { auto localSession = mContentSecurityManagerSession; //Remove potential isSessionValid(), getSessionID() race by using a local copy - MW_LOG_WARN("In DrmSessionManager:: setting video window size w:%d x h:%d mMaxDRMSessions=%d sessionID=[%" PRId64 "]",width,height,mMaxDRMSessions,localSession.getSessionID()); + MW_LOG_WARN("In DrmSessionManager:: setting video window size w:%d x h:%d mMaxDRMSessions=%d sessionID=[%s]",width,height,mMaxDRMSessions,localSession.getSessionID().c_str()); if(localSession.isSessionValid()) { MW_LOG_WARN("In DrmSessionManager:: valid session ID. Calling setVideoWindowSize()."); @@ -274,7 +274,7 @@ void DrmSessionManager::setPlaybackSpeedState(bool live, double currentLatency, { bool isVideoOnMute=mIsVideoOnMute.load(); auto localSession = mContentSecurityManagerSession; //Remove potential isSessionValid(), getSessionID() race by using a local copy - MW_LOG_WARN("In DrmSessionManager::after calling setPlaybackSpeedState speed=%d position=%f sessionID=[%" PRId64 "], mute: %d",speed, positionMs, localSession.getSessionID(), isVideoOnMute); + MW_LOG_WARN("In DrmSessionManager::after calling setPlaybackSpeedState speed=%d position=%f sessionID=[%s], mute: %d",speed, positionMs, localSession.getSessionID().c_str(), isVideoOnMute); mCurrentSpeed.store(speed); if(firstFrameSeen) { @@ -312,7 +312,7 @@ void DrmSessionManager::setPlaybackSpeedState(bool live, double currentLatency, { bool firstFrameSeenCopy=mFirstFrameSeen.load(); isVideoOnMute=mIsVideoOnMute.load(); - MW_LOG_INFO("Not calling ContentSecurityManager::setPlaybackSpeedState(), sessionID=[%" PRId64 "], mIsVideoOnMute=%d, firstFrameSeen=%d", localSession.getSessionID(), isVideoOnMute, firstFrameSeenCopy); + MW_LOG_INFO("Not calling ContentSecurityManager::setPlaybackSpeedState(), sessionID=[%s], mIsVideoOnMute=%d, firstFrameSeen=%d", localSession.getSessionID().c_str(), isVideoOnMute, firstFrameSeenCopy); } } @@ -561,7 +561,7 @@ DrmSession* DrmSessionManager::createDrmSession(int &responseCode, int &err, std const auto &localSession = mContentSecurityManagerSession; //Remove potential isSessionValid(), getSessionID() race by using a local copy if (localSession.isSessionValid()) { - MW_LOG_WARN(" Setting sessionId[%" PRId64 "] to current drmSession", localSession.getSessionID()); + MW_LOG_WARN(" Setting sessionId[%s] to current drmSession", localSession.getSessionID().c_str()); drmSessionContexts[selectedSlot].drmSession->setSecManagerSession(localSession); } @@ -851,7 +851,7 @@ KeyState DrmSessionManager::getDrmSession(int &err, std::shared_ptr d // Set the drmSession's ID as mContentSecurityManagerSession so that this code will not be repeated for multiple calls for createDrmSession mContentSecurityManagerSession = slotSession; bool videoMuteState = mIsVideoOnMute.load(); - MW_LOG_WARN("Activating re-used DRM, sessionId[%" PRId64 "], with video mute = %d", slotSession.getSessionID(), videoMuteState); + MW_LOG_WARN("Activating re-used DRM, sessionId[%s], with video mute = %d", slotSession.getSessionID().c_str(), videoMuteState); ContentSecurityManager::GetInstance()->UpdateSessionState(slotSession.getSessionID(), true); } return KEY_READY; @@ -972,7 +972,7 @@ void DrmSessionManager::notifyCleanup() if(localSession.isSessionValid()) { // Set current session to inactive - MW_LOG_WARN("De-activate DRM session [%" PRId64 "] and watermark", localSession.getSessionID() ); + MW_LOG_WARN("De-activate DRM session [%s] and watermark", localSession.getSessionID().c_str()); ContentSecurityManager::GetInstance()->UpdateSessionState(localSession.getSessionID(), false); // Reset the session ID, the session ID is preserved within DrmSession instances mContentSecurityManagerSession.setSessionInvalid(); //note this doesn't necessarily close the session as the session ID is also saved in the slot diff --git a/externals/contentsecuritymanager/ContentSecurityManager.cpp b/externals/contentsecuritymanager/ContentSecurityManager.cpp index 3f8874bb..a8b13222 100755 --- a/externals/contentsecuritymanager/ContentSecurityManager.cpp +++ b/externals/contentsecuritymanager/ContentSecurityManager.cpp @@ -167,7 +167,7 @@ bool ContentSecurityManager::AcquireLicense(std::string clientId, std::string ap /** * @brief To update session state to SecManager */ -bool ContentSecurityManager::UpdateSessionState(int64_t sessionId, bool active) +bool ContentSecurityManager::UpdateSessionState(const std::string& sessionId, bool active) { bool success = false; success = SetDrmSessionState(sessionId, active); @@ -177,7 +177,7 @@ bool ContentSecurityManager::UpdateSessionState(int64_t sessionId, bool active) /** * @brief To notify SecManager to release a session */ -void ContentSecurityManager::ReleaseSession(int64_t sessionId) +void ContentSecurityManager::ReleaseSession(const std::string& sessionId) { CloseDrmSession(sessionId); } @@ -185,7 +185,7 @@ void ContentSecurityManager::ReleaseSession(int64_t sessionId) /** * @brief To update session state to SecManager */ -bool ContentSecurityManager::setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height) +bool ContentSecurityManager::setVideoWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height) { bool rpcResult = false; rpcResult = setWindowSize(sessionId, video_width, video_height); @@ -195,7 +195,7 @@ bool ContentSecurityManager::setVideoWindowSize(int64_t sessionId, int64_t video /** * @brief To set Playback Speed State to SecManager */ -bool ContentSecurityManager::setPlaybackSpeedState(int64_t sessionId, int64_t playback_speed, int64_t playback_position) +bool ContentSecurityManager::setPlaybackSpeedState(const std::string& sessionId, int64_t playback_speed, int64_t playback_position) { bool rpcResult = false; rpcResult = SetPlaybackPosition(sessionId, static_cast(playback_speed), static_cast(playback_position)); @@ -218,4 +218,3 @@ std::function& ContentSecurityMana { return SendWatermarkSessionEvent_CB; } - diff --git a/externals/contentsecuritymanager/ContentSecurityManager.h b/externals/contentsecuritymanager/ContentSecurityManager.h index d8c32110..33c3468f 100755 --- a/externals/contentsecuritymanager/ContentSecurityManager.h +++ b/externals/contentsecuritymanager/ContentSecurityManager.h @@ -106,7 +106,7 @@ class ContentSecurityManager : public PlayerScheduler * @param[in] sessionId - session id * @param[in] active - true if session is active, false otherwise */ - virtual bool UpdateSessionState(int64_t sessionId, bool active); + virtual bool UpdateSessionState(const std::string& sessionId, bool active); /** * @fn setVideoWindowSize @@ -115,7 +115,7 @@ class ContentSecurityManager : public PlayerScheduler * @param[in] video_width - video width * @param[in] video_height - video height */ - virtual bool setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height); + virtual bool setVideoWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height); /** * @fn setPlaybackSpeedState * @@ -123,14 +123,14 @@ class ContentSecurityManager : public PlayerScheduler * @param[in] playback_speed - playback speed * @param[in] playback_position - playback position */ - virtual bool setPlaybackSpeedState(int64_t sessionId, int64_t playback_speed, int64_t playback_position); + virtual bool setPlaybackSpeedState(const std::string& sessionId, int64_t playback_speed, int64_t playback_position); /** * @fn ReleaseSession - this should only be used by ContentSecurityManagerSession::SessionManager::~SessionManager(); * * @param[in] sessionId - session id */ - virtual void ReleaseSession(int64_t sessionId); + virtual void ReleaseSession(const std::string& sessionId); /** * @fn getSessionToken @@ -185,13 +185,13 @@ class ContentSecurityManager : public PlayerScheduler * @param active Whether the session should be marked active * @return true on success, false otherwise */ - virtual bool SetDrmSessionState(int64_t sessionId, bool active) { return false; } + virtual bool SetDrmSessionState(const std::string& sessionId, bool active) { return false; } /** * @brief Closes an existing DRM session * @param sessionId DRM session ID * @return true if closed successfully */ - virtual void CloseDrmSession(int64_t sessionId) {} + virtual void CloseDrmSession(const std::string& sessionId) {} /** * @brief Sets playback state for watermark alignment * @param sessionId Session ID @@ -199,7 +199,7 @@ class ContentSecurityManager : public PlayerScheduler * @param position Current position in seconds * @return true if command succeeded */ - virtual bool SetPlaybackPosition(int64_t sessionId, float speed, int32_t position) { return false; } + virtual bool SetPlaybackPosition(const std::string& sessionId, float speed, int32_t position) { return false; } /** * @fn setWindowSize * @@ -207,7 +207,7 @@ class ContentSecurityManager : public PlayerScheduler * @param[in] video_width - video width * @param[in] video_height - video height */ - virtual bool setWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height) { return false; }; + virtual bool setWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height) { return false; }; /** * @fn ContentSecurityManager @@ -260,20 +260,20 @@ class FakeSecManager : public ContentSecurityManager return false; } - bool UpdateSessionState(int64_t sessionId, bool active) override + bool UpdateSessionState(const std::string& sessionId, bool active) override { return false; } - bool setPlaybackSpeedState(int64_t sessionId, int64_t speed, int64_t position) override + bool setPlaybackSpeedState(const std::string& sessionId, int64_t speed, int64_t position) override { return false; } - bool setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height) override + bool setVideoWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height) override { return false; } - void ReleaseSession(int64_t sessionId) override + void ReleaseSession(const std::string& sessionId) override { } diff --git a/externals/contentsecuritymanager/ContentSecurityManagerSession.cpp b/externals/contentsecuritymanager/ContentSecurityManagerSession.cpp index b1565033..b97bc51d 100644 --- a/externals/contentsecuritymanager/ContentSecurityManagerSession.cpp +++ b/externals/contentsecuritymanager/ContentSecurityManagerSession.cpp @@ -24,17 +24,17 @@ #include "ContentSecurityManager.h" #include "PlayerLogManager.h" -std::shared_ptr ContentSecurityManagerSession::SessionManager::getInstance(int64_t sessionID, std::size_t inputSummaryHash) +std::shared_ptr ContentSecurityManagerSession::SessionManager::getInstance(const std::string& sessionID, std::size_t inputSummaryHash) { std::shared_ptr returnValue; static std::mutex instancesMutex; std::lock_guard lock{instancesMutex}; - static std::map> instances; + static std::map> instances; //Remove pointers to expired instances { - std::vector keysToRemove; + std::vector keysToRemove; for (auto i : instances) { if(i.second.expired()) @@ -57,10 +57,8 @@ std::shared_ptr ContentSecurityMa } } - /* Only create or retrieve instances for valid sessionIDs. - * <0 is used as an invalid value e.g. CONTENT_SECURITY_MGR_INVALID_SESSION_ID - * 0 removes all sessions which is not the intended behaviour here*/ - if(sessionID>0) + /* Only create or retrieve instances for non-empty session IDs. */ + if(!sessionID.empty()) { if(instances.count(sessionID)>0) { @@ -70,8 +68,8 @@ std::shared_ptr ContentSecurityMa if(!returnValue) { //unexpected - MW_LOG_WARN("ContentSecurityManagerSession: session ID %" PRId64 " reused or session closed too early.", - sessionID); + MW_LOG_WARN("ContentSecurityManagerSession: session ID %s reused or session closed too early.", + sessionID.c_str()); } } @@ -80,7 +78,7 @@ std::shared_ptr ContentSecurityMa if(returnValue->getInputSummaryHash()!=inputSummaryHash) { //this should only occur after a successful updatePlaybackSession - MW_LOG_MIL("ContentSecurityManagerSession: session ID %" PRId64 " input data changed.", sessionID); + MW_LOG_MIL("ContentSecurityManagerSession: session ID %s input data changed.", sessionID.c_str()); returnValue->setInputSummaryHash(inputSummaryHash); } } @@ -90,14 +88,14 @@ std::shared_ptr ContentSecurityMa * create a new instance & save a pointer to it for possible future reuse*/ returnValue.reset(new SessionManager{sessionID, inputSummaryHash}); instances[sessionID] = returnValue; - MW_LOG_WARN("ContentSecurityManagerSession: new instance created for ID:%" PRId64 ", %zu instances total.", - sessionID, + MW_LOG_WARN("ContentSecurityManagerSession: new instance created for ID:%s, %zu instances total.", + sessionID.c_str(), instances.size()); } } else { - MW_LOG_WARN("ContentSecurityManagerSession: invalid ID:%" PRId64 ".", sessionID); + MW_LOG_WARN("ContentSecurityManagerSession: invalid ID:%s.", sessionID.c_str()); } return returnValue; @@ -105,7 +103,7 @@ std::shared_ptr ContentSecurityMa ContentSecurityManagerSession::SessionManager::~SessionManager() { - if(mID>0) + if(!mID.empty()) { ContentSecurityManager::GetInstance()->ReleaseSession(mID); } @@ -119,20 +117,20 @@ void ContentSecurityManagerSession::SessionManager::setInputSummaryHash(std::siz } -ContentSecurityManagerSession::SessionManager::SessionManager(int64_t sessionID, std::size_t inputSummaryHash): +ContentSecurityManagerSession::SessionManager::SessionManager(const std::string& sessionID, std::size_t inputSummaryHash): mID(sessionID), mInputSummaryHash(inputSummaryHash) {}; -ContentSecurityManagerSession::ContentSecurityManagerSession(int64_t sessionID, std::size_t inputSummaryHash): +ContentSecurityManagerSession::ContentSecurityManagerSession(const std::string& sessionID, std::size_t inputSummaryHash): mpSessionManager(ContentSecurityManagerSession::SessionManager::getInstance(sessionID, inputSummaryHash)), sessionIdMutex() {}; -int64_t ContentSecurityManagerSession::getSessionID(void) const +std::string ContentSecurityManagerSession::getSessionID(void) const { std::lock_guardlock(sessionIdMutex); - int64_t ID = CONTENT_SECURITY_MGR_INVALID_SESSION_ID; + std::string ID = CONTENT_SECURITY_MGR_INVALID_SESSION_ID; if(mpSessionManager) { ID = mpSessionManager->getID(); @@ -152,4 +150,3 @@ std::size_t ContentSecurityManagerSession::getInputSummaryHash() return hash; } - diff --git a/externals/contentsecuritymanager/ContentSecurityManagerSession.h b/externals/contentsecuritymanager/ContentSecurityManagerSession.h index ee3f0747..42ff6e67 100755 --- a/externals/contentsecuritymanager/ContentSecurityManagerSession.h +++ b/externals/contentsecuritymanager/ContentSecurityManagerSession.h @@ -30,8 +30,9 @@ #include #include #include +#include -#define CONTENT_SECURITY_MGR_INVALID_SESSION_ID (-1) +#define CONTENT_SECURITY_MGR_INVALID_SESSION_ID "" class ContentSecurityManager; @@ -52,9 +53,9 @@ class ContentSecurityManagerSession class SessionManager { private: - int64_t mID; //set once undermutex in constructor + std::string mID; //set once under mutex in constructor std::atomic mInputSummaryHash; //can be changed by setInputSummaryHash - SessionManager(int64_t sessionID, std::size_t inputSummaryHash); + SessionManager(const std::string& sessionID, std::size_t inputSummaryHash); public: /** @@ -62,9 +63,9 @@ class ContentSecurityManagerSession * @brief * Get a shared pointer to an object corresponding to the sessionID, creating a new one if required */ - static std::shared_ptr getInstance(int64_t sessionID, std::size_t inputSummaryHash); + static std::shared_ptr getInstance(const std::string& sessionID, std::size_t inputSummaryHash); - int64_t getID(){return mID;} + const std::string& getID(){return mID;} std::size_t getInputSummaryHash(){return mInputSummaryHash.load();} void setInputSummaryHash(std::size_t inputSummaryHash); @@ -83,7 +84,7 @@ class ContentSecurityManagerSession * this is only intended to be used in ContentSecurityManager::acquireLicence() * it is the responsibility of ContentSecurityManager::acquireLicence() to ensure sessionID is valid */ - ContentSecurityManagerSession(int64_t sessionID, std::size_t inputSummaryHash); + ContentSecurityManagerSession(const std::string& sessionID, std::size_t inputSummaryHash); /** * @brief constructor for an invalid object*/ @@ -116,7 +117,7 @@ class ContentSecurityManagerSession * the ContentSecurityManagerSession on which this method is called * otherwise the session may be closed before the ID can be used */ - int64_t getSessionID(void) const; + std::string getSessionID(void) const; std::size_t getInputSummaryHash(); bool isSessionValid(void) const diff --git a/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.cpp b/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.cpp index 717da747..84191f2b 100644 --- a/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.cpp +++ b/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.cpp @@ -157,7 +157,7 @@ void ContentProtectionFirebolt::Initialize() m_pFireboltInterface = FireboltInterface::GetInstance(); mInitialized = true; /* hide watermarking at startup */ - int64_t sessionId = 0; + std::string sessionId = "0"; ShowWatermark(false, sessionId); /* CP Thunder Plugin doesnt allow invalid sessionId like 0 as in Thunder, hence not calling CloseDrmSession */ //CloseDrmSession(sessionId); @@ -168,7 +168,7 @@ void ContentProtectionFirebolt::DeInitialize() { /* SessionID is not used internally in CP Thunder Plugin for ShowWatermark. However Native SDK requires it to be sent. Keeping it dummy*/ - ShowWatermark(false, 0); + ShowWatermark(false, "0"); UnSubscribeEvents(); mInitialized = false; m_pFireboltInterface = nullptr; @@ -234,7 +234,7 @@ bool ContentProtectionFirebolt::AcquireLicenseOpenOrUpdate( std::string clientId param.add("contentAspectDimensions", aspectDimensions); param.add("mediaUsage", mediaUsageStr); - int64_t sessionId; + std::string sessionId; if (session.isSessionValid()) { // If sessionId is present, we are trying to acquire a new license within the same session @@ -434,7 +434,7 @@ bool ContentProtectionFirebolt::AcquireLicenseOpenOrUpdate( std::string clientId return ret; } -void ContentProtectionFirebolt::CloseDrmSession(int64_t sessionId) +void ContentProtectionFirebolt::CloseDrmSession(const std::string& sessionId) { // Check if Firebolt is active before proceeding if (!IsActive()) @@ -444,20 +444,20 @@ void ContentProtectionFirebolt::CloseDrmSession(int64_t sessionId) } std::lock_guard lock(mContentProtectionMutex); // Call the closeDrmSession method from the interface - auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().closeDrmSession(std::to_string(sessionId)); + auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().closeDrmSession(sessionId); // Check for errors if (result.error() == Firebolt::Error::None) { // No error, session was closed successfully - MW_LOG_INFO("Drm session closed successfully for sessionId: %" PRId64 "", sessionId); + MW_LOG_INFO("Drm session closed successfully for sessionId: %s", sessionId.c_str()); } else { // An error occurred, log the error - MW_LOG_ERR("CloseDrmSession: failed for sessionID: %" PRId64 " Firebolt Error: \"%d\"", sessionId, static_cast(result.error())); + MW_LOG_ERR("CloseDrmSession: failed for sessionID: %s Firebolt Error: \"%d\"", sessionId.c_str(), static_cast(result.error())); } } -bool ContentProtectionFirebolt::SetDrmSessionState(int64_t sessionId, bool active) +bool ContentProtectionFirebolt::SetDrmSessionState(const std::string& sessionId, bool active) { bool ret = false; Firebolt::Error error = Firebolt::Error::None; @@ -478,25 +478,25 @@ bool ContentProtectionFirebolt::SetDrmSessionState(int64_t sessionId, bool activ } std::lock_guard lock(mContentProtectionMutex); // Call the setDrmSessionState method from the interface - auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().setDrmSessionState(std::to_string(sessionId), sessionState); + auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().setDrmSessionState(sessionId, sessionState); // Check for errors if (result.error() == Firebolt::Error::None) { // No error, state was set successfully - MW_LOG_INFO("DRM session state set to %d for sessionId: %" PRId64 "", active, sessionId); + MW_LOG_INFO("DRM session state set to %d for sessionId: %s", active, sessionId.c_str()); ret = true; } else { // An error occurred, log the error - MW_LOG_ERR("DRM session state failed to set to %d for sessionId: %" PRId64 ", Firebolt Error: \"%d\"", static_cast(sessionState), sessionId, static_cast(result.error())); + MW_LOG_ERR("DRM session state failed to set to %d for sessionId: %s, Firebolt Error: \"%d\"", static_cast(sessionState), sessionId.c_str(), static_cast(result.error())); } return ret; } /** * @brief To set Playback Speed State to SecManager */ -bool ContentProtectionFirebolt::SetPlaybackPosition(int64_t sessionId, float speed, int32_t position) +bool ContentProtectionFirebolt::SetPlaybackPosition(const std::string& sessionId, float speed, int32_t position) { bool ret = false; // Check if Firebolt is active before proceeding @@ -507,25 +507,25 @@ bool ContentProtectionFirebolt::SetPlaybackPosition(int64_t sessionId, float spe } std::lock_guard lock(mContentProtectionMutex); // Call the setPlaybackPosition method from the interface - auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().setPlaybackPosition(std::to_string(sessionId), speed, position); + auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().setPlaybackPosition(sessionId, speed, position); // Check for errors if (result.error() == Firebolt::Error::None) { // No error, playback position was set successfully - MW_LOG_INFO("SetPlaybackPosition set successfully for sessionId: %" PRId64 " at position %d with speed %.2f", sessionId, position, speed); + MW_LOG_INFO("SetPlaybackPosition set successfully for sessionId: %s at position %d with speed %.2f", sessionId.c_str(), position, speed); ret = true; } else { // An error occurred, log the error - MW_LOG_ERR("SetPlaybackPosition failed to set for ID: %" PRId64 " Firebolt Error: \"%d\"", sessionId, static_cast(result.error())); + MW_LOG_ERR("SetPlaybackPosition failed to set for ID: %s Firebolt Error: \"%d\"", sessionId.c_str(), static_cast(result.error())); } return ret; } /** * @brief Show watermark image */ -void ContentProtectionFirebolt::ShowWatermark(bool show, int64_t sessionId) +void ContentProtectionFirebolt::ShowWatermark(bool show, const std::string& sessionId) { // Check if Firebolt is active before proceeding if (!IsActive()) { @@ -535,7 +535,7 @@ void ContentProtectionFirebolt::ShowWatermark(bool show, int64_t sessionId) std::lock_guard lock(mContentProtectionMutex); // Call the showWatermark method from the interface - auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().showWatermark(std::to_string(sessionId), show, 0); + auto result = Firebolt::IFireboltAampAccessor::Instance().ContentProtectionInterface().showWatermark(sessionId, show, 0); // Check for errors if (result.error() == Firebolt::Error::None) { // No error, watermark visibility was successfully set @@ -565,7 +565,7 @@ static Firebolt::ContentProtection::KeySystem convertStringToKeySystem(const std return Firebolt::ContentProtection::KeySystem::WIDEVINE; // safest fallback default } } -bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, int64_t &sessionId, int32_t &errorCode, std::string &response) +bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, std::string& sessionId, int32_t &errorCode, std::string &response) { bool ret = false; // Check if the system is active before proceeding @@ -582,7 +582,7 @@ bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::strin { MW_LOG_WARN("DRM session opened successfully with sessionId: '%s' with Response %s", drmSession->sessionId.c_str(), drmSession->openSessionResponse.c_str()); response = drmSession->openSessionResponse; - sessionId = std::stoll(drmSession->sessionId); + sessionId = drmSession->sessionId; ret = true; } else @@ -592,7 +592,7 @@ bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::strin } return ret; } -bool ContentProtectionFirebolt::UpdateDrmSession(int64_t sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response) +bool ContentProtectionFirebolt::UpdateDrmSession(const std::string& sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response) { bool ret = false; // Check if the system is active before proceeding @@ -603,11 +603,11 @@ bool ContentProtectionFirebolt::UpdateDrmSession(int64_t sessionId, int32_t &err auto drmSession = Firebolt::IFireboltAampAccessor::Instance() .ContentProtectionInterface() - .updateDrmSession(std::to_string(sessionId), + .updateDrmSession(sessionId, licenseRequest, initData); if(drmSession) { - MW_LOG_INFO("DRM session updated successfully for sessionId: %" PRId64 " with Response %s", sessionId, drmSession.value().c_str()); + MW_LOG_INFO("DRM session updated successfully for sessionId: %s with Response %s", sessionId.c_str(), drmSession.value().c_str()); response = drmSession.value(); ret = true; } diff --git a/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.h b/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.h index 7c3ee35c..0e2f28c0 100644 --- a/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.h +++ b/externals/contentsecuritymanager/IFirebolt/ContentProtectionFirebolt.h @@ -132,13 +132,13 @@ class ContentProtectionFirebolt : public ContentSecurityManager * @param active Whether the session should be marked active * @return true on success, false otherwise */ - bool SetDrmSessionState(int64_t sessionId, bool active) override; + bool SetDrmSessionState(const std::string& sessionId, bool active) override; /** * @brief Closes an existing DRM session * @param sessionId DRM session ID * @return true if closed successfully */ - void CloseDrmSession(int64_t sessionId) override; + void CloseDrmSession(const std::string& sessionId) override; /* Run AcquireLicenseOpenOrUpdate is the old AcquireLicense code * It is used by AcquireLicense() to for opening sessions & for calling update when this is required*/ bool AcquireLicenseOpenOrUpdate( std::string clientId, std::string appId, const char* licenseUrl, const char* moneyTraceMetadata[][2], @@ -159,7 +159,7 @@ class ContentProtectionFirebolt : public ContentSecurityManager * @param[out] response License server response * @return true on success */ - bool OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, int64_t &sessionId, int32_t &errorCode, std::string &response); + bool OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, std::string& sessionId, int32_t &errorCode, std::string &response); /** * @brief Sends update license challenge to existing session * @param sessionId DRM session ID @@ -168,7 +168,7 @@ class ContentProtectionFirebolt : public ContentSecurityManager * @param[out] response Response from Firebolt * @return true on success */ - bool UpdateDrmSession(int64_t sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response); + bool UpdateDrmSession(const std::string& sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response); /** * @brief Sets playback state for watermark alignment * @param sessionId Session ID @@ -176,13 +176,13 @@ class ContentProtectionFirebolt : public ContentSecurityManager * @param position Current position in seconds * @return true if command succeeded */ - bool SetPlaybackPosition(int64_t sessionId, float speed, int32_t position) override; + bool SetPlaybackPosition(const std::string& sessionId, float speed, int32_t position) override; /** * @brief Enables or disables visual watermark * @param show Show/hide flag * @param sessionId Session context (optional) */ - void ShowWatermark(bool show, int64_t sessionId); + void ShowWatermark(bool show, const std::string& sessionId); void HandleWatermarkEvent(const std::string& sessionId, const std::string& statusStr, const std::string& appId); private: diff --git a/externals/contentsecuritymanager/SecManagerThunder.cpp b/externals/contentsecuritymanager/SecManagerThunder.cpp index d20b716e..b55805f9 100644 --- a/externals/contentsecuritymanager/SecManagerThunder.cpp +++ b/externals/contentsecuritymanager/SecManagerThunder.cpp @@ -31,8 +31,29 @@ #include #include #include +#include +#include #include "ThunderAccessPlayer.h" +static bool parseThunderSessionId(const std::string& sessionId, int64_t& numericSessionId) +{ + if (sessionId.empty()) + { + return false; + } + + char* end = nullptr; + errno = 0; + const long long parsedSessionId = std::strtoll(sessionId.c_str(), &end, 10); + if (errno == ERANGE || end == sessionId.c_str() || *end != '\0' || parsedSessionId <= 0) + { + return false; + } + + numericSessionId = static_cast(parsedSessionId); + return true; +} + /** * @brief SecManagerThunder Constructor */ @@ -179,7 +200,14 @@ bool SecManagerThunder::AcquireLicenseOpenOrUpdate( std::string clientId, std::s if (session.isSessionValid()) { apiName = "updatePlaybackSession"; - param["sessionId"] = session.getSessionID(); + int64_t numericSessionId = 0; + const std::string sessionId = session.getSessionID(); + if (!parseThunderSessionId(sessionId, numericSessionId)) + { + MW_LOG_ERR("SecManager updatePlaybackSession received invalid session ID: %s", sessionId.c_str()); + return false; + } + param["sessionId"] = numericSessionId; } #ifdef DEBUG_SECMANAGER @@ -229,10 +257,14 @@ bool SecManagerThunder::AcquireLicenseOpenOrUpdate( std::string clientId, std::s * multiple object creation is OK as an existing instance should be returned * where input data changes e.g. following a call to updatePlaybackSession * the input data to the shared session is updated here*/ - newSession = ContentSecurityManagerSession(response["sessionId"].Number(), - ContentSecurityManager::getInputSummaryHash(moneyTraceMetadata, contentMetaDataStr.c_str(), - contMetaLen, licenseRequestStr.c_str(), keySystemId, - mediaUsage, accessTokenStr.c_str(), isVideoMuted)); + const int64_t numericSessionId = response["sessionId"].Number(); + if (numericSessionId > 0) + { + newSession = ContentSecurityManagerSession(std::to_string(numericSessionId), + ContentSecurityManager::getInputSummaryHash(moneyTraceMetadata, contentMetaDataStr.c_str(), + contMetaLen, licenseRequestStr.c_str(), keySystemId, + mediaUsage, accessTokenStr.c_str(), isVideoMuted)); + } std::string license = response["license"].String(); MW_LOG_TRACE("SecManager obtained license with length: %d and data: %s",license.size(), license.c_str()); if (!license.empty()) @@ -334,15 +366,21 @@ bool SecManagerThunder::AcquireLicenseOpenOrUpdate( std::string clientId, std::s /** * @brief To update session state to SecManager */ -bool SecManagerThunder::SetDrmSessionState(int64_t sessionId, bool active) +bool SecManagerThunder::SetDrmSessionState(const std::string& sessionId, bool active) { bool success = false; bool rpcResult = false; + int64_t numericSessionId = 0; + if (!parseThunderSessionId(sessionId, numericSessionId)) + { + MW_LOG_ERR("SecManager setPlaybackSessionState received invalid session ID: %s", sessionId.c_str()); + return false; + } JsonObject result; JsonObject param; param["clientId"] = "player"; - param["sessionId"] = sessionId; - MW_LOG_INFO("%s:%d SecManager call setPlaybackSessionState for ID: %" PRId64 " and state: %d", __FUNCTION__, __LINE__, sessionId, active); + param["sessionId"] = numericSessionId; + MW_LOG_INFO("%s:%d SecManager call setPlaybackSessionState for ID: %s and state: %d", __FUNCTION__, __LINE__, sessionId.c_str(), active); if (active) { param["sessionState"] = "active"; @@ -367,12 +405,12 @@ bool SecManagerThunder::SetDrmSessionState(int64_t sessionId, bool active) { std::string responseStr; result.ToString(responseStr); - MW_LOG_ERR("%s:%d SecManager setPlaybackSessionState failed for ID: %" PRId64 ", active:%d and result: %s", __FUNCTION__, __LINE__, sessionId, active, responseStr.c_str()); + MW_LOG_ERR("%s:%d SecManager setPlaybackSessionState failed for ID: %s, active:%d and result: %s", __FUNCTION__, __LINE__, sessionId.c_str(), active, responseStr.c_str()); } } else { - MW_LOG_ERR("%s:%d SecManager setPlaybackSessionState failed for ID: %" PRId64 " and active: %d", __FUNCTION__, __LINE__, sessionId, active); + MW_LOG_ERR("%s:%d SecManager setPlaybackSessionState failed for ID: %s and active: %d", __FUNCTION__, __LINE__, sessionId.c_str(), active); } return success; } @@ -380,14 +418,20 @@ bool SecManagerThunder::SetDrmSessionState(int64_t sessionId, bool active) /** * @brief To notify SecManager to release a session */ -void SecManagerThunder::CloseDrmSession(int64_t sessionId) +void SecManagerThunder::CloseDrmSession(const std::string& sessionId) { bool rpcResult = false; + int64_t numericSessionId = 0; + if (!parseThunderSessionId(sessionId, numericSessionId)) + { + MW_LOG_ERR("SecManager closePlaybackSession received invalid session ID: %s", sessionId.c_str()); + return; + } JsonObject result; JsonObject param; param["clientId"] = "player"; - param["sessionId"] = sessionId; - MW_LOG_INFO("%s:%d SecManager call closePlaybackSession for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + param["sessionId"] = numericSessionId; + MW_LOG_INFO("%s:%d SecManager call closePlaybackSession for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); { std::lock_guard lock(mSecMutex); @@ -400,29 +444,35 @@ void SecManagerThunder::CloseDrmSession(int64_t sessionId) { std::string responseStr; result.ToString(responseStr); - MW_LOG_ERR("%s:%d SecManager closePlaybackSession failed for ID: %" PRId64 " and result: %s", __FUNCTION__, __LINE__, sessionId, responseStr.c_str()); + MW_LOG_ERR("%s:%d SecManager closePlaybackSession failed for ID: %s and result: %s", __FUNCTION__, __LINE__, sessionId.c_str(), responseStr.c_str()); } } else { - MW_LOG_ERR("%s:%d SecManager closePlaybackSession failed for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + MW_LOG_ERR("%s:%d SecManager closePlaybackSession failed for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); } } /** * @brief To update session state to SecManager */ -bool SecManagerThunder::setWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height) +bool SecManagerThunder::setWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height) { bool rpcResult = false; + int64_t numericSessionId = 0; + if (!parseThunderSessionId(sessionId, numericSessionId)) + { + MW_LOG_ERR("SecManager setVideoWindowSize received invalid session ID: %s", sessionId.c_str()); + return false; + } JsonObject result; JsonObject param; - param["sessionId"] = sessionId; + param["sessionId"] = numericSessionId; param["videoWidth"] = video_width; param["videoHeight"] = video_height; - MW_LOG_INFO("%s:%d SecManager call setVideoWindowSize for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + MW_LOG_INFO("%s:%d SecManager call setVideoWindowSize for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); { std::lock_guard lock(mSecMutex); rpcResult = mSecManagerObj.InvokeJSONRPC("setVideoWindowSize", param, result); @@ -434,14 +484,14 @@ bool SecManagerThunder::setWindowSize(int64_t sessionId, int64_t video_width, in { std::string responseStr; result.ToString(responseStr); - MW_LOG_ERR("%s:%d SecManager setVideoWindowSize failed for ID: %" PRId64 " and result: %s", __FUNCTION__, __LINE__, sessionId, responseStr.c_str()); + MW_LOG_ERR("%s:%d SecManager setVideoWindowSize failed for ID: %s and result: %s", __FUNCTION__, __LINE__, sessionId.c_str(), responseStr.c_str()); rpcResult = false; } } else { - MW_LOG_ERR("%s:%d SecManager setVideoWindowSize failed for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + MW_LOG_ERR("%s:%d SecManager setVideoWindowSize failed for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); } return rpcResult; } @@ -449,19 +499,25 @@ bool SecManagerThunder::setWindowSize(int64_t sessionId, int64_t video_width, in /** * @brief To set Playback Speed State to SecManager */ -bool SecManagerThunder::SetPlaybackPosition(int64_t sessionId, float playback_speed, int32_t playback_position) +bool SecManagerThunder::SetPlaybackPosition(const std::string& sessionId, float playback_speed, int32_t playback_position) { bool rpcResult = false; + int64_t numericSessionId = 0; + if (!parseThunderSessionId(sessionId, numericSessionId)) + { + MW_LOG_ERR("SecManager setPlaybackSpeedState received invalid session ID: %s", sessionId.c_str()); + return false; + } JsonObject result; JsonObject param; //mSpeedStateMutex is used to avoid any speedstate event to go when a delayed event is in progress results change in order of event call (i.e, if user tries a trickplay within half a second of tune) std::lock_guard lock(mSpeedStateMutex); - param["sessionId"] = sessionId; + param["sessionId"] = numericSessionId; param["playbackSpeed"] = playback_speed; param["playbackPosition"] = playback_position; - MW_LOG_INFO("%s:%d SecManager call setPlaybackSpeedState for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + MW_LOG_INFO("%s:%d SecManager call setPlaybackSpeedState for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); { std::lock_guard lock(mSecMutex); @@ -474,13 +530,13 @@ bool SecManagerThunder::SetPlaybackPosition(int64_t sessionId, float playback_sp { std::string responseStr; result.ToString(responseStr); - MW_LOG_ERR("%s:%d SecManager setPlaybackSpeedState failed for ID: %" PRId64 " and result: %s", __FUNCTION__, __LINE__, sessionId, responseStr.c_str()); + MW_LOG_ERR("%s:%d SecManager setPlaybackSpeedState failed for ID: %s and result: %s", __FUNCTION__, __LINE__, sessionId.c_str(), responseStr.c_str()); rpcResult = false; } } else { - MW_LOG_ERR("%s:%d SecManager setPlaybackSpeedState failed for ID: %" PRId64 "", __FUNCTION__, __LINE__, sessionId); + MW_LOG_ERR("%s:%d SecManager setPlaybackSpeedState failed for ID: %s", __FUNCTION__, __LINE__, sessionId.c_str()); } return rpcResult; } @@ -977,4 +1033,3 @@ void SecManagerThunder::ModifyWatermarkPalette(int graphicId, int clutKey, int i MW_LOG_ERR("ContentSecurityManager Thunder invocation for modifyPalettedWatermark failed!, graphic id: %d", graphicId); } } - diff --git a/externals/contentsecuritymanager/SecManagerThunder.h b/externals/contentsecuritymanager/SecManagerThunder.h index 750a1d62..fa59c775 100644 --- a/externals/contentsecuritymanager/SecManagerThunder.h +++ b/externals/contentsecuritymanager/SecManagerThunder.h @@ -56,13 +56,13 @@ class SecManagerThunder : public ContentSecurityManager * @param active Whether the session should be marked active * @return true on success, false otherwise */ - bool SetDrmSessionState(int64_t sessionId, bool active) override; + bool SetDrmSessionState(const std::string& sessionId, bool active) override; /** * @brief Closes an existing DRM session * @param sessionId DRM session ID * @return true if closed successfully */ - void CloseDrmSession(int64_t sessionId) override; + void CloseDrmSession(const std::string& sessionId) override; /* Run AcquireLicenseOpenOrUpdate is the old AcquireLicense code * It is used by AcquireLicense() to for opening sessions & for calling update when this is required*/ bool AcquireLicenseOpenOrUpdate( std::string clientId, std::string appId, const char* licenseUrl, const char* moneyTraceMetadata[][2], @@ -87,7 +87,7 @@ class SecManagerThunder : public ContentSecurityManager * @param position Current position in seconds * @return true if command succeeded */ - bool SetPlaybackPosition(int64_t sessionId, float speed, int32_t position) override; + bool SetPlaybackPosition(const std::string& sessionId, float speed, int32_t position) override; /** * @brief Enables or disables visual watermark * @param show Show/hide flag @@ -107,7 +107,7 @@ class SecManagerThunder : public ContentSecurityManager * @param[in] video_width - video width * @param[in] video_height - video height */ - bool setWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height); + bool setWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height); /** * @fn getSchedulerStatus diff --git a/test/utests/fakes/FakeContentProtectionFireBolt.cpp b/test/utests/fakes/FakeContentProtectionFireBolt.cpp index 838ac926..0c2d229d 100644 --- a/test/utests/fakes/FakeContentProtectionFireBolt.cpp +++ b/test/utests/fakes/FakeContentProtectionFireBolt.cpp @@ -44,20 +44,21 @@ bool ContentProtectionFirebolt::AcquireLicenseOpenOrUpdate( if (statusCode) *statusCode = 0; if (reasonCode) *reasonCode = 0; if (businessStatus) *businessStatus = 0; - session = ContentSecurityManagerSession(1, 0); // fake valid session + session = ContentSecurityManagerSession("1", 0); // fake valid session return true; } -void ContentProtectionFirebolt::CloseDrmSession(int64_t) {} -bool ContentProtectionFirebolt::SetDrmSessionState(int64_t, bool) { return true; } -bool ContentProtectionFirebolt::SetPlaybackPosition(int64_t, float, int32_t) { return true; } -void ContentProtectionFirebolt::ShowWatermark(bool, int64_t) {} -bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, int64_t &sessionId, int32_t &errorCode, std::string &response) +void ContentProtectionFirebolt::CloseDrmSession(const std::string&) {} +bool ContentProtectionFirebolt::SetDrmSessionState(const std::string&, bool) { return true; } +bool ContentProtectionFirebolt::SetPlaybackPosition(const std::string&, float, int32_t) { return true; } +void ContentProtectionFirebolt::ShowWatermark(bool, const std::string&) {} +bool ContentProtectionFirebolt::OpenDrmSession(std::string& clientId, std::string appId, std::string keySystem, std::string licenseRequest, std::string initData, std::string& sessionId, int32_t &errorCode, std::string &response) { response = "{\"license\":\"RkFLRV9MSUNFTlNF\"}"; // base64 for "FAKE_LICENSE" + sessionId = "1"; return true; } -bool ContentProtectionFirebolt::UpdateDrmSession(int64_t sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response) +bool ContentProtectionFirebolt::UpdateDrmSession(const std::string& sessionId, int32_t &errorCode, std::string licenseRequest, std::string initData, std::string &response) { response = "{\"license\":\"RkFLRV9MSUNFTlNF\"}"; return true; diff --git a/test/utests/fakes/FakeContentSecurityManager.cpp b/test/utests/fakes/FakeContentSecurityManager.cpp index 5553b12f..982cebe8 100644 --- a/test/utests/fakes/FakeContentSecurityManager.cpp +++ b/test/utests/fakes/FakeContentSecurityManager.cpp @@ -70,7 +70,7 @@ bool ContentSecurityManager::getSessionToken(std::string &token) /** * @brief To update session state to SecManager */ -bool ContentSecurityManager::UpdateSessionState(int64_t sessionId, bool active) +bool ContentSecurityManager::UpdateSessionState(const std::string& sessionId, bool active) { return false; } @@ -78,7 +78,7 @@ bool ContentSecurityManager::UpdateSessionState(int64_t sessionId, bool active) /** * @brief To update session state to SecManager */ -bool ContentSecurityManager::setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height) +bool ContentSecurityManager::setVideoWindowSize(const std::string& sessionId, int64_t video_width, int64_t video_height) { return false; } @@ -86,7 +86,7 @@ bool ContentSecurityManager::setVideoWindowSize(int64_t sessionId, int64_t video /** * @brief To set Playback Speed State to SecManager */ -bool ContentSecurityManager::setPlaybackSpeedState(int64_t sessionId, int64_t playback_speed, int64_t playback_position) +bool ContentSecurityManager::setPlaybackSpeedState(const std::string& sessionId, int64_t playback_speed, int64_t playback_position) { return false; } @@ -94,7 +94,7 @@ bool ContentSecurityManager::setPlaybackSpeedState(int64_t sessionId, int64_t pl /** * @brief To notify SecManager to release a session */ -void ContentSecurityManager::ReleaseSession(int64_t sessionId) +void ContentSecurityManager::ReleaseSession(const std::string& sessionId) { return; } diff --git a/test/utests/fakes/FakeContentSecurityManagerSession.cpp b/test/utests/fakes/FakeContentSecurityManagerSession.cpp index 36f8cd58..f77b549c 100644 --- a/test/utests/fakes/FakeContentSecurityManagerSession.cpp +++ b/test/utests/fakes/FakeContentSecurityManagerSession.cpp @@ -24,7 +24,7 @@ #include "ContentSecurityManagerSession.h" -std::shared_ptr ContentSecurityManagerSession::SessionManager::getInstance(int64_t sessionID, std::size_t inputSummaryHash) +std::shared_ptr ContentSecurityManagerSession::SessionManager::getInstance(const std::string& sessionID, std::size_t inputSummaryHash) { std::shared_ptr returnValue = nullptr; return returnValue; @@ -38,15 +38,15 @@ void ContentSecurityManagerSession::SessionManager::setInputSummaryHash(std::siz } -ContentSecurityManagerSession::SessionManager::SessionManager(int64_t sessionID, std::size_t inputSummaryHash) +ContentSecurityManagerSession::SessionManager::SessionManager(const std::string& sessionID, std::size_t inputSummaryHash) {}; -ContentSecurityManagerSession::ContentSecurityManagerSession(int64_t sessionID, std::size_t inputSummaryHash) +ContentSecurityManagerSession::ContentSecurityManagerSession(const std::string& sessionID, std::size_t inputSummaryHash) {}; -int64_t ContentSecurityManagerSession::getSessionID(void) const +std::string ContentSecurityManagerSession::getSessionID(void) const { - int64_t ID = CONTENT_SECURITY_MGR_INVALID_SESSION_ID; + std::string ID = CONTENT_SECURITY_MGR_INVALID_SESSION_ID; return ID; } diff --git a/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerSessionTests.cpp b/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerSessionTests.cpp index 4c04cc19..ec5bff06 100644 --- a/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerSessionTests.cpp +++ b/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerSessionTests.cpp @@ -91,7 +91,7 @@ TEST(ContentSecurityManagerSession, DefaultConstructor) { TEST(ContentSecurityManagerSession, ConstructorWithValidId) { std::cout << "[ContentSecurityManagerSession] ConstructorWithValidId - START" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::size_t hash = 67890; ContentSecurityManagerSession session(sessionId, hash); @@ -125,15 +125,14 @@ TEST(ContentSecurityManagerSession, ConstructorWithValidId) { TEST(ContentSecurityManagerSession, ConstructorWithZeroId) { std::cout << "[ContentSecurityManagerSession] ConstructorWithZeroId - START" << std::endl; - int64_t sessionId = 0; // Invalid session ID + std::string sessionId = std::to_string(0); std::size_t hash = 1234; ContentSecurityManagerSession session(sessionId, hash); - // Zero session ID is treated as invalid by implementation - EXPECT_FALSE(session.isSessionValid()); - EXPECT_EQ(session.getSessionID(), -1); // Invalid session returns -1 - EXPECT_EQ(session.getInputSummaryHash(), 0u); // Hash not stored for invalid session + EXPECT_TRUE(session.isSessionValid()); + EXPECT_EQ(session.getSessionID(), sessionId); + EXPECT_EQ(session.getInputSummaryHash(), hash); std::cout << "[ContentSecurityManagerSession] ConstructorWithZeroId - PASS" << std::endl; } @@ -160,13 +159,13 @@ TEST(ContentSecurityManagerSession, ConstructorWithZeroId) { TEST(ContentSecurityManagerSession, ConstructorWithNegativeId) { std::cout << "[ContentSecurityManagerSession] ConstructorWithNegativeId - START" << std::endl; - int64_t sessionId = -100; // Invalid session ID + std::string sessionId = std::to_string(-100); // Invalid session ID std::size_t hash = 5000; EXPECT_NO_THROW({ ContentSecurityManagerSession session(sessionId, hash); - // Negative session ID is treated as invalid by implementation - EXPECT_EQ(session.getSessionID(), -1); // Invalid session returns -1 + EXPECT_EQ(session.getSessionID(), sessionId); + EXPECT_EQ(session.getInputSummaryHash(), hash); }); std::cout << "[ContentSecurityManagerSession] ConstructorWithNegativeId - PASS" << std::endl; @@ -194,7 +193,7 @@ TEST(ContentSecurityManagerSession, ConstructorWithNegativeId) { TEST(ContentSecurityManagerSession, ConstructorWithMaxInt64Id) { std::cout << "[ContentSecurityManagerSession] ConstructorWithMaxInt64Id - START" << std::endl; - int64_t sessionId = INT64_MAX; + std::string sessionId = std::to_string(INT64_MAX); std::size_t hash = 9999; EXPECT_NO_THROW({ @@ -228,13 +227,13 @@ TEST(ContentSecurityManagerSession, ConstructorWithMaxInt64Id) { TEST(ContentSecurityManagerSession, ConstructorWithMinInt64Id) { std::cout << "[ContentSecurityManagerSession] ConstructorWithMinInt64Id - START" << std::endl; - int64_t sessionId = INT64_MIN; // Invalid session ID (negative) + std::string sessionId = std::to_string(INT64_MIN); std::size_t hash = 1111; EXPECT_NO_THROW({ ContentSecurityManagerSession session(sessionId, hash); - // INT64_MIN is treated as invalid by implementation - EXPECT_EQ(session.getSessionID(), -1); // Invalid session returns -1 + EXPECT_EQ(session.getSessionID(), sessionId); + EXPECT_EQ(session.getInputSummaryHash(), hash); }); std::cout << "[ContentSecurityManagerSession] ConstructorWithMinInt64Id - PASS" << std::endl; @@ -262,7 +261,7 @@ TEST(ContentSecurityManagerSession, ConstructorWithMinInt64Id) { TEST(ContentSecurityManagerSession, ConstructorWithZeroHash) { std::cout << "[ContentSecurityManagerSession] ConstructorWithZeroHash - START" << std::endl; - int64_t sessionId = 2000; + std::string sessionId = std::to_string(2000); std::size_t hash = 0; ContentSecurityManagerSession session(sessionId, hash); @@ -295,7 +294,7 @@ TEST(ContentSecurityManagerSession, ConstructorWithZeroHash) { TEST(ContentSecurityManagerSession, ConstructorWithMaxHash) { std::cout << "[ContentSecurityManagerSession] ConstructorWithMaxHash - START" << std::endl; - int64_t sessionId = 3000; + std::string sessionId = std::to_string(3000); std::size_t hash = std::numeric_limits::max(); ContentSecurityManagerSession session(sessionId, hash); @@ -332,7 +331,7 @@ TEST(ContentSecurityManagerSession, ConstructorWithMaxHash) { TEST(ContentSecurityManagerSession, CopyConstructor) { std::cout << "[ContentSecurityManagerSession] CopyConstructor - START" << std::endl; - int64_t sessionId = 99999; + std::string sessionId = std::to_string(99999); std::size_t hash = 11111; ContentSecurityManagerSession session1(sessionId, hash); @@ -399,7 +398,7 @@ TEST(ContentSecurityManagerSession, CopyConstructorFromInvalid) { TEST(ContentSecurityManagerSession, AssignmentOperator) { std::cout << "[ContentSecurityManagerSession] AssignmentOperator - START" << std::endl; - int64_t sessionId = 77777; + std::string sessionId = std::to_string(77777); std::size_t hash = 22222; ContentSecurityManagerSession session1(sessionId, hash); @@ -439,7 +438,7 @@ TEST(ContentSecurityManagerSession, AssignmentOperator) { TEST(ContentSecurityManagerSession, AssignmentChain) { std::cout << "[ContentSecurityManagerSession] AssignmentChain - START" << std::endl; - int64_t sessionId = 44444; + std::string sessionId = std::to_string(44444); std::size_t hash = 88888; ContentSecurityManagerSession session1(sessionId, hash); @@ -482,7 +481,7 @@ TEST(ContentSecurityManagerSession, AssignmentChain) { TEST(ContentSecurityManagerSession, GetSessionID_ValidSession) { std::cout << "[ContentSecurityManagerSession] GetSessionID_ValidSession - START" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); ContentSecurityManagerSession session(sessionId, 100); EXPECT_EQ(session.getSessionID(), sessionId); @@ -490,6 +489,14 @@ TEST(ContentSecurityManagerSession, GetSessionID_ValidSession) { std::cout << "[ContentSecurityManagerSession] GetSessionID_ValidSession - PASS" << std::endl; } +TEST(ContentSecurityManagerSession, PreservesOpaqueSessionID) { + const std::string sessionId = "firebolt-session:ab12-cd34"; + ContentSecurityManagerSession session(sessionId, 100); + + EXPECT_TRUE(session.isSessionValid()); + EXPECT_EQ(session.getSessionID(), sessionId); +} + /** * @brief Test getSessionID for invalid session * @@ -542,7 +549,7 @@ TEST(ContentSecurityManagerSession, GetInputSummaryHash_ValidInput) { std::cout << "[ContentSecurityManagerSession] GetInputSummaryHash_ValidInput - START" << std::endl; std::size_t hash = 12345; - ContentSecurityManagerSession session(1000, hash); + ContentSecurityManagerSession session(std::to_string(1000), hash); EXPECT_EQ(session.getInputSummaryHash(), hash); @@ -571,7 +578,7 @@ TEST(ContentSecurityManagerSession, GetInputSummaryHash_ValidInput) { TEST(ContentSecurityManagerSession, GetInputSummaryHash_ZeroHash) { std::cout << "[ContentSecurityManagerSession] GetInputSummaryHash_ZeroHash - START" << std::endl; - ContentSecurityManagerSession session(1001, 0); + ContentSecurityManagerSession session(std::to_string(1001), 0); EXPECT_EQ(session.getInputSummaryHash(), 0); @@ -633,7 +640,7 @@ TEST(ContentSecurityManagerSession, GetInputSummaryHash_DefaultConstructor) { TEST(ContentSecurityManagerSession, IsSessionValid_ValidSession) { std::cout << "[ContentSecurityManagerSession] IsSessionValid_ValidSession - START" << std::endl; - ContentSecurityManagerSession session(12345, 67890); + ContentSecurityManagerSession session(std::to_string(12345), 67890); EXPECT_TRUE(session.isSessionValid()); @@ -691,7 +698,7 @@ TEST(ContentSecurityManagerSession, IsSessionValid_InvalidSession) { TEST(ContentSecurityManagerSession, SetSessionInvalid) { std::cout << "[ContentSecurityManagerSession] SetSessionInvalid - START" << std::endl; - int64_t sessionId = 55555; + std::string sessionId = std::to_string(55555); std::size_t hash = 33333; ContentSecurityManagerSession session(sessionId, hash); @@ -727,7 +734,7 @@ TEST(ContentSecurityManagerSession, SetSessionInvalid) { TEST(ContentSecurityManagerSession, SetSessionInvalid_MultipleTimes) { std::cout << "[ContentSecurityManagerSession] SetSessionInvalid_MultipleTimes - START" << std::endl; - ContentSecurityManagerSession session(11111, 22222); + ContentSecurityManagerSession session(std::to_string(11111), 22222); session.setSessionInvalid(); EXPECT_FALSE(session.isSessionValid()); @@ -767,7 +774,7 @@ TEST(ContentSecurityManagerSession, SetSessionInvalid_MultipleTimes) { TEST(ContentSecurityManagerSession, ToString_ValidSession) { std::cout << "[ContentSecurityManagerSession] ToString_ValidSession - START" << std::endl; - int64_t sessionId = 44444; + std::string sessionId = std::to_string(44444); std::size_t hash = 88888; ContentSecurityManagerSession session(sessionId, hash); @@ -834,7 +841,7 @@ TEST(ContentSecurityManagerSession, ToString_InvalidSession) { TEST(ContentSecurityManagerSession, ToString_AfterInvalidation) { std::cout << "[ContentSecurityManagerSession] ToString_AfterInvalidation - START" << std::endl; - ContentSecurityManagerSession session(99999, 11111); + ContentSecurityManagerSession session(std::to_string(99999), 11111); session.setSessionInvalid(); std::string str = session.ToString(); @@ -871,7 +878,7 @@ TEST(ContentSecurityManagerSession, ToString_AfterInvalidation) { TEST(ContentSecurityManagerSession, CompleteLifecycle) { std::cout << "[ContentSecurityManagerSession] CompleteLifecycle - START" << std::endl; - int64_t sessionId = 88888; + std::string sessionId = std::to_string(88888); std::size_t hash = 77777; { @@ -921,12 +928,12 @@ TEST(ContentSecurityManagerSession, MultipleValidSessions) { std::vector sessions; for (int i = 0; i < 10; i++) { - sessions.emplace_back(1000 + i, 2000 + i); + sessions.emplace_back(std::to_string(1000 + i), 2000 + i); } for (size_t i = 0; i < sessions.size(); i++) { EXPECT_TRUE(sessions[i].isSessionValid()); - EXPECT_EQ(sessions[i].getSessionID(), 1000 + static_cast(i)); + EXPECT_EQ(sessions[i].getSessionID(), std::to_string(1000 + static_cast(i))); EXPECT_EQ(sessions[i].getInputSummaryHash(), 2000 + i); } @@ -959,11 +966,11 @@ TEST(ContentSecurityManagerSession, ReassignmentOverwrite) { // Start from i=1 to avoid sessionId=0 which is invalid for (int i = 1; i <= 5; i++) { - ContentSecurityManagerSession tempSession(100 * i, 200 * i); + ContentSecurityManagerSession tempSession(std::to_string(100 * i), 200 * i); session = tempSession; EXPECT_TRUE(session.isSessionValid()); - EXPECT_EQ(session.getSessionID(), 100 * i); + EXPECT_EQ(session.getSessionID(), std::to_string(100 * i)); EXPECT_EQ(session.getInputSummaryHash(), 200 * i); } @@ -992,34 +999,23 @@ TEST(ContentSecurityManagerSession, ReassignmentOverwrite) { TEST(ContentSecurityManagerSession, BoundarySessionIds) { std::cout << "[ContentSecurityManagerSession] BoundarySessionIds - START" << std::endl; - // Valid boundary values (positive) - std::vector validValues = { + // Session IDs are opaque strings; numeric boundary values are preserved as strings. + std::vector boundaryValues = { 1, INT64_MAX, - INT64_MAX - 1 - }; - - // Invalid boundary values (zero and negative) - std::vector invalidValues = { + INT64_MAX - 1, 0, -1, INT64_MIN, INT64_MIN + 1 }; - // Test valid sessionIds - for (auto sessionId : validValues) { - EXPECT_NO_THROW({ - ContentSecurityManagerSession session(sessionId, 100); - EXPECT_EQ(session.getSessionID(), sessionId); - }); - } - - // Test invalid sessionIds (should return -1) - for (auto sessionId : invalidValues) { + for (auto sessionId : boundaryValues) { + const std::string sessionIdString = std::to_string(sessionId); EXPECT_NO_THROW({ - ContentSecurityManagerSession session(sessionId, 100); - EXPECT_EQ(session.getSessionID(), -1); // Invalid IDs return -1 + ContentSecurityManagerSession session(sessionIdString, 100); + EXPECT_TRUE(session.isSessionValid()); + EXPECT_EQ(session.getSessionID(), sessionIdString); }); } @@ -1057,7 +1053,7 @@ TEST(ContentSecurityManagerSession, BoundaryHashValues) { for (auto hash : boundaryValues) { EXPECT_NO_THROW({ - ContentSecurityManagerSession session(100, hash); + ContentSecurityManagerSession session(std::to_string(100), hash); EXPECT_EQ(session.getInputSummaryHash(), hash); }); } diff --git a/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerTests.cpp b/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerTests.cpp index 6d6948c1..1d55ff37 100644 --- a/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerTests.cpp +++ b/test/utests/tests/ContentsecuritymanagerTests/ContentSecurityManagerTests.cpp @@ -219,7 +219,7 @@ TEST(ContentSecurityManager_ReleaseSession, ValidPositiveSessionId) { std::cout << "[ContentSecurityManager_ReleaseSession] ValidPositiveSessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -251,7 +251,7 @@ TEST(ContentSecurityManager_ReleaseSession, ZeroSessionId) { std::cout << "[ContentSecurityManager_ReleaseSession] ZeroSessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -284,7 +284,7 @@ TEST(ContentSecurityManager_ReleaseSession, NegativeSessionId) { std::cout << "[ContentSecurityManager_ReleaseSession] NegativeSessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = -100; + std::string sessionId = std::to_string(-100); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -318,7 +318,7 @@ TEST(ContentSecurityManager_ReleaseSession, MaxInt64SessionId) { std::cout << "[ContentSecurityManager_ReleaseSession] MaxInt64SessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = INT64_MAX; + std::string sessionId = std::to_string(INT64_MAX); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -350,7 +350,7 @@ TEST(ContentSecurityManager_ReleaseSession, MinInt64SessionId) { std::cout << "[ContentSecurityManager_ReleaseSession] MinInt64SessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = INT64_MIN; + std::string sessionId = std::to_string(INT64_MIN); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -383,7 +383,7 @@ TEST(ContentSecurityManager_ReleaseSession, MultipleCallsSameSession) { std::cout << "[ContentSecurityManager_ReleaseSession] MultipleCallsSameSession - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 999; + std::string sessionId = std::to_string(999); EXPECT_NO_THROW({ manager.ReleaseSession(sessionId); @@ -421,7 +421,7 @@ TEST(ContentSecurityManager_UpdateSessionState, ActivateValidSession) { std::cout << "[ContentSecurityManager_UpdateSessionState] ActivateValidSession - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool result = manager.UpdateSessionState(sessionId, true); @@ -455,7 +455,7 @@ TEST(ContentSecurityManager_UpdateSessionState, DeactivateValidSession) { std::cout << "[ContentSecurityManager_UpdateSessionState] DeactivateValidSession - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 54321; + std::string sessionId = std::to_string(54321); bool result = manager.UpdateSessionState(sessionId, false); @@ -488,7 +488,7 @@ TEST(ContentSecurityManager_UpdateSessionState, NegativeSessionId) { std::cout << "[ContentSecurityManager_UpdateSessionState] NegativeSessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = -999; + std::string sessionId = std::to_string(-999); bool resultActivate = manager.UpdateSessionState(sessionId, true); bool resultDeactivate = manager.UpdateSessionState(sessionId, false); @@ -522,7 +522,7 @@ TEST(ContentSecurityManager_UpdateSessionState, ZeroSessionId) { std::cout << "[ContentSecurityManager_UpdateSessionState] ZeroSessionId - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); bool result = manager.UpdateSessionState(sessionId, true); @@ -554,7 +554,7 @@ TEST(ContentSecurityManager_UpdateSessionState, ToggleMultipleTimes) { std::cout << "[ContentSecurityManager_UpdateSessionState] ToggleMultipleTimes - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 7777; + std::string sessionId = std::to_string(7777); EXPECT_NO_THROW({ manager.UpdateSessionState(sessionId, true); @@ -594,7 +594,7 @@ TEST(ContentSecurityManager_VideoWindow, ValidDimensions) { std::cout << "[ContentSecurityManager_VideoWindow] ValidDimensions - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); int64_t width = 1920; int64_t height = 1080; @@ -628,7 +628,7 @@ TEST(ContentSecurityManager_VideoWindow, Resolution4K) { std::cout << "[ContentSecurityManager_VideoWindow] Resolution4K - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t width = 3840; int64_t height = 2160; @@ -662,7 +662,7 @@ TEST(ContentSecurityManager_VideoWindow, MinimalDimensions) { std::cout << "[ContentSecurityManager_VideoWindow] MinimalDimensions - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 200; + std::string sessionId = std::to_string(200); int64_t width = 1; int64_t height = 1; @@ -696,7 +696,7 @@ TEST(ContentSecurityManager_VideoWindow, ZeroWidth) { std::cout << "[ContentSecurityManager_VideoWindow] ZeroWidth - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 300; + std::string sessionId = std::to_string(300); int64_t width = 0; int64_t height = 1080; @@ -730,7 +730,7 @@ TEST(ContentSecurityManager_VideoWindow, ZeroHeight) { std::cout << "[ContentSecurityManager_VideoWindow] ZeroHeight - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 400; + std::string sessionId = std::to_string(400); int64_t width = 1920; int64_t height = 0; @@ -764,7 +764,7 @@ TEST(ContentSecurityManager_VideoWindow, NegativeDimensions) { std::cout << "[ContentSecurityManager_VideoWindow] NegativeDimensions - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 500; + std::string sessionId = std::to_string(500); int64_t width = -100; int64_t height = -200; @@ -798,7 +798,7 @@ TEST(ContentSecurityManager_VideoWindow, LargeDimensions) { std::cout << "[ContentSecurityManager_VideoWindow] LargeDimensions - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 600; + std::string sessionId = std::to_string(600); int64_t width = 1000000; int64_t height = 1000000; @@ -836,7 +836,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, NormalSpeed) { std::cout << "[ContentSecurityManager_PlaybackSpeed] NormalSpeed - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); int64_t speed = 1; int64_t position = 1000; @@ -870,7 +870,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, FastForward2x) { std::cout << "[ContentSecurityManager_PlaybackSpeed] FastForward2x - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t speed = 2; int64_t position = 5000; @@ -904,7 +904,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, Rewind) { std::cout << "[ContentSecurityManager_PlaybackSpeed] Rewind - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 200; + std::string sessionId = std::to_string(200); int64_t speed = -1; int64_t position = 3000; @@ -938,7 +938,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, ZeroSpeedPaused) { std::cout << "[ContentSecurityManager_PlaybackSpeed] ZeroSpeedPaused - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 300; + std::string sessionId = std::to_string(300); int64_t speed = 0; int64_t position = 2000; @@ -972,7 +972,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, ZeroPosition) { std::cout << "[ContentSecurityManager_PlaybackSpeed] ZeroPosition - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 400; + std::string sessionId = std::to_string(400); int64_t speed = 1; int64_t position = 0; @@ -1006,7 +1006,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, NegativePosition) { std::cout << "[ContentSecurityManager_PlaybackSpeed] NegativePosition - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 500; + std::string sessionId = std::to_string(500); int64_t speed = 1; int64_t position = -1000; @@ -1040,7 +1040,7 @@ TEST(ContentSecurityManager_PlaybackSpeed, HighSpeedFastForward) { std::cout << "[ContentSecurityManager_PlaybackSpeed] HighSpeedFastForward - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 600; + std::string sessionId = std::to_string(600); int64_t speed = 16; int64_t position = 10000; @@ -1407,7 +1407,7 @@ TEST(FakeSecManager, UpdateSessionState_ReturnsFalse) { FakeSecManager manager; - bool result = manager.UpdateSessionState(12345, true); + bool result = manager.UpdateSessionState("12345", true); EXPECT_FALSE(result); @@ -1438,7 +1438,7 @@ TEST(FakeSecManager, SetPlaybackSpeedState_ReturnsFalse) { FakeSecManager manager; - bool result = manager.setPlaybackSpeedState(12345, 1, 1000); + bool result = manager.setPlaybackSpeedState("12345", 1, 1000); EXPECT_FALSE(result); @@ -1469,7 +1469,7 @@ TEST(FakeSecManager, SetVideoWindowSize_ReturnsFalse) { FakeSecManager manager; - bool result = manager.setVideoWindowSize(12345, 1920, 1080); + bool result = manager.setVideoWindowSize("12345", 1920, 1080); EXPECT_FALSE(result); @@ -1501,7 +1501,7 @@ TEST(FakeSecManager, ReleaseSession_NoException) { FakeSecManager manager; EXPECT_NO_THROW({ - manager.ReleaseSession(12345); + manager.ReleaseSession("12345"); }); std::cout << "[FakeSecManager] ReleaseSession_NoException - PASS" << std::endl; @@ -1536,7 +1536,7 @@ TEST(ContentSecurityManager_EdgeCases, MultipleSessionsSequential) { TestableContentSecurityManager manager; for (int i = 0; i < 10; i++) { - int64_t sessionId = 1000 + i; + std::string sessionId = std::to_string(1000 + i); EXPECT_NO_THROW({ manager.UpdateSessionState(sessionId, true); @@ -1573,7 +1573,7 @@ TEST(ContentSecurityManager_EdgeCases, RapidStateChanges) { std::cout << "[ContentSecurityManager_EdgeCases] RapidStateChanges - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 99999; + std::string sessionId = std::to_string(99999); EXPECT_NO_THROW({ for (int i = 0; i < 100; i++) { @@ -1612,10 +1612,10 @@ TEST(ContentSecurityManager_EdgeCases, MaxInt64Values) { int64_t maxValue = INT64_MAX; EXPECT_NO_THROW({ - manager.UpdateSessionState(maxValue, true); - manager.setVideoWindowSize(maxValue, maxValue, maxValue); - manager.setPlaybackSpeedState(maxValue, maxValue, maxValue); - manager.ReleaseSession(maxValue); + manager.UpdateSessionState(std::to_string(maxValue), true); + manager.setVideoWindowSize(std::to_string(maxValue), maxValue, maxValue); + manager.setPlaybackSpeedState(std::to_string(maxValue), maxValue, maxValue); + manager.ReleaseSession(std::to_string(maxValue)); }); std::cout << "[ContentSecurityManager_EdgeCases] MaxInt64Values - PASS" << std::endl; @@ -1647,10 +1647,10 @@ TEST(ContentSecurityManager_EdgeCases, MinInt64Values) { int64_t minValue = INT64_MIN; EXPECT_NO_THROW({ - manager.UpdateSessionState(minValue, false); - manager.setVideoWindowSize(minValue, minValue, minValue); - manager.setPlaybackSpeedState(minValue, minValue, minValue); - manager.ReleaseSession(minValue); + manager.UpdateSessionState(std::to_string(minValue), false); + manager.setVideoWindowSize(std::to_string(minValue), minValue, minValue); + manager.setPlaybackSpeedState(std::to_string(minValue), minValue, minValue); + manager.ReleaseSession(std::to_string(minValue)); }); std::cout << "[ContentSecurityManager_EdgeCases] MinInt64Values - PASS" << std::endl; @@ -1683,7 +1683,7 @@ TEST(ContentSecurityManager_SetDrmSessionState, ValidSessionActive) { std::cout << "[ContentSecurityManager_SetDrmSessionState] ValidSessionActive - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); // Base class implementation returns false bool result = manager.SetDrmSessionState(sessionId, true); @@ -1715,7 +1715,7 @@ TEST(ContentSecurityManager_SetDrmSessionState, ValidSessionInactive) { std::cout << "[ContentSecurityManager_SetDrmSessionState] ValidSessionInactive - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 54321; + std::string sessionId = std::to_string(54321); bool result = manager.SetDrmSessionState(sessionId, false); EXPECT_FALSE(result); @@ -1747,10 +1747,10 @@ TEST(ContentSecurityManager_SetDrmSessionState, BoundaryValues) { TestableContentSecurityManager manager; - EXPECT_FALSE(manager.SetDrmSessionState(INT64_MAX, true)); - EXPECT_FALSE(manager.SetDrmSessionState(INT64_MIN, false)); - EXPECT_FALSE(manager.SetDrmSessionState(0, true)); - EXPECT_FALSE(manager.SetDrmSessionState(-1, false)); + EXPECT_FALSE(manager.SetDrmSessionState(std::to_string(INT64_MAX), true)); + EXPECT_FALSE(manager.SetDrmSessionState(std::to_string(INT64_MIN), false)); + EXPECT_FALSE(manager.SetDrmSessionState("0", true)); + EXPECT_FALSE(manager.SetDrmSessionState("-1", false)); std::cout << "[ContentSecurityManager_SetDrmSessionState] BoundaryValues - PASS" << std::endl; } @@ -1782,7 +1782,7 @@ TEST(ContentSecurityManager_CloseDrmSession, ValidSession) { std::cout << "[ContentSecurityManager_CloseDrmSession] ValidSession - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 98765; + std::string sessionId = std::to_string(98765); // Should execute without exception (empty implementation) EXPECT_NO_THROW(manager.CloseDrmSession(sessionId)); @@ -1813,7 +1813,7 @@ TEST(ContentSecurityManager_CloseDrmSession, MultipleCallsSameSession) { std::cout << "[ContentSecurityManager_CloseDrmSession] MultipleCallsSameSession - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 11111; + std::string sessionId = std::to_string(11111); EXPECT_NO_THROW({ manager.CloseDrmSession(sessionId); @@ -1849,10 +1849,10 @@ TEST(ContentSecurityManager_CloseDrmSession, BoundaryValues) { TestableContentSecurityManager manager; EXPECT_NO_THROW({ - manager.CloseDrmSession(INT64_MAX); - manager.CloseDrmSession(INT64_MIN); - manager.CloseDrmSession(0); - manager.CloseDrmSession(-12345); + manager.CloseDrmSession(std::to_string(INT64_MAX)); + manager.CloseDrmSession(std::to_string(INT64_MIN)); + manager.CloseDrmSession("0"); + manager.CloseDrmSession("-12345"); }); std::cout << "[ContentSecurityManager_CloseDrmSession] BoundaryValues - PASS" << std::endl; @@ -1885,7 +1885,7 @@ TEST(ContentSecurityManager_SetPlaybackPosition, NormalPlayback) { std::cout << "[ContentSecurityManager_SetPlaybackPosition] NormalPlayback - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = 1.0f; int32_t position = 120; // 2 minutes @@ -1918,7 +1918,7 @@ TEST(ContentSecurityManager_SetPlaybackPosition, FastForward) { std::cout << "[ContentSecurityManager_SetPlaybackPosition] FastForward - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 67890; + std::string sessionId = std::to_string(67890); float speed = 4.0f; int32_t position = 300; // 5 minutes @@ -1951,7 +1951,7 @@ TEST(ContentSecurityManager_SetPlaybackPosition, Rewind) { std::cout << "[ContentSecurityManager_SetPlaybackPosition] Rewind - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 11111; + std::string sessionId = std::to_string(11111); float speed = -2.0f; int32_t position = 600; // 10 minutes @@ -1984,7 +1984,7 @@ TEST(ContentSecurityManager_SetPlaybackPosition, PausedState) { std::cout << "[ContentSecurityManager_SetPlaybackPosition] PausedState - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 22222; + std::string sessionId = std::to_string(22222); float speed = 0.0f; int32_t position = 450; @@ -2019,20 +2019,20 @@ TEST(ContentSecurityManager_SetPlaybackPosition, EdgeCases) { TestableContentSecurityManager manager; // Negative session ID - EXPECT_FALSE(manager.SetPlaybackPosition(-1, 1.0f, 100)); + EXPECT_FALSE(manager.SetPlaybackPosition("-1", 1.0f, 100)); // Zero position - EXPECT_FALSE(manager.SetPlaybackPosition(12345, 1.0f, 0)); + EXPECT_FALSE(manager.SetPlaybackPosition("12345", 1.0f, 0)); // Negative position - EXPECT_FALSE(manager.SetPlaybackPosition(12345, 1.0f, -100)); + EXPECT_FALSE(manager.SetPlaybackPosition("12345", 1.0f, -100)); // Very high speed - EXPECT_FALSE(manager.SetPlaybackPosition(12345, 32.0f, 100)); + EXPECT_FALSE(manager.SetPlaybackPosition("12345", 32.0f, 100)); // Boundary session IDs - EXPECT_FALSE(manager.SetPlaybackPosition(INT64_MAX, 1.0f, 1000)); - EXPECT_FALSE(manager.SetPlaybackPosition(INT64_MIN, 1.0f, 1000)); + EXPECT_FALSE(manager.SetPlaybackPosition(std::to_string(INT64_MAX), 1.0f, 1000)); + EXPECT_FALSE(manager.SetPlaybackPosition(std::to_string(INT64_MIN), 1.0f, 1000)); std::cout << "[ContentSecurityManager_SetPlaybackPosition] EdgeCases - PASS" << std::endl; } @@ -2064,7 +2064,7 @@ TEST(ContentSecurityManager_setWindowSize, ValidDimensions) { std::cout << "[ContentSecurityManager_setWindowSize] ValidDimensions - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); int64_t width = 1920; int64_t height = 1080; @@ -2099,7 +2099,7 @@ TEST(ContentSecurityManager_setWindowSize, Resolution4K) { TestableContentSecurityManager manager; - bool result = manager.setWindowSize(99999, 3840, 2160); + bool result = manager.setWindowSize("99999", 3840, 2160); EXPECT_FALSE(result); std::cout << "[ContentSecurityManager_setWindowSize] Resolution4K - PASS" << std::endl; @@ -2130,19 +2130,19 @@ TEST(ContentSecurityManager_setWindowSize, BoundaryConditions) { TestableContentSecurityManager manager; // Zero dimensions - EXPECT_FALSE(manager.setWindowSize(12345, 0, 1080)); - EXPECT_FALSE(manager.setWindowSize(12345, 1920, 0)); - EXPECT_FALSE(manager.setWindowSize(12345, 0, 0)); + EXPECT_FALSE(manager.setWindowSize("12345", 0, 1080)); + EXPECT_FALSE(manager.setWindowSize("12345", 1920, 0)); + EXPECT_FALSE(manager.setWindowSize("12345", 0, 0)); // Negative dimensions - EXPECT_FALSE(manager.setWindowSize(12345, -1920, 1080)); - EXPECT_FALSE(manager.setWindowSize(12345, 1920, -1080)); + EXPECT_FALSE(manager.setWindowSize("12345", -1920, 1080)); + EXPECT_FALSE(manager.setWindowSize("12345", 1920, -1080)); // Negative session ID - EXPECT_FALSE(manager.setWindowSize(-1, 1920, 1080)); + EXPECT_FALSE(manager.setWindowSize("-1", 1920, 1080)); // Extreme values - EXPECT_FALSE(manager.setWindowSize(INT64_MAX, INT64_MAX, INT64_MAX)); + EXPECT_FALSE(manager.setWindowSize(std::to_string(INT64_MAX), INT64_MAX, INT64_MAX)); std::cout << "[ContentSecurityManager_setWindowSize] BoundaryConditions - PASS" << std::endl; } @@ -2371,8 +2371,8 @@ TEST(ContentSecurityManager_Lifecycle, InstanceCreationAndDestruction) { ASSERT_NE(instance, nullptr); // Perform operations - instance->ReleaseSession(12345); - instance->UpdateSessionState(67890, true); + instance->ReleaseSession("12345"); + instance->UpdateSessionState("67890", true); ContentSecurityManager::DestroyInstance(); } @@ -2484,7 +2484,7 @@ TEST(ContentSecurityManager_Integration, AllAPIsSequentially) { ContentSecurityManager::UseFireboltSDK(true); // Session operations - int64_t sessionId = 88888; + std::string sessionId = std::to_string(88888); manager->UpdateSessionState(sessionId, true); manager->setVideoWindowSize(sessionId, 1920, 1080); manager->setPlaybackSpeedState(sessionId, 1, 0); @@ -2530,7 +2530,7 @@ TEST(ContentSecurityManager_Integration, ConcurrentSessionOperations) { ContentSecurityManager* manager = ContentSecurityManager::GetInstance(); ASSERT_NE(manager, nullptr); - std::vector sessionIds = {1001, 1002, 1003, 1004, 1005}; + std::vector sessionIds = {"1001", "1002", "1003", "1004", "1005"}; // Activate all sessions for (auto sessionId : sessionIds) { @@ -2540,13 +2540,13 @@ TEST(ContentSecurityManager_Integration, ConcurrentSessionOperations) { } // Modify middle session - manager->setVideoWindowSize(1003, 3840, 2160); - manager->setPlaybackSpeedState(1003, 2, 500); + manager->setVideoWindowSize("1003", 3840, 2160); + manager->setPlaybackSpeedState("1003", 2, 500); // Deactivate alternating sessions - manager->UpdateSessionState(1001, false); - manager->UpdateSessionState(1003, false); - manager->UpdateSessionState(1005, false); + manager->UpdateSessionState("1001", false); + manager->UpdateSessionState("1003", false); + manager->UpdateSessionState("1005", false); // Release all sessions for (auto sessionId : sessionIds) { @@ -2579,7 +2579,7 @@ TEST(ContentSecurityManager_Integration, StateTransitionCoverage) { std::cout << "[ContentSecurityManager_Integration] StateTransitionCoverage - START" << std::endl; TestableContentSecurityManager manager; - int64_t sessionId = 77777; + std::string sessionId = std::to_string(77777); // Inactive → Active manager.UpdateSessionState(sessionId, true); diff --git a/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerFun.cpp b/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerFun.cpp index 00f1877f..a86e97b1 100644 --- a/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerFun.cpp +++ b/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerFun.cpp @@ -156,7 +156,7 @@ TEST(ContentSecurityManager, ReleaseSession_TypicalValidSessionID) { EXPECT_NO_THROW({ TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object using default constructor" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::cout << "Invoking ReleaseSession with sessionId: " << sessionId << std::endl; manager.ReleaseSession(sessionId); std::cout << "Method ReleaseSession executed successfully for sessionId: " << sessionId << std::endl; @@ -187,7 +187,7 @@ TEST(ContentSecurityManager, ReleaseSession_NegativeSessionID) { EXPECT_NO_THROW({ TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object using default constructor" << std::endl; - int64_t sessionId = -100; + std::string sessionId = std::to_string(-100); std::cout << "Invoking ReleaseSession with sessionId: " << sessionId << std::endl; manager.ReleaseSession(sessionId); std::cout << "Method ReleaseSession executed successfully for sessionId: " << sessionId << std::endl; @@ -220,7 +220,7 @@ TEST(ContentSecurityManager, ReleaseSession_MaximumInt64SessionID) { EXPECT_NO_THROW({ TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object using default constructor" << std::endl; - int64_t sessionId = 9223372036854775807; + std::string sessionId = std::to_string(9223372036854775807); std::cout << "Invoking ReleaseSession with sessionId: " << sessionId << std::endl; manager.ReleaseSession(sessionId); std::cout << "Method ReleaseSession executed successfully for sessionId: " << sessionId << std::endl; @@ -250,7 +250,7 @@ TEST(ContentSecurityManager, ReleaseSession_MinimumInt64SessionID) { EXPECT_NO_THROW({ TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object using default constructor" << std::endl; - int64_t sessionId = std::numeric_limits::min(); + std::string sessionId = std::to_string(std::numeric_limits::min()); std::cout << "Invoking ReleaseSession with sessionId: " << sessionId << std::endl; manager.ReleaseSession(sessionId); std::cout << "Method ReleaseSession executed successfully for sessionId: " << sessionId << std::endl; @@ -280,7 +280,7 @@ TEST(ContentSecurityManager, UpdateActiveSessionValidPositiveId) { GTEST_SKIP(); std::cout << "Entering UpdateActiveSessionValidPositiveId test" << std::endl; TestContentSecurityManager csm; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = true; std::cout << "Invoking UpdateSessionState with sessionId: " << sessionId << ", active: " << std::boolalpha << active << std::endl; bool result = false; @@ -314,7 +314,7 @@ TEST(ContentSecurityManager, UpdateInactiveSessionValidPositiveId) { GTEST_SKIP(); std::cout << "Entering UpdateInactiveSessionValidPositiveId test" << std::endl; TestContentSecurityManager csm; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = false; std::cout << "Invoking UpdateSessionState with sessionId: " << sessionId << ", active: " << std::boolalpha << active << std::endl; bool result = false; @@ -346,7 +346,7 @@ TEST(ContentSecurityManager, UpdateInactiveSessionValidPositiveId) { TEST(ContentSecurityManager, UpdateSessionWithNegativeSessionId) { std::cout << "Entering UpdateSessionWithNegativeSessionId test" << std::endl; TestContentSecurityManager csm; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); bool active = false; std::cout << "Invoking UpdateSessionState with sessionId: " << sessionId << ", active: " << std::boolalpha << active << std::endl; bool result = true; @@ -380,7 +380,7 @@ TEST(ContentSecurityManager, UpdateSessionWithLargeSessionId) { GTEST_SKIP(); std::cout << "Entering UpdateSessionWithLargeSessionId test" << std::endl; TestContentSecurityManager csm; - int64_t sessionId = INT64_MAX; + std::string sessionId = std::to_string(INT64_MAX); bool active = true; std::cout << "Invoking UpdateSessionState with sessionId: " << sessionId << ", active: " << std::boolalpha << active << std::endl; bool result = false; @@ -415,7 +415,7 @@ TEST(ContentSecurityManager, UpdateSessionWithLargeSessionId) { TEST(ContentSecurityManager, UpdateSessionWithSmallSessionId) { std::cout << "Entering UpdateSessionWithSmallSessionId test" << std::endl; TestContentSecurityManager csm; - int64_t sessionId = INT64_MIN; + std::string sessionId = std::to_string(INT64_MIN); bool active = false; std::cout << "Invoking UpdateSessionState with sessionId: " << sessionId << ", active: " << std::boolalpha << active << std::endl; bool result = true; @@ -533,7 +533,7 @@ TEST(ContentSecurityManager, ValidInput_PositiveValues) { std::cout << "Created ContentSecurityManager object using default constructor." << std::endl; // Input parameters. - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 2; int64_t playback_position = 5000; @@ -576,7 +576,7 @@ TEST(ContentSecurityManager, NegativeSessionId) { TestContentSecurityManager contentSecManager; std::cout << "Created ContentSecurityManager object using default constructor." << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); int64_t playback_speed = 2; int64_t playback_position = 5000; @@ -620,7 +620,7 @@ TEST(ContentSecurityManager, NegativePlaybackSpeed) { TestContentSecurityManager contentSecManager; std::cout << "Created ContentSecurityManager object using default constructor." << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = -2; int64_t playback_position = 5000; @@ -661,7 +661,7 @@ TEST(ContentSecurityManager, NegativePlaybackPosition) { TestContentSecurityManager contentSecManager; std::cout << "Created ContentSecurityManager object using default constructor." << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 2; int64_t playback_position = -5000; @@ -705,7 +705,7 @@ TEST(ContentSecurityManager, ZeroPlaybackSpeed) { TestContentSecurityManager contentSecManager; std::cout << "Created ContentSecurityManager object using default constructor." << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 0; int64_t playback_position = 5000; @@ -750,7 +750,7 @@ TEST(ContentSecurityManager, ValidInputTypicalResolution) { TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object." << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t video_width = 1920; int64_t video_height = 1080; @@ -793,7 +793,7 @@ TEST(ContentSecurityManager, ValidInputMinimalNonZeroDimensions) { TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object." << std::endl; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = 1; int64_t video_height = 1; @@ -836,7 +836,7 @@ TEST(ContentSecurityManager, NegativeInputNegativeSessionId) { TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object." << std::endl; - int64_t sessionId = -10; + std::string sessionId = std::to_string(-10); int64_t video_width = 1920; int64_t video_height = 1080; @@ -877,7 +877,7 @@ TEST(ContentSecurityManager, NegativeInputZeroVideoWidth) { TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object." << std::endl; - int64_t sessionId = 50; + std::string sessionId = std::to_string(50); int64_t video_width = 0; int64_t video_height = 1080; @@ -918,7 +918,7 @@ TEST(ContentSecurityManager, NegativeInputZeroVideoHeight) { TestContentSecurityManager manager; std::cout << "Created ContentSecurityManager object." << std::endl; - int64_t sessionId = 50; + std::string sessionId = std::to_string(50); int64_t video_width = 1920; int64_t video_height = 0; @@ -954,7 +954,7 @@ TEST(ContentSecurityManager, NegativeInputZeroVideoHeight) { */ TEST_F(ContentSecurityManagerTest, CloseDrmSessionValidPositive) { std::cout << "Entering CloseDrmSessionValidPositive test" << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); std::cout << "Invoking CloseDrmSession with sessionId: " << sessionId << std::endl; EXPECT_NO_THROW({ manager->CloseDrmSession(sessionId); @@ -982,7 +982,7 @@ TEST_F(ContentSecurityManagerTest, CloseDrmSessionValidPositive) { */ TEST_F(ContentSecurityManagerTest, CloseDrmSessionNegative) { std::cout << "Entering CloseDrmSessionNegative test" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); std::cout << "Invoking CloseDrmSession with sessionId: " << sessionId << std::endl; EXPECT_NO_THROW({ manager->CloseDrmSession(sessionId); @@ -1012,7 +1012,7 @@ TEST_F(ContentSecurityManagerTest, CloseDrmSessionNegative) { */ TEST_F(ContentSecurityManagerTest, CloseDrmSessionMaxInt64) { std::cout << "Entering CloseDrmSessionMaxInt64 test" << std::endl; - int64_t sessionId = 9223372036854775807LL; + std::string sessionId = std::to_string(9223372036854775807LL); std::cout << "Invoking CloseDrmSession with sessionId: " << sessionId << std::endl; EXPECT_NO_THROW({ manager->CloseDrmSession(sessionId); @@ -1040,7 +1040,7 @@ TEST_F(ContentSecurityManagerTest, CloseDrmSessionMaxInt64) { */ TEST_F(ContentSecurityManagerTest, CloseDrmSessionMinInt64) { std::cout << "Entering CloseDrmSessionMinInt64 test" << std::endl; - int64_t sessionId = -9223372036854775807LL - 1; + std::string sessionId = std::to_string(-9223372036854775807LL - 1); std::cout << "Invoking CloseDrmSession with sessionId: " << sessionId << std::endl; EXPECT_NO_THROW({ manager->CloseDrmSession(sessionId); @@ -1109,7 +1109,7 @@ TEST_F(ContentSecurityManagerTest, ContentSecurityManager_ContentSecurityManager */ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_PositiveActive) { std::cout << "Entering SetDrmSessionState_PositiveActive test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = true; std::cout << "Invoking ContentSecurityManager::SetDrmSessionState with sessionId: " << sessionId << " and active: " << std::boolalpha << active << std::endl; @@ -1140,7 +1140,7 @@ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_PositiveActive) { */ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_PositiveInactive) { std::cout << "Entering SetDrmSessionState_PositiveInactive test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = false; std::cout << "Invoking ContentSecurityManager::SetDrmSessionState with sessionId: " << sessionId << " and active: " << std::boolalpha << active << std::endl; @@ -1174,7 +1174,7 @@ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_PositiveInactive) { */ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_MaximumInt64Active) { std::cout << "Entering SetDrmSessionState_MaximumInt64Active test" << std::endl; - int64_t sessionId = 9223372036854775807LL; + std::string sessionId = std::to_string(9223372036854775807LL); bool active = true; std::cout << "Invoking ContentSecurityManager::SetDrmSessionState with sessionId: " << sessionId << " and active: " << std::boolalpha << active << std::endl; @@ -1204,7 +1204,7 @@ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_MaximumInt64Active) { */ TEST_F(ContentSecurityManagerTest, SetDrmSessionState_MinimumInt64Inactive) { std::cout << "Entering SetDrmSessionState_MinimumInt64Inactive test" << std::endl; - int64_t sessionId = (-9223372036854775807LL - 1); + std::string sessionId = std::to_string((-9223372036854775807LL - 1)); bool active = false; std::cout << "Invoking ContentSecurityManager::SetDrmSessionState with sessionId: " << sessionId << " and active: " << std::boolalpha << active << std::endl; @@ -1236,7 +1236,7 @@ TEST_F(ContentSecurityManagerTest, ValidNormalPlaybackPositionUpdate) { GTEST_SKIP(); std::cout << "Entering ValidNormalPlaybackPositionUpdate test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = 1.0; int32_t position = 30; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1274,7 +1274,7 @@ TEST_F(ContentSecurityManagerTest, ValidUpdatedPlaybackWithIncreasedSpeed) { GTEST_SKIP(); std::cout << "Entering ValidUpdatedPlaybackWithIncreasedSpeed test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = 1.5; int32_t position = 45; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1309,7 +1309,7 @@ TEST_F(ContentSecurityManagerTest, ReversePlaybackScenarioWithNegativeSpeed) { GTEST_SKIP(); std::cout << "Entering ReversePlaybackScenarioWithNegativeSpeed test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = -1.0; int32_t position = 30; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1345,7 +1345,7 @@ TEST_F(ContentSecurityManagerTest, ReversePlaybackScenarioWithNegativeSpeed) { TEST_F(ContentSecurityManagerTest, InvalidSessionId) { std::cout << "Entering InvalidSessionId test" << std::endl; - int64_t sessionId = -12345; + std::string sessionId = std::to_string(-12345); float speed = 1.0; int32_t position = 30; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1380,7 +1380,7 @@ TEST_F(ContentSecurityManagerTest, InvalidSessionId) { TEST_F(ContentSecurityManagerTest, InvalidPlaybackPosition) { std::cout << "Entering InvalidPlaybackPosition test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = 1.0; int32_t position = -10; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1414,7 +1414,7 @@ TEST_F(ContentSecurityManagerTest, InvalidPlaybackPosition) { TEST_F(ContentSecurityManagerTest, MinimumBoundaryForSpeed) { std::cout << "Entering MinimumBoundaryForSpeed test" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); float speed = 0.0; int32_t position = 30; std::cout << "Invoking SetPlaybackPosition with sessionId: " << sessionId @@ -1448,7 +1448,7 @@ TEST_F(ContentSecurityManagerTest, MinimumBoundaryForSpeed) { TEST_F(ContentSecurityManagerTest, ValidPositiveValues) { std::cout << "Entering ValidPositiveValues test" << std::endl; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = 1920; int64_t video_height = 1080; std::cout << "Invoking setWindowSize with sessionId = " << sessionId @@ -1484,7 +1484,7 @@ TEST_F(ContentSecurityManagerTest, ValidPositiveValues) { TEST_F(ContentSecurityManagerTest, ZeroDimensionsValidSessionId) { std::cout << "Entering ZeroDimensionsValidSessionId test" << std::endl; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = 0; int64_t video_height = 0; std::cout << "Invoking setWindowSize with sessionId = " << sessionId @@ -1519,7 +1519,7 @@ TEST_F(ContentSecurityManagerTest, ZeroDimensionsValidSessionId) { TEST_F(ContentSecurityManagerTest, NegativeSessionIdPositiveDimensions) { std::cout << "Entering NegativeSessionIdPositiveDimensions test" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); int64_t video_width = 640; int64_t video_height = 480; std::cout << "Invoking setWindowSize with sessionId = " << sessionId @@ -1554,7 +1554,7 @@ TEST_F(ContentSecurityManagerTest, NegativeSessionIdPositiveDimensions) { TEST_F(ContentSecurityManagerTest, PositiveSessionIdNegativeVideoWidth) { std::cout << "Entering PositiveSessionIdNegativeVideoWidth test" << std::endl; - int64_t sessionId = 10; + std::string sessionId = std::to_string(10); int64_t video_width = -640; int64_t video_height = 480; std::cout << "Invoking setWindowSize with sessionId = " << sessionId @@ -1591,7 +1591,7 @@ TEST_F(ContentSecurityManagerTest, PositiveSessionIdNegativeVideoWidth) { TEST_F(ContentSecurityManagerTest, MixedPositiveSessionIdNegativeVideoHeight) { std::cout << "Entering MixedPositiveSessionIdNegativeVideoHeight test" << std::endl; - int64_t sessionId = 10; + std::string sessionId = std::to_string(10); int64_t video_width = 1280; int64_t video_height = -720; std::cout << "Invoking setWindowSize with sessionId = " << sessionId @@ -1708,7 +1708,7 @@ TEST(FakeSecManager, ReleaseSession_TypicalValidSessionId) { FakeSecManager fakeSecManager; // Define test input sessionId - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::cout << "Test input sessionId: " << sessionId << std::endl; // Invoking ReleaseSession method @@ -1745,7 +1745,7 @@ TEST(FakeSecManager, ReleaseSession_NegativeSessionId) { FakeSecManager fakeSecManager; // Define test input sessionId - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); std::cout << "Test input sessionId: " << sessionId << std::endl; // Invoking ReleaseSession method @@ -1782,7 +1782,7 @@ TEST(FakeSecManager, ReleaseSession_Int64Max) { FakeSecManager fakeSecManager; // Define test input sessionId as maximum int64_t value - int64_t sessionId = 9223372036854775807LL; + std::string sessionId = std::to_string(9223372036854775807LL); std::cout << "Test input sessionId (INT64_MAX): " << sessionId << std::endl; // Invoking ReleaseSession method @@ -1820,7 +1820,7 @@ TEST(FakeSecManager, ValidSessionIdTrue) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = true; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -1860,7 +1860,7 @@ TEST(FakeSecManager, ValidSessionIdFalse) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); bool active = false; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -1901,7 +1901,7 @@ TEST(FakeSecManager, NegativeSessionIdTrue) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); bool active = true; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -1941,7 +1941,7 @@ TEST(FakeSecManager, NegativeSessionIdFalse) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); bool active = false; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -1981,7 +1981,7 @@ TEST(FakeSecManager, MaxSessionIdTrue) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = 9223372036854775807LL; + std::string sessionId = std::to_string(9223372036854775807LL); bool active = true; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -2020,7 +2020,7 @@ TEST(FakeSecManager, MaxSessionIdFalse) { FakeSecManager fsm; std::cout << "Created FakeSecManager object" << std::endl; - int64_t sessionId = 9223372036854775807LL; + std::string sessionId = std::to_string(9223372036854775807LL); bool active = false; std::cout << "Invoking FakeSecManager::UpdateSessionState with sessionId = " << sessionId << " and active = " << active << std::endl; @@ -2060,7 +2060,7 @@ TEST(FakeSecManager, ValidTypicalInput) FakeSecManager fsm; std::cout << "FakeSecManager object created using default constructor." << std::endl; - int64_t sessionId = 123; + std::string sessionId = std::to_string(123); int64_t speed = 150; int64_t position = 500; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2101,7 +2101,7 @@ TEST(FakeSecManager, NegativeSessionId_SetPlaybackSpeedState) FakeSecManager fsm; std::cout << "FakeSecManager object created using default constructor." << std::endl; - int64_t sessionId = -100; + std::string sessionId = std::to_string(-100); int64_t speed = 150; int64_t position = 500; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2143,7 +2143,7 @@ TEST(FakeSecManager, NegativeSpeed) FakeSecManager fsm; std::cout << "FakeSecManager object created using default constructor." << std::endl; - int64_t sessionId = 123; + std::string sessionId = std::to_string(123); int64_t speed = -150; int64_t position = 500; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2185,7 +2185,7 @@ TEST(FakeSecManager, NegativePosition) FakeSecManager fsm; std::cout << "FakeSecManager object created using default constructor." << std::endl; - int64_t sessionId = 123; + std::string sessionId = std::to_string(123); int64_t speed = 150; int64_t position = -500; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2225,7 +2225,7 @@ TEST(FakeSecManager, NormalValues) { // Create an object of FakeSecManager using the default constructor FakeSecManager secMgr; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = 640; int64_t video_height = 480; @@ -2266,7 +2266,7 @@ TEST(FakeSecManager, NegativeSessionId_setVideoWindowSize) { EXPECT_NO_THROW(FakeSecManager secMgr); FakeSecManager secMgr; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); int64_t video_width = 640; int64_t video_height = 480; @@ -2306,7 +2306,7 @@ TEST(FakeSecManager, NegativeVideoWindowWidth) { EXPECT_NO_THROW(FakeSecManager secMgr); FakeSecManager secMgr; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = -640; int64_t video_height = 480; @@ -2345,7 +2345,7 @@ TEST(FakeSecManager, NegativeVideoWindowHeight) { EXPECT_NO_THROW(FakeSecManager secMgr); FakeSecManager secMgr; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); int64_t video_width = 640; int64_t video_height = -480; @@ -2578,7 +2578,7 @@ TEST(FakeSecManager, ValidInputPositiveValues) { FakeSecManager fakeSecManager; std::cout << "Constructed FakeSecManager object successfully" << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 2; int64_t playback_position = 5000; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2616,7 +2616,7 @@ TEST(FakeSecManager, NegativeSessionId_NegativeSessionId) { FakeSecManager fakeSecManager; std::cout << "Constructed FakeSecManager object successfully" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); int64_t playback_speed = 2; int64_t playback_position = 5000; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2655,7 +2655,7 @@ TEST(FakeSecManager, NegativePlaybackSpeed) { FakeSecManager fakeSecManager; std::cout << "Constructed FakeSecManager object successfully" << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = -2; int64_t playback_position = 5000; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2693,7 +2693,7 @@ TEST(FakeSecManager, NegativePlaybackPosition) { FakeSecManager fakeSecManager; std::cout << "Constructed FakeSecManager object successfully" << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 2; int64_t playback_position = -5000; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId @@ -2735,7 +2735,7 @@ TEST(FakeSecManager, ZeroPlaybackSpeed) { FakeSecManager fakeSecManager; std::cout << "Constructed FakeSecManager object successfully" << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); int64_t playback_speed = 0; int64_t playback_position = 5000; std::cout << "Invoking setPlaybackSpeedState with sessionId: " << sessionId diff --git a/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerSes.cpp b/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerSes.cpp index 6bc3c178..f00cca56 100644 --- a/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerSes.cpp +++ b/test/utests/tests/ContentsecuritymanagerTests/PlayerContentSecurityManagerSes.cpp @@ -86,11 +86,11 @@ TEST(ContentSecurityManagerSession, CopyValidSession) { EXPECT_NO_THROW({ // Create a valid session with sessionID=100 and inputSummaryHash=12345 - ContentSecurityManagerSession originalSession(100, 12345); + ContentSecurityManagerSession originalSession(std::to_string(100), 12345); std::cout << "Invoked ContentSecurityManagerSession(100, 12345) constructor." << std::endl; // Debug log: Retrieve original session state - int64_t origSessionID = originalSession.getSessionID(); + std::string origSessionID = originalSession.getSessionID(); std::size_t origInputSummaryHash = originalSession.getInputSummaryHash(); std::cout << "Original session getSessionID returned: " << origSessionID << std::endl; std::cout << "Original session getInputSummaryHash returned: " << origInputSummaryHash << std::endl; @@ -100,13 +100,13 @@ TEST(ContentSecurityManagerSession, CopyValidSession) { std::cout << "Invoked copy constructor on a valid session object." << std::endl; // Debug log: Retrieve copied session state - int64_t copiedSessionID = copiedSession.getSessionID(); + std::string copiedSessionID = copiedSession.getSessionID(); std::size_t copiedInputSummaryHash = copiedSession.getInputSummaryHash(); std::cout << "Copied session getSessionID returned: " << copiedSessionID << std::endl; std::cout << "Copied session getInputSummaryHash returned: " << copiedInputSummaryHash << std::endl; // Verify that the copied session has the same sessionID and inputSummaryHash as the original - EXPECT_EQ(copiedSessionID, 100); + EXPECT_EQ(copiedSessionID, "100"); EXPECT_EQ(copiedInputSummaryHash, 12345); }); @@ -132,7 +132,7 @@ TEST(ContentSecurityManagerSession, CopyValidSession) { */ TEST(ContentSecurityManagerSession, CreateSession_PositiveID_NonZeroHash) { std::cout << "Entering CreateSession_PositiveID_NonZeroHash test" << std::endl; - int64_t sessionID = 1000; + std::string sessionID = std::to_string(1000); std::size_t inputSummaryHash = 5000; std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -163,7 +163,7 @@ TEST(ContentSecurityManagerSession, CreateSession_PositiveID_NonZeroHash) { */ TEST(ContentSecurityManagerSession, CreateSession_ZeroID_NonZeroHash) { std::cout << "Entering CreateSession_ZeroID_NonZeroHash test" << std::endl; - int64_t sessionID = 0; + std::string sessionID = std::to_string(0); std::size_t inputSummaryHash = 1234; std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -194,7 +194,7 @@ TEST(ContentSecurityManagerSession, CreateSession_ZeroID_NonZeroHash) { */ TEST(ContentSecurityManagerSession, CreateSession_PositiveID_ZeroHash) { std::cout << "Entering CreateSession_PositiveID_ZeroHash test" << std::endl; - int64_t sessionID = 2000; + std::string sessionID = std::to_string(2000); std::size_t inputSummaryHash = 0; std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -226,7 +226,7 @@ TEST(ContentSecurityManagerSession, CreateSession_PositiveID_ZeroHash) { */ TEST(ContentSecurityManagerSession, CreateSession_NegativeID_ValidHash) { std::cout << "Entering CreateSession_NegativeID_ValidHash test" << std::endl; - int64_t sessionID = -100; + std::string sessionID = std::to_string(-100); std::size_t inputSummaryHash = 100; std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -258,7 +258,7 @@ TEST(ContentSecurityManagerSession, CreateSession_NegativeID_ValidHash) { */ TEST(ContentSecurityManagerSession, CreateSession_MaxValues) { std::cout << "Entering CreateSession_MaxValues test" << std::endl; - int64_t sessionID = INT64_MAX; + std::string sessionID = std::to_string(INT64_MAX); std::size_t inputSummaryHash = std::numeric_limits::max(); std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -289,7 +289,7 @@ TEST(ContentSecurityManagerSession, CreateSession_MaxValues) { */ TEST(ContentSecurityManagerSession, CreateSession_MinValueID) { std::cout << "Entering CreateSession_MinValueID test" << std::endl; - int64_t sessionID = INT64_MIN; + std::string sessionID = std::to_string(INT64_MIN); std::size_t inputSummaryHash = 1; std::cout << "Invoking constructor ContentSecurityManagerSession(" << sessionID << ", " << inputSummaryHash << ")" << std::endl; @@ -325,7 +325,7 @@ TEST(ContentSecurityManagerSession, ValidSession_PositiveID) std::cout << "Entering ValidSession_PositiveID test" << std::endl; // Create object with sessionID = 12345 and a valid inputSummaryHash (e.g., 1111) - int64_t testSessionID = 12345; + std::string testSessionID = std::to_string(12345); std::size_t testInputSummaryHash = 1111; std::cout << "Creating ContentSecurityManagerSession object with sessionID = " << testSessionID << " and inputSummaryHash = " << testInputSummaryHash << std::endl; @@ -339,7 +339,7 @@ TEST(ContentSecurityManagerSession, ValidSession_PositiveID) std::cout << "ToString() returned: " << result << std::endl; // Expected result: "Session 12345 valid" - std::string expected = "Session " + std::to_string(testSessionID) + " valid"; + std::string expected = "Session " + testSessionID + " valid"; std::cout << "Expected result: " << expected << std::endl; EXPECT_EQ(result, expected); @@ -370,7 +370,7 @@ TEST(ContentSecurityManagerSession, ValidSession_ZeroID) std::cout << "Entering ValidSession_ZeroID test" << std::endl; // Create object with sessionID = 0 and a valid inputSummaryHash (e.g., 2222) - int64_t testSessionID = 0; + std::string testSessionID = std::to_string(0); std::size_t testInputSummaryHash = 2222; std::cout << "Creating ContentSecurityManagerSession object with sessionID = " << testSessionID << " and inputSummaryHash = " << testInputSummaryHash << std::endl; @@ -384,7 +384,7 @@ TEST(ContentSecurityManagerSession, ValidSession_ZeroID) std::cout << "ToString() returned: " << result << std::endl; // Expected result: "Session 0 valid" - std::string expected = "Session " + std::to_string(testSessionID) + " valid"; + std::string expected = "Session " + testSessionID + " valid"; std::cout << "Expected result: " << expected << std::endl; EXPECT_EQ(result, expected); @@ -414,7 +414,7 @@ TEST(ContentSecurityManagerSession, BoundaryCondition_MaxInt64) std::cout << "Entering BoundaryCondition_MaxInt64 test" << std::endl; // Create object with sessionID = INT64_MAX and a valid inputSummaryHash (e.g., 3333) - int64_t testSessionID = INT64_MAX; + std::string testSessionID = std::to_string(INT64_MAX); std::size_t testInputSummaryHash = 3333; std::cout << "Creating ContentSecurityManagerSession object with sessionID = " << testSessionID << " and inputSummaryHash = " << testInputSummaryHash << std::endl; @@ -428,7 +428,7 @@ TEST(ContentSecurityManagerSession, BoundaryCondition_MaxInt64) std::cout << "ToString() returned: " << result << std::endl; // Expected result: "Session 9223372036854775807 valid" - std::string expected = "Session " + std::to_string(testSessionID) + " valid"; + std::string expected = "Session " + testSessionID + " valid"; std::cout << "Expected result: " << expected << std::endl; EXPECT_EQ(result, expected); @@ -460,7 +460,7 @@ TEST(ContentSecurityManagerSession, getInputSummaryHash_Positive_ValidInput) { // Using parameterized constructor with sessionID = 1000, inputSummaryHash = 12345 std::cout << "Creating ContentSecurityManagerSession object with sessionID = 1000 and inputSummaryHash = 12345" << std::endl; - ContentSecurityManagerSession session(1000, 12345); + ContentSecurityManagerSession session(std::to_string(1000), 12345); std::cout << "Invoking getInputSummaryHash method" << std::endl; std::size_t result = session.getInputSummaryHash(); @@ -495,7 +495,7 @@ TEST(ContentSecurityManagerSession, getInputSummaryHash_Positive_LowBoundary) { // Using parameterized constructor with sessionID = 1001, inputSummaryHash = 0 (boundary condition) std::cout << "Creating ContentSecurityManagerSession object with sessionID = 1001 and inputSummaryHash = 0" << std::endl; - ContentSecurityManagerSession session(1001, 0); + ContentSecurityManagerSession session(std::to_string(1001), 0); std::cout << "Invoking getInputSummaryHash method" << std::endl; std::size_t result = session.getInputSummaryHash(); @@ -531,7 +531,7 @@ TEST(ContentSecurityManagerSession, getInputSummaryHash_Positive_MaximumInput) { // Using parameterized constructor with sessionID = 1002, inputSummaryHash = maximum possible value std::size_t maxHash = std::numeric_limits::max(); std::cout << "Creating ContentSecurityManagerSession object with sessionID = 1002 and inputSummaryHash = " << maxHash << std::endl; - ContentSecurityManagerSession session(1002, maxHash); + ContentSecurityManagerSession session(std::to_string(1002), maxHash); std::cout << "Invoking getInputSummaryHash method" << std::endl; std::size_t result = session.getInputSummaryHash(); @@ -604,7 +604,7 @@ TEST(ContentSecurityManagerSession, PositiveValidPositiveSessionId) { std::cout << "Invoked parameterized constructor with sessionID = " << expectedID << " and inputSummaryHash = " << 0 << std::endl; std::cout << "Invoking getSessionID()" << std::endl; - int64_t sessionID = session.getSessionID(); + std::string sessionID = session.getSessionID(); std::cout << "getSessionID() returned " << sessionID << std::endl; EXPECT_EQ(sessionID, expectedID); }); @@ -639,7 +639,7 @@ TEST(ContentSecurityManagerSession, PositiveValidZeroSessionId) { std::cout << "Invoked parameterized constructor with sessionID = " << expectedID << " and inputSummaryHash = " << 0 << std::endl; std::cout << "Invoking getSessionID()" << std::endl; - int64_t sessionID = session.getSessionID(); + std::string sessionID = session.getSessionID(); std::cout << "getSessionID() returned " << sessionID << std::endl; EXPECT_EQ(sessionID, expectedID); }); @@ -674,7 +674,7 @@ TEST(ContentSecurityManagerSession, BoundaryMaxInt64) { std::cout << "Invoked parameterized constructor with sessionID = " << expectedID << " and inputSummaryHash = " << 0 << std::endl; std::cout << "Invoking getSessionID()" << std::endl; - int64_t sessionID = session.getSessionID(); + std::string sessionID = session.getSessionID(); std::cout << "getSessionID() returned " << sessionID << std::endl; EXPECT_EQ(sessionID, expectedID); }); @@ -710,7 +710,7 @@ TEST(ContentSecurityManagerSession, BoundaryMinInt64) { std::cout << "Invoked parameterized constructor with sessionID = " << expectedID << " and inputSummaryHash = " << 0 << std::endl; std::cout << "Invoking getSessionID()" << std::endl; - int64_t sessionID = session.getSessionID(); + std::string sessionID = session.getSessionID(); std::cout << "getSessionID() returned " << sessionID << std::endl; EXPECT_EQ(sessionID, expectedID); }); @@ -742,7 +742,7 @@ TEST(ContentSecurityManagerSession, DefaultConstructorTest_SessionIDZero) { ContentSecurityManagerSession session; std::cout << "Invoked default constructor" << std::endl; std::cout << "Invoking getSessionID()" << std::endl; - int64_t sessionID = session.getSessionID(); + std::string sessionID = session.getSessionID(); std::cout << "getSessionID() returned " << sessionID << std::endl; EXPECT_EQ(sessionID, int64_t(0)); }); @@ -774,7 +774,7 @@ TEST(ContentSecurityManagerSession, SessionValidProperInitialized) std::cout << "Entering Session is valid when a proper SessionManager is initialized test" << std::endl; // Create object using parameterized constructor with proper SessionManager initialization - std::int64_t sessionID = 12345; + std::string sessionID = std::to_string(12345); std::size_t inputSummaryHash = 67890; std::cout << "Creating ContentSecurityManagerSession with sessionID: " << sessionID << " and inputSummaryHash: " << inputSummaryHash << std::endl; @@ -860,11 +860,11 @@ TEST(ContentSecurityManagerSession, AssignmentOfTwoDistinctValidSessions) { std::cout << "Entering AssignmentOfTwoDistinctValidSessions test" << std::endl; EXPECT_NO_THROW({ // Create SessionA with sessionID = 100 and inputSummaryHash = 555 - ContentSecurityManagerSession sessionA(100, 555); + ContentSecurityManagerSession sessionA(std::to_string(100), 555); std::cout << "[DEBUG] Created sessionA with sessionID: " << sessionA.getSessionID() << " and inputSummaryHash: " << 555 << std::endl; // Create SessionB with sessionID = 200 and inputSummaryHash = 777 - ContentSecurityManagerSession sessionB(200, 777); + ContentSecurityManagerSession sessionB(std::to_string(200), 777); std::cout << "[DEBUG] Created sessionB with sessionID: " << sessionB.getSessionID() << " and inputSummaryHash: " << 777 << std::endl; @@ -902,7 +902,7 @@ TEST(ContentSecurityManagerSession, setSessionInvalidValid) { std::cout << "Entering setSessionInvalidValid test" << std::endl; EXPECT_NO_THROW({ // Create SessionA with sessionID = 100 and inputSummaryHash = 555 - ContentSecurityManagerSession session(100, 555); + ContentSecurityManagerSession session(std::to_string(100), 555); std::cout << "[DEBUG] Created session with sessionID: " << 100 << " and inputSummaryHash: " << 555 << std::endl; @@ -915,6 +915,3 @@ TEST(ContentSecurityManagerSession, setSessionInvalidValid) { } - - - diff --git a/test/utests/tests/FireBoltTests/FireBoltFun.cpp b/test/utests/tests/FireBoltTests/FireBoltFun.cpp index 1819a32d..86cf948d 100644 --- a/test/utests/tests/FireBoltTests/FireBoltFun.cpp +++ b/test/utests/tests/FireBoltTests/FireBoltFun.cpp @@ -57,7 +57,7 @@ TEST(ContentProtectionFirebolt, CloseDrmSession_with_valid_session) // Logging internal state after construction (if any known state exists - simulated log) std::cout << "ContentProtectionFirebolt object created. (Internal state logged if available)" << std::endl; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::cout << "Invoking CloseDrmSession with sessionId = " << sessionId << std::endl; EXPECT_NO_THROW({ cp.CloseDrmSession(sessionId); @@ -98,7 +98,7 @@ TEST(ContentProtectionFirebolt, CloseDrmSession_with_negative_session) // Logging the initial state of the object (if any known state exists - simulated log) std::cout << "ContentProtectionFirebolt object created. (Internal state logged if available)" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); std::cout << "Invoking CloseDrmSession with sessionId = " << sessionId << std::endl; EXPECT_NO_THROW({ cp.CloseDrmSession(sessionId); @@ -139,7 +139,7 @@ TEST(ContentProtectionFirebolt, CloseDrmSession_with_zero_session) // Logging the initial state of the object (if any known state exists - simulated log) std::cout << "ContentProtectionFirebolt object created. (Internal state logged if available)" << std::endl; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::cout << "Invoking CloseDrmSession with sessionId = " << sessionId << std::endl; EXPECT_NO_THROW({ cp.CloseDrmSession(sessionId); @@ -562,7 +562,7 @@ TEST(ContentProtectionFirebolt, PositiveTestWithValidParameters) { std::string keySystem = "widevine"; std::string licenseRequest = "licenseChallenge"; std::string initData = "initDataPayload"; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -625,7 +625,7 @@ TEST(ContentProtectionFirebolt, NegativeTestEmptyClientId) { std::string keySystem = "widevine"; std::string licenseRequest = "licenseChallenge"; std::string initData = "initDataPayload"; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -685,7 +685,7 @@ TEST(ContentProtectionFirebolt, NegativeTestEmptyAppId) { std::string keySystem = "widevine"; std::string licenseRequest = "licenseChallenge"; std::string initData = "initDataPayload"; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -749,7 +749,7 @@ TEST(ContentProtectionFirebolt, NegativeTestEmptyKeySystem) { std::string keySystem = ""; std::string licenseRequest = "licenseChallenge"; std::string initData = "initDataPayload"; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -809,7 +809,7 @@ TEST(ContentProtectionFirebolt, NegativeTestEmptyLicenseRequest) { std::string keySystem = "widevine"; std::string licenseRequest = ""; std::string initData = "initDataPayload"; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -868,7 +868,7 @@ TEST(ContentProtectionFirebolt, NegativeTestEmptyInitData) { std::string keySystem = "widevine"; std::string licenseRequest = "licenseChallenge"; std::string initData = ""; - int64_t sessionId = 0; + std::string sessionId = std::to_string(0); std::string response = ""; int32_t err = 0; @@ -923,7 +923,7 @@ TEST(ContentProtectionFirebolt, ValidPositiveSessionID_ActiveTrue) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); bool active = true; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -963,7 +963,7 @@ TEST(ContentProtectionFirebolt, ValidPositiveSessionID_ActiveFalse) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = 1; + std::string sessionId = std::to_string(1); bool active = false; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -1006,7 +1006,7 @@ TEST(ContentProtectionFirebolt, NegativeSessionID_ActiveTrue) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); bool active = true; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -1047,7 +1047,7 @@ TEST(ContentProtectionFirebolt, NegativeSessionID_ActiveFalse) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); bool active = false; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -1087,7 +1087,7 @@ TEST(ContentProtectionFirebolt, MaxInt64SessionID_ActiveTrue) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = std::numeric_limits::max(); + std::string sessionId = std::to_string(std::numeric_limits::max()); bool active = true; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -1127,7 +1127,7 @@ TEST(ContentProtectionFirebolt, MaxInt64SessionID_ActiveFalse) { ContentProtectionFirebolt cp; std::cout << "Constructed ContentProtectionFirebolt object" << std::endl; - int64_t sessionId = std::numeric_limits::max(); + std::string sessionId = std::to_string(std::numeric_limits::max()); bool active = false; std::cout << "Invoking SetDrmSessionState with sessionId: " << sessionId << " and active: " << (active ? "true" : "false") << std::endl; @@ -1168,7 +1168,7 @@ TEST(ContentProtectionFirebolt, ValidInputTypicalParameters) ContentProtectionFirebolt obj; std::cout << "Created ContentProtectionFirebolt instance using default constructor." << std::endl; - int64_t sessionId = 100; + std::string sessionId = std::to_string(100); float speed = 1.0f; int32_t position = 30; @@ -1209,7 +1209,7 @@ TEST(ContentProtectionFirebolt, NegativeSessionId) ContentProtectionFirebolt obj; std::cout << "Created ContentProtectionFirebolt instance using default constructor." << std::endl; - int64_t sessionId = -50; + std::string sessionId = std::to_string(-50); float speed = 1.0f; int32_t position = 30; @@ -1249,7 +1249,7 @@ TEST(ContentProtectionFirebolt, NegativePlaybackSpeed) ContentProtectionFirebolt obj; std::cout << "Created ContentProtectionFirebolt instance using default constructor." << std::endl; - int64_t sessionId = 101; + std::string sessionId = std::to_string(101); float speed = -1.0f; int32_t position = 45; @@ -1292,7 +1292,7 @@ TEST(ContentProtectionFirebolt, NegativePosition) ContentProtectionFirebolt obj; std::cout << "Created ContentProtectionFirebolt instance using default constructor." << std::endl; - int64_t sessionId = 102; + std::string sessionId = std::to_string(102); float speed = 1.0f; int32_t position = -10; @@ -1332,7 +1332,7 @@ TEST(ContentProtectionFirebolt, ZeroPlaybackSpeed) ContentProtectionFirebolt obj; std::cout << "Created ContentProtectionFirebolt instance using default constructor." << std::endl; - int64_t sessionId = 103; + std::string sessionId = std::to_string(103); float speed = 0.0f; int32_t position = 30; @@ -1374,7 +1374,7 @@ TEST(ContentProtectionFirebolt, ShowWatermark_Enable_ValidPositiveSessionId) { // Parameters for test bool show = true; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::cout << "Invoking ShowWatermark with parameters: show = " << show << ", sessionId = " << sessionId << std::endl; @@ -1416,7 +1416,7 @@ TEST(ContentProtectionFirebolt, ShowWatermark_Disable_ValidPositiveSessionId) { // Set test parameters bool show = false; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::cout << "Invoking ShowWatermark with parameters: show = " << show << ", sessionId = " << sessionId << std::endl; @@ -1461,7 +1461,7 @@ TEST(ContentProtectionFirebolt, ShowWatermark_Disable_NegativeSessionId) { // Set test parameters bool show = false; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); std::cout << "Invoking ShowWatermark with parameters: show = " << show << ", sessionId = " << sessionId << " (negative sessionId)" << std::endl; @@ -1503,7 +1503,7 @@ TEST(ContentProtectionFirebolt, ShowWatermark_Enable_INT64_MAX) { // Set test parameters bool show = true; - int64_t sessionId = std::numeric_limits::max(); + std::string sessionId = std::to_string(std::numeric_limits::max()); std::cout << "Invoking ShowWatermark with parameters: show = " << show << ", sessionId = " << sessionId << " (INT64_MAX)" << std::endl; @@ -1543,7 +1543,7 @@ TEST(ContentProtectionFirebolt, UpdateDrmSession_ValidInputs_ReturnsSuccess) EXPECT_NO_THROW({ ContentProtectionFirebolt cp; }); ContentProtectionFirebolt cp; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::string licenseRequest; char licenseReqBuffer[64]; strncpy(licenseReqBuffer, "validLicenseRequest", sizeof(licenseReqBuffer)-1); @@ -1598,7 +1598,7 @@ TEST(ContentProtectionFirebolt, UpdateDrmSession_NegativeSessionId_ReturnsFailur EXPECT_NO_THROW({ ContentProtectionFirebolt cp; }); ContentProtectionFirebolt cp; - int64_t sessionId = -1; + std::string sessionId = std::to_string(-1); std::string licenseRequest; char licenseReqBuffer[64]; strncpy(licenseReqBuffer, "validLicenseRequest", sizeof(licenseReqBuffer)-1); @@ -1656,7 +1656,7 @@ TEST(ContentProtectionFirebolt, UpdateDrmSession_EmptyLicenseRequest_ReturnsFail EXPECT_NO_THROW({ ContentProtectionFirebolt cp; }); ContentProtectionFirebolt cp; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::string licenseRequest = ""; std::string initData; char initDataBuffer[64]; @@ -1709,7 +1709,7 @@ TEST(ContentProtectionFirebolt, UpdateDrmSession_EmptyInitData_ReturnsFailure) EXPECT_NO_THROW({ ContentProtectionFirebolt cp; }); ContentProtectionFirebolt cp; - int64_t sessionId = 12345; + std::string sessionId = std::to_string(12345); std::string licenseRequest; char licenseReqBuffer[64]; strncpy(licenseReqBuffer, "validLicenseRequest", sizeof(licenseReqBuffer)-1);