(t *testing.T)
| 667 | } |
| 668 | |
| 669 | func TestIssueSignedAppToken(t *testing.T) { |
| 670 | t.Parallel() |
| 671 | |
| 672 | connectionLogger := connectionlog.NewFake() |
| 673 | |
| 674 | client, user := coderdenttest.New(t, &coderdenttest.Options{ |
| 675 | ConnectionLogging: true, |
| 676 | Options: &coderdtest.Options{ |
| 677 | IncludeProvisionerDaemon: true, |
| 678 | ConnectionLogger: connectionLogger, |
| 679 | }, |
| 680 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 681 | Features: license.Features{ |
| 682 | codersdk.FeatureWorkspaceProxy: 1, |
| 683 | codersdk.FeatureConnectionLog: 1, |
| 684 | }, |
| 685 | }, |
| 686 | }) |
| 687 | |
| 688 | // Create a workspace + apps |
| 689 | authToken := uuid.NewString() |
| 690 | version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
| 691 | Parse: echo.ParseComplete, |
| 692 | ProvisionGraph: echo.ProvisionGraphWithAgent(authToken), |
| 693 | }) |
| 694 | template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) |
| 695 | coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) |
| 696 | workspace := coderdtest.CreateWorkspace(t, client, template.ID) |
| 697 | build := coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) |
| 698 | workspace.LatestBuild = build |
| 699 | |
| 700 | // Connect an agent to the workspace |
| 701 | _ = agenttest.New(t, client.URL, authToken) |
| 702 | _ = coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) |
| 703 | |
| 704 | createProxyCtx := testutil.Context(t, testutil.WaitLong) |
| 705 | proxyRes, err := client.CreateWorkspaceProxy(createProxyCtx, codersdk.CreateWorkspaceProxyRequest{ |
| 706 | Name: testutil.GetRandomName(t), |
| 707 | Icon: "/emojis/flag.png", |
| 708 | }) |
| 709 | require.NoError(t, err) |
| 710 | |
| 711 | t.Run("BadAppRequest", func(t *testing.T) { |
| 712 | t.Parallel() |
| 713 | proxyClient := wsproxysdk.New(client.URL, proxyRes.ProxyToken) |
| 714 | |
| 715 | ctx := testutil.Context(t, testutil.WaitLong) |
| 716 | _, err := proxyClient.IssueSignedAppToken(ctx, workspaceapps.IssueTokenRequest{ |
| 717 | // Invalid request. |
| 718 | AppRequest: workspaceapps.Request{}, |
| 719 | SessionToken: client.SessionToken(), |
| 720 | }, "127.0.0.1") |
| 721 | require.Error(t, err) |
| 722 | }) |
| 723 | |
| 724 | goodRequest := workspaceapps.IssueTokenRequest{ |
| 725 | AppRequest: workspaceapps.Request{ |
| 726 | BasePath: "/app", |
nothing calls this directly
no test coverage detected