Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: test but config not init
Browse files Browse the repository at this point in the history
  • Loading branch information
ozline committed Aug 18, 2023
1 parent fdef2ed commit 4f94ed6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
3 changes: 2 additions & 1 deletion cmd/chat/test/main_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package test

import (
"testing"

"github.com/cloudwego/kitex/client"
"github.com/ozline/tiktok/kitex_gen/chat/messageservice"
"testing"
)

var conn messageservice.Client
Expand Down
12 changes: 2 additions & 10 deletions config/config_exmple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ services:
load-balance: false
addr:
- 127.0.0.1:10004
interactive:
comment:
name: interactive
load-balance: false
addr:
Expand All @@ -67,12 +67,4 @@ services:
name: video
load-balance: false
addr:
- 127.0.0.1:10006
experimental:
name: experimental
load-balance: false
addr:
- 127.0.0.1:10007
- 127.0.0.1:10008
- 127.0.0.1:10009
- 127.0.0.1:10010
- 127.0.0.1:10006
2 changes: 2 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package constants
import "time"

const (
JWTValue = "MTAxNTkwMTg1Mw=="

ReidsDB_Chat = 1

// RPC
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/golang-jwt/jwt"
"github.com/ozline/tiktok/config"
"github.com/ozline/tiktok/pkg/constants"
)

type Claims struct {
Expand All @@ -24,12 +24,12 @@ func CreateToken(userId int64) (string, error) {
},
}
tokenStruct := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return tokenStruct.SignedString([]byte(config.Server.Secret))
return tokenStruct.SignedString([]byte(constants.JWTValue))
}

func CheckToken(token string) (*Claims, error) {
response, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(config.Server.Secret), nil
return []byte(constants.JWTValue), nil
})

if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ func GetMQUrl() string {

url := strings.Join([]string{"amqp://", config.RabbitMQ.Username, ":", config.RabbitMQ.Password, "@", config.RabbitMQ.Addr, "/"}, "")

klog.Infof("generate url: %v\n", url)

return url

// amqp://tiktok:tiktok@127.0.0.1:5672/
}

func AddrCheck(addr string) bool {
Expand Down

0 comments on commit 4f94ed6

Please sign in to comment.