Skip to content
Open
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
3 changes: 3 additions & 0 deletions lib/management/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ export interface UserOptions {
familyName?: string;
additionalLoginIds?: string[];
ssoAppIds?: string[];
password?: string;
hashedPassword?: UserPasswordHashed;
seed?: string;
}

export type MgmtUserOptions = Omit<
Expand Down
55 changes: 55 additions & 0 deletions lib/management/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,61 @@ describe('Management User', () => {
response: httpResponse,
});
});

it('should send password and hashed password with options argument', async () => {
const httpResponse = {
ok: true,
json: () => mockMgmtUserResponse,
clone: () => ({
json: () => Promise.resolve(mockMgmtUserResponse),
}),
status: 200,
};
mockHttpClient.post.mockResolvedValue(httpResponse);

const hashed: UserPasswordHashed = {
firebase: {
hash: 'h',
salt: 's',
saltSeparator: 'ss',
signerKey: 'sk',
memory: 14,
rounds: 8,
},
};

const resp: SdkResponse<UserResponse> = await management.user.create('loginId', {
email: 'a@b.c',
password: 'cleartext',
hashedPassword: hashed,
seed: 'totp-seed',
});

expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.user.create, {
loginId: 'loginId',
email: 'a@b.c',
password: 'cleartext',
hashedPassword: {
firebase: {
hash: 'h',
salt: 's',
saltSeparator: 'ss',
signerKey: 'sk',
memory: 14,
rounds: 8,
},
},
seed: 'totp-seed',
roleNames: undefined,
});

expect(resp).toEqual({
code: 200,
data: mockUserResponse,
ok: true,
response: httpResponse,
});
});
});

describe('createTestUser', () => {
Expand Down
Loading