public async Task FetchesAnUncachedSecret() { var actual = await Target.GetSecretObjectAsync(SecretNameA); Assert.Same(SecretA.Object, actual); SecretReader.Verify(x => x.GetSecretObjectAsync(SecretNameA), Times.Once); }
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); }
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); }
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); }
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); }
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); }