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

Fix address not returning on 10001+ list value #3644

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.

### Bug Fixes

* LDAP auth methods: allow bind-dn and bind-password to be updated independently. ([PR](https://github.com/hashicorp/boundary/pull/3511))
* LDAP auth methods: allow bind-dn and bind-password to be updated
independently. ([PR](https://github.com/hashicorp/boundary/pull/3511))
* targets: Fix address field not being populated if the number of targets on a
list returns more than 10000 entries
([PR](https://github.com/hashicorp/boundary/pull/3644))

## 0.13.1 (2023/07/10)

Expand Down
15 changes: 12 additions & 3 deletions internal/target/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,12 @@ func (r *Repository) ListTargets(ctx context.Context, opt ...Option) ([]Target,
}

var foundTargets []*targetView
err := r.reader.SearchWhere(ctx, &foundTargets, strings.Join(where, " or "), args,
db.WithLimit(limit))
err := r.reader.SearchWhere(ctx,
&foundTargets,
strings.Join(where, " or "),
args,
db.WithLimit(limit),
)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
Expand All @@ -263,7 +267,12 @@ func (r *Repository) ListTargets(ctx context.Context, opt ...Option) ([]Target,

addresses := map[string]string{}
var foundAddresses []*Address
err = r.reader.SearchWhere(ctx, &foundAddresses, "target_id in (?)", []any{targetIds})
err = r.reader.SearchWhere(ctx,
&foundAddresses,
"target_id in (?)",
[]any{targetIds},
db.WithLimit(limit),
)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
Expand Down
39 changes: 39 additions & 0 deletions internal/target/tcp/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,42 @@ func TestRepository_DeleteTarget(t *testing.T) {
})
}
}

func TestRepository_ListRoles_Above_Default_Count(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
testKms := kms.TestKms(t, conn, wrapper)
iamRepo := iam.TestRepo(t, conn, wrapper)

_, proj := iam.TestScopes(t, iamRepo)

numToCreate := db.DefaultLimit + 5
var total int
for i := 0; i < numToCreate; i++ {
tcp.TestTarget(ctx, t, conn, proj.GetPublicId(), fmt.Sprintf("proj1-%d", i), target.WithAddress("1.2.3.4"))
total++
}
require.Equal(t, numToCreate, total)

rw := db.New(conn)
repo, err := target.NewRepository(ctx, rw, rw, testKms,
target.WithPermissions([]perms.Permission{
{
ScopeId: proj.PublicId,
Resource: resource.Target,
Action: action.List,
All: true,
},
}))
require.NoError(t, err)

got, err := repo.ListTargets(ctx, target.WithLimit(-1))
require.NoError(t, err)
assert.Equal(t, total, len(got))

for _, tar := range got {
assert.Equal(t, "1.2.3.4", tar.GetAddress())
}
}