Skip to content

Commit

Permalink
Fix Auth emulator export only exporting 20 users. (#3311)
Browse files Browse the repository at this point in the history
* Fix Auth emulator export only exporting 20 users.

Fixes b/186445689

* Rename the variable limit to maxResults.
  • Loading branch information
yuchenshi authored Apr 27, 2021
1 parent fcfc72c commit b818b51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/emulator/auth/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,17 @@ function batchGet(
reqBody: unknown,
ctx: ExegesisContext
): Schemas["GoogleCloudIdentitytoolkitV1DownloadAccountResponse"] {
const limit = Math.min(Math.floor(ctx.params.query.maxResults) || 20, 1000);
const maxResults = Math.min(Math.floor(ctx.params.query.maxResults) || 20, 1000);

const users = state.queryUsers(
{},
{ sortByField: "localId", order: "ASC", startToken: ctx.params.query.nextPageToken }
);
let newPageToken: string | undefined = undefined;

// As a non-standard behavior, passing in limit=-1 will return all users.
if (limit >= 0 && users.length >= limit) {
users.length = limit;
// As a non-standard behavior, passing in maxResults=-1 will return all users.
if (maxResults >= 0 && users.length >= maxResults) {
users.length = maxResults;
if (users.length) {
newPageToken = users[users.length - 1].localId;
}
Expand Down
2 changes: 1 addition & 1 deletion src/emulator/hubExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class HubExport {
{
host,
port,
path: `/identitytoolkit.googleapis.com/v1/projects/${this.projectId}/accounts:batchGet?limit=-1`,
path: `/identitytoolkit.googleapis.com/v1/projects/${this.projectId}/accounts:batchGet?maxResults=-1`,
headers: { Authorization: "Bearer owner" },
},
accountsFile
Expand Down

0 comments on commit b818b51

Please sign in to comment.