(t *testing.T)
| 37 | ) |
| 38 | |
| 39 | func Test_ResolveRequest(t *testing.T) { |
| 40 | t.Parallel() |
| 41 | |
| 42 | const ( |
| 43 | agentName = "agent" |
| 44 | appNameOwner = "app-owner" |
| 45 | appNameAuthed = "app-authed" |
| 46 | appNamePublic = "app-public" |
| 47 | appNameInvalidURL = "app-invalid-url" |
| 48 | // Users can access unhealthy and initializing apps (as of 2024-02). |
| 49 | appNameUnhealthy = "app-unhealthy" |
| 50 | appNameInitializing = "app-initializing" |
| 51 | appNameEndsInS = "app-ends-in-s" |
| 52 | |
| 53 | // This agent will never connect, so it will never become "connected". |
| 54 | // Users cannot access unhealthy agents. |
| 55 | agentNameUnhealthy = "agent-unhealthy" |
| 56 | appNameAgentUnhealthy = "app-agent-unhealthy" |
| 57 | |
| 58 | // This is not a valid URL we listen on in the test, but it needs to be |
| 59 | // set to a value. |
| 60 | appURL = "http://localhost:8080" |
| 61 | ) |
| 62 | allApps := []string{appNameOwner, appNameAuthed, appNamePublic} |
| 63 | |
| 64 | // Start a listener for a server that always responds with 500 for the |
| 65 | // unhealthy app. |
| 66 | unhealthySrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 67 | w.WriteHeader(http.StatusInternalServerError) |
| 68 | _, _ = w.Write([]byte("unhealthy")) |
| 69 | })) |
| 70 | t.Cleanup(unhealthySrv.Close) |
| 71 | |
| 72 | // Start a listener for a server that never responds. |
| 73 | initializingServer, err := net.Listen("tcp", "localhost:0") |
| 74 | require.NoError(t, err) |
| 75 | t.Cleanup(func() { |
| 76 | _ = initializingServer.Close() |
| 77 | }) |
| 78 | initializingURL := fmt.Sprintf("http://%s", initializingServer.Addr().String()) |
| 79 | |
| 80 | deploymentValues := coderdtest.DeploymentValues(t) |
| 81 | deploymentValues.DisablePathApps = false |
| 82 | deploymentValues.Dangerous.AllowPathAppSharing = true |
| 83 | deploymentValues.Dangerous.AllowPathAppSiteOwnerAccess = true |
| 84 | |
| 85 | connLogger := connectionlog.NewFake() |
| 86 | t.Cleanup(func() { |
| 87 | if t.Failed() { |
| 88 | return |
| 89 | } |
| 90 | assert.Len(t, connLogger.ConnectionLogs(), 0, "one or more test cases produced unexpected connection logs, did you replace the auditor or forget to call ResetLogs?") |
| 91 | }) |
| 92 | client, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{ |
| 93 | AppHostname: "*.test.coder.com", |
| 94 | DeploymentValues: deploymentValues, |
| 95 | IncludeProvisionerDaemon: true, |
| 96 | AgentStatsRefreshInterval: time.Millisecond * 100, |
nothing calls this directly
no test coverage detected