|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestRemoveIntegration() {
|
|
|
|
|
|
|
|
|
|
|
|
// Object under test.
|
|
|
|
|
|
PostfixMilterConf TestObj;
|
|
|
|
|
|
|
|
|
|
|
|
// Container of test lines.
|
|
|
|
|
|
std::vector<std::string> TestInput;
|
|
|
|
|
|
|
|
|
|
|
|
// Container of expected output.
|
|
|
|
|
|
std::vector<std::string> ExpectedOutput;
|
|
|
|
|
|
|
|
|
|
|
|
// Test lines that are milter lines with SNFMilter already integrated.
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = unix:/var/snf-milter/socket");
|
|
|
|
|
|
ExpectedOutput.push_back("");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = unix:/var/snf-milter/socket ");
|
|
|
|
|
|
ExpectedOutput.push_back("");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = unix:/var/snf-milter/socket\t ");
|
|
|
|
|
|
ExpectedOutput.push_back("");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = otherMilterSpec unix:/var/snf-milter/socket");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = otherMilterSpec");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = otherMilterSpec\txxx qqq,unix:/var/snf-milter/socket");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = otherMilterSpec xxx qqq");
|
|
|
|
|
|
|
|
|
|
|
|
// Test lines that are milter lines with SNFMilter not integrated.
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = unix:/var/snf-milter/sockett");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = unix:/var/snf-milter/sockett");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = unix:/var/snf-milter/sock ");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = unix:/var/snf-milter/sock");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = otherMilterSpec unix:/var/snf-milter\t\t");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = otherMilterSpec unix:/var/snf-milter");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters = otherMilterSpec\tunix:/var/snf-milter\t\t");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters = otherMilterSpec\tunix:/var/snf-milter");
|
|
|
|
|
|
|
|
|
|
|
|
// Test lines that are not milter lines.
|
|
|
|
|
|
TestInput.push_back("smtpd_milterss = unix:/var/snf-milter/socketb");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milterss = unix:/var/snf-milter/socketb");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters unix:/var/snf-milter/socket");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters unix:/var/snf-milter/socket");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("smtpd_milters\tunix:/var/snf-milter/socketb");
|
|
|
|
|
|
ExpectedOutput.push_back("smtpd_milters\tunix:/var/snf-milter/socketb");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("#smtpd_milterss = unix:/var/snf-milter/socketb");
|
|
|
|
|
|
ExpectedOutput.push_back("#smtpd_milterss = unix:/var/snf-milter/socketb");
|
|
|
|
|
|
|
|
|
|
|
|
TestInput.push_back("manpage_directory = /usr/share/man");
|
|
|
|
|
|
ExpectedOutput.push_back("manpage_directory = /usr/share/man");
|
|
|
|
|
|
|
|
|
|
|
|
std::string ActualOutput;
|
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < TestInput.size(); i++) {
|
|
|
|
|
|
|
|
|
|
|
|
TestObj.ConfLine(TestInput[i]);
|
|
|
|
|
|
|
|
|
|
|
|
TestObj.RemoveIntegration();
|
|
|
|
|
|
|
|
|
|
|
|
ActualOutput = TestObj.ConfLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (ActualOutput != ExpectedOutput[i]) {
|
|
|
|
|
|
|
|
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
|
|
|
|
Temp = "***Error--RemoveItegration() returned\n\t'";
|
|
|
|
|
|
Temp += ActualOutput;
|
|
|
|
|
|
Temp += "'\nwith input\n\t'";
|
|
|
|
|
|
Temp += TestInput[i];
|
|
|
|
|
|
Temp += "'\n";
|
|
|
|
|
|
|
|
|
|
|
|
Error(Temp);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/// Unit tests for PostfixMilterConf.
|
|
|
/// Unit tests for PostfixMilterConf.
|
|
|
//
|
|
|
//
|
|
|
int main(int argc, char* argv[]) {
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
|
try { // Catch anything that breaks loose.
|
|
|
try { // Catch anything that breaks loose.
|
|
|
// Test IsIntegrated.
|
|
|
|
|
|
|
|
|
|
|
|
if (!TestIsIntegrated()) {
|
|
|
if (!TestIsIntegrated()) {
|
|
|
ErrorExit("TestIsIntegrated() failure.\n");
|
|
|
ErrorExit("TestIsIntegrated() failure.\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Test IsMilterLine.
|
|
|
|
|
|
if (!TestIsMilterLine()) {
|
|
|
if (!TestIsMilterLine()) {
|
|
|
ErrorExit("TestIsMilterLine() failure.\n");
|
|
|
ErrorExit("TestIsMilterLine() failure.\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Test AddItegration.
|
|
|
|
|
|
if (!TestAddIntegration()) {
|
|
|
if (!TestAddIntegration()) {
|
|
|
ErrorExit("TestAddIntegration() failure.\n");
|
|
|
ErrorExit("TestAddIntegration() failure.\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!TestRemoveIntegration()) {
|
|
|
|
|
|
ErrorExit("TestRemoveIntegration() failure.\n");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} // That's all folks.
|
|
|
} // That's all folks.
|
|
|
|
|
|
|
|
|
catch(std::exception& e) { // Report any normal exceptions.
|
|
|
catch(std::exception& e) { // Report any normal exceptions.
|