(t *testing.T)
| 780 | } |
| 781 | |
| 782 | func TestReconnectingPTYSignedToken(t *testing.T) { |
| 783 | t.Parallel() |
| 784 | |
| 785 | connectionLogger := connectionlog.NewFake() |
| 786 | |
| 787 | db, pubsub := dbtestutil.NewDB(t) |
| 788 | client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{ |
| 789 | ConnectionLogging: true, |
| 790 | Options: &coderdtest.Options{ |
| 791 | Database: db, |
| 792 | Pubsub: pubsub, |
| 793 | IncludeProvisionerDaemon: true, |
| 794 | ConnectionLogger: connectionLogger, |
| 795 | }, |
| 796 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 797 | Features: license.Features{ |
| 798 | codersdk.FeatureWorkspaceProxy: 1, |
| 799 | codersdk.FeatureConnectionLog: 1, |
| 800 | }, |
| 801 | }, |
| 802 | }) |
| 803 | t.Cleanup(func() { |
| 804 | closer.Close() |
| 805 | }) |
| 806 | |
| 807 | _ = dbgen.CryptoKey(t, db, database.CryptoKey{ |
| 808 | Feature: database.CryptoKeyFeatureWorkspaceAppsToken, |
| 809 | }) |
| 810 | |
| 811 | // Create a workspace + apps |
| 812 | authToken := uuid.NewString() |
| 813 | version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
| 814 | Parse: echo.ParseComplete, |
| 815 | ProvisionGraph: echo.ProvisionGraphWithAgent(authToken), |
| 816 | }) |
| 817 | template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) |
| 818 | coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) |
| 819 | workspace := coderdtest.CreateWorkspace(t, client, template.ID) |
| 820 | build := coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) |
| 821 | workspace.LatestBuild = build |
| 822 | |
| 823 | // Connect an agent to the workspace |
| 824 | agentID := build.Resources[0].Agents[0].ID |
| 825 | _ = agenttest.New(t, client.URL, authToken) |
| 826 | _ = coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) |
| 827 | |
| 828 | proxyURL, err := url.Parse(fmt.Sprintf("https://%s.com", testutil.GetRandomName(t))) |
| 829 | require.NoError(t, err) |
| 830 | |
| 831 | _ = coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ |
| 832 | Name: testutil.GetRandomName(t), |
| 833 | ProxyURL: proxyURL, |
| 834 | AppHostname: "*.sub.example.com", |
| 835 | }) |
| 836 | |
| 837 | u, err := url.Parse(proxyURL.String()) |
| 838 | require.NoError(t, err) |
| 839 | if u.Scheme == "https" { |
nothing calls this directly
no test coverage detected