Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions rfcMgr/gtest/gtest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,129 @@ TEST(rfcMgrTest, EmptyFeatures) {
}
}

// RDKEMW-11615: AccountID Validation Tests
class AccountIDValidationTest : public ::testing::Test {
protected:
std::string currentAccountID;
std::string unknownStr;

void SetUp() override {
currentAccountID = "3064488088886635972";
unknownStr = "Unknown";
}
};

// Test case: Empty AccountID should be rejected
TEST_F(AccountIDValidationTest, EmptyAccountIDRejected)
{
std::string emptyValue = "";
EXPECT_TRUE(emptyValue.empty());
}

// Test case: Unknown AccountID should be replaced with current value
TEST_F(AccountIDValidationTest, UnknownAccountIDReplaced)
{
std::string receivedAccountID = "Unknown";
std::string replacementAccountID = currentAccountID;

// Check if received value is "Unknown"
bool isUnknown = StringCaseCompare(receivedAccountID, unknownStr);
EXPECT_TRUE(isUnknown);

// When unknown, should use current value
if (isUnknown) {
receivedAccountID = replacementAccountID;
}

EXPECT_EQ(receivedAccountID, "3064488088886635972");
}

// Test case: Valid AccountID should be accepted
TEST_F(AccountIDValidationTest, ValidAccountIDAccepted)
{
std::string validAccountID = "3064488088886635972";
std::string currentValue = "OldAccountID";

// Check if it's not empty and not "Unknown"
bool isValid = (!validAccountID.empty() && !StringCaseCompare(validAccountID, unknownStr));
EXPECT_TRUE(isValid);
}

// Test case: AccountID comparison should be case-insensitive
TEST_F(AccountIDValidationTest, UnknownCaseInsensitiveComparison)
{
std::string unknownUpper = "UNKNOWN";
std::string unknownMixed = "UnKnOwN";

EXPECT_TRUE(StringCaseCompare(unknownUpper, unknownStr));
EXPECT_TRUE(StringCaseCompare(unknownMixed, unknownStr));
}

// Test case: Config value change detection
TEST_F(AccountIDValidationTest, ConfigValueChangeDetection)
{
std::string currentValue = "OldAccountID";
std::string newValue = "3064488088886635972";

bool valueChanged = (currentValue != newValue);
EXPECT_TRUE(valueChanged);
}

// Test case: No change when current and new values are same
TEST_F(AccountIDValidationTest, NoConfigValueChangeWhenSame)
{
std::string currentValue = "3064488088886635972";
std::string newValue = "3064488088886635972";

bool valueChanged = (currentValue != newValue);
EXPECT_FALSE(valueChanged);
}
Comment on lines +1339 to +1414
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test cases in the AccountIDValidationTest fixture only test local variables and helper functions, but they do not actually test the RuntimeFeatureControlProcessor class methods (GetAccountID or GetValidAccountId) that are the focus of this PR. These tests validate the logic in isolation but don't verify that the production code correctly implements the AccountID validation behavior. Consider either removing these fixture-based tests since they provide limited value, or refactor them to actually test the RuntimeFeatureControlProcessor methods.

Copilot uses AI. Check for mistakes.

TEST(rfcMgrTest, GetAccountID_ValidValue) {
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID", "3064488088886635972", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
rfcObj->GetAccountID();
EXPECT_EQ(rfcObj->_accountId, "3064488088886635972");
EXPECT_FALSE(StringCaseCompare(rfcObj->_accountId, "Unknown"));
delete rfcObj;
}

TEST(rfcMgrTest, GetAccountID_UnknownValue) {
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID", "Unknown", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
rfcObj->GetAccountID();
EXPECT_TRUE(StringCaseCompare(rfcObj->_accountId, "Unknown"));
delete rfcObj;
}

TEST(rfcMgrTest, GetAccountID_EmptyValue) {
writeToTr181storeFile("Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID", "", "/opt/secure/RFC/tr181store.ini", Quoted);
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
rfcObj->GetAccountID();
EXPECT_TRUE(rfcObj->_accountId.empty());
delete rfcObj;
}
Comment on lines +1416 to +1439
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for these new tests uses PascalCase (GetAccountID_ValidValue, GetAccountID_UnknownValue, GetAccountID_EmptyValue) while existing tests for the same functionality use camelCase (getAccountID, getAccountID_Unknown at line 309 and 1020). For consistency, consider using camelCase naming (e.g., getAccountID_ValidValue) to match the existing test naming pattern in this file.

