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:
@@ -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::_;
|
||||
|
||||
Reference in New Issue
Block a user