public void TestUpdateBaggageRestrictions() { _baggageRestrictionProxy.GetBaggageRestrictionsAsync(SERVICE_NAME).Returns(new List <BaggageRestrictionResponse> { RESTRICTION }); _undertest.UpdateBaggageRestrictions(); Assert.Equal(new Restriction(true, MAX_VALUE_LENGTH), _undertest.GetRestriction(SERVICE_NAME, BAGGAGE_KEY)); Assert.False(_undertest.GetRestriction(SERVICE_NAME, "bad-key").KeyAllowed); Assert.True(_inMemoryMetricsFactory.GetCounter("jaeger:baggage_restrictions_updates", "result=ok") > 0L); }
public void TestDenyBaggageOnInitializationFailure() { _baggageRestrictionProxy.GetBaggageRestrictionsAsync(SERVICE_NAME) .Returns(new List <BaggageRestrictionResponse> { RESTRICTION }); _undertest = new RemoteBaggageRestrictionManager(SERVICE_NAME, _baggageRestrictionProxy, _metrics, true, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)); Assert.False(_undertest.GetRestriction(SERVICE_NAME, BAGGAGE_KEY).KeyAllowed); _undertest.UpdateBaggageRestrictions(); Assert.True(_undertest.IsReady()); Assert.True(_undertest.GetRestriction(SERVICE_NAME, BAGGAGE_KEY).KeyAllowed); }
public void TestAllowBaggageOnInitializationFailure() { _baggageRestrictionProxy.GetBaggageRestrictionsAsync(SERVICE_NAME) .Returns <List <BaggageRestrictionResponse> >(_ => throw new InvalidOperationException()); _undertest = new RemoteBaggageRestrictionManager(SERVICE_NAME, _baggageRestrictionProxy, _metrics, false, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)); Assert.True(_undertest.GetRestriction(SERVICE_NAME, BAGGAGE_KEY).KeyAllowed); _undertest.UpdateBaggageRestrictions(); Assert.False(_undertest.IsReady()); // If baggage restriction update fails, all baggage should still be allowed. Assert.True(_undertest.GetRestriction(SERVICE_NAME, BAGGAGE_KEY).KeyAllowed); Assert.True(_inMemoryMetricsFactory.GetCounter("jaeger:baggage_restrictions_updates", "result=err") > 0L); }