@@ -17,34 +17,25 @@ const mockActivityId = '507f1f77bcf86cd799439011';
1717mockRequire . stopAll ( ) ;
1818
1919mockRequire ( '~/server/middlewares/access-token-parser' , {
20- accessTokenParser :
21- ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) =>
22- next ( ) ,
20+ accessTokenParser : ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) => next ( ) ,
2321} ) ;
2422
25- mockRequire (
26- '../../../middlewares/login-required' ,
27- ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) => next ( ) ,
28- ) ;
29- mockRequire (
30- '../../../middlewares/admin-required' ,
31- ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) => next ( ) ,
32- ) ;
23+ mockRequire ( '../../../middlewares/login-required' , ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) => next ( ) ) ;
24+ mockRequire ( '../../../middlewares/admin-required' , ( ) => ( _req : Request , _res : ApiV3Response , next : ( ) => void ) => next ( ) ) ;
3325
3426mockRequire ( '../../../middlewares/add-activity' , {
35- generateAddActivityMiddleware :
36- ( ) => ( _req : Request , res : ApiV3Response , next : ( ) => void ) => {
37- res . locals = res . locals || { } ;
38- res . locals . activity = { _id : mockActivityId } ;
39- next ( ) ;
40- } ,
27+ generateAddActivityMiddleware : ( ) => ( _req : Request , res : ApiV3Response , next : ( ) => void ) => {
28+ res . locals = res . locals || { } ;
29+ res . locals . activity = { _id : mockActivityId } ;
30+ next ( ) ;
31+ } ,
4132} ) ;
4233
4334describe ( 'file-upload-setting route' , ( ) => {
4435 let app : express . Application ;
4536 let crowiMock : Crowi ;
4637
47- beforeEach ( async ( ) => {
38+ beforeEach ( async ( ) => {
4839 // Initialize configManager for each test
4940 const s2sMessagingServiceMock = mock < S2sMessagingService > ( ) ;
5041 configManager . setS2sMessagingService ( s2sMessagingServiceMock ) ;
@@ -68,16 +59,14 @@ describe('file-upload-setting route', () => {
6859 // Mock apiv3 response methods
6960 app . use ( ( _req , res , next ) => {
7061 const apiRes = res as ApiV3Response ;
71- apiRes . apiv3 = ( data ) => res . json ( data ) ;
72- apiRes . apiv3Err = ( error , statusCode = 500 ) =>
73- res . status ( statusCode ) . json ( { error } ) ;
62+ apiRes . apiv3 = data => res . json ( data ) ;
63+ apiRes . apiv3Err = ( error , statusCode = 500 ) => res . status ( statusCode ) . json ( { error } ) ;
7464 next ( ) ;
7565 } ) ;
7666
7767 // Import and mount the actual router using dynamic import
7868 const fileUploadSettingModule = await import ( './file-upload-setting' ) ;
79- const fileUploadSettingRouterFactory =
80- ( fileUploadSettingModule as any ) . default || fileUploadSettingModule ;
69+ const fileUploadSettingRouterFactory = ( fileUploadSettingModule as any ) . default || fileUploadSettingModule ;
8170 const fileUploadSettingRouter = fileUploadSettingRouterFactory ( crowiMock ) ;
8271 app . use ( '/' , fileUploadSettingRouter ) ;
8372 } ) ;
@@ -86,7 +75,7 @@ describe('file-upload-setting route', () => {
8675 mockRequire . stopAll ( ) ;
8776 } ) ;
8877
89- it ( 'should update file upload type to local' , async ( ) => {
78+ it ( 'should update file upload type to local' , async ( ) => {
9079 const response = await request ( app )
9180 . put ( '/' )
9281 . send ( {
@@ -100,7 +89,7 @@ describe('file-upload-setting route', () => {
10089 } ) ;
10190
10291 describe ( 'AWS settings' , ( ) => {
103- const setupAwsSecret = async ( secret : string ) => {
92+ const setupAwsSecret = async ( secret : string ) => {
10493 await configManager . updateConfigs ( {
10594 'app:fileUploadType' : 'aws' ,
10695 'aws:s3SecretAccessKey' : toNonBlankString ( secret ) ,
@@ -110,13 +99,11 @@ describe('file-upload-setting route', () => {
11099 await configManager . loadConfigs ( ) ;
111100 } ;
112101
113- it ( 'should preserve existing s3SecretAccessKey when not included in request' , async ( ) => {
102+ it ( 'should preserve existing s3SecretAccessKey when not included in request' , async ( ) => {
114103 const existingSecret = 'existing-secret-key-12345' ;
115104 await setupAwsSecret ( existingSecret ) ;
116105
117- expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe (
118- existingSecret ,
119- ) ;
106+ expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe ( existingSecret ) ;
120107
121108 const response = await request ( app )
122109 . put ( '/' )
@@ -130,19 +117,15 @@ describe('file-upload-setting route', () => {
130117
131118 await configManager . loadConfigs ( ) ;
132119
133- expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe (
134- existingSecret ,
135- ) ;
120+ expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe ( existingSecret ) ;
136121 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'aws' ) ;
137122 } ) ;
138123
139- it ( 'should update s3SecretAccessKey when new value is provided in request' , async ( ) => {
124+ it ( 'should update s3SecretAccessKey when new value is provided in request' , async ( ) => {
140125 const existingSecret = 'existing-secret-key-12345' ;
141126 await setupAwsSecret ( existingSecret ) ;
142127
143- expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe (
144- existingSecret ,
145- ) ;
128+ expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe ( existingSecret ) ;
146129
147130 const newSecret = 'new-secret-key-67890' ;
148131 const response = await request ( app )
@@ -162,13 +145,11 @@ describe('file-upload-setting route', () => {
162145 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'aws' ) ;
163146 } ) ;
164147
165- it ( 'should remove s3SecretAccessKey when empty string is provided in request' , async ( ) => {
148+ it ( 'should remove s3SecretAccessKey when empty string is provided in request' , async ( ) => {
166149 const existingSecret = 'existing-secret-key-12345' ;
167150 await setupAwsSecret ( existingSecret ) ;
168151
169- expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe (
170- existingSecret ,
171- ) ;
152+ expect ( configManager . getConfig ( 'aws:s3SecretAccessKey' ) ) . toBe ( existingSecret ) ;
172153
173154 const response = await request ( app )
174155 . put ( '/' )
@@ -189,7 +170,7 @@ describe('file-upload-setting route', () => {
189170 } ) ;
190171
191172 describe ( 'GCS settings' , ( ) => {
192- const setupGcsSecret = async ( apiKeyPath : string ) => {
173+ const setupGcsSecret = async ( apiKeyPath : string ) => {
193174 await configManager . updateConfigs ( {
194175 'app:fileUploadType' : 'gcs' ,
195176 'gcs:apiKeyJsonPath' : toNonBlankString ( apiKeyPath ) ,
@@ -198,13 +179,11 @@ describe('file-upload-setting route', () => {
198179 await configManager . loadConfigs ( ) ;
199180 } ;
200181
201- it ( 'should preserve existing gcsApiKeyJsonPath when not included in request' , async ( ) => {
182+ it ( 'should preserve existing gcsApiKeyJsonPath when not included in request' , async ( ) => {
202183 const existingApiKeyPath = '/path/to/existing-api-key.json' ;
203184 await setupGcsSecret ( existingApiKeyPath ) ;
204185
205- expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe (
206- existingApiKeyPath ,
207- ) ;
186+ expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe ( existingApiKeyPath ) ;
208187
209188 const response = await request ( app )
210189 . put ( '/' )
@@ -217,19 +196,15 @@ describe('file-upload-setting route', () => {
217196
218197 await configManager . loadConfigs ( ) ;
219198
220- expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe (
221- existingApiKeyPath ,
222- ) ;
199+ expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe ( existingApiKeyPath ) ;
223200 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'gcs' ) ;
224201 } ) ;
225202
226- it ( 'should update gcsApiKeyJsonPath when new value is provided in request' , async ( ) => {
203+ it ( 'should update gcsApiKeyJsonPath when new value is provided in request' , async ( ) => {
227204 const existingApiKeyPath = '/path/to/existing-api-key.json' ;
228205 await setupGcsSecret ( existingApiKeyPath ) ;
229206
230- expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe (
231- existingApiKeyPath ,
232- ) ;
207+ expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe ( existingApiKeyPath ) ;
233208
234209 const newApiKeyPath = '/path/to/new-api-key.json' ;
235210 const response = await request ( app )
@@ -248,13 +223,11 @@ describe('file-upload-setting route', () => {
248223 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'gcs' ) ;
249224 } ) ;
250225
251- it ( 'should remove gcsApiKeyJsonPath when empty string is provided in request' , async ( ) => {
226+ it ( 'should remove gcsApiKeyJsonPath when empty string is provided in request' , async ( ) => {
252227 const existingApiKeyPath = '/path/to/existing-api-key.json' ;
253228 await setupGcsSecret ( existingApiKeyPath ) ;
254229
255- expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe (
256- existingApiKeyPath ,
257- ) ;
230+ expect ( configManager . getConfig ( 'gcs:apiKeyJsonPath' ) ) . toBe ( existingApiKeyPath ) ;
258231
259232 const response = await request ( app )
260233 . put ( '/' )
@@ -274,7 +247,7 @@ describe('file-upload-setting route', () => {
274247 } ) ;
275248
276249 describe ( 'Azure settings' , ( ) => {
277- const setupAzureSecret = async ( secret : string ) => {
250+ const setupAzureSecret = async ( secret : string ) => {
278251 await configManager . updateConfigs ( {
279252 'app:fileUploadType' : 'azure' ,
280253 'azure:clientSecret' : toNonBlankString ( secret ) ,
@@ -286,13 +259,11 @@ describe('file-upload-setting route', () => {
286259 await configManager . loadConfigs ( ) ;
287260 } ;
288261
289- it ( 'should preserve existing azureClientSecret when not included in request' , async ( ) => {
262+ it ( 'should preserve existing azureClientSecret when not included in request' , async ( ) => {
290263 const existingSecret = 'existing-azure-secret-12345' ;
291264 await setupAzureSecret ( existingSecret ) ;
292265
293- expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe (
294- existingSecret ,
295- ) ;
266+ expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe ( existingSecret ) ;
296267
297268 const response = await request ( app )
298269 . put ( '/' )
@@ -308,19 +279,15 @@ describe('file-upload-setting route', () => {
308279
309280 await configManager . loadConfigs ( ) ;
310281
311- expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe (
312- existingSecret ,
313- ) ;
282+ expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe ( existingSecret ) ;
314283 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'azure' ) ;
315284 } ) ;
316285
317- it ( 'should update azureClientSecret when new value is provided in request' , async ( ) => {
286+ it ( 'should update azureClientSecret when new value is provided in request' , async ( ) => {
318287 const existingSecret = 'existing-azure-secret-12345' ;
319288 await setupAzureSecret ( existingSecret ) ;
320289
321- expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe (
322- existingSecret ,
323- ) ;
290+ expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe ( existingSecret ) ;
324291
325292 const newSecret = 'new-azure-secret-67890' ;
326293 const response = await request ( app )
@@ -342,13 +309,11 @@ describe('file-upload-setting route', () => {
342309 expect ( response . body . responseParams . fileUploadType ) . toBe ( 'azure' ) ;
343310 } ) ;
344311
345- it ( 'should remove azureClientSecret when empty string is provided in request' , async ( ) => {
312+ it ( 'should remove azureClientSecret when empty string is provided in request' , async ( ) => {
346313 const existingSecret = 'existing-azure-secret-12345' ;
347314 await setupAzureSecret ( existingSecret ) ;
348315
349- expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe (
350- existingSecret ,
351- ) ;
316+ expect ( configManager . getConfig ( 'azure:clientSecret' ) ) . toBe ( existingSecret ) ;
352317
353318 const response = await request ( app )
354319 . put ( '/' )
0 commit comments