@@ -105,25 +105,50 @@ func newV2FakeFactory(tools []vmcp.Tool) *v2FakeMultiSessionFactory {
105105}
106106
107107func (f * v2FakeMultiSessionFactory ) MakeSession (
108- _ context.Context , _ * auth.Identity , _ []* vmcp.Backend ,
108+ _ context.Context , identity * auth.Identity , _ []* vmcp.Backend ,
109109) (vmcpsession.MultiSession , error ) {
110110 if f .err != nil {
111111 return nil , f .err
112112 }
113113 baseSession := transportsession .NewStreamableSession ("auto-id" )
114+
115+ // Set basic metadata to indicate whether this is an anonymous session.
116+ // Integration tests don't need to verify crypto implementation details.
117+ allowAnonymous := vmcpsession .ShouldAllowAnonymous (identity )
118+ if ! allowAnonymous {
119+ // Authenticated session - set non-empty hash placeholder
120+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenHash , "fake-hash-for-testing" )
121+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenSalt , "fake-salt-for-testing" )
122+ } else {
123+ // Anonymous session - set empty hash
124+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenHash , "" )
125+ }
126+
114127 sess := newV2FakeMultiSession (baseSession , f .tools )
115128 f .lastCreatedSession = sess
116129 return sess , nil
117130}
118131
119132func (f * v2FakeMultiSessionFactory ) MakeSessionWithID (
120- _ context.Context , id string , _ * auth.Identity , _ bool , _ []* vmcp.Backend ,
133+ _ context.Context , id string , identity * auth.Identity , allowAnonymous bool , _ []* vmcp.Backend ,
121134) (vmcpsession.MultiSession , error ) {
122135 f .makeWithIDCalled .Store (true )
123136 if f .err != nil {
124137 return nil , f .err
125138 }
126139 baseSession := transportsession .NewStreamableSession (id )
140+
141+ // Set basic metadata to indicate whether this is an anonymous session.
142+ // Integration tests don't need to verify crypto implementation details.
143+ if identity != nil && identity .Token != "" && ! allowAnonymous {
144+ // Authenticated session - set non-empty hash placeholder
145+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenHash , "fake-hash-for-testing" )
146+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenSalt , "fake-salt-for-testing" )
147+ } else {
148+ // Anonymous session - set empty hash
149+ baseSession .SetMetadata (vmcpsession .MetadataKeyTokenHash , "" )
150+ }
151+
127152 sess := newV2FakeMultiSession (baseSession , f .tools )
128153 f .lastCreatedSession = sess
129154 return sess , nil
0 commit comments