public void SecretValueEmptyOnConstruction() { var login = new Mock <ILoginAction>(); var createSecret = new Mock <ICreateSecretAction>(); var secretsList = new Mock <ISecretsList>(); var sut = new CopySecretOnSecretSave("HackerUser", "TargetUser", "TargetKey", login.Object, createSecret.Object, secretsList.Object); Assert.Empty(sut.SecretValue); }
public void SuccessfulFalseOnConstruction() { var login = new Mock <ILoginAction>(); var createSecret = new Mock <ICreateSecretAction>(); var secretsList = new Mock <ISecretsList>(); var sut = new CopySecretOnSecretSave("HackerUser", "TargetUser", "TargetKey", login.Object, createSecret.Object, secretsList.Object); Assert.False(sut.Successful); }
private IExploitRunner GetSqlInjectionCopySecretOnSecretSave(int id) { var sharedHttpClient = _serviceProvider.GetRequiredService <IHttpClientProxy>(); var exploit = new CopySecretOnSecretSave(_hackerUser, _targetUser, _targetKey, new LoginAction(sharedHttpClient, new AntiForgeryAction(sharedHttpClient)), new CreateSecretAction(sharedHttpClient, new AntiForgeryAction(sharedHttpClient)), new SecretsList(sharedHttpClient)); return(new ExploitRunner(id, exploit)); }
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); }