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

Function setupWorkspaceAgent

enterprise/coderd/workspaceagents_test.go:274–345  ·  view source on GitHub ↗
(t *testing.T, client *codersdk.Client, user codersdk.CreateFirstUserResponse, appPort uint16)

Source from the content-addressed store, hash-verified

272}
273
274func setupWorkspaceAgent(t *testing.T, client *codersdk.Client, user codersdk.CreateFirstUserResponse, appPort uint16) setupResp {
275 authToken := uuid.NewString()
276 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
277 Parse: echo.ParseComplete,
278 ProvisionGraph: []*proto.Response{{
279 Type: &proto.Response_Graph{
280 Graph: &proto.GraphComplete{
281 Resources: []*proto.Resource{{
282 Name: "example",
283 Type: "aws_instance",
284 Agents: []*proto.Agent{{
285 Id: uuid.NewString(),
286 Name: "example",
287 Auth: &proto.Agent_Token{
288 Token: authToken,
289 },
290 Apps: []*proto.App{
291 {
292 Slug: testAppNameOwner,
293 DisplayName: testAppNameOwner,
294 SharingLevel: proto.AppSharingLevel_OWNER,
295 Url: fmt.Sprintf("http://localhost:%d", appPort),
296 },
297 {
298 Slug: testAppNameAuthenticated,
299 DisplayName: testAppNameAuthenticated,
300 SharingLevel: proto.AppSharingLevel_AUTHENTICATED,
301 Url: fmt.Sprintf("http://localhost:%d", appPort),
302 },
303 {
304 Slug: testAppNamePublic,
305 DisplayName: testAppNamePublic,
306 SharingLevel: proto.AppSharingLevel_PUBLIC,
307 Url: fmt.Sprintf("http://localhost:%d", appPort),
308 },
309 },
310 }},
311 }},
312 },
313 },
314 }},
315 })
316 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
317 template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
318 workspace := coderdtest.CreateWorkspace(t, client, template.ID)
319 coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
320 agentClient := agentsdk.New(client.URL, agentsdk.WithFixedToken(authToken))
321 agentClient.SDK.HTTPClient = &http.Client{
322 Transport: &http.Transport{
323 TLSClientConfig: &tls.Config{
324 //nolint:gosec
325 InsecureSkipVerify: true,
326 },
327 },
328 }
329 agnt := agent.New(agent.Options{
330 Client: agentClient,
331 Logger: testutil.Logger(t).Named("agent"),

Callers 5

TestBlockNonBrowserFunction · 0.85
TestAuditLoggingFunction · 0.85
TestReplicasFunction · 0.85

Calls 14

CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
NewFunction · 0.92
WithFixedTokenFunction · 0.92
NewFunction · 0.92
LoggerFunction · 0.92
AwaitWorkspaceAgentsFunction · 0.92
NamedMethod · 0.80
WorkspaceAgentMethod · 0.80

Tested by

no test coverage detected