mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Add agent authentication based on instance ID (#336)
* 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
This commit is contained in:
@@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
|
||||
func TestCli(t *testing.T) {
|
||||
t.Parallel()
|
||||
clitest.CreateProjectVersionSource(t, nil)
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
cmd, config := clitest.New(t)
|
||||
clitest.SetupConfig(t, client, config)
|
||||
pty := ptytest.New(t)
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ func TestLogin(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("InitialUserNoTTY", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
root, _ := clitest.New(t, "login", client.URL.String())
|
||||
err := root.Execute()
|
||||
require.Error(t, err)
|
||||
@@ -24,7 +24,7 @@ func TestLogin(t *testing.T) {
|
||||
|
||||
t.Run("InitialUserTTY", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
// The --force-tty flag is required on Windows, because the `isatty` library does not
|
||||
// accurately detect Windows ptys when they are not attached to a process:
|
||||
// https://github.com/mattn/go-isatty/issues/59
|
||||
@@ -55,7 +55,7 @@ func TestLogin(t *testing.T) {
|
||||
|
||||
t.Run("ExistingUserValidTokenTTY", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
_, err := client.CreateInitialUser(context.Background(), coderd.CreateInitialUserRequest{
|
||||
Username: "test-user",
|
||||
Email: "test-user@coder.com",
|
||||
@@ -85,7 +85,7 @@ func TestLogin(t *testing.T) {
|
||||
|
||||
t.Run("ExistingUserInvalidTokenTTY", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
_, err := client.CreateInitialUser(context.Background(), coderd.CreateInitialUserRequest{
|
||||
Username: "test-user",
|
||||
Email: "test-user@coder.com",
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestProjectCreate(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("NoParameters", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
coderdtest.CreateInitialUser(t, client)
|
||||
source := clitest.CreateProjectVersionSource(t, &echo.Responses{
|
||||
Parse: echo.ParseComplete,
|
||||
@@ -53,7 +53,7 @@ func TestProjectCreate(t *testing.T) {
|
||||
|
||||
t.Run("Parameter", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
coderdtest.CreateInitialUser(t, client)
|
||||
source := clitest.CreateProjectVersionSource(t, &echo.Responses{
|
||||
Parse: []*proto.Parse_Response{{
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestProjectList(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("None", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
coderdtest.CreateInitialUser(t, client)
|
||||
cmd, root := clitest.New(t, "projects", "list")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
@@ -32,7 +32,7 @@ func TestProjectList(t *testing.T) {
|
||||
})
|
||||
t.Run("List", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
user := coderdtest.CreateInitialUser(t, client)
|
||||
daemon := coderdtest.NewProvisionerDaemon(t, client)
|
||||
job := coderdtest.CreateProjectImportJob(t, client, user.Organization, nil)
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestWorkspaceCreate(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Create", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t)
|
||||
client := coderdtest.New(t, nil)
|
||||
user := coderdtest.CreateInitialUser(t, client)
|
||||
_ = coderdtest.NewProvisionerDaemon(t, client)
|
||||
job := coderdtest.CreateProjectImportJob(t, client, user.Organization, &echo.Responses{
|
||||
|
||||
Reference in New Issue
Block a user