示例#1
0
            public async Task FetchesAnUncachedSecret()
            {
                var actual = await Target.GetSecretObjectAsync(SecretNameA);

                Assert.Same(SecretA.Object, actual);
                SecretReader.Verify(x => x.GetSecretObjectAsync(SecretNameA), Times.Once);
            }
示例#2
0
            public async Task DoesNothingWithEmptyCache()
            {
                await Target.RefreshAsync(CancellationToken.None);

                SecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Never);
                SecretReader.Verify(x => x.GetSecretObjectAsync(It.IsAny <string>()), Times.Never);
            }
示例#3
0
            public async Task FetchesAnUncachedSecret()
            {
                var actual = await Target.GetSecretAsync(SecretNameA);

                Assert.Same(SecretA.Object.Value, actual);
                SecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Never);
                SecretReader.Verify(x => x.GetSecretObjectAsync(SecretNameA), Times.Once);
            }
示例#4
0
            public async Task DoesNotSwitchThreadIfAlreadyCached()
            {
                await Target.GetSecretObjectAsync(SecretNameA);

                SecretReader.Invocations.Clear();
                var threadId = Thread.CurrentThread.ManagedThreadId;

                await Target.GetSecretObjectAsync(SecretNameA);

                Assert.Equal(threadId, Thread.CurrentThread.ManagedThreadId);
                SecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Never);
                SecretReader.Verify(x => x.GetSecretObjectAsync(It.IsAny <string>()), Times.Never);
            }
示例#5
0
            public async Task RefreshesAllNames()
            {
                await Target.GetSecretAsync(SecretNameA);

                await Target.GetSecretAsync(SecretNameB);

                SecretReader.Invocations.Clear();

                await Target.RefreshAsync(CancellationToken.None);

                SecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Never);
                SecretReader.Verify(x => x.GetSecretObjectAsync(SecretNameA), Times.Once);
                SecretReader.Verify(x => x.GetSecretObjectAsync(SecretNameB), Times.Once);
            }
示例#6
0
            public async Task RespectsTheToken()
            {
                await Target.GetSecretAsync(SecretNameA);

                SecretReader.Invocations.Clear();
                var cts   = new CancellationTokenSource();
                var token = cts.Token;

                cts.Cancel();

                await Target.RefreshAsync(token);

                SecretReader.Verify(x => x.GetSecretAsync(It.IsAny <string>()), Times.Never);
                SecretReader.Verify(x => x.GetSecretObjectAsync(It.IsAny <string>()), Times.Never);
            }