Make username lookup case-insensitive

finger [email protected] (or any mixed-case name) failed because the plan
path was built from the raw username while plan files are lower-case on
disk. Lower-case the requested name before resolving the plan path; the
original spelling is still echoed back when no plan file exists. Add a mock
test asserting Pete -> .../pete.
This commit is contained in:
waffle2k
2026-06-15 15:47:55 -07:00
parent 84fc383137
commit 268ededc19
2 changed files with 26 additions and 1 deletions
+15
View File
@@ -64,6 +64,21 @@ TEST_F(ProcessMockTest, ProcessWithEmptyFile) {
EXPECT_EQ(result, "emptyfileuser");
}
// Username lookup is case-insensitive: a mixed-case request is lowercased
// before the plan-file path is built, so "Pete" reads .../pete.
TEST_F(ProcessMockTest, ProcessLowercasesUsernameForLookup) {
using ::testing::Return;
const std::filesystem::path base{"/var/finger/users/"};
EXPECT_CALL(*mock_filesystem, exists(base / "pete"))
.WillOnce(Return(true));
EXPECT_CALL(*mock_filesystem, read_file(base / "pete"))
.WillOnce(Return("Just another hacker.\r\n"));
std::string result = process("Pete", *mock_filesystem, base);
EXPECT_EQ(result, "Just another hacker.\r\n");
}
// Test showing multiple expectations
TEST_F(ProcessMockTest, MultipleFileOperations) {
using ::testing::_;