@@ -146,13 +146,15 @@ describe('AttachmentsController (e2e)', () => {
146146 expect ( response . headers [ 'content-disposition' ] ) . toContain ( testFilename ) ;
147147 } ) ;
148148
149- it ( 'should reject download without authentication' , async ( ) => {
150- await client
149+ it ( 'should redirect to login when no authentication provided ' , async ( ) => {
150+ const response = await client
151151 . request ( )
152152 . get (
153153 `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ attachmentId } ` ,
154154 )
155- . expect ( 401 ) ;
155+ . expect ( 302 ) ;
156+
157+ expect ( response . headers . location ) . toContain ( '/user/login' ) ;
156158 } ) ;
157159
158160 it ( 'should reject download with invalid attachment ID' , async ( ) => {
@@ -257,7 +259,7 @@ describe('AttachmentsController (e2e)', () => {
257259 } ) ;
258260 } ) ;
259261
260- describe ( 'GET /api/v1/namespaces/:namespaceId/resources/:resourceId/attachments/:attachmentId/images (Public)' , ( ) => {
262+ describe ( 'GET /api/v1/namespaces/:namespaceId/resources/:resourceId/attachments/:attachmentId (Public)' , ( ) => {
261263 let imageAttachmentId : string ;
262264 const imageContent = Buffer . from ( 'fake-image-content' ) ;
263265 const imageFilename = 'test-image.png' ;
@@ -278,7 +280,7 @@ describe('AttachmentsController (e2e)', () => {
278280 const response = await client
279281 . request ( )
280282 . get (
281- `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ imageAttachmentId } /images ` ,
283+ `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ imageAttachmentId } ` ,
282284 )
283285 . expect ( HttpStatus . FOUND ) ;
284286
@@ -290,7 +292,7 @@ describe('AttachmentsController (e2e)', () => {
290292 const response = await client
291293 . request ( )
292294 . get (
293- `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ imageAttachmentId } /images ` ,
295+ `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ imageAttachmentId } ` ,
294296 )
295297 . set ( 'Cookie' , `token=${ client . user . token } ` )
296298 . expect ( 200 ) ;
@@ -299,7 +301,7 @@ describe('AttachmentsController (e2e)', () => {
299301 } ) ;
300302 } ) ;
301303
302- describe ( 'GET /api/v1/namespaces/:namespaceId/resources/:resourceId/attachments/:attachmentId/media (Public)' , ( ) => {
304+ describe ( 'GET /api/v1/namespaces/:namespaceId/resources/:resourceId/attachments/:attachmentId (Public)' , ( ) => {
303305 let mediaAttachmentId : string ;
304306 const mediaContent = Buffer . from ( 'fake-media-content' ) ;
305307 const mediaFilename = 'test-media.mp3' ;
@@ -320,7 +322,7 @@ describe('AttachmentsController (e2e)', () => {
320322 const response = await client
321323 . request ( )
322324 . get (
323- `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ mediaAttachmentId } /media ` ,
325+ `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ mediaAttachmentId } ` ,
324326 )
325327 . expect ( HttpStatus . FOUND ) ;
326328
@@ -332,7 +334,7 @@ describe('AttachmentsController (e2e)', () => {
332334 const response = await client
333335 . request ( )
334336 . get (
335- `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ mediaAttachmentId } /media ` ,
337+ `/api/v1/namespaces/${ client . namespace . id } /resources/${ testResourceId } /attachments/${ mediaAttachmentId } ` ,
336338 )
337339 . set ( 'Cookie' , `token=${ client . user . token } ` )
338340 . expect ( 200 ) ;
0 commit comments