mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +02:00
30 lines
678 B
Go
30 lines
678 B
Go
package autocert
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/caddyserver/certmagic"
|
|
"github.com/stretchr/testify/assert"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
func TestCertMagicLogger(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
encoder := zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig())
|
|
var buf bytes.Buffer
|
|
core := zapcore.NewCore(encoder, zapcore.AddSync(&buf), zapcore.DebugLevel)
|
|
core = certMagicLoggerCore{core: core}
|
|
|
|
logger := zap.New(core)
|
|
|
|
ocspError := fmt.Errorf("ocsp error: %w", certmagic.ErrNoOCSPServerSpecified)
|
|
logger.Info("TEST", zap.Error(ocspError))
|
|
assert.Empty(t, buf.Bytes())
|
|
|
|
logger.Info("TEST")
|
|
assert.NotEmpty(t, buf.Bytes())
|
|
}
|