@@ -17,7 +17,7 @@ describe('Pin add ', () => {
1717 /** @type {DBTestClient } */
1818 let client
1919
20- before ( async ( ) => {
20+ beforeEach ( async ( ) => {
2121 client = await createClientWithUser ( )
2222 } )
2323
@@ -229,4 +229,31 @@ describe('Pin add ', () => {
229229 assert . strictEqual ( pin . meta . invalid , undefined )
230230 assert . strictEqual ( pin . meta . valid , 'string' )
231231 } )
232+
233+ it ( 'should restrict requests to quota' , async ( ) => {
234+ const cids = [
235+ 'bafkreidyeivj7adnnac6ljvzj2e3rd5xdw3revw4da7mx2ckrstapoupoq' ,
236+ 'bafybeih74zqc6kamjpruyra4e4pblnwdpickrvk4hvturisbtveghflovq' ,
237+ ]
238+
239+ await Promise . all (
240+ cids . map ( async ( cid ) => {
241+ const res = await fetch ( 'pins' , {
242+ method : 'POST' ,
243+ headers : { Authorization : `Bearer ${ client . token } ` } ,
244+ body : JSON . stringify ( { cid } ) ,
245+ } )
246+ assert . strictEqual ( res . status , 200 )
247+ } )
248+ )
249+
250+ const extraQuotaCid =
251+ 'bafkreihbjbbccwxn7hzv5hun5pxuswide7q3lhjvfbvmd7r3kf2sodybgi'
252+ const res = await fetch ( 'pins' , {
253+ method : 'POST' ,
254+ headers : { Authorization : `Bearer ${ client . token } ` } ,
255+ body : JSON . stringify ( { cid : extraQuotaCid } ) ,
256+ } )
257+ assert . strictEqual ( res . status , 429 )
258+ } )
232259} )
0 commit comments