@@ -265,14 +265,14 @@ describe('AccessControlConfigSchema', () => {
265265 expect ( config . publicAccess ?. allowPublicWrite ) . toBe ( false ) ;
266266 } ) ;
267267
268- it ( 'should accept IP whitelist/blacklist ' , ( ) => {
268+ it ( 'should accept IP allow/block lists ' , ( ) => {
269269 const config = AccessControlConfigSchema . parse ( {
270- ipWhitelist : [ '192.168.1.0/24' , '10.0.0.1' ] ,
271- ipBlacklist : [ '1.2.3.4' ] ,
270+ allowedIps : [ '192.168.1.0/24' , '10.0.0.1' ] ,
271+ blockedIps : [ '1.2.3.4' ] ,
272272 } ) ;
273273
274- expect ( config . ipWhitelist ) . toHaveLength ( 2 ) ;
275- expect ( config . ipBlacklist ) . toHaveLength ( 1 ) ;
274+ expect ( config . allowedIps ) . toHaveLength ( 2 ) ;
275+ expect ( config . blockedIps ) . toHaveLength ( 1 ) ;
276276 } ) ;
277277} ) ;
278278
@@ -342,6 +342,53 @@ describe('LifecyclePolicyRuleSchema', () => {
342342 daysAfterCreation : 30 ,
343343 } ) ) . toThrow ( ) ;
344344 } ) ;
345+
346+ it ( 'should require targetStorageClass when action is transition' , ( ) => {
347+ expect ( ( ) => LifecyclePolicyRuleSchema . parse ( {
348+ id : 'move_to_glacier' ,
349+ enabled : true ,
350+ action : 'transition' ,
351+ daysAfterCreation : 30 ,
352+ // missing targetStorageClass
353+ } ) ) . toThrow ( ) ;
354+
355+ // Verify the specific error message
356+ try {
357+ LifecyclePolicyRuleSchema . parse ( {
358+ id : 'move_to_glacier' ,
359+ enabled : true ,
360+ action : 'transition' ,
361+ daysAfterCreation : 30 ,
362+ } ) ;
363+ } catch ( error : any ) {
364+ expect ( error . issues [ 0 ] . message ) . toContain ( 'targetStorageClass is required' ) ;
365+ }
366+ } ) ;
367+
368+ it ( 'should accept transition rule with targetStorageClass' , ( ) => {
369+ const rule = LifecyclePolicyRuleSchema . parse ( {
370+ id : 'move_to_glacier' ,
371+ enabled : true ,
372+ action : 'transition' ,
373+ daysAfterCreation : 30 ,
374+ targetStorageClass : 'glacier' ,
375+ } ) ;
376+
377+ expect ( rule . action ) . toBe ( 'transition' ) ;
378+ expect ( rule . targetStorageClass ) . toBe ( 'glacier' ) ;
379+ } ) ;
380+
381+ it ( 'should allow delete action without targetStorageClass' , ( ) => {
382+ const rule = LifecyclePolicyRuleSchema . parse ( {
383+ id : 'delete_old' ,
384+ enabled : true ,
385+ action : 'delete' ,
386+ daysAfterCreation : 365 ,
387+ } ) ;
388+
389+ expect ( rule . action ) . toBe ( 'delete' ) ;
390+ expect ( rule . targetStorageClass ) . toBeUndefined ( ) ;
391+ } ) ;
345392} ) ;
346393
347394describe ( 'LifecyclePolicyConfigSchema' , ( ) => {
0 commit comments