Skip to content

Commit

Permalink
fixed token tests error
Browse files Browse the repository at this point in the history
  • Loading branch information
skyface753 committed Dec 16, 2022
1 parent f9f8f4e commit b9d529a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions grpc-server-go/helper/generators/tokens_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package generators_test

import (
"strings"
"template/server/helper/generators"
"testing"
)
Expand All @@ -21,8 +22,12 @@ func TestJwt(t *testing.T) {
if userId != 10 {
t.Errorf("Expected 10, got %d", userId)
}
// Manipulate token
s = s[:len(s)-1] + "a"
splitted := strings.Split(s, ".")
for i, v := range splitted {
splitted[i] = v + "a"
}
s = strings.Join(splitted, ".")
t.Logf("Token (manipulated): %v", s)
userId, err = generators.VerifyJwt(s)
if err == nil {
t.Errorf("Expected error, got %d", userId)
Expand Down Expand Up @@ -58,7 +63,13 @@ func TestS3Jwt(t *testing.T) {
t.Errorf("Expected image/png, got %s", fileType)
}
// Manipulate token
s = s[:len(s)-1] + "a"
// add a to each block
splitted := strings.Split(s, ".")
for i, v := range splitted {
splitted[i] = v + "a"
}
s = strings.Join(splitted, ".")
t.Logf("Token (manipulated): %v", s)
filename, _, _, err = generators.VerifyJwtForS3Upload(s)
if err == nil {
t.Errorf("Expected error, got %s", filename)
Expand Down

0 comments on commit b9d529a

Please sign in to comment.