MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetResourceFromRequest

Function TestGetResourceFromRequest

backend/api/v1/acl_test.go:13–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestGetResourceFromRequest(t *testing.T) {
14 tests := []struct {
15 request any
16 method string
17 want []string
18 }{
19 {
20 request: &v1pb.LoginRequest{Email: "hello@world.com"},
21 method: "/bytebase.v1.AuthService/Login",
22 want: []string{""},
23 },
24 {
25 request: &v1pb.CreateProjectRequest{
26 Project: &v1pb.Project{
27 Name: "projects/hello",
28 },
29 },
30 method: "/bytebase.v1.ProjectService/CreateProject",
31 want: []string{""},
32 },
33 {
34 request: &v1pb.UpdateProjectRequest{
35 Project: &v1pb.Project{
36 Name: "projects/hello",
37 },
38 },
39 method: "/bytebase.v1.ProjectService/UpdateProject",
40 want: []string{"projects/hello"},
41 },
42 {
43 request: &v1pb.ListProjectsRequest{},
44 method: "/bytebase.v1.ProjectService/ListProjects",
45 want: []string{""},
46 },
47 // The database group has not been annotated with resource yet.
48 {
49 request: &v1pb.CreateDatabaseGroupRequest{
50 Parent: "projects/hello",
51 },
52 method: "/bytebase.v1.DatabaseGroupService/CreateDatabaseGroup",
53 want: []string{"projects/hello"},
54 },
55 {
56 // The instance has not been annotated with resource yet.
57 request: &v1pb.UpdateInstanceRequest{
58 Instance: &v1pb.Instance{
59 Name: "instances/hello",
60 },
61 },
62 method: "/bytebase.v1.InstanceService/UpdateInstance",
63 want: []string{"instances/hello"},
64 },
65 {
66 request: &v1pb.UploadLicenseRequest{
67 License: "123",
68 },
69 method: "/bytebase.v1.SubscriptionService/UpdateSubscription",
70 want: []string{""},

Callers

nothing calls this directly

Calls 2

getResourceFromRequestFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected