public void AffinitizeRequest_AffinityOptionSettingNotFound_Throw() { var provider = new ProviderStub(GetDataProtector().Object, AffinityTestHelper.GetLogger <BaseSessionAffinityProvider <string> >().Object); var options = GetOptionsWithUnknownSetting(); Assert.Throws <ArgumentException>(() => provider.AffinitizeRequest(new DefaultHttpContext(), options, new DestinationInfo("dest-A"))); }
public void AffinitizeRequest_AffinitiDisabled_DoNothing() { var dataProtector = GetDataProtector(); var provider = new ProviderStub(dataProtector.Object, AffinityTestHelper.GetLogger <BaseSessionAffinityProvider <string> >().Object); Assert.Throws <InvalidOperationException>(() => provider.AffinitizeRequest(new DefaultHttpContext(), new SessionAffinityOptions(), new DestinationInfo("id"))); }
public void AffinitizeRequest_RequestIsAffinitized_DoNothing() { var dataProtector = GetDataProtector(); var provider = new ProviderStub(dataProtector.Object, AffinityTestHelper.GetLogger <BaseSessionAffinityProvider <string> >().Object); var context = new DefaultHttpContext(); provider.DirectlySetExtractedKeyOnContext(context, "ExtractedKey"); provider.AffinitizeRequest(context, _defaultOptions, new DestinationInfo("id")); Assert.Null(provider.LastSetEncryptedKey); dataProtector.Verify(p => p.Protect(It.IsAny <byte[]>()), Times.Never); }
public void AffinitizeRequest_RequestIsNotAffinitized_SetAffinityKey() { var dataProtector = GetDataProtector(); var provider = new ProviderStub(dataProtector.Object, AffinityTestHelper.GetLogger <BaseSessionAffinityProvider <string> >().Object); var destination = new DestinationInfo("dest-A"); provider.AffinitizeRequest(new DefaultHttpContext(), _defaultOptions, destination); Assert.Equal("ZGVzdC1B", provider.LastSetEncryptedKey); var keyBytes = Encoding.UTF8.GetBytes(destination.DestinationId); dataProtector.Verify(p => p.Protect(It.Is <byte[]>(b => b.SequenceEqual(keyBytes))), Times.Once); }