MCPcopy Index your code
hub / github.com/coder/coder / TestExternalAuthRequestQuery

Function TestExternalAuthRequestQuery

codersdk/agentsdk/agentsdk_test.go:158–188  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestExternalAuthRequestQuery(t *testing.T) {
159 t.Parallel()
160
161 t.Run("IncludesGitRefFieldsAndOmitsWorkdir", func(t *testing.T) {
162 t.Parallel()
163
164 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
165 require.Equal(t, "/api/v2/workspaceagents/me/external-auth", r.URL.Path)
166 require.Equal(t, "true", r.URL.Query().Get("listen"))
167 require.Equal(t, "main", r.URL.Query().Get("git_branch"))
168 require.Equal(t, "https://github.com/coder/coder.git", r.URL.Query().Get("git_remote_origin"))
169 require.Equal(t, "test-chat-id", r.URL.Query().Get("chat_id"))
170 require.False(t, r.URL.Query().Has("workdir"))
171 _, _ = w.Write([]byte(`{"type":"github","access_token":"token"}`))
172 }))
173 defer srv.Close()
174
175 parsedURL, err := url.Parse(srv.URL)
176 require.NoError(t, err)
177
178 client := agentsdk.New(parsedURL, agentsdk.WithFixedToken("token"))
179 _, err = client.ExternalAuth(testutil.Context(t, testutil.WaitShort), agentsdk.ExternalAuthRequest{
180 Match: "github.com",
181 Listen: true,
182 GitBranch: "main",
183 GitRemoteOrigin: "https://github.com/coder/coder.git",
184 ChatID: "test-chat-id",
185 })
186 require.NoError(t, err)
187 })
188}

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
NewFunction · 0.92
WithFixedTokenFunction · 0.92
ContextFunction · 0.92
ExternalAuthMethod · 0.80
RunMethod · 0.65
GetMethod · 0.65
WriteMethod · 0.65
ParseMethod · 0.65
EqualMethod · 0.45
HasMethod · 0.45

Tested by

no test coverage detected