docker-mailserver/test/config/example-opendkim/keys/localhost.localdomain/mail.private
Brennan Kinney 88767f7cc8
tests(refactor): open_dkim.bats (#3060)
* tests(refactor): Make test cases for opendkim keysizes DRY

- These all do roughly the same logic that can be split into two separate methods.
- `_should_generate_dkim_key()` covers a bit more logic as it can be leveraged to handle other test cases that also perform the same logic.
- The `config/opendkim/` doesn't seem necessary for tests. Only the first few test cases here are testing against it, so we can conditionally make that available. `process_check_restart.bats` also depended on it to run OpenDKIM successfully, but this was due to the `setup-stack.sh` config defaults failing to find an "empty" file forcing `supervisord` to constantly restart the process..
- With this, there we inverse the default opendkim config, so we don't have to mount unique / empty subfolders for each test case, followed by copying over the two extra configs.

* tests(refactor): DRY up more test cases

All the remaining test cases but the last one were refactored here for a clean commit diff. The last test case will be refactored in the following commit.

Plenty of repeated logic spread across these test cases, now condensed into shared methods.

* tests(refactor): Make final test case DRY

* chore: Migrate to new testing helpers

* chore: Revise test case descriptions

* tests(refactor): Improve and simplify assertions

* tests(refactor): Use common container setup instead of `docker run`

- As the majority of test cases are only running `open-dkim` helper, we don't actually have to wait for a full container setup. So an alternative container start is called.
- Also improves assertions a bit more instead of just counting lines.
- Some test cases don't bind mount all of `/tmp/docker-mailserver` contents, thus don't raise permission errors on subsequent test runs.
- Instead of `rm -f` on some config files, have opted to mount them read-only instead, or alternatively mount an anonymous empty volume instead.
- Collapsed the first three test cases into one, thus no `setup_file()` necessary.
- Shift the `_wait_for_finished_setup_in_container()` method into `_common_container_setup()` instead since nothing else is using `_common_container_start()` yet, this allows for avoiding the wait.

* tests(refactor): Collapse dkim key size test cases into single test case

This makes these tests a bit more DRY, and enhances the raised quality issue with these tests. Now not only is the domain checked in the generated DNS dkim record, but we also verify the key size is corrected in the public and private keys via openssl.

* chore: Revise container names

* chore: Swap order of test case 1 and 2

* tests(refactor): Assert generated log output

- `__should_have_tables_trustedhosts_for_domain` shifted in each test case to just after generating the domains keys.
- Asserts `open-dkim` logs instead of just counting them.
- Added checks for domains that should not be present in a test case.
- Additional coverage and notes about the alias from vhost `@localdomain.com`
- Single assert statement with switch statement as all are using common args.

* chore: Minor changes

* tests(refactor):  Share `find` logic in helpers and tests

* tests(fix): Listing file content does not need to match line order

The order printed from local system vs CI differed causing the CI to fail. The order of lines is irrelevant so `--index` is not required.

Additionally correct the prefix of the called method to be only one `_` now that it's a `common.bash` helper method.

* chore: Collapse custom DKIM selector test into custom DKIM domain test

These cover the same test logic for the most part, the first domain could also be testing the custom selector.

`special_use_folders.bats` + `mailbox_format_dbox` can assert lines instead, removing the need for `--partial`.

* Apply suggestions from code review

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>

* chore: Split switch statement method into wrapper methods

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2023-02-10 00:18:06 +13:00

16 lines
887 B
Plaintext

-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQCzUJyyhq+TeT1wlIth5Z0yr7Ohd62n4rL5X3vRJO4EDyOEicJ7
3cjuaU4JLTYhbqmbNalOyXE9btS9I55Gv3RyomVBD1JpVTKdjVBUQug2L/ggw2dt
t1FAn99svQWMs1XxmxiTR+sCEVkgKMmLSkCJuDCIfY/Bc9nlcng9+juB8wIDAQAB
AoGBAKF6dMJoe/Coe+XIP4TXjCq7A17jMaVAh7/+drgvM5DAOVH/5P47Cdl5R2cI
KfkNePtm5aMn0SxrhHUXgE9h1nBp7hrwvDnRwIUB8Ml3yE6f18p3OpHX8txVo1Qg
Ov8LsJ1XUWaCmMnLg95wrUP0yHKjRmxxJjIfkCzqPXo/6HvRAkEA6ZJQffUYfMeo
OrjVg3CpOYKR/deneC2x5ZbqyXgOQBJH010nU3DfFqEg5L+DHwpyiodOco6TRrrM
prp90j3wvQJBAMSIjcLPC/1NxW7QQGnMl9CdnD11bnV17+gMCHJfUYAdKpU9EQDB
dqJYP3GEOJXmC77Yua9P+QhEdZpF2M4yoG8CQEQ5l8di+zcffrVAXiWZl+STjh9O
ib1h44/DiGs25Tqz3EUR9bW6x38tq5UFl8BOZeyu3yw5Fy3WzIZ6/NuXeiUCQDF3
KS8CC8N6gpnMgpnea8uPD9cMKnwX7gUamjmnMg0ryh772r608tYTngxFOjTITOaB
B+NPHp/tEyh8MgBcD7MCQQCT7ABW3W+tekXOP/NvSwYlA0Ty2oQ75p9pPao94Tef
vz8CQFrb3C16789YH9lNyFmbClwpp9x9V2pXS8akyOxW
-----END RSA PRIVATE KEY-----