Пример #1
0
        public async Task CreateAppInvalidParametersTest(string appName, bool isRepNull)
        {
            var rep = isRepNull ? null : AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.GetType(), isRepNull ? typeof(ArgumentNullException) : typeof(ArgumentException));
            }
        }
Пример #2
0
        public async Task CreateAppTest(string appName, bool exception, Type exceptionType = null)
        {
            var rep = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.IsFalse(exception);
            }
            catch (Exception ex)
            {
                Assert.IsTrue((exception) && (exceptionType.FullName == ex.GetType().FullName));
            }
        }
Пример #3
0
        public async Task CreateAppFlowTest(string appName, bool incCreate, bool incGetByName)
        {
            var rep = AppRepositoryMock.CreateRepository();

            try
            {
                await CreateApp.Execute(rep, appName);

                Assert.AreEqual(rep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(rep.GetByNameCount, incGetByName ? 1 : 0);
            }
            catch
            {
                Assert.AreEqual(rep.CreateCount, incCreate ? 1 : 0);
                Assert.AreEqual(rep.GetByNameCount, incGetByName ? 1 : 0);
            }
        }
        public void CreateApp_Test()
        {
            using (ShimsContext.Create())
            {
                CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin;

                CloudFoundry.Manifests.Fakes.ShimManifestDiskRepository.ReadManifestString = TestUtils.CustomReadManifest;

                CloudFoundry.Manifests.Fakes.ShimManifest.AllInstances.Applications = TestUtils.CustomManifestApplications;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesResponse> .AllInstances.ResourcesGet = TestUtils.CustomGetPaged;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractStacksEndpoint.AllInstances.ListAllStacks = TestUtils.CustomListAllStacks;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllStacksResponse> .AllInstances.ResourcesGet = TestUtils.CustomGetStacks;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.CreateAppCreateAppRequest = TestUtils.CustomCreateApp;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllAppsForSpaceResponse> .AllInstances.ResourcesGet = TestUtils.CusomListAllAppsForSpacePagedResponseCreate;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllAppsForSpaceNullableOfGuidRequestOptions = TestUtils.CustomListAllAppsForSpace;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllOrganizationsResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllSpacesForOrganizationResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization;

                TestUtils.InitTestMetadata();

                CreateApp task = new CreateApp();
                task.CFUser         = Settings.Default.User;
                task.CFPassword     = Settings.Default.Password;
                task.CFServerUri    = Settings.Default.ServerUri;
                task.CFSpace        = "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFManifest     = Settings.Default.CFManifest;

                task.BuildEngine = new FakeBuildEngine();
                Assert.IsTrue(task.Execute());
            }
        }
        public void CreateApp_Test()
        {
            using (ShimsContext.Create())
            {
                CloudFoundry.CloudController.V2.Client.Fakes.ShimCloudFoundryClient.AllInstances.LoginCloudCredentials = TestUtils.CustomLogin;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllSpacesRequestOptions = TestUtils.CustomListAllSpaces;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetPaged;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractStacksEndpoint.AllInstances.ListAllStacks = TestUtils.CustomListAllStacks;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllStacksResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetStacks;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractAppsEndpoint.AllInstances.CreateAppCreateAppRequest = TestUtils.CustomCreateApp;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllAppsForSpaceResponse>.AllInstances.ResourcesGet = TestUtils.CusomListAllAppsForSpacePagedResponseCreate;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractSpacesEndpoint.AllInstances.ListAllAppsForSpaceNullableOfGuidRequestOptions = TestUtils.CustomListAllAppsForSpace;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllOrganizationsResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllOrganizationsResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllOrganizationsRequestOptions = TestUtils.CustomListAllOrganizations;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllSpacesForOrganizationResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllSpacesForOrganizationResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractOrganizationsEndpoint.AllInstances.ListAllSpacesForOrganizationNullableOfGuidRequestOptions = TestUtils.CustomListAllSpacesForOrganization;

                TestUtils.InitTestMetadata();

                CreateApp task = new CreateApp();
                task.CFUser = Settings.Default.User;
                task.CFPassword = Settings.Default.Password;
                task.CFServerUri = Settings.Default.ServerUri;
                task.CFSpace= "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFStack = "testStack";

                task.BuildEngine = new FakeBuildEngine();
                Assert.IsTrue(task.Execute());
            }
        }
        public void Flow_IntegrationTest()
        {
            LoginTask login = new LoginTask();

            login.BuildEngine         = new FakeBuildEngine();
            login.CFUser              = Settings.Default.User;
            login.CFPassword          = Settings.Default.Password;
            login.CFServerUri         = Settings.Default.ServerUri;
            login.CFSkipSslValidation = true;

            login.Execute();

            CreateApp task = new CreateApp();

            task.CFRefreshToken      = login.CFRefreshToken;
            task.CFServerUri         = Settings.Default.ServerUri;
            task.CFSkipSslValidation = true;
            task.CFAppName           = "testIntegration";
            task.CFAppMemory         = 512;
            task.CFAppInstances      = 1;
            task.CFSpace             = "TestSpace";
            task.CFOrganization      = "TestOrg";
            task.CFStack             = "win2012";
            task.CFEnvironmentJson   = "{\"mykey\":\"abcd\",\"secondkey\":\"efgh\"}";

            task.BuildEngine = new FakeBuildEngine();
            task.Execute();

            PushApp pushTask = new PushApp();

            pushTask.CFUser              = Settings.Default.User;
            pushTask.CFPassword          = Settings.Default.Password;
            pushTask.CFServerUri         = Settings.Default.ServerUri;
            pushTask.CFSkipSslValidation = true;
            pushTask.CFAppGuid           = task.CFAppGuid;
            pushTask.CFAppPath           = Settings.Default.AppPath;
            pushTask.CFStart             = true;

            pushTask.BuildEngine = new FakeBuildEngine();

            pushTask.Execute();

            CreateRoutes routeTask = new CreateRoutes();

            routeTask.CFUser              = Settings.Default.User;
            routeTask.CFPassword          = Settings.Default.Password;
            routeTask.CFServerUri         = Settings.Default.ServerUri;
            routeTask.CFSkipSslValidation = true;
            routeTask.CFRoutes            = new string[1] {
                "testRoute.15.126.213.170.xip.io"
            };
            routeTask.CFSpace        = "TestSpace";
            routeTask.CFOrganization = "TestOrg";

            routeTask.BuildEngine = new FakeBuildEngine();

            routeTask.Execute();

            BindRoutes bindTask = new BindRoutes();

            bindTask.CFUser              = Settings.Default.User;
            bindTask.CFPassword          = Settings.Default.Password;
            bindTask.CFServerUri         = Settings.Default.ServerUri;
            bindTask.BuildEngine         = new FakeBuildEngine();
            bindTask.CFSkipSslValidation = true;

            bindTask.CFAppGuid    = task.CFAppGuid;
            bindTask.CFRouteGuids = routeTask.CFRouteGuids;

            bindTask.Execute();

            CreateService serviceTask = new CreateService();

            serviceTask.CFUser              = Settings.Default.User;
            serviceTask.CFPassword          = Settings.Default.Password;
            serviceTask.CFServerUri         = Settings.Default.ServerUri;
            serviceTask.BuildEngine         = new FakeBuildEngine();
            serviceTask.CFSkipSslValidation = true;
            serviceTask.CFServiceName       = "testService";
            serviceTask.CFServicePlan       = "free";
            serviceTask.CFServiceType       = "mysql";
            serviceTask.CFSpace             = "TestSpace";
            serviceTask.CFOrganization      = "TestOrg";
            serviceTask.Execute();

            BindServices bindServiceTask = new BindServices();

            bindServiceTask.CFUser              = Settings.Default.User;
            bindServiceTask.CFPassword          = Settings.Default.Password;
            bindServiceTask.CFServerUri         = Settings.Default.ServerUri;
            bindServiceTask.BuildEngine         = new FakeBuildEngine();
            bindServiceTask.CFSkipSslValidation = true;
            bindServiceTask.CFAppGuid           = task.CFAppGuid;
            bindServiceTask.CFServicesGuids     = new string[1] {
                serviceTask.CFServiceGuid
            };
            bindServiceTask.Execute();

            if (CheckIfAppIsWorking(routeTask.CFRoutes[0], 3) == true)
            {
                DeleteApp delTask = new DeleteApp();
                delTask.CFUser              = Settings.Default.User;
                delTask.CFPassword          = Settings.Default.Password;
                delTask.CFServerUri         = Settings.Default.ServerUri;
                delTask.CFSkipSslValidation = true;
                delTask.CFOrganization      = "TestOrg";
                delTask.CFSpace             = "TestSpace";
                delTask.CFAppName           = "testIntegration";
                delTask.CFDeleteServices    = true;
                delTask.CFDeleteRoutes      = true;
                delTask.BuildEngine         = new FakeBuildEngine();

                Assert.IsTrue(delTask.Execute());
            }
            else
            {
                Assert.Fail("Application is not working");
            }
        }
        public void Flow_IntegrationTest()
        {
            string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string appPath = Path.Combine(assemblyDirectory, "TestApp");

            LoginTask login = new LoginTask();
            login.BuildEngine = new FakeBuildEngine();
            login.CFUser = Settings.Default.User;
            login.CFPassword = Settings.Default.Password;
            login.CFServerUri = Settings.Default.ServerUri;
            login.CFSkipSslValidation = true;

            login.Execute();

            CreateApp task = new CreateApp();

            task.CFRefreshToken = login.CFRefreshToken;
            task.CFServerUri = Settings.Default.ServerUri;
            task.CFSkipSslValidation = true;
            task.CFAppName = Guid.NewGuid().ToString("N");
            task.CFAppMemory = 256;
            task.CFAppInstances = 1;
            task.CFSpace = Settings.Default.Space;
            task.CFOrganization = Settings.Default.Organization;
            task.CFStack = Settings.Default.Stack;
            task.CFEnvironmentJson = "{\"mykey\":\"abcd\",\"secondkey\":\"efgh\"}";

            task.BuildEngine = new FakeBuildEngine();
            task.Execute();

            PushApp pushTask = new PushApp();
            pushTask.CFUser = Settings.Default.User;
            pushTask.CFPassword = Settings.Default.Password;
            pushTask.CFServerUri = Settings.Default.ServerUri;
            pushTask.CFSkipSslValidation = true;
            pushTask.CFAppGuid = task.CFAppGuid;
            pushTask.CFAppPath = appPath;
            pushTask.CFStart = true;

            pushTask.BuildEngine = new FakeBuildEngine();

            pushTask.Execute();

            CreateRoutes routeTask = new CreateRoutes();
            routeTask.CFUser = Settings.Default.User;
            routeTask.CFPassword = Settings.Default.Password;
            routeTask.CFServerUri = Settings.Default.ServerUri;
            routeTask.CFSkipSslValidation = true;
            routeTask.CFRoutes = new string[1] {
                string.Format(Settings.Default.Route, task.CFAppName)
            };
            routeTask.CFSpace = Settings.Default.Space;
            routeTask.CFOrganization = Settings.Default.Organization;

            routeTask.BuildEngine = new FakeBuildEngine();

            routeTask.Execute();

            BindRoutes bindTask = new BindRoutes();
            bindTask.CFUser = Settings.Default.User;
            bindTask.CFPassword = Settings.Default.Password;
            bindTask.CFServerUri = Settings.Default.ServerUri;
            bindTask.BuildEngine = new FakeBuildEngine();
            bindTask.CFSkipSslValidation = true;

            bindTask.CFAppGuid = task.CFAppGuid;
            bindTask.CFRouteGuids = routeTask.CFRouteGuids;

            bindTask.Execute();

            CreateService serviceTask = new CreateService();
            serviceTask.CFUser = Settings.Default.User;
            serviceTask.CFPassword = Settings.Default.Password;
            serviceTask.CFServerUri = Settings.Default.ServerUri;
            serviceTask.BuildEngine = new FakeBuildEngine();
            serviceTask.CFSkipSslValidation = true;
            serviceTask.CFServiceName = Guid.NewGuid().ToString("N");
            serviceTask.CFServicePlan = Settings.Default.ServicePlan;
            serviceTask.CFServiceType = Settings.Default.ServiceType;
            serviceTask.CFSpace = Settings.Default.Space;
            serviceTask.CFOrganization = Settings.Default.Organization;
            serviceTask.Execute();

            BindServices bindServiceTask = new BindServices();
            bindServiceTask.CFUser = Settings.Default.User;
            bindServiceTask.CFPassword = Settings.Default.Password;
            bindServiceTask.CFServerUri = Settings.Default.ServerUri;
            bindServiceTask.BuildEngine = new FakeBuildEngine();
            bindServiceTask.CFSkipSslValidation = true;
            bindServiceTask.CFAppGuid = task.CFAppGuid;
            bindServiceTask.CFServicesGuids = new string[1] { serviceTask.CFServiceGuid };
            bindServiceTask.Execute();

            if (CheckIfAppIsWorking(routeTask.CFRoutes[0], 60) == true)
            {

                DeleteApp delTask = new DeleteApp();
                delTask.CFUser = Settings.Default.User;
                delTask.CFPassword = Settings.Default.Password;
                delTask.CFServerUri = Settings.Default.ServerUri;
                delTask.CFSkipSslValidation = true;
                delTask.CFSpace = Settings.Default.Space;
                delTask.CFOrganization = Settings.Default.Organization;
                delTask.CFAppName = task.CFAppName;
                delTask.CFDeleteServices = true;
                delTask.CFDeleteRoutes = true;
                delTask.BuildEngine = new FakeBuildEngine();

                Assert.IsTrue(delTask.Execute());
            }
            else
            {
                Assert.Fail("Application is not working");
            }
        }
Пример #8
0
        private bool RunTasks(string manifest, string host, string appPath)
        {
            LoginTask login = new LoginTask();

            login.BuildEngine         = new FakeBuildEngine();
            login.CFUser              = Settings.Default.User;
            login.CFPassword          = Settings.Default.Password;
            login.CFServerUri         = Settings.Default.ServerUri;
            login.CFManifest          = manifest;
            login.CFSkipSslValidation = true;

            login.Execute();

            CreateApp task = new CreateApp();

            task.CFRefreshToken      = login.CFRefreshToken;
            task.CFServerUri         = Settings.Default.ServerUri;
            task.CFSkipSslValidation = true;
            task.CFSpace             = Settings.Default.Space;
            task.CFOrganization      = Settings.Default.Organization;
            task.CFManifest          = manifest;
            task.BuildEngine         = new FakeBuildEngine();
            task.Execute();

            PushApp pushTask = new PushApp();

            pushTask.CFUser              = Settings.Default.User;
            pushTask.CFPassword          = Settings.Default.Password;
            pushTask.CFServerUri         = Settings.Default.ServerUri;
            pushTask.CFSkipSslValidation = true;
            pushTask.CFManifest          = manifest;
            pushTask.CFOrganization      = Settings.Default.Organization;
            pushTask.CFSpace             = Settings.Default.Space;
            pushTask.CFAppPath           = appPath;

            pushTask.BuildEngine = new FakeBuildEngine();

            pushTask.Execute();

            CreateRoutes routeTask = new CreateRoutes();

            routeTask.CFUser              = Settings.Default.User;
            routeTask.CFPassword          = Settings.Default.Password;
            routeTask.CFServerUri         = Settings.Default.ServerUri;
            routeTask.CFSkipSslValidation = true;
            routeTask.CFManifest          = manifest;
            routeTask.CFSpace             = Settings.Default.Space;
            routeTask.CFOrganization      = Settings.Default.Organization;

            routeTask.BuildEngine = new FakeBuildEngine();

            routeTask.Execute();

            BindRoutes bindTask = new BindRoutes();

            bindTask.CFUser              = Settings.Default.User;
            bindTask.CFPassword          = Settings.Default.Password;
            bindTask.CFServerUri         = Settings.Default.ServerUri;
            bindTask.BuildEngine         = new FakeBuildEngine();
            bindTask.CFSkipSslValidation = true;
            bindTask.CFManifest          = manifest;
            bindTask.CFOrganization      = Settings.Default.Organization;
            bindTask.CFSpace             = Settings.Default.Space;

            bindTask.Execute();

            BindServices bindServiceTask = new BindServices();

            bindServiceTask.CFUser              = Settings.Default.User;
            bindServiceTask.CFPassword          = Settings.Default.Password;
            bindServiceTask.CFServerUri         = Settings.Default.ServerUri;
            bindServiceTask.BuildEngine         = new FakeBuildEngine();
            bindServiceTask.CFSkipSslValidation = true;
            bindServiceTask.CFManifest          = manifest;
            bindServiceTask.CFOrganization      = Settings.Default.Organization;
            bindServiceTask.CFSpace             = Settings.Default.Space;
            bindServiceTask.Execute();

            RestartApp restartTask = new RestartApp();

            restartTask.BuildEngine         = new FakeBuildEngine();
            restartTask.CFUser              = Settings.Default.User;
            restartTask.CFPassword          = Settings.Default.Password;
            restartTask.CFServerUri         = Settings.Default.ServerUri;
            restartTask.CFManifest          = manifest;
            restartTask.CFSkipSslValidation = true;
            restartTask.CFOrganization      = Settings.Default.Organization;
            restartTask.CFSpace             = Settings.Default.Space;
            restartTask.Execute();

            if (CheckIfAppIsWorking(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", host, Settings.Default.Domain), 60) == true)
            {
                DeleteApp delTask = new DeleteApp();
                delTask.CFUser              = Settings.Default.User;
                delTask.CFPassword          = Settings.Default.Password;
                delTask.CFServerUri         = Settings.Default.ServerUri;
                delTask.CFSkipSslValidation = true;
                delTask.CFSpace             = Settings.Default.Space;
                delTask.CFOrganization      = Settings.Default.Organization;
                delTask.CFManifest          = manifest;
                delTask.CFDeleteServices    = true;
                delTask.CFDeleteRoutes      = true;
                delTask.BuildEngine         = new FakeBuildEngine();

                return(delTask.Execute());
            }
            else
            {
                return(false);
            }
        }