@@ -274,23 +274,153 @@ func Test_containsMatchingBlockListEntry(t *testing.T) {
274274 wantErr bool
275275 }{
276276 {
277- name : "matching entry found" ,
277+ name : "matching entry found blocked outside cool down period 1 " ,
278278 args : args {
279279 blocklist : & []osdAdmin.Blocklist {
280280 {
281281 Addr : "192.0.1.0:0/32" ,
282- Until : time .Now ().Format (ISO8601TimeLayout ),
282+ Until : time .Now ().Add ( 1 * time . Hour ). Format (ISO8601TimeLayout ),
283283 },
284284 {
285285 Addr : "192.0.2.0:0/32" ,
286- Until : time .Now ().Format (ISO8601TimeLayout ),
286+ Until : time .Now ().Add (1 * time .Hour ).Format (ISO8601TimeLayout ),
287+ },
288+ },
289+ addr : "192.0.1.0" ,
290+ },
291+ want : true ,
292+ wantErr : false ,
293+ },
294+ {
295+ name : "matching entry found blocked outside cool down period 2" ,
296+ args : args {
297+ blocklist : & []osdAdmin.Blocklist {
298+ {
299+ Addr : "192.0.1.0:0/32" ,
300+ Until : time .Now ().Add (util .AutoBlocklistTime - blockListCoolDownPeriod ).Format (ISO8601TimeLayout ),
301+ },
302+ {
303+ Addr : "192.0.2.0:0/32" ,
304+ Until : time .Now ().Add (util .AutoBlocklistTime - blockListCoolDownPeriod ).Format (ISO8601TimeLayout ),
287305 },
288306 },
289307 addr : "192.0.1.0" ,
290308 },
291309 want : true ,
292310 wantErr : false ,
293311 },
312+ {
313+ name : "matching entry found blocked in cool down period 1" ,
314+ args : args {
315+ blocklist : & []osdAdmin.Blocklist {
316+ {
317+ Addr : "192.0.1.0:0/32" ,
318+ Until : time .Now ().Add (util .AutoBlocklistTime ).Format (ISO8601TimeLayout ),
319+ },
320+ {
321+ Addr : "192.0.2.0:0/32" ,
322+ Until : time .Now ().Add (util .AutoBlocklistTime ).Format (ISO8601TimeLayout ),
323+ },
324+ },
325+ addr : "192.0.1.0" ,
326+ },
327+ want : false ,
328+ wantErr : true ,
329+ },
330+ {
331+ name : "matching entry found blocked in cool down period 2" ,
332+ args : args {
333+ blocklist : & []osdAdmin.Blocklist {
334+ {
335+ Addr : "192.0.1.0:0/32" ,
336+ Until : time .Now ().Add (util .AutoBlocklistTime - 2 * time .Minute ).
337+ Format (ISO8601TimeLayout ),
338+ },
339+ {
340+ Addr : "192.0.2.0:0/32" ,
341+ Until : time .Now ().Add (util .AutoBlocklistTime - 2 * time .Minute ).
342+ Format (ISO8601TimeLayout ),
343+ },
344+ },
345+ addr : "192.0.1.0" ,
346+ },
347+ want : false ,
348+ wantErr : true ,
349+ },
350+ {
351+ name : "matching IPv6 entry found blocked outside cool down period 1" ,
352+ args : args {
353+ blocklist : & []osdAdmin.Blocklist {
354+ {
355+ Addr : "2001:db8::1:0/128" ,
356+ Until : time .Now ().Add (1 * time .Hour ).Format (ISO8601TimeLayout ),
357+ },
358+ {
359+ Addr : "2001:db8::2:0/128" ,
360+ Until : time .Now ().Add (1 * time .Hour ).Format (ISO8601TimeLayout ),
361+ },
362+ },
363+ addr : "2001:db8::1" ,
364+ },
365+ want : true ,
366+ wantErr : false ,
367+ },
368+ {
369+ name : "matching IPv6 entry found blocked outside cool down period 2" ,
370+ args : args {
371+ blocklist : & []osdAdmin.Blocklist {
372+ {
373+ Addr : "2001:db8::1:0/128" ,
374+ Until : time .Now ().Add (util .AutoBlocklistTime - blockListCoolDownPeriod ).Format (ISO8601TimeLayout ),
375+ },
376+ {
377+ Addr : "2001:db8::2:0/128" ,
378+ Until : time .Now ().Add (util .AutoBlocklistTime - blockListCoolDownPeriod ).Format (ISO8601TimeLayout ),
379+ },
380+ },
381+ addr : "2001:db8::1" ,
382+ },
383+ want : true ,
384+ wantErr : false ,
385+ },
386+ {
387+ name : "matching IPv6 entry found blocked in cool down period 1" ,
388+ args : args {
389+ blocklist : & []osdAdmin.Blocklist {
390+ {
391+ Addr : "2001:db8::1:0/128" ,
392+ Until : time .Now ().Add (util .AutoBlocklistTime ).Format (ISO8601TimeLayout ),
393+ },
394+ {
395+ Addr : "2001:db8::2:0/128" ,
396+ Until : time .Now ().Add (util .AutoBlocklistTime ).Format (ISO8601TimeLayout ),
397+ },
398+ },
399+ addr : "2001:db8::1" ,
400+ },
401+ want : false ,
402+ wantErr : true ,
403+ },
404+ {
405+ name : "matching IPv6 entry found blocked in cool down period 2" ,
406+ args : args {
407+ blocklist : & []osdAdmin.Blocklist {
408+ {
409+ Addr : "2001:db8::1:0/128" ,
410+ Until : time .Now ().Add (util .AutoBlocklistTime - 2 * time .Minute ).
411+ Format (ISO8601TimeLayout ),
412+ },
413+ {
414+ Addr : "2001:db8::2:0/128" ,
415+ Until : time .Now ().Add (util .AutoBlocklistTime - 2 * time .Minute ).
416+ Format (ISO8601TimeLayout ),
417+ },
418+ },
419+ addr : "2001:db8::1" ,
420+ },
421+ want : false ,
422+ wantErr : true ,
423+ },
294424 {
295425 name : "address does not match" ,
296426 args : args {
0 commit comments