|
@@ -3,12 +3,6 @@ package admin_common
|
|
|
import (
|
|
|
"fmt"
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
|
- "gorm.io/driver/mysql"
|
|
|
- "gorm.io/gorm"
|
|
|
- "gorm.io/gorm/logger"
|
|
|
- "gorm.io/gorm/schema"
|
|
|
- "sghgogs.com/sghblog/authorization-service/domain/repository"
|
|
|
- "sghgogs.com/sghblog/authorization-service/domain/service"
|
|
|
"testing"
|
|
|
"time"
|
|
|
)
|
|
@@ -29,17 +23,17 @@ func hashPassword(password string) (string, error) {
|
|
|
}
|
|
|
|
|
|
func TestAdminLogin(t *testing.T) {
|
|
|
- address := fmt.Sprintf("%v:%v@(%v:%v)/%v?charset=utf8mb4,utf8&parseTime=True&loc=Local", "root", "xugang131500", "47.56.16.206", 3306, "sghblog")
|
|
|
- db, err := gorm.Open(mysql.Open(address), &gorm.Config{
|
|
|
- Logger: logger.Default.LogMode(logger.Info),
|
|
|
- NamingStrategy: schema.NamingStrategy{
|
|
|
- SingularTable: true,
|
|
|
- }})
|
|
|
- if err != nil {
|
|
|
- t.Fatal(err)
|
|
|
- }
|
|
|
- repo := repository.NewRepository(db)
|
|
|
- newService := service.NewService(repo)
|
|
|
+ // address := fmt.Sprintf("%v:%v@(%v:%v)/%v?charset=utf8mb4,utf8&parseTime=True&loc=Local", "root", "xugang131500", "47.56.16.206", 3306, "sghblog")
|
|
|
+ // db, err := gorm.Open(mysql.Open(address), &gorm.Config{
|
|
|
+ // Logger: logger.Default.LogMode(logger.Info),
|
|
|
+ // NamingStrategy: schema.NamingStrategy{
|
|
|
+ // SingularTable: true,
|
|
|
+ // }})
|
|
|
+ // if err != nil {
|
|
|
+ // t.Fatal(err)
|
|
|
+ // }
|
|
|
+ // repo := repository.NewRepository(db)
|
|
|
+ // newService := service.NewService(repo)
|
|
|
t.Run("过期时间", func(t *testing.T) {
|
|
|
old := time.Now().Unix()
|
|
|
add := time.Now().Add(time.Second * time.Duration(0.5*3600)).Unix()
|
|
@@ -50,10 +44,10 @@ func TestAdminLogin(t *testing.T) {
|
|
|
// fmt.Println("expiryTime", expiryTime)
|
|
|
})
|
|
|
t.Run("登录", func(t *testing.T) {
|
|
|
- login, err := newService.AdminLogin("admin", "123456", 1)
|
|
|
+ // login, err := newService.AdminLogin("admin", "123456", 1)
|
|
|
// fmt.Println(checkPasswordHash("123456", login.Password))
|
|
|
- fmt.Println(err)
|
|
|
- fmt.Println(login.Roles)
|
|
|
- fmt.Println(login.Teams)
|
|
|
+ // fmt.Println(err)
|
|
|
+ // fmt.Println(login.Roles)
|
|
|
+ // fmt.Println(login.Teams)
|
|
|
})
|
|
|
}
|