@@ -21,6 +21,8 @@ import { IAMClient, IAMClientInternal, internalEndpoint } from './iamClient'
2121
2222const tenantId = 'test-tenant-id'
2323
24+ process . env . TZ = 'UTC'
25+
2426suite ( 'IAM Internal Client' , ( ) => {
2527 const client = IAMClientInternal ( '' , '' )
2628 let agent : MockAgent
@@ -74,12 +76,32 @@ suite('IAM Internal Client', () => {
7476 query : {
7577 per_page : '200' ,
7678 page : '0' ,
77- from : '0000000000000000' ,
78- to : '9999999999999999' ,
79+ from : '1710154800000' ,
80+ to : '1710156600000' ,
81+ } ,
82+ } ) . reply ( 200 , mockedResult )
83+
84+ const result = await client . companyAuditLogs ( tenantId , '1710154800000' , '1710156600000' )
85+ t . assert . deepStrictEqual ( result , mockedResult )
86+ } )
87+
88+ test ( 'list company audit logs with dates as a filter' , async ( t : TestContext ) => {
89+ const mockedResult = [
90+ { id : 'identity1' , type : 'user' , name : 'User 1' } ,
91+ ]
92+
93+ agent . get ( internalEndpoint ) . intercept ( {
94+ path : `/tenants/${ tenantId } /audit-logs` ,
95+ method : 'GET' ,
96+ query : {
97+ per_page : '200' ,
98+ page : '0' ,
99+ from : '1710154800000' ,
100+ to : '1710156600000' ,
79101 } ,
80102 } ) . reply ( 200 , mockedResult )
81103
82- const result = await client . companyAuditLogs ( tenantId , '0000000000000000 ' , '9999999999999999 ' )
104+ const result = await client . companyAuditLogs ( tenantId , '2024-03-11T11:00:00 ' , '2024-03-11T11:30:00 ' )
83105 t . assert . deepStrictEqual ( result , mockedResult )
84106 } )
85107
@@ -127,7 +149,27 @@ suite('IAM Client', () => {
127149 t . assert . deepStrictEqual ( result , mockedResult )
128150 } )
129151
130- test ( 'list company audit logs' , async ( t : TestContext ) => {
152+ test ( 'list company audit logs with unix timestamps as a filter' , async ( t : TestContext ) => {
153+ const mockedResult = [
154+ { id : 'identity1' , type : 'user' , name : 'User 1' } ,
155+ ]
156+
157+ agent . get ( mockedEndpoint ) . intercept ( {
158+ path : `/api/tenants/${ tenantId } /audit-logs` ,
159+ method : 'GET' ,
160+ query : {
161+ per_page : '200' ,
162+ page : '0' ,
163+ from : '1710154800000' ,
164+ to : '1710156600000' ,
165+ } ,
166+ } ) . reply ( 200 , mockedResult )
167+
168+ const result = await client . companyAuditLogs ( tenantId , '1710154800000' , '1710156600000' )
169+ t . assert . deepStrictEqual ( result , mockedResult )
170+ } )
171+
172+ test ( 'list company audit logs with dates as a filter' , async ( t : TestContext ) => {
131173 const mockedResult = [
132174 { id : 'identity1' , type : 'user' , name : 'User 1' } ,
133175 ]
@@ -138,12 +180,12 @@ suite('IAM Client', () => {
138180 query : {
139181 per_page : '200' ,
140182 page : '0' ,
141- from : '0000000000000000 ' ,
142- to : '9999999999999999 ' ,
183+ from : '1710154800000 ' ,
184+ to : '1710156600000 ' ,
143185 } ,
144186 } ) . reply ( 200 , mockedResult )
145187
146- const result = await client . companyAuditLogs ( tenantId , '0000000000000000 ' , '9999999999999999 ' )
188+ const result = await client . companyAuditLogs ( tenantId , '2024-03-11T11:00:00 ' , '2024-03-11T11:30:00 ' )
147189 t . assert . deepStrictEqual ( result , mockedResult )
148190 } )
149191} )
0 commit comments