MCPcopy Create free account
hub / github.com/coder/aibridge / TestSessionIDTracking

Function TestSessionIDTracking

internal/integrationtest/bridge_test.go:832–917  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

830}
831
832func TestSessionIDTracking(t *testing.T) {
833 t.Parallel()
834
835 testCases := []struct {
836 name string
837 fixture []byte
838 header http.Header
839 metadataSessionID string
840 expectedClient aibridge.Client
841 expectSessionID string
842 }{
843 // Session in header.
844 {
845 name: "mux",
846 fixture: fixtures.AntSimple,
847 expectedClient: aibridge.ClientMux,
848 expectSessionID: "mux-workspace-321",
849 header: http.Header{
850 "User-Agent": []string{"mux/1.0.0"},
851 "X-Mux-Workspace-Id": []string{"mux-workspace-321"},
852 },
853 },
854 // Session in body.
855 {
856 name: "claude_code",
857 fixture: fixtures.AntSimple,
858 expectedClient: aibridge.ClientClaudeCode,
859 expectSessionID: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
860 header: http.Header{
861 "User-Agent": []string{"claude-cli/2.0.67 (external, cli)"},
862 },
863 metadataSessionID: "user_abc123_account_456_session_f47ac10b-58cc-4372-a567-0e02b2c3d479",
864 },
865 // No session.
866 {
867 name: "zed",
868 fixture: fixtures.AntSimple,
869 expectedClient: aibridge.ClientZed,
870 header: http.Header{
871 "User-Agent": []string{"Zed/0.219.4+stable.119.abc123 (macos; aarch64)"},
872 },
873 },
874 }
875
876 for _, tc := range testCases {
877 t.Run(tc.name, func(t *testing.T) {
878 t.Parallel()
879
880 ctx, cancel := context.WithTimeout(t.Context(), testutil.WaitLong)
881 t.Cleanup(cancel)
882
883 fix := fixtures.Parse(t, tc.fixture)
884 upstream := newMockUpstream(ctx, t, newFixtureResponse(fix))
885 bridgeServer := newBridgeTestServer(ctx, t, upstream.URL, withProvider(config.ProviderAnthropic))
886
887 reqBody := fix.Request()
888 if tc.metadataSessionID != "" {
889 var err error

Callers

nothing calls this directly

Calls 10

ParseFunction · 0.92
newMockUpstreamFunction · 0.85
newFixtureResponseFunction · 0.85
newBridgeTestServerFunction · 0.85
withProviderFunction · 0.85
RequestMethod · 0.80
makeRequestMethod · 0.80
RecordedInterceptionsMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected