@@ -223,89 +223,6 @@ func TestWfCache_AllowDomainCacheError(t *testing.T) {
223
223
logger .AssertExpectations (t )
224
224
}
225
225
226
- // TestWfCache_CacheExternalDisabled tests that the cache will allow requests only for the requests where it is enabled
227
- func TestWfCache_CacheExternalDisabled (t * testing.T ) {
228
- ctrl := gomock .NewController (t )
229
-
230
- domainCache := cache .NewMockDomainCache (ctrl )
231
- domainCache .EXPECT ().GetDomainName (testDomainID ).Return (testDomainName , nil ).Times (2 )
232
-
233
- // Setup the mock logger
234
- logger := new (log.MockLogger )
235
- expectRatelimitLog (logger , "internal" , "enabled" )
236
-
237
- externalLimiterFactory := quotas .NewMockLimiterFactory (ctrl )
238
- externalLimiter := quotas .NewMockLimiter (ctrl )
239
- externalLimiterFactory .EXPECT ().GetLimiter (testDomainName ).Return (externalLimiter ).Times (1 )
240
-
241
- internalLimiter := quotas .NewMockLimiter (ctrl )
242
- internalLimiterFactory := quotas .NewMockLimiterFactory (ctrl )
243
- internalLimiterFactory .EXPECT ().GetLimiter (testDomainName ).Return (internalLimiter ).Times (1 )
244
-
245
- internalLimiter .EXPECT ().Allow ().Return (false ).Times (1 )
246
-
247
- wfCache := New (Params {
248
- TTL : time .Minute ,
249
- MaxCount : 1_000 ,
250
- ExternalLimiterFactory : externalLimiterFactory ,
251
- InternalLimiterFactory : internalLimiterFactory ,
252
- Logger : logger ,
253
- DomainCache : domainCache ,
254
- MetricsClient : metrics .NewNoopMetricsClient (),
255
- RatelimitExternalPerWorkflowID : func (domain string ) bool { return false },
256
- RatelimitInternalPerWorkflowID : func (domain string ) bool { return true },
257
- })
258
-
259
- // We fail open
260
- assert .True (t , wfCache .AllowExternal (testDomainID , testWorkflowID ))
261
-
262
- // We use cache
263
- assert .False (t , wfCache .AllowInternal (testDomainID , testWorkflowID ))
264
-
265
- // We log the error
266
- logger .AssertExpectations (t )
267
- }
268
-
269
- // TestWfCache_CacheInternalDisabled tests that the cache will allow requests only for the requests where it is enabled
270
- func TestWfCache_CacheInternalDisabled (t * testing.T ) {
271
- ctrl := gomock .NewController (t )
272
-
273
- domainCache := cache .NewMockDomainCache (ctrl )
274
- domainCache .EXPECT ().GetDomainName (testDomainID ).Return (testDomainName , nil ).Times (2 )
275
-
276
- // Setup the mock logger
277
- logger := new (log.MockLogger )
278
- expectRatelimitLog (logger , "external" , "enabled" )
279
-
280
- externalLimiterFactory := quotas .NewMockLimiterFactory (ctrl )
281
- externalLimiter := quotas .NewMockLimiter (ctrl )
282
- externalLimiterFactory .EXPECT ().GetLimiter (testDomainName ).Return (externalLimiter ).Times (1 )
283
- externalLimiter .EXPECT ().Allow ().Return (false ).Times (1 )
284
- internalLimiter := quotas .NewMockLimiter (ctrl )
285
- internalLimiterFactory := quotas .NewMockLimiterFactory (ctrl )
286
- internalLimiterFactory .EXPECT ().GetLimiter (testDomainName ).Return (internalLimiter ).Times (1 )
287
-
288
- wfCache := New (Params {
289
- TTL : time .Minute ,
290
- MaxCount : 1_000 ,
291
- ExternalLimiterFactory : externalLimiterFactory ,
292
- InternalLimiterFactory : internalLimiterFactory ,
293
- Logger : logger ,
294
- DomainCache : domainCache ,
295
- MetricsClient : metrics .NewNoopMetricsClient (),
296
- RatelimitExternalPerWorkflowID : func (domain string ) bool { return true },
297
- RatelimitInternalPerWorkflowID : func (domain string ) bool { return false },
298
- })
299
-
300
- // We use cache
301
- assert .False (t , wfCache .AllowExternal (testDomainID , testWorkflowID ))
302
- // We fail open
303
- assert .True (t , wfCache .AllowInternal (testDomainID , testWorkflowID ))
304
-
305
- // We log the error
306
- logger .AssertExpectations (t )
307
- }
308
-
309
226
func TestWfCache_RejectLog (t * testing.T ) {
310
227
ctrl := gomock .NewController (t )
311
228
0 commit comments