test: generate tls cert/key in test

This commit is contained in:
James Houlahan
2020-08-03 09:24:39 +02:00
parent da381130a3
commit 7e6d09a247
3 changed files with 14 additions and 4 deletions

View File

@ -23,8 +23,10 @@ import (
"os"
"path/filepath"
"github.com/ProtonMail/proton-bridge/pkg/config"
"github.com/ProtonMail/proton-bridge/pkg/constants"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
"github.com/sirupsen/logrus"
)
type fakeConfig struct {
@ -39,9 +41,16 @@ func newFakeConfig() *fakeConfig {
panic(err)
}
return &fakeConfig{
cfg := &fakeConfig{
dir: dir,
}
// We must generate cert.pem and key.pem to prevent errors when attempting to open them.
if _, err = config.GenerateTLSConfig(cfg.GetTLSCertPath(), cfg.GetTLSKeyPath()); err != nil {
logrus.WithError(err).Fatal()
}
return cfg
}
func (c *fakeConfig) ClearData() error {