go18/devcloud/mcenter/apps/policy/impl/policy_test.go

37 lines
672 B
Go
Raw Normal View History

2025-06-08 16:14:19 +08:00
package impl_test
import (
"testing"
"122.51.31.227/go-course/go18/devcloud/mcenter/apps/policy"
)
func TestQueryPolicy(t *testing.T) {
req := policy.NewQueryPolicyRequest()
req.WithUser = true
req.WithRole = true
req.WithNamespace = true
set, err := impl.QueryPolicy(ctx, req)
if err != nil {
t.Fatal(err)
}
t.Log(set)
}
func TestCreatePolicy(t *testing.T) {
req := policy.NewCreatePolicyRequest()
2025-06-29 15:26:49 +08:00
// guest
2025-06-08 17:27:04 +08:00
req.UserId = 2
2025-06-29 15:26:49 +08:00
// 开发
req.RoleId = []uint64{3}
// default
2025-06-22 23:53:53 +08:00
req.SetNamespaceId(1)
2025-06-29 15:26:49 +08:00
// 开发小组1的资源
req.SetScope("team", []string{"dev01"})
2025-06-08 16:14:19 +08:00
set, err := impl.CreatePolicy(ctx, req)
if err != nil {
t.Fatal(err)
}
t.Log(set)
}