public static void ClassInit(TestContext context)
        {
            client = TestUtil.GetClient();
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;
            try
            {
                client.Login(credentials).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Error while loging in" + ex.ToString());
            }

            CreateOrganizationRequest org = new CreateOrganizationRequest();
            org.Name = "test_" + Guid.NewGuid().ToString();
            var newOrg = client.Organizations.CreateOrganization(org).Result;
            orgGuid = newOrg.EntityMetadata.Guid;

            CreateSpaceRequest spc = new CreateSpaceRequest();
            spc.Name = "test_" + Guid.NewGuid().ToString();
            spc.OrganizationGuid = orgGuid;
            var newSpace = client.Spaces.CreateSpace(spc).Result;
            spaceGuid = newSpace.EntityMetadata.Guid;

            stackGuid = client.Stacks.ListAllStacks().Result[0].EntityMetadata.Guid;
        }
示例#2
0
        public static void ClassInit(TestContext context)
        {
            client = TestUtil.GetClient();
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;
            try
            {
                client.Login(credentials).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Error while loging in" + ex.ToString());
            }
            CreateOrganizationRequest org = new CreateOrganizationRequest();
            org.Name = "test_" + Guid.NewGuid().ToString();
            var newOrg = client.Organizations.CreateOrganization(org).Result;
            orgGuid = newOrg.EntityMetadata.Guid;

            CreateSpaceRequest spc = new CreateSpaceRequest();
            spc.Name = "test_" + Guid.NewGuid().ToString();
            spc.OrganizationGuid = orgGuid;
            var newSpace = client.Spaces.CreateSpace(spc).Result;
            spaceGuid = newSpace.EntityMetadata.Guid;

            CreatesSharedDomainDeprecatedRequest r = new CreatesSharedDomainDeprecatedRequest();
            r.Name = Guid.NewGuid().ToString() + ".com";
            r.Wildcard = true;
            domainGuid = client.DomainsDeprecated.CreatesSharedDomainDeprecated(r).Result.EntityMetadata.Guid;
        }
示例#3
0
        public static void ClassInit(TestContext context)
        {
            Directory.CreateDirectory(tempAppPath);

            client = TestUtil.GetClient();
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;
            try
            {
                client.Login(credentials).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Error while logging in" + ex.ToString());
            }

            PagedResponseCollection<ListAllSpacesResponse> spaces = client.Spaces.ListAllSpaces().Result;

            Guid spaceGuid = Guid.Empty;

            foreach (ListAllSpacesResponse space in spaces)
            {
                spaceGuid = space.EntityMetadata.Guid;
                break;
            }

            if (spaceGuid == Guid.Empty)
            {
                throw new Exception("No spaces found");
            }

            PagedResponseCollection<ListAllAppsResponse> apps = client.Apps.ListAllApps().Result;

            foreach (ListAllAppsResponse app in apps)
            {
                if (app.Name.StartsWith("logTest"))
                {
                    client.Apps.DeleteApp(app.EntityMetadata.Guid).Wait();
                    break;
                }
            }

            apprequest = new CreateAppRequest();
            apprequest.Name = "logTest" + Guid.NewGuid().ToString();
            apprequest.Memory = 512;
            apprequest.Instances = 1;
            apprequest.SpaceGuid = spaceGuid;
            apprequest.Buildpack = "https://github.com/ryandotsmith/null-buildpack.git";
            apprequest.EnvironmentJson = new Dictionary<string, string>() { { "env-test-1234", "env-test-value-1234" } };
            apprequest.Command = "export; cat content.txt; sleep 5000;";

            client.Apps.PushProgress += Apps_PushProgress;

            File.WriteAllText(Path.Combine(tempAppPath, "content.txt"), "dummy content");
        }
