- ``basic-auth-user-file`` - is an alternative to ``basic-auth-user``:
instead of presenting the user ID in the configuration file it is specified
- in the file indicated by this parameter.
+ in the first line of the file indicated by this parameter.
- ``basic-auth-password`` - specifies the password for basic HTTP
authentication. This parameter is ignored when the user ID is not specified
- ``basic-auth-password-file`` - is an alternative to ``basic-auth-password``:
instead of presenting the password in the configuration file it is specified
- in the file indicated by this parameter.
+ in the first line of the file indicated by this parameter.
- ``role`` - denotes the role of the server in the HA setup. The following
roles are supported in the ``load-balancing`` configuration: ``primary``,
try:
file = open(cmd_args.auth_password_file, 'r')
password = file.readline()
+ if len(password) > 0 and password[-1] == '\n':
+ password = password[:-1]
file.close()
except Exception as exc:
print("Failed to run: " + str(exc))
isc_throw(BadValue, "Cannot open '" << file_name);
}
string content;
- file >> content;
+ getline(file, content);
return (content);
}
/// @brief Get the content of a regular file.
///
+/// @note Here the content is the first line not including the final
+/// line feed character if there is one.
+///
/// @param file_name The file name.
///
/// @return The content of the file.
EXPECT_EQ("abdc", content);
}
+/// @brief Check getContent with embedded spaces.
+TEST_F(FileUtilTest, getContentSpaces) {
+ string file_name(TEST_DATA_BUILDDIR "/fu.test");
+ ofstream fs(file_name.c_str(), ofstream::out | ofstream::trunc);
+ ASSERT_TRUE(fs.is_open());
+ fs << "ab\tc d\nxxx";
+ fs.close();
+ string content;
+ EXPECT_NO_THROW_LOG(content = getContent(file_name));
+ EXPECT_EQ("ab\tc d", content);
+}
+
/// @brief Check isDir.
TEST_F(FileUtilTest, isDir) {
EXPECT_TRUE(isDir("/dev"));