add basic tests for the ctl subcommands, and fix two small bugs

this doesn't really test the output of the ctl commands, just that they succeed
without error. better than nothing...

testing found two small bugs, that are not an issue in practice:

1. we were ack'ing streamed data from the other side of the ctl connection
before having read it. when there is no buffer space on the connection (always
the case for net.Pipe) that would cause a deadlock. only actually happened
during the new tests.

2. the generated dkim keys are relatively to the directory of the dynamic
config file. mox looked it up relative to the directory of the _static_ config
file at startup. this directory is typicaly the same. users would have noticed
if they had triggered this.
This commit is contained in:
Mechiel Lukkien
2023-07-02 13:53:34 +02:00
parent 1469b7293e
commit 03c3f56a59
11 changed files with 321 additions and 107 deletions

View File

@ -186,7 +186,7 @@ func MakeDomainConfig(ctx context.Context, domain, hostname dns.Domain, accountN
addSelector := func(kind, name string, privKey []byte) error {
record := fmt.Sprintf("%s._domainkey.%s", name, domain.ASCII)
keyPath := filepath.Join("dkim", fmt.Sprintf("%s.%s.%skey.pkcs8.pem", record, timestamp, kind))
p := ConfigDirPath(keyPath)
p := configDirPath(ConfigDynamicPath, keyPath)
if err := writeFile(p, privKey); err != nil {
return err
}