示例#4
0
 public static void ClassInit(TestContext context)
 {
     client = TestUtil.GetClient();
     CloudCredentials credentials = new CloudCredentials();
     credentials.User = TestUtil.User;
     credentials.Password = TestUtil.Password;
     try
     {
         client.Login(credentials).Wait();
     }
     catch (Exception ex)
     {
         Assert.Fail("Error while loging in" + ex.ToString());
     }
 }
        internal CloudFoundryClient InitClient()
        {
            CloudFoundryClient client = new CloudFoundryClient(new Uri(CFServerUri), new System.Threading.CancellationToken(), null, CFSkipSslValidation);

            if (string.IsNullOrWhiteSpace(CFUser)==false && (string.IsNullOrWhiteSpace(CFPassword) == false || CFSavedPassword))
            {
                if (string.IsNullOrWhiteSpace(CFPassword))
                {
                    this.CFPassword = CloudCredentialsManager.GetPassword(new Uri(this.CFServerUri), this.CFUser);

                    if (string.IsNullOrWhiteSpace(this.CFPassword))
                    {
                        throw new AuthenticationException(
                            string.Format(CultureInfo.InvariantCulture,
                            "Could not find a password for user '{0}' and target '{1}' in your local credentials store. Either make sure the entry exists in your credentials store, or provide CFPassword.",
                            this.CFUser,
                            this.CFServerUri));
                    }
                }

                CloudCredentials creds = new CloudCredentials();
                creds.User = CFUser;
                creds.Password = CFPassword;
                var authContext =  client.Login(creds).Result;
                if (this is LoginTask)
                {
                    if (authContext.Token != null)
                    {
                        ((LoginTask)this).CFRefreshToken = authContext.Token.RefreshToken;
                    }

                }
            }
            else if (string.IsNullOrWhiteSpace(CFRefreshToken) == false)
            {
                client.Login(CFRefreshToken).Wait();
            }
            else
            {
                throw new AuthenticationException("Could not authenticate client without refresh token or credentials.");
            }

            return client;
        }
 internal EnvironmentVariableGroupsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal AppUsageEventsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#8
0
 internal BlobstoresEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal EnvironmentVariableGroupsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal PrivateDomainsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#11
0
 internal SharedDomainsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#12
0
 internal ServiceKeysEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#13
0
 internal RoutesMappingEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal ServiceAuthTokensDeprecatedEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#15
0
 internal ResourceMatchEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal ServiceUsageEventsExperimentalEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal ServicePlanVisibilitiesEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
        internal static PagedResponseCollection <T> DeserializePage <T>(string value, CloudFoundryClient client)
        {
            PagedResponseCollection <T> page = new PagedResponseCollection <T>();

            page.Client     = client;
            page.Properties = JsonConvert.DeserializeObject <PageProperties>(value, jsonSettings);
            page.Resources  = DeserializeJsonResources <T>(value).ToList <T>();
            return(page);
        }
 internal BuildpacksEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#20
0
        public static void ClassInit(TestContext context)
        {
            client = TestUtil.GetClient();
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;
            try
            {
                client.Login(credentials).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Error while loging in" + ex.ToString());
            }

            PagedResponseCollection<ListAllSpacesResponse> spaces = client.Spaces.ListAllSpaces().Result;

            Guid spaceGuid = Guid.Empty;

            foreach (ListAllSpacesResponse space in spaces)
            {
                spaceGuid = space.EntityMetadata.Guid;
                break;
            }

            if (spaceGuid == Guid.Empty)
            {
                throw new Exception("No spaces found");
            }

            PagedResponseCollection<ListAllStacksResponse> stacks = client.Stacks.ListAllStacks().Result;

            var winStack = Guid.Empty;

            foreach (ListAllStacksResponse stack in stacks)
            {
                if (stack.Name == "win2012r2" || stack.Name == "win2012")
                {
                    winStack = stack.EntityMetadata.Guid;
                    break;
                }
            }

            if (winStack == Guid.Empty)
            {
                throw new Exception("Could not test on a deployment without a windows 2012 stack");
            }

            PagedResponseCollection<ListAllAppsResponse> apps = client.Apps.ListAllApps().Result;

            foreach (ListAllAppsResponse app in apps)
            {
                if (app.Name.StartsWith("simplePushTest"))
                {
                    client.Apps.DeleteApp(app.EntityMetadata.Guid).Wait();
                    break;
                }
            }

            apprequest = new CreateAppRequest();
            apprequest.Memory = 512;
            apprequest.Instances = 1;
            apprequest.SpaceGuid = spaceGuid;
            apprequest.StackGuid = winStack;

            client.Apps.PushProgress += Apps_PushProgress;
        }
 internal ResourceMatchEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#22
0
 internal SecurityGroupsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#23
0
 internal AppUsageEventsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
        private void CreateRoute(CloudFoundryClient client, Guid? spaceGuid, List<string> createdGuid, string host, ListAllDomainsDeprecatedResponse domainInfo)
        {
            CreateRouteRequest req = new CreateRouteRequest();
            req.DomainGuid = new Guid(domainInfo.EntityMetadata.Guid);
            req.SpaceGuid = spaceGuid;
            req.Host = host;
            try
            {

                var routes = client.Routes.ListAllRoutes(new RequestOptions() { Query = string.Format(CultureInfo.InvariantCulture, "host:{0}&domain_guid:{1}", host, domainInfo.EntityMetadata.Guid) }).Result;

                if (routes.Count() > 0)
                {
                    ListAllRoutesResponse routeInfo = routes.FirstOrDefault();
                    logger.LogMessage("Route {0}.{1} already exists", routeInfo.Host, routeInfo.DomainUrl);
                    if (routeInfo != null)
                    {
                        createdGuid.Add(routeInfo.EntityMetadata.Guid);
                    }
                }
                else
                {
                    CreateRouteResponse response = client.Routes.CreateRoute(req).Result;
                    createdGuid.Add(response.EntityMetadata.Guid);
                }
            }
            catch (AggregateException ex)
            {
                foreach (Exception e in ex.Flatten().InnerExceptions)
                {
                    if (e is CloudFoundryException)
                    {
                        logger.LogWarning(e.Message);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
示例#25
0
 internal FeatureFlagsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal UserProvidedServiceInstancesEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal DomainsDeprecatedEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
        private bool ValidateServices(CloudFoundryClient client, string CFServices)
        {
            List<ProvisionedService> servicesList = new List<ProvisionedService>();
            try
            {
                string[] provServs = CFServices.Split(';');

                foreach (string service in provServs)
                {
                    if (string.IsNullOrWhiteSpace(service) == false)
                    {
                        string[] serviceInfo = service.Split(',');

                        if (serviceInfo.Length != 3)
                        {
                            logger.LogError("Invalid service information in {0}", service);
                            continue;
                        }

                        ProvisionedService serviceDetails = new ProvisionedService();

                        serviceDetails.Name = serviceInfo[0].Trim();
                        serviceDetails.Type = serviceInfo[1].Trim();
                        serviceDetails.Plan = serviceInfo[2].Trim();

                        servicesList.Add(serviceDetails);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogErrorFromException(ex);
                logger.LogWarning("Error trying to obtain service information, trying to deserialize as xml");
                servicesList = Utils.Deserialize<List<ProvisionedService>>(CFServices);
            }

            foreach (ProvisionedService service in servicesList)
            {
                logger.LogMessage("Validating {0} service {1}", service.Type, service.Name);

                PagedResponseCollection<ListAllServicesResponse> allServicesList = client.Services.ListAllServices(new RequestOptions() { Query = "label:" + service.Type }).Result;

                if (allServicesList.Count() < 1)
                {
                    logger.LogError("Invalid service type {0}", service.Type);
                    return false;
                }

                foreach (var serviceInfo in allServicesList)
                {
                    var planList = client.Services.ListAllServicePlansForService(new Guid(serviceInfo.EntityMetadata.Guid)).Result;

                    var plan = planList.Where(o => o.Name == service.Plan).FirstOrDefault();

                    if (plan != null)
                    {
                        break;
                    }
                    else
                    {
                        logger.LogError("Invalid plan {2} for service {0} - {1}", service.Name, service.Type, service.Plan);
                        return false;
                    }
                }
            }

            return true;
        }
示例#29
0
 internal ServiceAuthTokensDeprecatedEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#30
0
 internal SecurityGroupRunningDefaultsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal ServicePlanVisibilitiesEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#32
0
 internal ServiceUsageEventsExperimentalEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#33
0
 internal DomainsDeprecatedEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#34
0
 internal SpaceQuotaDefinitionsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#35
0
 internal UsersEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#36
0
 internal RoutesEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal SpaceQuotaDefinitionsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#38
0
 internal FeatureFlagsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal OrganizationQuotaDefinitionsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal SharedDomainsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
 internal SecurityGroupRunningDefaultsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#42
0
 internal StacksEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#43
0
 internal UserProvidedServiceInstancesEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#44
0
 internal OrganizationsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#45
0
 internal ServiceBrokersEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#46
0
 internal InfoEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }
示例#47
0
 internal PrivateDomainsEndpoint(CloudFoundryClient client) : base()
 {
     this.Client = client;
 }