private void TestFullBuilderPath() { BasicExpiringCryptoPolicy.IKeyExpirationDaysStep builder = BasicExpiringCryptoPolicy.NewBuilder(); BasicExpiringCryptoPolicy basicExpiringCryptoPolicy = builder .WithKeyExpirationDays(TestExpirationDays) .WithRevokeCheckMinutes(TestCachingPeriod) .WithRotationStrategy(CryptoPolicy.KeyRotationStrategy.Queued) .WithCanCacheSystemKeys(false) .WithCanCacheIntermediateKeys(false) .WithCanCacheSessions(true) .WithSessionCacheMaxSize(42) .WithSessionCacheExpireMillis(33000) .WithNotifyExpiredSystemKeyOnRead(true) .WithNotifyExpiredIntermediateKeyOnRead(true) .Build(); Assert.NotNull(basicExpiringCryptoPolicy); Assert.Equal(CryptoPolicy.KeyRotationStrategy.Queued, basicExpiringCryptoPolicy.GetKeyRotationStrategy()); Assert.False(basicExpiringCryptoPolicy.CanCacheSystemKeys()); Assert.False(basicExpiringCryptoPolicy.CanCacheIntermediateKeys()); Assert.True(basicExpiringCryptoPolicy.CanCacheSessions()); Assert.Equal(42, basicExpiringCryptoPolicy.GetSessionCacheMaxSize()); Assert.Equal(33000, basicExpiringCryptoPolicy.GetSessionCacheExpireMillis()); Assert.True(basicExpiringCryptoPolicy.NotifyExpiredSystemKeyOnRead()); Assert.True(basicExpiringCryptoPolicy.NotifyExpiredIntermediateKeyOnRead()); }
private void TestDefaultsDontChange() { Assert.True(policy.CanCacheSystemKeys()); Assert.True(policy.CanCacheIntermediateKeys()); Assert.False(policy.CanCacheSessions()); Assert.Equal(1000, policy.GetSessionCacheMaxSize()); Assert.Equal(2 * 60 * 1000, policy.GetSessionCacheExpireMillis()); Assert.Equal(CryptoPolicy.KeyRotationStrategy.Inline, policy.GetKeyRotationStrategy()); Assert.False(policy.NotifyExpiredSystemKeyOnRead()); Assert.False(policy.NotifyExpiredIntermediateKeyOnRead()); }