Example #1
0
        public void CreateRoutes_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;

                CloudController.V2.Client.Base.Fakes.ShimAbstractDomainsDeprecatedEndpoint.AllInstances.ListAllDomainsDeprecated = TestUtils.CustomListAllDomains;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllDomainsDeprecatedResponse> .AllInstances.ResourcesGet = TestUtils.CustomGetDomains;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.CreateRouteCreateRouteRequest = TestUtils.CustomCreateRoute;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection <ListAllRoutesResponse> .AllInstances.ResourcesGet = TestUtils.CustomListAllRoutesResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.ListAllRoutesRequestOptions = TestUtils.CustomListAllRoutes;

                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();

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

                task.Execute();

                Assert.AreEqual(task.CFRouteGuids.Length, 1);
            }
        }
        public void CreateRoutes_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;

                CloudController.V2.Client.Base.Fakes.ShimAbstractDomainsDeprecatedEndpoint.AllInstances.ListAllDomainsDeprecated = TestUtils.CustomListAllDomains;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllDomainsDeprecatedResponse>.AllInstances.ResourcesGet = TestUtils.CustomGetDomains;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.CreateRouteCreateRouteRequest = TestUtils.CustomCreateRoute;

                CloudFoundry.CloudController.V2.Client.Fakes.ShimPagedResponseCollection<ListAllRoutesResponse>.AllInstances.ResourcesGet = TestUtils.CustomListAllRoutesResponse;

                CloudFoundry.CloudController.V2.Client.Base.Fakes.ShimAbstractRoutesEndpoint.AllInstances.ListAllRoutesRequestOptions = TestUtils.CustomListAllRoutes;

                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();

                CreateRoutes task = new CreateRoutes();
                task.CFRoutes = new string[2] { "test.domain.com;test3.domain.com" ,"test2.domain.com" };
                task.CFSpace = "TestSpace";
                task.CFOrganization = "TestOrg";
                task.CFUser = Settings.Default.User;
                task.CFPassword = Settings.Default.Password;
                task.CFServerUri = Settings.Default.ServerUri;
                task.BuildEngine = new FakeBuildEngine();

                task.Execute();

                Assert.AreEqual(task.CFRouteGuids.Length, 3);
            }
        }
        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");
            }
        }
Example #5
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);
            }
        }