コード例 #1
0
        public async Task GetByIdAsync_EmptyDb_ReturnsNull()
        {
            Guid id = Guid.NewGuid();

            m_mockPublicKeyDataProvider.Setup(kp => kp.GetByIdAsync(id)).ReturnsAsync(null);

            JsonWebKey result = await m_publicKeyDataProvider
                                .GetByIdAsync(id)
                                .SafeAsync();

            Assert.IsNull(result);
        }
        public async Task GetByIdAsync_EmptyDb_ReturnsNull()
        {
            var id = Guid.NewGuid();

            m_mockPublicKeyDataProvider.Setup(kp => kp.GetByIdAsync(id)).ReturnsAsync(value: null);

            JsonWebKey result = await m_publicKeyDataProvider
                                .GetByIdAsync(id)
                                .ConfigureAwait(false);

            Assert.IsNull(result);
        }
コード例 #3
0
        async Task <D2LSecurityToken> IPublicKeyProvider.GetByIdAsync(Guid id)
        {
            D2LSecurityToken result = m_cache.Get(PUBLIC_KEY_SOURCE, id);

            if (result != null)
            {
                return(result);
            }

            JsonWebKey jwk = await m_publicKeyDataProvider
                             .GetByIdAsync(id)
                             .SafeAsync();

            if (jwk != null)
            {
                result = jwk.ToSecurityToken();
                m_cache.Set(PUBLIC_KEY_SOURCE, result);
                return(result);
            }

            throw new PublicKeyNotFoundException(id, PUBLIC_KEY_SOURCE);
        }
コード例 #4
0
        public async Task GetById_NoKeys_ReturnsNull()
        {
            var key = await m_publicKeyDataProvider.GetByIdAsync(Guid.NewGuid()).SafeAsync();

            Assert.IsNull(key);
        }
        public async Task GetById_NoKeys_ReturnsNull()
        {
            var key = await m_publicKeyDataProvider.GetByIdAsync(Guid.NewGuid()).ConfigureAwait(false);

            Assert.IsNull(key);
        }