Copilot uses AI. Check for mistakes.

TEST(rfcMgrTest, GetValidAccountId_ReplacesUnknown) {
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
rfcObj->_accountId = "4123705941507160513";
rfcObj->_RFCKeyAndValueMap[RFC_ACCOUNT_ID_KEY_STR] = "Unknown";
rfcObj->GetValidAccountId();
// Should use the stored valid account ID instead of "Unknown"
EXPECT_EQ(rfcObj->_valid_accountId, "4123705941507160513");
delete rfcObj;
}

TEST(rfcMgrTest, GetValidAccountId_RejectsEmpty) {
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
rfcObj->_accountId = "4123705941507160513";
rfcObj->_RFCKeyAndValueMap[RFC_ACCOUNT_ID_KEY_STR] = "";
rfcObj->GetValidAccountId();
// Should use the stored valid account ID instead of empty string
EXPECT_EQ(rfcObj->_valid_accountId, "4123705941507160513");
delete rfcObj;
}

GTEST_API_ int main(int argc, char *argv[]){
::testing::InitGoogleTest(&argc, argv);

Expand Down
5 changes: 5 additions & 0 deletions rfcMgr/rfc_xconf_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ class RuntimeFeatureControlProcessor : public xconf::XconfHandler
FRIEND_TEST(rfcMgrTest, ValidPartnerId);
FRIEND_TEST(rfcMgrTest, Removed_PERSISTENCE_FILE);
FRIEND_TEST(rfcMgrTest, EmptyFeatures);
FRIEND_TEST(rfcMgrTest, GetAccountID_ValidValue);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra leading space before the FRIEND_TEST declaration. All other FRIEND_TEST declarations in this file start without leading spaces. Please remove the extra space to maintain consistency with the rest of the file.

Suggested change
FRIEND_TEST(rfcMgrTest, GetAccountID_ValidValue);
FRIEND_TEST(rfcMgrTest, GetAccountID_ValidValue);

Copilot uses AI. Check for mistakes.
FRIEND_TEST(rfcMgrTest, GetAccountID_UnknownValue);
FRIEND_TEST(rfcMgrTest, GetAccountID_EmptyValue);
FRIEND_TEST(rfcMgrTest, GetValidAccountId_ReplacesUnknown);
FRIEND_TEST(rfcMgrTest, GetValidAccountId_RejectsEmpty);

#endif
};
Expand Down
2 changes: 1 addition & 1 deletion rfcMgr/xconf_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern "C" {
namespace xconf {
class XconfHandler {
public :
XconfHandler(){ }
XconfHandler() : _ebuild_type(eUNKNOWN) { }
int initializeXconfHandler(void);

// We do not allow this class to be copied !!
Expand Down
7 changes: 7 additions & 0 deletions test/rfcTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@

#include "gtest/gtest.h"



int add(int num1,int num2)
{
return (num1+num2);
}



TEST(Add, PositiveCase)
{
EXPECT_EQ(30,add(10,20));
EXPECT_EQ(50,add(30,20));
}




Comment on lines +22 to +39
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These blank line additions appear to be unrelated to the PR's purpose of adding AccountID validation tests. The test/rfcTest.cpp file is unrelated to the AccountID validation functionality being tested. Consider removing these unintentional changes to keep the PR focused on the AccountID validation tests described in the PR description.

Suggested change
int add(int num1,int num2)
{
return (num1+num2);
}
TEST(Add, PositiveCase)
{
EXPECT_EQ(30,add(10,20));
EXPECT_EQ(50,add(30,20));
}
int add(int num1,int num2)
{
return (num1+num2);
}
TEST(Add, PositiveCase)
{
EXPECT_EQ(30,add(10,20));
EXPECT_EQ(50,add(30,20));
}

Copilot uses AI. Check for mistakes.