Skip to content

Commit 4ee51be

Browse files
authored
Added search users by createdTime and modifiedTime (#441)
1 parent 4880691 commit 4ee51be

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

lib/management/user.test.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ describe('Management User', () => {
811811
});
812812
});
813813

814-
describe('search', () => {
814+
describe('searchTestUsers', () => {
815815
it('should send the correct request and receive correct response', async () => {
816816
const httpResponse = {
817817
ok: true,
@@ -822,7 +822,64 @@ describe('Management User', () => {
822822
status: 200,
823823
};
824824
mockHttpClient.post.mockResolvedValue(httpResponse);
825+
const now = new Date().getTime();
826+
const resp: SdkResponse<UserResponse[]> = await management.user.searchTestUsers({
827+
tenantIds: ['t1'],
828+
roles: ['r1'],
829+
limit: 100,
830+
statuses: ['enabled'],
831+
emails: ['[email protected]'],
832+
phones: ['+11111111'],
833+
text: 'some text',
834+
fromCreatedTime: now,
835+
toCreatedTime: now,
836+
fromModifiedTime: now,
837+
toModifiedTime: now,
838+
sort: [{ field: 'aa', desc: true }, { field: 'bb' }],
839+
});
840+
841+
expect(mockHttpClient.post).toHaveBeenCalledWith(
842+
apiPaths.user.searchTestUsers,
843+
{
844+
tenantIds: ['t1'],
845+
roleNames: ['r1'],
846+
limit: 100,
847+
statuses: ['enabled'],
848+
emails: ['[email protected]'],
849+
phones: ['+11111111'],
850+
text: 'some text',
851+
fromCreatedTime: now,
852+
toCreatedTime: now,
853+
fromModifiedTime: now,
854+
toModifiedTime: now,
855+
withTestUser: true,
856+
testUsersOnly: true,
857+
sort: [{ field: 'aa', desc: true }, { field: 'bb' }],
858+
},
859+
{ token: 'key' },
860+
);
861+
862+
expect(resp).toEqual({
863+
code: 200,
864+
data: [mockUserResponse],
865+
ok: true,
866+
response: httpResponse,
867+
});
868+
});
869+
});
825870

871+
describe('search', () => {
872+
it('should send the correct request and receive correct response', async () => {
873+
const httpResponse = {
874+
ok: true,
875+
json: () => mockMgmtUsersResponse,
876+
clone: () => ({
877+
json: () => Promise.resolve(mockMgmtUsersResponse),
878+
}),
879+
status: 200,
880+
};
881+
mockHttpClient.post.mockResolvedValue(httpResponse);
882+
const now = new Date().getTime();
826883
const resp: SdkResponse<UserResponse[]> = await management.user.search({
827884
tenantIds: ['t1'],
828885
roles: ['r1'],
@@ -831,6 +888,10 @@ describe('Management User', () => {
831888
emails: ['[email protected]'],
832889
phones: ['+11111111'],
833890
text: 'some text',
891+
fromCreatedTime: now,
892+
toCreatedTime: now,
893+
fromModifiedTime: now,
894+
toModifiedTime: now,
834895
sort: [{ field: 'aa', desc: true }, { field: 'bb' }],
835896
});
836897

@@ -844,6 +905,10 @@ describe('Management User', () => {
844905
emails: ['[email protected]'],
845906
phones: ['+11111111'],
846907
text: 'some text',
908+
fromCreatedTime: now,
909+
toCreatedTime: now,
910+
fromModifiedTime: now,
911+
toModifiedTime: now,
847912
sort: [{ field: 'aa', desc: true }, { field: 'bb' }],
848913
},
849914
{ token: 'key' },

lib/management/user.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ type SearchRequest = {
4343
testUsersOnly?: boolean;
4444
ssoAppIds?: string[];
4545
loginIds?: string[];
46+
fromCreatedTime?: number; // Search users created after this time (epoch in milliseconds)
47+
toCreatedTime?: number; // Search users created before this time (epoch in milliseconds)
48+
fromModifiedTime?: number; // Search users modified after this time (epoch in milliseconds)
49+
toModifiedTime?: number; // Search users modified before this time (epoch in milliseconds)
4650
};
4751

4852
type SingleUserResponse = {

0 commit comments

Comments
 (0)