mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-12 00:27:35 +02:00
envoy: Initial changes
This commit is contained in:
parent
8f78497e99
commit
99e788a9b4
107 changed files with 2542 additions and 3322 deletions
|
@ -218,7 +218,7 @@ func TestOptionsFromViper(t *testing.T) {
|
|||
wantErr bool
|
||||
}{
|
||||
{"good",
|
||||
[]byte(`{"autocert_dir":"","insecure_server":true,"policy":[{"from": "https://from.example","to":"https://to.example"}]}`),
|
||||
[]byte(`{"insecure_server":true,"policy":[{"from": "https://from.example","to":"https://to.example"}]}`),
|
||||
&Options{
|
||||
Policies: []Policy{{From: "https://from.example", To: "https://to.example"}},
|
||||
CookieName: "_pomerium",
|
||||
|
@ -235,7 +235,7 @@ func TestOptionsFromViper(t *testing.T) {
|
|||
}},
|
||||
false},
|
||||
{"good disable header",
|
||||
[]byte(`{"autocert_dir":"","insecure_server":true,"headers": {"disable":"true"},"policy":[{"from": "https://from.example","to":"https://to.example"}]}`),
|
||||
[]byte(`{"insecure_server":true,"headers": {"disable":"true"},"policy":[{"from": "https://from.example","to":"https://to.example"}]}`),
|
||||
&Options{
|
||||
Policies: []Policy{{From: "https://from.example", To: "https://to.example"}},
|
||||
CookieName: "_pomerium",
|
||||
|
@ -423,39 +423,3 @@ func Test_HandleConfigUpdate(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptions_sourceHostnames(t *testing.T) {
|
||||
t.Parallel()
|
||||
testOptions := func() *Options {
|
||||
o := NewDefaultOptions()
|
||||
o.SharedKey = "test"
|
||||
o.Services = "all"
|
||||
o.InsecureServer = true
|
||||
return o
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
policies []Policy
|
||||
authenticateURL string
|
||||
want []string
|
||||
}{
|
||||
{"empty", []Policy{}, "", nil},
|
||||
{"good no authN", []Policy{{From: "https://from.example", To: "https://to.example"}}, "", []string{"from.example"}},
|
||||
{"good with authN", []Policy{{From: "https://from.example", To: "https://to.example"}}, "https://authn.example.com", []string{"from.example", "authn.example.com"}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
o := testOptions()
|
||||
o.Policies = tt.policies
|
||||
o.AuthenticateURLString = tt.authenticateURL
|
||||
err := o.Validate()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := o.sourceHostnames()
|
||||
if diff := cmp.Diff(got, tt.want); diff != "" {
|
||||
t.Errorf("Options.sourceHostnames() = %v", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue