@@ -275,6 +275,64 @@ func (s *Suite) TestRateLimitThenNoRateLimit() {
275
275
}
276
276
}
277
277
278
+ func (s * Suite ) TestRateLimitWhiteList () {
279
+ getNodegroupFunc = func () (string , error ) {
280
+ return "the_nodegroup" , nil
281
+ }
282
+
283
+ // Intervals between events.
284
+ durations := []time.Duration {
285
+ time .Minute ,
286
+ time .Minute ,
287
+ time .Minute ,
288
+ time .Minute ,
289
+ time .Minute ,
290
+ time .Minute ,
291
+ time .Minute ,
292
+ time .Minute ,
293
+ time .Minute ,
294
+ }
295
+
296
+ // Make event times
297
+ eventTime := time .Now ()
298
+ times := []time.Time {eventTime }
299
+ for _ , d := range durations {
300
+ eventTime = eventTime .Add (d )
301
+ times = append (times , eventTime )
302
+ }
303
+
304
+ // Make events
305
+ description := EventDescription {Details : map [string ]interface {}{"file" : "abc" }, Type : "CorruptFile" }
306
+ for _ , t := range times {
307
+ event := Event {
308
+ Timestamp : t ,
309
+ Description : description ,
310
+ }
311
+ s .NoError (s .store .Add (& event ))
312
+ }
313
+
314
+ // Test GetKeys
315
+ keys , err := s .store .GetKeys ()
316
+ s .NoError (err , "error returned when getting all keys" )
317
+ // Check 10 events + 1 rate limit event
318
+ s .Equal (len (durations )+ 1 , len (keys ), "error with number of keys returned" )
319
+
320
+ // Check that there was a rate limit event
321
+ rateLimitEvent := false
322
+ for _ , key := range keys {
323
+ eventBytes , err := s .store .Get (key )
324
+ s .NoError (err )
325
+ event := & Event {}
326
+ s .NoError (json .Unmarshal (eventBytes , event ))
327
+ if event .Description .Type == "rateLimit" {
328
+ rateLimitEvent = true
329
+ }
330
+ }
331
+ if rateLimitEvent {
332
+ s .Fail ("Rate limit event found" )
333
+ }
334
+ }
335
+
278
336
func TestRun (t * testing.T ) {
279
337
suite .Run (t , new (Suite ))
280
338
}
0 commit comments