public void ExceptionDuringLogin() { var login = new Mock <ILoginAction>(); login.Setup(x => x.LoginAsync("HackerUser", "Test1234!")).Returns(() => throw new Exception("End of the world")); var createSecret = new Mock <ICreateSecretAction>(); var secretsList = new Mock <ISecretsList>(); var sut = new CopySecretOnSecretSave("HackerUser", "TargetUser", "TargetKey", login.Object, createSecret.Object, secretsList.Object); sut.Exploit(); Assert.False(sut.Successful); Assert.Empty(sut.SecretValue); }
public void FailedExploit() { var login = new Mock <ILoginAction>(); login.Setup(x => x.LoginAsync("HackerUser", "Test1234!")).Returns(Task.CompletedTask); var createSecret = new Mock <ICreateSecretAction>(); createSecret.Setup(x => x.Create("HackerKey", It.IsAny <string>())); var secretsList = new Mock <ISecretsList>(); secretsList.Setup(x => x.GetTargetSecret("TargetKey")).Returns(""); var sut = new CopySecretOnSecretSave("HackerUser", "TargetUser", "TargetKey", login.Object, createSecret.Object, secretsList.Object); sut.Exploit(); login.VerifyAll(); createSecret.VerifyAll(); secretsList.VerifyAll(); Assert.False(sut.Successful); Assert.Empty(sut.SecretValue); }