vitess.io/vitess@v0.16.2/go/vt/vtorc/server/api_test.go (about) 1 package server 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 "vitess.io/vitess/go/acl" 9 ) 10 11 func TestGetACLPermissionLevelForAPI(t *testing.T) { 12 tests := []struct { 13 apiEndpoint string 14 want string 15 }{ 16 { 17 apiEndpoint: problemsAPI, 18 want: acl.MONITORING, 19 }, { 20 apiEndpoint: disableGlobalRecoveriesAPI, 21 want: acl.ADMIN, 22 }, { 23 apiEndpoint: enableGlobalRecoveriesAPI, 24 want: acl.ADMIN, 25 }, { 26 apiEndpoint: replicationAnalysisAPI, 27 want: acl.MONITORING, 28 }, { 29 apiEndpoint: healthAPI, 30 want: acl.MONITORING, 31 }, { 32 apiEndpoint: "gibberish", 33 want: acl.ADMIN, 34 }, 35 } 36 for _, tt := range tests { 37 t.Run(tt.apiEndpoint, func(t *testing.T) { 38 got := getACLPermissionLevelForAPI(tt.apiEndpoint) 39 require.Equal(t, tt.want, got) 40 }) 41 } 42 }