mirror of
https://github.com/bokysan/docker-postfix.git
synced 2024-09-20 14:56:10 +08:00
9b1902c047
Summary ^^^^^^^ This commit refactors the code base to be more manageble and prepares the groundwork for tests. Refactoring ^^^^^^^^^^^ Files are now moved to subdirectories, all for the sole purpose of easier management. Tests live in their own folders, as well as configs and other files. Test framework ^^^^^^^^^^^^^^ Two new important scripts/directories are available: - `unit-tests.sh` / `/unit-test` which executes unit tests across shell scripts, and - `integration-test.sh` / `integration-tests`, which spins up the container and tries to send the email. Both tests use the [BATS](https://github.com/sstephenson/bats) framework for testing. To create a new test, simply drop a `.bats` file into a corresponding directory. Functions have been extracted into `common-run.sh`, to be able to test them independently. DKIM_SELECTOR ^^^^^^^^^^^^^ It is now possible to specify a DKIM selector to use (instead of the default "mail"). See `README.md` for more details. JSON logging ^^^^^^^^^^^^ WIP: rsyslog will now output JSON logs. This is especially important if you plan on deploying the image into Kubernetes, as [Prometheus](https://prometheus.io/) can handle logs in JSON much easier. TODO: Make this an optional feature, to not confuse existing users.
56 lines
1.7 KiB
Bash
56 lines
1.7 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load /code/scripts/common.sh
|
|
|
|
@test "check if 'mail' when DKIM_SELECTOR is not defined" {
|
|
result="$(get_dkim_selector)"
|
|
[ "$result" == "mail" ]
|
|
}
|
|
|
|
@test "check if 'xxx' when DKIM_SELECTOR is defined" {
|
|
local DKIM_SELECTOR="xxx"
|
|
result="$(get_dkim_selector)"
|
|
[ "$result" == "xxx" ]
|
|
}
|
|
|
|
@test "check if 'xxx' without domain when DKIM_SELECTOR=xxx,example.org=yyy,example.com=zzz" {
|
|
local DKIM_SELECTOR="xxx,example.org=yyy,example.com=zzz"
|
|
result="$(get_dkim_selector example.org)"
|
|
echo "result=$result"
|
|
[ "$result" == "yyy" ]
|
|
}
|
|
|
|
@test "check if 'yyy' when domain is example.org DKIM_SELECTOR=xxx,example.org=yyy,example.com=zzz" {
|
|
local DKIM_SELECTOR="xxx,example.org=yyy,example.com=zzz"
|
|
result="$(get_dkim_selector example.org)"
|
|
echo "result=$result"
|
|
[ "$result" == "yyy" ]
|
|
}
|
|
|
|
@test "check if 'zzz' when domain is example.org DKIM_SELECTOR=xxx,example.org=yyy,example.com=zzz" {
|
|
local DKIM_SELECTOR="xxx,example.org=yyy,example.com=zzz"
|
|
result="$(get_dkim_selector example.com)"
|
|
echo "result=$result"
|
|
[ "$result" == "zzz" ]
|
|
}
|
|
|
|
@test "check if 'aaa' when domain is example.net DKIM_SELECTOR=xxx,example.org=yyy,example.com=zzz,bbb,aaa" {
|
|
local DKIM_SELECTOR="xxx,example.org=yyy,example.com=zzz,bbb,aaa"
|
|
result="$(get_dkim_selector example.net)"
|
|
echo "result=$result"
|
|
[ "$result" == "aaa" ]
|
|
}
|
|
|
|
@test "check if 'bbb' when domain is example.net DKIM_SELECTOR=example.com=bbb" {
|
|
local DKIM_SELECTOR="example.com=bbb"
|
|
result="$(get_dkim_selector example.com)"
|
|
echo "result=$result"
|
|
[ "$result" == "bbb" ]
|
|
}
|
|
|
|
@test "check if 'mail' when domain is example.net DKIM_SELECTOR=example.com=bbb" {
|
|
local DKIM_SELECTOR="example.com=bbb"
|
|
result="$(get_dkim_selector example.net)"
|
|
echo "result=$result"
|
|
[ "$result" == "mail" ]
|
|
} |