Skip to content

Commit 647be9c

Browse files
committed
changes from review
Simplify code, remove tests and move related packages Related-to: #3867
1 parent 27e8d57 commit 647be9c

10 files changed

Lines changed: 747 additions & 914 deletions

pkg/vmcp/server/session_management_v2_integration_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package server_test
66
import (
77
"bytes"
88
"context"
9-
"encoding/hex"
109
"encoding/json"
1110
"errors"
1211
"io"
@@ -29,7 +28,6 @@ import (
2928
"github.com/stacklok/toolhive/pkg/vmcp/router"
3029
"github.com/stacklok/toolhive/pkg/vmcp/server"
3130
vmcpsession "github.com/stacklok/toolhive/pkg/vmcp/session"
32-
"github.com/stacklok/toolhive/pkg/vmcp/session/security"
3331
)
3432

3533
// ---------------------------------------------------------------------------
@@ -113,19 +111,6 @@ func (f *v2FakeMultiSessionFactory) MakeSession(
113111
return nil, f.err
114112
}
115113
baseSession := transportsession.NewStreamableSession("auto-id")
116-
117-
// Populate token hash metadata to match real session factory behavior.
118-
allowAnonymous := vmcpsession.ShouldAllowAnonymous(identity)
119-
if identity != nil && identity.Token != "" && !allowAnonymous {
120-
testSecret := []byte("integration-test-secret")
121-
testSalt := []byte("test-salt-123456")
122-
tokenHash := security.HashToken(identity.Token, testSecret, testSalt)
123-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenHash, tokenHash)
124-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenSalt, hex.EncodeToString(testSalt))
125-
} else {
126-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenHash, "")
127-
}
128-
129114
sess := newV2FakeMultiSession(baseSession, f.tools)
130115
f.lastCreatedSession = sess
131116
return sess, nil
@@ -139,21 +124,6 @@ func (f *v2FakeMultiSessionFactory) MakeSessionWithID(
139124
return nil, f.err
140125
}
141126
baseSession := transportsession.NewStreamableSession(id)
142-
143-
// Populate token hash metadata to match real session factory behavior.
144-
// This allows integration tests to verify that hashes (not raw tokens) are stored.
145-
if identity != nil && identity.Token != "" && !allowAnonymous {
146-
// Use a test HMAC secret and salt for integration tests
147-
testSecret := []byte("integration-test-secret")
148-
testSalt := []byte("test-salt-123456") // 16 bytes
149-
tokenHash := security.HashToken(identity.Token, testSecret, testSalt)
150-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenHash, tokenHash)
151-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenSalt, hex.EncodeToString(testSalt))
152-
} else {
153-
// Anonymous session
154-
baseSession.SetMetadata(vmcpsession.MetadataKeyTokenHash, "")
155-
}
156-
157127
sess := newV2FakeMultiSession(baseSession, f.tools)
158128
f.lastCreatedSession = sess
159129
return sess, nil

pkg/vmcp/server/sessionmanager/session_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (sm *Manager) CreateSession(
165165
// Build the fully-formed MultiSession using the SDK-assigned session ID.
166166
// Sessions created with an identity are bound to that identity (allowAnonymous=false).
167167
// Sessions created without an identity allow anonymous access (allowAnonymous=true).
168-
allowAnonymous := vmcpsession.ShouldAllowAnonymous(identity)
168+
allowAnonymous := identity == nil || identity.Token == ""
169169
sess, err := sm.factory.MakeSessionWithID(ctx, sessionID, identity, allowAnonymous, backends)
170170
if err != nil {
171171
return nil, fmt.Errorf("Manager.CreateSession: failed to create multi-session: %w", err)

0 commit comments

Comments
 (0)