| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using Google.Apis.Auth.OAuth2; |
| | using Google.Apis.Tests.Mocks; |
| | using System; |
| | using System.Security.Cryptography; |
| | using System.Threading.Tasks; |
| | using Xunit; |
| |
|
| | namespace Google.Apis.Auth.Tests |
| | { |
| | public class SignedTokenVerificationTests |
| | { |
| | [Fact] |
| | public async Task CertificateCache_Caches() |
| | { |
| | MockClock clock = new MockClock(DateTime.UtcNow); |
| |
|
| | |
| | |
| | var certCache = new FakeCertificateCache(clock); |
| |
|
| | var firstCall = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), false, default); |
| | |
| | clock.UtcNow = clock.UtcNow.AddMinutes(30); |
| | var secondCallCached = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), false, default); |
| |
|
| | Assert.NotNull(firstCall); |
| | Assert.Same(firstCall, secondCallCached); |
| | } |
| |
|
| | [Fact] |
| | public async Task CertificateCache_Refreshes() |
| | { |
| | MockClock clock = new MockClock(DateTime.UtcNow); |
| | |
| | |
| | var certCache = new FakeCertificateCache(clock); |
| |
|
| | var firstCall = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), false, default); |
| | |
| | clock.UtcNow = clock.UtcNow.AddMinutes(61); |
| | var secondCall = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), false, default); |
| |
|
| | Assert.NotNull(firstCall); |
| | Assert.NotNull(secondCall); |
| | Assert.NotSame(firstCall, secondCall); |
| | } |
| |
|
| | [Fact] |
| | public async Task CertificateCache_ForceRefresh() |
| | { |
| | MockClock clock = new MockClock(DateTime.UtcNow); |
| | |
| | |
| | var certCache = new FakeCertificateCache(clock); |
| |
|
| | var firstCall = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), false, default); |
| | |
| | clock.UtcNow = clock.UtcNow.AddMinutes(30); |
| | var secondCall = await certCache.GetCertificatesAsync(GoogleAuthConsts.JsonWebKeySetUrl, json => RSA.Create(), true, default); |
| |
|
| | Assert.NotNull(firstCall); |
| | Assert.NotNull(secondCall); |
| | |
| | Assert.NotSame(firstCall, secondCall); |
| | } |
| | } |
| | } |
| |
|