mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 01:47:33 +02:00
auto tls (#3856)
This commit is contained in:
parent
78fc4853db
commit
488bcd6f72
12 changed files with 447 additions and 67 deletions
44
config/layered_test.go
Normal file
44
config/layered_test.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package config_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
)
|
||||
|
||||
func TestLayeredConfig(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("error on initial build", func(t *testing.T) {
|
||||
underlying := config.NewStaticSource(&config.Config{})
|
||||
_, err := config.NewLayeredSource(ctx, underlying, func(c *config.Config) error {
|
||||
return errors.New("error")
|
||||
})
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("propagate new config on error", func(t *testing.T) {
|
||||
underlying := config.NewStaticSource(&config.Config{Options: &config.Options{DeriveInternalDomainCert: proto.String("a.com")}})
|
||||
layered, err := config.NewLayeredSource(ctx, underlying, func(c *config.Config) error {
|
||||
if c.Options.GetDeriveInternalDomain() == "b.com" {
|
||||
return errors.New("reject update")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
var dst *config.Config
|
||||
layered.OnConfigChange(ctx, func(ctx context.Context, c *config.Config) {
|
||||
dst = c
|
||||
})
|
||||
|
||||
underlying.SetConfig(ctx, &config.Config{Options: &config.Options{DeriveInternalDomainCert: proto.String("b.com")}})
|
||||
assert.Equal(t, "b.com", dst.Options.GetDeriveInternalDomain())
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue