mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-17 19:17:17 +02:00
config: add a consistent route ID (#905)
This commit is contained in:
parent
34d06e521d
commit
ee2170f5f5
4 changed files with 76 additions and 6 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_PolicyValidate(t *testing.T) {
|
||||
|
@ -81,3 +82,48 @@ func TestPolicy_String(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_PolicyRouteID(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
basePolicy *Policy
|
||||
comparePolicy *Policy
|
||||
wantID uint64
|
||||
wantSame bool
|
||||
}{
|
||||
{
|
||||
"same",
|
||||
&Policy{From: "https://pomerium.io", To: "http://localhost", AllowedUsers: []string{"foo@bar.com"}},
|
||||
&Policy{From: "https://pomerium.io", To: "http://localhost", AllowedGroups: []string{"allusers"}},
|
||||
6315033228798964203,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"different from",
|
||||
&Policy{From: "https://pomerium.io", To: "http://localhost"},
|
||||
&Policy{From: "https://notpomerium.io", To: "http://localhost"},
|
||||
6315033228798964203,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"different path",
|
||||
&Policy{From: "https://pomerium.io", To: "http://localhost"},
|
||||
&Policy{From: "https://pomerium.io", To: "http://localhost", Path: "/foo"},
|
||||
6315033228798964203,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.NoError(t, tt.basePolicy.Validate())
|
||||
assert.NoError(t, tt.comparePolicy.Validate())
|
||||
|
||||
assert.Equal(t, tt.wantSame, tt.basePolicy.RouteID() == tt.comparePolicy.RouteID())
|
||||
assert.Equal(t, tt.wantID, tt.basePolicy.RouteID())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue