Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(server): validate ipv6 address for upsert worker status #5079

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions internal/server/repository_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,72 @@ func TestUpsertWorkerStatus(t *testing.T) {
require.NoError(t, err)
assert.Len(t, workers, 2)
})

t.Run("ipv4 address", func(t *testing.T) {
status := server.NewWorker(scope.Global.String(),
server.WithName("worker-with-ipv4-address"),
server.WithAddress("8.8.8.8"),
server.WithReleaseVersion("Boundary v0.11.0"))
_, err = repo.UpsertWorkerStatus(ctx, status)
require.NoError(t, err)

workers, err := repo.ListWorkers(ctx, []string{scope.Global.String()})
require.NoError(t, err)
require.NotEmpty(t, workers)
var actualWorker *server.Worker
for _, w := range workers {
if w.Name == "worker-with-ipv4-address" {
actualWorker = w
break
}
}
require.NotNil(t, actualWorker)
assert.Equal(t, actualWorker.Address, "8.8.8.8")
})

t.Run("ipv6 address", func(t *testing.T) {
status := server.NewWorker(scope.Global.String(),
server.WithName("worker-with-ipv6-address"),
server.WithAddress("2001:4860:4860:0:0:0:0:8888"),
server.WithReleaseVersion("Boundary v0.11.0"))
_, err = repo.UpsertWorkerStatus(ctx, status)
require.NoError(t, err)

workers, err := repo.ListWorkers(ctx, []string{scope.Global.String()})
require.NoError(t, err)
require.NotEmpty(t, workers)
var actualWorker *server.Worker
for _, w := range workers {
if w.Name == "worker-with-ipv6-address" {
actualWorker = w
break
}
}
require.NotNil(t, actualWorker)
assert.Equal(t, actualWorker.Address, "2001:4860:4860:0:0:0:0:8888")
})

t.Run("ipv6 abbreviated address", func(t *testing.T) {
status := server.NewWorker(scope.Global.String(),
server.WithName("worker-with-abbreviated-ipv6-address"),
server.WithAddress("2001:4860:4860::8888"),
server.WithReleaseVersion("Boundary v0.11.0"))
_, err = repo.UpsertWorkerStatus(ctx, status)
require.NoError(t, err)

workers, err := repo.ListWorkers(ctx, []string{scope.Global.String()})
require.NoError(t, err)
require.NotEmpty(t, workers)
var actualWorker *server.Worker
for _, w := range workers {
if w.Name == "worker-with-abbreviated-ipv6-address" {
actualWorker = w
break
}
}
require.NotNil(t, actualWorker)
assert.Equal(t, actualWorker.Address, "2001:4860:4860::8888")
})
}

func TestTagUpdatingListing(t *testing.T) {
Expand Down
Loading