Fix address not returning on 10001+ list value (#3644)

Fixes ICU-10786
pull/3647/head
Jeff Mitchell 3 years ago committed by GitHub
parent 2774fbb8d4
commit be8e9fc61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

@ -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)
}
@ -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)
}

@ -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())
}
}

Loading…
Cancel
Save