public async Task Deploy_WindowsPathSeparatorsInFiles_DeployToClusterCommandFiredWithUnixPathSeparatorsInFiles() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User()); fakeMediator .Send(Arg.Any <GetRepositoryLoginForUserQuery>()) .Returns(new RepositoryLoginResponse( "dummy", "dummy")); fakeMediator .Send(Arg.Any <EnsureRepositoryWithNameCommand>()) .Returns(new RepositoryResponse( "dummy", "dummy", new AmazonUser(), new AmazonUser())); var fakeMapper = Substitute.For <IMapper>(); var controller = new ClustersController( fakeMediator, fakeMapper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.Deploy(new DeployToClusterRequest() { DockerComposeYmlFilePaths = new[] { "some-docker-compose-contents" }, Files = new [] { new FileRequest() { Contents = Array.Empty <byte>(), Path = "some\\windows\\path\\separator\\path" } } }); //Assert Assert.IsNotNull(result); await fakeMediator .Received(1) .Send(Arg.Is <DeployToClusterCommand>(args => args.Files.Single().Path == "some/windows/path/separator/path")); }
public async Task Deploy_UserIdGiven_DeployToClusterCommandFiredWithAuthorizationFromRepository() { //Arrange var readUser = new AmazonUser(); var writeUser = new AmazonUser(); var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User()); fakeMediator .Send(Arg.Is <GetRepositoryLoginForUserQuery>(arg => arg.AmazonUser == readUser)) .Returns(new RepositoryLoginResponse( "some-username", "some-password")); fakeMediator .Send(Arg.Is <EnsureRepositoryWithNameCommand>(arg => arg.UserId != null)) .Returns(new RepositoryResponse( "dummy", "some-host-name", readUser, writeUser)); var fakeMapper = Substitute.For <IMapper>(); var controller = new ClustersController( fakeMediator, fakeMapper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.Deploy(new DeployToClusterRequest() { DockerComposeYmlFilePaths = new[] { "some-docker-compose-contents" } }); //Assert Assert.IsNotNull(result); await fakeMediator .Received(1) .Send(Arg.Is <DeployToClusterCommand>(args => args.Authentication.Single().Username == "some-username" && args.Authentication.Single().Password == "some-password" && args.Authentication.Single().RegistryHostName == "some-host-name")); }
public async Task Deploy_ClusterQueryTooBroadExceptionThrown_TooBroadValidationErrorReturned() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <DeployToClusterCommand>()) .Throws(new ClusterQueryTooBroadException("dummy")); fakeMediator .Send(Arg.Any <GetRepositoryLoginForUserQuery>()) .Returns(new RepositoryLoginResponse( "dummy", "dummy")); fakeMediator .Send(Arg.Any <EnsureRepositoryWithNameCommand>()) .Returns(new RepositoryResponse( "dummy", "dummy", new AmazonUser(), new AmazonUser())); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User()); var mapper = AutoMapperFactory.CreateValidMapper(); var controller = new ClustersController( fakeMediator, mapper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.Deploy(new DeployToClusterRequest() { DockerComposeYmlFilePaths = new[] { "some-docker-compose-contents" } }); //Assert var response = result.GetValidationProblemDetails(); Assert.IsNotNull(response); Assert.AreEqual("TOO_BROAD", response.Type); }
public async Task Deploy_NoClusterIdGiven_DeployToClusterCommandFiredWithNoClusterId() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <EnsureUserForIdentityCommand>()) .Returns(new User()); fakeMediator .Send(Arg.Any <GetRepositoryLoginForUserQuery>()) .Returns(new RepositoryLoginResponse( "dummy", "dummy")); fakeMediator .Send(Arg.Any <EnsureRepositoryWithNameCommand>()) .Returns(new RepositoryResponse( "dummy", "dummy", new AmazonUser(), new AmazonUser())); var fakeMapper = Substitute.For <IMapper>(); var controller = new ClustersController( fakeMediator, fakeMapper); controller.FakeAuthentication("some-identity-name"); //Act var result = await controller.Deploy(new DeployToClusterRequest() { DockerComposeYmlFilePaths = new[] { "some-docker-compose-contents" } }); //Assert Assert.IsNotNull(result); await fakeMediator .Received(1) .Send(Arg.Is <DeployToClusterCommand>(args => args.ClusterId == default)); }