Merge Go frontend (apiserver + xcecli) into meson build
This commit is contained in:
parent
43dc12a36c
commit
c9dc8c4676
205 changed files with 30793 additions and 328 deletions
33
src/frontend/apiserver/middleware/whitelist_test.go
Normal file
33
src/frontend/apiserver/middleware/whitelist_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package middleware
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPathMatchesPattern(t *testing.T) {
|
||||
cases := []struct {
|
||||
pattern string
|
||||
path string
|
||||
want bool
|
||||
}{
|
||||
// wildcard patterns
|
||||
{"/xce/v1/hosts/*", "/xce/v1/hosts/host1", true},
|
||||
{"/xce/v1/jobs/*", "/xce/v1/jobs/123/control", true},
|
||||
{"/xce/v1/roles/*", "/xce/v1/roles/cluster_admin", true},
|
||||
{"/xce/v1/users/*", "/xce/v1/users/current", true},
|
||||
{"/xce/v1/users/*", "/xce/v1/users/admin/basic_user", true},
|
||||
// exact patterns
|
||||
{"/xce/v1/hosts", "/xce/v1/hosts", true},
|
||||
{"/xce/v1/hosts", "/xce/v1/host", false},
|
||||
{"/xce/v1/roles", "/xce/v1/roles", true},
|
||||
{"/xce/v1/roles", "/xce/v1/role", false},
|
||||
{"/xce/v1/clusters", "/xce/v1/clusters", true},
|
||||
{"/ping", "/ping", true},
|
||||
{"/ping", "/pin", false},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
got := pathMatchesPattern(tc.path, tc.pattern)
|
||||
if got != tc.want {
|
||||
t.Errorf("pathMatchesPattern(%q, %q) = %v, want %v", tc.path, tc.pattern, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue