mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
* feat: Add agent authentication based on instance ID Each cloud has it's own unique instance identity signatures, which can be used for zero-token authentication. This change adds support for tracking by "instance_id", and automatically authenticating with Google Cloud. * Add test for CLI * Fix workspace agent request name * Fix race with adding to wait group * Fix name of instance identity token
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/cli/clitest"
|
|
"github.com/coder/coder/coderd/coderdtest"
|
|
"github.com/coder/coder/provisioner/echo"
|
|
"github.com/coder/coder/provisionersdk/proto"
|
|
"github.com/coder/coder/pty/ptytest"
|
|
)
|
|
|
|
func TestWorkspaceCreate(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("Create", func(t *testing.T) {
|
|
t.Parallel()
|
|
client := coderdtest.New(t, nil)
|
|
user := coderdtest.CreateInitialUser(t, client)
|
|
_ = coderdtest.NewProvisionerDaemon(t, client)
|
|
job := coderdtest.CreateProjectImportJob(t, client, user.Organization, &echo.Responses{
|
|
Parse: echo.ParseComplete,
|
|
Provision: []*proto.Provision_Response{{
|
|
Type: &proto.Provision_Response_Complete{
|
|
Complete: &proto.Provision_Complete{
|
|
Resources: []*proto.Resource{{
|
|
Name: "example",
|
|
Type: "aws_instance",
|
|
}},
|
|
},
|
|
},
|
|
}},
|
|
})
|
|
coderdtest.AwaitProjectImportJob(t, client, user.Organization, job.ID)
|
|
project := coderdtest.CreateProject(t, client, user.Organization, job.ID)
|
|
cmd, root := clitest.New(t, "workspaces", "create", project.Name)
|
|
clitest.SetupConfig(t, client, root)
|
|
|
|
pty := ptytest.New(t)
|
|
cmd.SetIn(pty.Input())
|
|
cmd.SetOut(pty.Output())
|
|
closeChan := make(chan struct{})
|
|
go func() {
|
|
err := cmd.Execute()
|
|
require.NoError(t, err)
|
|
close(closeChan)
|
|
}()
|
|
|
|
matches := []string{
|
|
"name?", "workspace-name",
|
|
"Create workspace", "y",
|
|
}
|
|
for i := 0; i < len(matches); i += 2 {
|
|
match := matches[i]
|
|
value := matches[i+1]
|
|
pty.ExpectMatch(match)
|
|
pty.WriteLine(value)
|
|
}
|
|
pty.ExpectMatch("Create")
|
|
<-closeChan
|
|
})
|
|
}
|