mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-08-17 20:03:08 +00:00
Fix tests
This commit is contained in:
parent
c38e27b097
commit
eb72be0aab
1 changed files with 10 additions and 1 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -47,7 +48,14 @@ func TestValidateJWT(t *testing.T) {
|
|||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := ValidateJWT(tc.authHeader)
|
||||
var accessToken string
|
||||
parts := strings.Split(tc.authHeader, "Bearer ")
|
||||
if len(parts) == 2 {
|
||||
accessToken = parts[1]
|
||||
} else {
|
||||
accessToken = ""
|
||||
}
|
||||
err := ValidateJWT(true, accessToken, "test-audience")
|
||||
if tc.expectError && err == nil {
|
||||
t.Errorf("Expected error but got none")
|
||||
}
|
||||
|
@ -128,6 +136,7 @@ func createValidJWT(t *testing.T) string {
|
|||
token := jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.MapClaims{
|
||||
"sub": "1234567890",
|
||||
"name": "Test User",
|
||||
"aud": "test-audience",
|
||||
"iat": time.Now().Unix(),
|
||||
"exp": time.Now().Add(time.Hour).Unix(),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue