feat:完善项目信息
This commit is contained in:
47
app/service/auth_test.go
Normal file
47
app/service/auth_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/serve/orm/logic"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func mysql() *gorm.DB {
|
||||
instance := orm.NewInstance(
|
||||
orm.WithDebug(false),
|
||||
orm.WithDBMode("mysql"),
|
||||
orm.WithTablePrefix(""),
|
||||
orm.WithSingularTable(false),
|
||||
orm.WithMaxIdleConns(3600),
|
||||
orm.WithMaxOpenConns(2000),
|
||||
orm.WithMaxLifetime(1000),
|
||||
orm.WithMysqlOption(&logic.Mysql{
|
||||
Username: "appuser", Password: "ABCabc01", Host: "192.168.0.188", Port: 3306,
|
||||
Database: "sciences", Parameters: "charset=utf8mb4,utf8&parseTime=True&loc=Local",
|
||||
}),
|
||||
).Init()
|
||||
return instance.Engine
|
||||
}
|
||||
|
||||
func TestNewPermission(t *testing.T) {
|
||||
mysql := mysql()
|
||||
NewAuth().Register()("mysql", mysql, model.NewSysAuthRule().TableName())
|
||||
|
||||
permission := NewPermission(
|
||||
WithAuthTenant("0"),
|
||||
WithAuthUser("123"),
|
||||
WithAuthRoles([]string{"1", "2"}),
|
||||
WithAuthRequest([]*AuthRequest{&AuthRequest{
|
||||
Url: "/admin/123",
|
||||
Method: "*",
|
||||
}}),
|
||||
)
|
||||
//status, err := permission.AddPolicies()
|
||||
//status, err := permission.AddRoleForUser()
|
||||
//status, err := permission.RemoveRolePolicies()
|
||||
status, err := permission.Enforce()
|
||||
t.Log(status)
|
||||
t.Log(err)
|
||||
}
|
Reference in New Issue
Block a user