parent
74d2751d88
commit
a1f808c86e
12 changed files with 44 additions and 69 deletions
|
|
@ -36,7 +36,7 @@ func TestNewEnterpriseHandler_Validation(t *testing.T) {
|
||||||
AccessToken: "mock_access_token",
|
AccessToken: "mock_access_token",
|
||||||
TokenType: "Bearer",
|
TokenType: "Bearer",
|
||||||
}
|
}
|
||||||
return token.WithExtra(map[string]interface{}{"id_token": "mock_id_token"}), nil
|
return token.WithExtra(map[string]any{"id_token": "mock_id_token"}), nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ func TestNewEnterpriseHandler_Validation(t *testing.T) {
|
||||||
AccessToken: "mock_access_token",
|
AccessToken: "mock_access_token",
|
||||||
TokenType: "Bearer",
|
TokenType: "Bearer",
|
||||||
}
|
}
|
||||||
return token.WithExtra(map[string]interface{}{"id_token": "mock_id_token"}), nil
|
return token.WithExtra(map[string]any{"id_token": "mock_id_token"}), nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantError: "",
|
wantError: "",
|
||||||
|
|
@ -254,7 +254,7 @@ func TestEnterpriseHandler_Authorize_E2E(t *testing.T) {
|
||||||
AccessToken: "mock_access_token",
|
AccessToken: "mock_access_token",
|
||||||
TokenType: "Bearer",
|
TokenType: "Bearer",
|
||||||
}
|
}
|
||||||
return token.WithExtra(map[string]interface{}{"id_token": "mock_id_token_from_user_login"}), nil
|
return token.WithExtra(map[string]any{"id_token": "mock_id_token_from_user_login"}), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -305,7 +305,7 @@ func setupIdPServer(t *testing.T) *httptest.Server {
|
||||||
// OAuth/OIDC metadata endpoint - uses closure to get server URL
|
// OAuth/OIDC metadata endpoint - uses closure to get server URL
|
||||||
mux.HandleFunc("/.well-known/oauth-authorization-server", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/.well-known/oauth-authorization-server", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"issuer": server.URL,
|
"issuer": server.URL,
|
||||||
"token_endpoint": server.URL + "/token",
|
"token_endpoint": server.URL + "/token",
|
||||||
"authorization_endpoint": server.URL + "/authorize",
|
"authorization_endpoint": server.URL + "/authorize",
|
||||||
|
|
@ -350,7 +350,7 @@ func setupIdPServer(t *testing.T) *httptest.Server {
|
||||||
|
|
||||||
// Return ID-JAG (Identity Assertion JWT Authorization Grant)
|
// Return ID-JAG (Identity Assertion JWT Authorization Grant)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"access_token": "id-jag-token-from-idp",
|
"access_token": "id-jag-token-from-idp",
|
||||||
"issued_token_type": oauthex.TokenTypeIDJAG,
|
"issued_token_type": oauthex.TokenTypeIDJAG,
|
||||||
"token_type": "N_A",
|
"token_type": "N_A",
|
||||||
|
|
@ -375,7 +375,7 @@ func setupMCPAuthServer(t *testing.T) *httptest.Server {
|
||||||
// OAuth metadata endpoint - uses closure to get server URL
|
// OAuth metadata endpoint - uses closure to get server URL
|
||||||
mux.HandleFunc("/.well-known/oauth-authorization-server", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/.well-known/oauth-authorization-server", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"issuer": server.URL,
|
"issuer": server.URL,
|
||||||
"token_endpoint": server.URL + "/token",
|
"token_endpoint": server.URL + "/token",
|
||||||
"code_challenge_methods_supported": []string{"S256"},
|
"code_challenge_methods_supported": []string{"S256"},
|
||||||
|
|
@ -412,7 +412,7 @@ func setupMCPAuthServer(t *testing.T) *httptest.Server {
|
||||||
|
|
||||||
// Return access token
|
// Return access token
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"access_token": "mcp_access_token_from_jwt_bearer",
|
"access_token": "mcp_access_token_from_jwt_bearer",
|
||||||
"token_type": "Bearer",
|
"token_type": "Bearer",
|
||||||
"expires_in": 3600,
|
"expires_in": 3600,
|
||||||
|
|
@ -480,7 +480,7 @@ func TestEnterpriseHandler_TokenSource_BeforeAuthorization(t *testing.T) {
|
||||||
AccessToken: "mock_access_token",
|
AccessToken: "mock_access_token",
|
||||||
TokenType: "Bearer",
|
TokenType: "Bearer",
|
||||||
}
|
}
|
||||||
return token.WithExtra(map[string]interface{}{"id_token": "mock_id_token"}), nil
|
return token.WithExtra(map[string]any{"id_token": "mock_id_token"}), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ func createMockOIDCServer(t *testing.T) *httptest.Server {
|
||||||
// Handle OIDC discovery
|
// Handle OIDC discovery
|
||||||
if r.URL.Path == "/.well-known/openid-configuration" {
|
if r.URL.Path == "/.well-known/openid-configuration" {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"issuer": serverURL,
|
"issuer": serverURL,
|
||||||
"authorization_endpoint": serverURL + "/authorize",
|
"authorization_endpoint": serverURL + "/authorize",
|
||||||
"token_endpoint": serverURL + "/token",
|
"token_endpoint": serverURL + "/token",
|
||||||
|
|
@ -351,7 +351,7 @@ func createMockOIDCServerWithToken(t *testing.T) *httptest.Server {
|
||||||
// Handle OIDC discovery
|
// Handle OIDC discovery
|
||||||
if r.URL.Path == "/.well-known/openid-configuration" {
|
if r.URL.Path == "/.well-known/openid-configuration" {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"issuer": serverURL,
|
"issuer": serverURL,
|
||||||
"authorization_endpoint": serverURL + "/authorize",
|
"authorization_endpoint": serverURL + "/authorize",
|
||||||
"token_endpoint": serverURL + "/token",
|
"token_endpoint": serverURL + "/token",
|
||||||
|
|
@ -376,7 +376,7 @@ func createMockOIDCServerWithToken(t *testing.T) *httptest.Server {
|
||||||
// Create mock ID token (JWT)
|
// Create mock ID token (JWT)
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
idToken := fmt.Sprintf("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.%s.mock-signature",
|
idToken := fmt.Sprintf("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.%s.mock-signature",
|
||||||
base64EncodeClaims(map[string]interface{}{
|
base64EncodeClaims(map[string]any{
|
||||||
"iss": serverURL,
|
"iss": serverURL,
|
||||||
"sub": "test-user",
|
"sub": "test-user",
|
||||||
"aud": "test-client",
|
"aud": "test-client",
|
||||||
|
|
@ -386,7 +386,7 @@ func createMockOIDCServerWithToken(t *testing.T) *httptest.Server {
|
||||||
}))
|
}))
|
||||||
// Return token response
|
// Return token response
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"access_token": "mock-access-token",
|
"access_token": "mock-access-token",
|
||||||
"token_type": "Bearer",
|
"token_type": "Bearer",
|
||||||
"expires_in": 3600,
|
"expires_in": 3600,
|
||||||
|
|
@ -402,7 +402,7 @@ func createMockOIDCServerWithToken(t *testing.T) *httptest.Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
// base64EncodeClaims encodes JWT claims for testing.
|
// base64EncodeClaims encodes JWT claims for testing.
|
||||||
func base64EncodeClaims(claims map[string]interface{}) string {
|
func base64EncodeClaims(claims map[string]any) string {
|
||||||
claimsJSON, _ := json.Marshal(claims)
|
claimsJSON, _ := json.Marshal(claims)
|
||||||
return base64.RawURLEncoding.EncodeToString(claimsJSON)
|
return base64.RawURLEncoding.EncodeToString(claimsJSON)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,7 @@ func main() {
|
||||||
// Run the test.
|
// Run the test.
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for range *workers {
|
for range *workers {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
|
client := mcp.NewClient(&mcp.Implementation{Name: "mcp-client", Version: "v1.0.0"}, nil)
|
||||||
cs, err := client.Connect(parentCtx, &mcp.StreamableClientTransport{Endpoint: args[0]}, nil)
|
cs, err := client.Connect(parentCtx, &mcp.StreamableClientTransport{Endpoint: args[0]}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -108,7 +106,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
stop() // restore the interrupt signal
|
stop() // restore the interrupt signal
|
||||||
|
|
|
||||||
|
|
@ -89,16 +89,14 @@ func parent() {
|
||||||
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", childPortVar, port))
|
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", childPortVar, port))
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
log.Printf("starting child %d at %s", i, childURL)
|
log.Printf("starting child %d at %s", i, childURL)
|
||||||
if err := cmd.Run(); err != nil && ctx.Err() == nil {
|
if err := cmd.Run(); err != nil && ctx.Err() == nil {
|
||||||
log.Printf("child %d failed: %v", i, err)
|
log.Printf("child %d failed: %v", i, err)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("child %d exited gracefully", i)
|
log.Printf("child %d exited gracefully", i)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a reverse proxy that round-robin's requests to each backend.
|
// Start a reverse proxy that round-robin's requests to each backend.
|
||||||
|
|
@ -116,13 +114,11 @@ func parent() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
if err := server.ListenAndServe(); err != nil && ctx.Err() == nil {
|
if err := server.ListenAndServe(); err != nil && ctx.Err() == nil {
|
||||||
log.Printf("Server failed: %v", err)
|
log.Printf("Server failed: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
log.Printf("Serving at %s (CTRL-C to cancel)", *httpAddr)
|
log.Printf("Serving at %s (CTRL-C to cancel)", *httpAddr)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ func (s *FakeAuthorizationServer) handleToken(w http.ResponseWriter, r *http.Req
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
"access_token": "test_access_token",
|
"access_token": "test_access_token",
|
||||||
"token_type": "Bearer",
|
"token_type": "Bearer",
|
||||||
"expires_in": 3600,
|
"expires_in": 3600,
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,7 @@ func TestStdioContextCancellation(t *testing.T) {
|
||||||
func TestCmdTransport(t *testing.T) {
|
func TestCmdTransport(t *testing.T) {
|
||||||
requireExec(t)
|
requireExec(t)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := t.Context()
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
cmd := createServerCommand(t, "default")
|
cmd := createServerCommand(t, "default")
|
||||||
|
|
||||||
|
|
@ -287,8 +286,7 @@ func TestCommandTransportTerminateDuration(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := t.Context()
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// Use a command that won't exit when stdin is closed
|
// Use a command that won't exit when stdin is closed
|
||||||
cmd := exec.Command("sleep", "20")
|
cmd := exec.Command("sleep", "20")
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ func TestContentUnmarshalNil(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
json string
|
json string
|
||||||
content interface{}
|
content any
|
||||||
want interface{}
|
want any
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "CallToolResult nil Content",
|
name: "CallToolResult nil Content",
|
||||||
|
|
@ -83,7 +83,7 @@ func TestContentUnmarshalNilWithDifferentTypes(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
json string
|
json string
|
||||||
content interface{}
|
content any
|
||||||
expectError bool
|
expectError bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +145,7 @@ func TestContentUnmarshalNilWithEmptyContent(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
json string
|
json string
|
||||||
content interface{}
|
content any
|
||||||
expectError bool
|
expectError bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -186,7 +186,7 @@ func TestContentUnmarshalNilWithInvalidContent(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
json string
|
json string
|
||||||
content interface{}
|
content any
|
||||||
expectError bool
|
expectError bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -676,13 +676,11 @@ func TestServerClosing(t *testing.T) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
if err := cs.Wait(); err != nil {
|
if err := cs.Wait(); err != nil {
|
||||||
t.Errorf("server connection failed: %v", err)
|
t.Errorf("server connection failed: %v", err)
|
||||||
}
|
}
|
||||||
wg.Done()
|
})
|
||||||
}()
|
|
||||||
if _, err := cs.CallTool(ctx, &CallToolParams{
|
if _, err := cs.CallTool(ctx, &CallToolParams{
|
||||||
Name: "greet",
|
Name: "greet",
|
||||||
Arguments: map[string]any{"Name": "user"},
|
Arguments: map[string]any{"Name": "user"},
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ func TestAddToolWithSharedCache(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate stateless server pattern: new server per request, shared cache.
|
// Simulate stateless server pattern: new server per request, shared cache.
|
||||||
for i := 0; i < 3; i++ {
|
for range 3 {
|
||||||
s := NewServer(&Implementation{Name: "test", Version: "1.0"}, &ServerOptions{
|
s := NewServer(&Implementation{Name: "test", Version: "1.0"}, &ServerOptions{
|
||||||
SchemaCache: cache,
|
SchemaCache: cache,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
package mcp_test
|
package mcp_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -51,8 +50,7 @@ func BenchmarkStreamableServing(b *testing.B) {
|
||||||
httpServer := httptest.NewServer(handler)
|
httpServer := httptest.NewServer(handler)
|
||||||
defer httpServer.Close()
|
defer httpServer.Close()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := b.Context()
|
||||||
defer cancel()
|
|
||||||
session, err := mcp.NewClient(testImpl, nil).Connect(ctx, &mcp.StreamableClientTransport{Endpoint: httpServer.URL}, nil)
|
session, err := mcp.NewClient(testImpl, nil).Connect(ctx, &mcp.StreamableClientTransport{Endpoint: httpServer.URL}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
|
|
@ -84,8 +82,7 @@ func BenchmarkStreamableServing_BadSessions(b *testing.B) {
|
||||||
httpServer := httptest.NewServer(handler)
|
httpServer := httptest.NewServer(handler)
|
||||||
defer httpServer.Close()
|
defer httpServer.Close()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := b.Context()
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
if *streamableHeap != "" {
|
if *streamableHeap != "" {
|
||||||
writeHeap := func(file string) {
|
writeHeap := func(file string) {
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,7 @@ func TestStreamableTransports(t *testing.T) {
|
||||||
}
|
}
|
||||||
// Now, spin off a goroutine that runs after the sampling request, to
|
// Now, spin off a goroutine that runs after the sampling request, to
|
||||||
// check behavior when the client request has completed.
|
// check behavior when the client request has completed.
|
||||||
sampleWG.Add(1)
|
sampleWG.Go(func() {
|
||||||
go func() {
|
|
||||||
defer sampleWG.Done()
|
|
||||||
<-sampleDone
|
<-sampleDone
|
||||||
// Test that sampling requests in the tool context fail outside of
|
// Test that sampling requests in the tool context fail outside of
|
||||||
// tool handling, but succeed on the background context.
|
// tool handling, but succeed on the background context.
|
||||||
|
|
@ -120,7 +118,7 @@ func TestStreamableTransports(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
testSample(test)
|
testSample(test)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
return &CallToolResult{}, nil, nil
|
return &CallToolResult{}, nil, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -268,9 +266,7 @@ func TestStreamableConcurrentHandling(t *testing.T) {
|
||||||
client := NewClient(testImpl, nil)
|
client := NewClient(testImpl, nil)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for range 100 {
|
for range 100 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
clientSession, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, nil)
|
clientSession, err := client.Connect(ctx, &StreamableClientTransport{Endpoint: httpServer.URL}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Connect failed: %v", err)
|
t.Errorf("Connect failed: %v", err)
|
||||||
|
|
@ -287,7 +283,7 @@ func TestStreamableConcurrentHandling(t *testing.T) {
|
||||||
t.Errorf("got count %d, want %d", got, i)
|
t.Errorf("got count %d, want %d", got, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
@ -1293,9 +1289,7 @@ func testStreamableHandler(t *testing.T, handler http.Handler, requests []stream
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
for m := range out {
|
for m := range out {
|
||||||
if req, ok := m.(*jsonrpc.Request); ok && req.IsCall() {
|
if req, ok := m.(*jsonrpc.Request); ok && req.IsCall() {
|
||||||
|
|
@ -1315,7 +1309,7 @@ func testStreamableHandler(t *testing.T, handler http.Handler, requests []stream
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
gotSessionID, gotStatusCode, gotBody, err := request.do(ctx, httpServer.URL, sessionID.Load().(string), out)
|
gotSessionID, gotStatusCode, gotBody, err := request.do(ctx, httpServer.URL, sessionID.Load().(string), out)
|
||||||
|
|
||||||
|
|
@ -1353,11 +1347,9 @@ func testStreamableHandler(t *testing.T, handler http.Handler, requests []stream
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i, request := range requests {
|
for i, request := range requests {
|
||||||
if request.async || request.onRequest > 0 {
|
if request.async || request.onRequest > 0 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
doStep(t, i, request)
|
doStep(t, i, request)
|
||||||
}()
|
})
|
||||||
} else {
|
} else {
|
||||||
doStep(t, i, request)
|
doStep(t, i, request)
|
||||||
}
|
}
|
||||||
|
|
@ -2071,18 +2063,15 @@ func TestStreamableSessionTimeout(t *testing.T) {
|
||||||
// Spin up two goroutines, each making a request every 10ms. These requests
|
// Spin up two goroutines, each making a request every 10ms. These requests
|
||||||
// should keep the server from timing out.
|
// should keep the server from timing out.
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(2)
|
|
||||||
for range 2 {
|
for range 2 {
|
||||||
go func() {
|
wg.Go(func() {
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
for range 20 {
|
for range 20 {
|
||||||
if _, err := session.ListTools(ctx, nil); err != nil {
|
if _, err := session.ListTools(ctx, nil); err != nil {
|
||||||
t.Errorf("ListTools failed: %v", err)
|
t.Errorf("ListTools failed: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
@ -2154,8 +2143,7 @@ data: keepalive
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a minimal streamableClientConn for testing
|
// Create a minimal streamableClientConn for testing
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := t.Context()
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
incoming := make(chan jsonrpc.Message, 10)
|
incoming := make(chan jsonrpc.Message, 10)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func TestExchangeToken(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return successful token exchange response per SEP-990 Section 4.2
|
// Return successful token exchange response per SEP-990 Section 4.2
|
||||||
resp := map[string]interface{}{
|
resp := map[string]any{
|
||||||
"issued_token_type": TokenTypeIDJAG,
|
"issued_token_type": TokenTypeIDJAG,
|
||||||
"access_token": "fake-id-jag-token",
|
"access_token": "fake-id-jag-token",
|
||||||
"token_type": "N_A",
|
"token_type": "N_A",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue