Beispiel #1
0
        public async Task Validate_CertCache()
        {
            var clock1 = new MockClock()
            {
                UtcNow = new DateTime(2017, 5, 31, 11, 24, 0, DateTimeKind.Utc)
            };
            var clock2Cached = new MockClock()
            {
                UtcNow = clock1.UtcNow + GoogleJsonWebSignature.CertCacheRefreshInterval - TimeSpan.FromSeconds(1)
            };
            var clock3Uncached = new MockClock()
            {
                UtcNow = clock1.UtcNow + GoogleJsonWebSignature.CertCacheRefreshInterval + TimeSpan.FromSeconds(1)
            };

            var rsas1 = await GoogleJsonWebSignature.GetGoogleCertsAsync(clock1, false, GoogleCertsJson);

            var rsas2Cached = await GoogleJsonWebSignature.GetGoogleCertsAsync(clock2Cached, false, GoogleCertsJson);

            var rsas3Refreshed = await GoogleJsonWebSignature.GetGoogleCertsAsync(clock3Uncached, false, GoogleCertsJson);

            var rsas4Forced = await GoogleJsonWebSignature.GetGoogleCertsAsync(clock3Uncached, true, GoogleCertsJson);

            Assert.NotNull(rsas1);
            Assert.Same(rsas1, rsas2Cached);
            Assert.NotSame(rsas1, rsas3Refreshed);
            Assert.NotSame(rsas3Refreshed, rsas4Forced);
        }
Beispiel #2
0
        public async Task GetGoogleCerts()
        {
            // Verifies certs are downloaded and loaded into RSAs
            var certs = await GoogleJsonWebSignature.GetGoogleCertsAsync(SystemClock.Default, false, null);

            Assert.NotEmpty(certs);
        }