-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Try fixing the #147 issue and conver it by unit tests
- Loading branch information
Showing
21 changed files
with
212 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bats | ||
|
||
load /code/scripts/common.sh | ||
load /code/scripts/common-run.sh | ||
|
||
|
||
@test "verify reading and writting propreties" { | ||
local value | ||
local old_value | ||
old_value="$(get_postconf "mydestination")" | ||
|
||
do_postconf -# mydestination | ||
|
||
value="$(get_postconf "mydestination")" | ||
if [[ -n "${value}" ]]; then | ||
echo "Expected '', got: '$value' for 'mydestination'" >&2 | ||
exit 1 | ||
fi | ||
|
||
do_postconf -e 'mydestination=$myhostname, localhost.$mydomain $mydomain' | ||
|
||
value="$(get_postconf "mydestination")" | ||
if [[ "${value}" != 'mydestination=$myhostname, localhost.$mydomain $mydomain' ]]; then | ||
echo "Expected 'mydestination=\$myhostname, localhost.\$mydomain \$mydomain', got: '$value' for mydestination" >&2 | ||
exit 1 | ||
fi | ||
|
||
do_postconf -# mydestination | ||
echo " mydestination = localhost" >> /etc/postfix/main.cf | ||
|
||
value="$(get_postconf "mydestination")" | ||
if [[ "${value}" != "localhost" ]]; then | ||
echo "Expected 'localhost', got: '$value' for mydestination" >&2 | ||
exit 1 | ||
fi | ||
|
||
do_postconf -e "mydestination=${old_value}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bats | ||
|
||
load /code/scripts/common.sh | ||
load /code/scripts/common-run.sh | ||
|
||
|
||
@test "verify reading of daemon_directory" { | ||
local daemon_directory | ||
local old_daemon_directory | ||
local dir_debian="/usr/lib/postfix/sbin" | ||
local dir_alpine="/usr/libexec/postfix" | ||
local dir_temp="/tmp/deamon_directory" | ||
old_daemon_directory="$(get_postconf "daemon_directory")" | ||
|
||
rm -rf "${dir_debian}.bak" "${dir_alpine}.bak" | ||
if [[ -d "${dir_debian}" ]]; then | ||
cp -r ${dir_debian} ${dir_temp} | ||
mv ${dir_debian} ${dir_debian}.bak | ||
fi | ||
|
||
if [[ -d "${dir_alpine}" ]]; then | ||
cp -r ${dir_alpine} ${dir_temp} | ||
mv ${dir_alpine} ${dir_alpine}.bak | ||
fi | ||
|
||
# Test if Debian/Ubuntu directory remains the same when run on Debian/Ubuntu | ||
cp -r ${dir_temp} ${dir_debian} | ||
do_postconf -e "daemon_directory=${dir_debian}" | ||
postfix_upgrade_daemon_directory | ||
postfix check | ||
rm -rf ${dir_debian} ${dir_alpine} | ||
[ "$(get_postconf "daemon_directory")" == "${dir_debian}" ] | ||
|
||
# Test if Debian/Ubuntu directory gets changes the same when run on Alpine | ||
cp -r ${dir_temp} ${dir_alpine} | ||
do_postconf -e "daemon_directory=${dir_debian}" | ||
postfix_upgrade_daemon_directory | ||
postfix check | ||
rm -rf ${dir_debian} ${dir_alpine} | ||
[ "$(get_postconf "daemon_directory")" == "${dir_alpine}" ] | ||
|
||
# Test if Alpine directory remains the same when run on Alpine | ||
cp -r ${dir_temp} ${dir_alpine} | ||
do_postconf -e "daemon_directory=${dir_alpine}" | ||
postfix_upgrade_daemon_directory | ||
postfix check | ||
rm -rf ${dir_debian} ${dir_alpine} | ||
[ "$(get_postconf "daemon_directory")" == "${dir_alpine}" ] | ||
|
||
# Test if Alpine directory gets changes the same when run on Debian/Ubuntu | ||
cp -r ${dir_temp} ${dir_debian} | ||
do_postconf -e "daemon_directory=${dir_alpine}" | ||
postfix_upgrade_daemon_directory | ||
postfix check | ||
rm -rf ${dir_debian} ${dir_alpine} | ||
[ "$(get_postconf "daemon_directory")" == "${dir_debian}" ] | ||
|
||
# Test if things work with custom directory | ||
do_postconf -e "daemon_directory=${dir_temp}" | ||
postfix_upgrade_daemon_directory | ||
postfix check | ||
rm -rf ${dir_debian} ${dir_alpine} | ||
[ "$(get_postconf "daemon_directory")" == "${dir_temp}" ] | ||
|
||
rm -rf ${dir_temp} | ||
|
||
if [[ -d "${dir_debian}.bak" ]]; then | ||
mv ${dir_debian}.bak ${dir_debian} | ||
fi | ||
|
||
if [[ -d "${dir_alpine}.bak" ]]; then | ||
mv ${dir_alpine}.bak ${dir_alpine} | ||
fi | ||
|
||
do_postconf -e "daemon_directory=${old_daemon_directory}" | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: '3.7' | ||
version: '3.8' | ||
services: | ||
tests: | ||
image: "boky/postfix-unit-test" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index da4dd69..3739e18 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -31,7 +31,6 @@ option(EnableTests "Enable tests." ON) | ||
if(EnableTests) | ||
enable_testing() | ||
endif() | ||
-add_subdirectory(docs) | ||
add_subdirectory(scripts) | ||
add_subdirectory(src) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- a/src/test_config.cc 2022-09-06 21:21:10.600553457 +0200 | ||
+++ b/src/test_config.cc 2022-09-06 21:21:42.736614599 +0200 | ||
@@ -1,6 +1,7 @@ | ||
#include <getopt.h> | ||
#include <sasl/sasl.h> | ||
#include <string.h> | ||
+#include <libgen.h> | ||
|
||
#include "config.h" | ||
#include "log.h" |