-
Notifications
You must be signed in to change notification settings - Fork 6
Add AccountID validation unit tests for RDKEMW-11615 #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
e365d62
599e81f
a00c0c4
4722957
8323fce
4d18068
7057c3e
0203e12
0339fe2
661848e
0f0aca1
0a05f1b
fed4c06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| } | ||
|
|
||
| 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
|
||
|
|
||
| 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); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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); | ||||||
|
||||||
| FRIEND_TEST(rfcMgrTest, GetAccountID_ValidValue); | |
| FRIEND_TEST(rfcMgrTest, GetAccountID_ValidValue); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)); | |
| } |
There was a problem hiding this comment.
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.