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;
        }
        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;
        }
Example #3
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;
        }
        public void Spaces_test()
        {
            CreateSpaceResponse     newSpace     = null;
            UpdateSpaceResponse     updatedSpace = null;
            GetSpaceSummaryResponse spaceSummary = null;
            CreateSpaceRequest      spc          = new CreateSpaceRequest();

            spc.Name             = "test_" + Guid.NewGuid().ToString();
            spc.OrganizationGuid = orgGuid;

            try
            {
                newSpace = client.Spaces.CreateSpace(spc).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while creating space: {0}", ex.ToString());
            }
            Assert.IsNotNull(newSpace);

            try
            {
                spaceSummary = client.Spaces.GetSpaceSummary(newSpace.EntityMetadata.Guid).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while reading space: {0}", ex.ToString());
            }
            Assert.IsNotNull(spaceSummary);

            UpdateSpaceRequest sr = new UpdateSpaceRequest();

            sr.Name = "new_name_" + Guid.NewGuid().ToString();

            try
            {
                updatedSpace = client.Spaces.UpdateSpace(newSpace.EntityMetadata.Guid, sr).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while updating space: {0}", ex.ToString());
            }
            Assert.IsNotNull(updatedSpace);
            Assert.AreEqual(sr.Name, updatedSpace.Name);

            try
            {
                client.Spaces.DeleteSpace(newSpace.EntityMetadata.Guid).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while deleting space: {0}", ex.ToString());
            }
        }
Example #5
0
        public void Spaces_test()
        {
            CreateSpaceResponse newSpace = null;
            UpdateSpaceResponse updatedSpace = null;
            GetSpaceSummaryResponse spaceSummary = null;
            CreateSpaceRequest spc = new CreateSpaceRequest();
            spc.Name = "test_" + Guid.NewGuid().ToString();
            spc.OrganizationGuid = orgGuid;

            try
            {
                newSpace = client.Spaces.CreateSpace(spc).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while creating space: {0}", ex.ToString());
            }
            Assert.IsNotNull(newSpace);

            try
            {
                spaceSummary = client.Spaces.GetSpaceSummary(newSpace.EntityMetadata.Guid).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while reading space: {0}", ex.ToString());
            }
            Assert.IsNotNull(spaceSummary);

            UpdateSpaceRequest sr = new UpdateSpaceRequest();
            sr.Name = "new_name_" + Guid.NewGuid().ToString();

            try
            {
                updatedSpace = client.Spaces.UpdateSpace(newSpace.EntityMetadata.Guid, sr).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while updating space: {0}", ex.ToString());
            }
            Assert.IsNotNull(updatedSpace);
            Assert.AreEqual(sr.Name, updatedSpace.Name);

            try
            {
                client.Spaces.DeleteSpace(newSpace.EntityMetadata.Guid).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while deleting space: {0}", ex.ToString());
            }
        }
Example #6
0
        public void TestCreateSpaceRequest()
        {
            string json = @"{
  ""name"": ""development"",
  ""organization_guid"": ""df7cbf3b-1933-4deb-ae48-16457b60f772""
}";

            CreateSpaceRequest request = new CreateSpaceRequest();

            request.Name = "development";
            request.OrganizationGuid = new Guid("df7cbf3b-1933-4deb-ae48-16457b60f772");
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Example #7
0
        public void TestCreateSpaceRequest()
        {
            string json = @"{
  ""name"": ""development"",
  ""organization_guid"": ""9e56d5e5-95bf-40a0-bf7c-8ebc278f2bf4""
}";

            CreateSpaceRequest request = new CreateSpaceRequest();

            request.Name             = "development";
            request.OrganizationGuid = new Guid("9e56d5e5-95bf-40a0-bf7c-8ebc278f2bf4");
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Example #8
0
        public void TestCreateSpaceRequest()
        {
            string json = @"{
  ""name"": ""development"",
  ""organization_guid"": ""2028c684-827a-4eb8-a233-2bc624b92af1""
}";

            CreateSpaceRequest request = new CreateSpaceRequest();

            request.Name             = "development";
            request.OrganizationGuid = new Guid("2028c684-827a-4eb8-a233-2bc624b92af1");
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Example #9
0
        public void TestCreateSpaceRequest()
        {
            string json = @"{
  ""name"": ""development"",
  ""organization_guid"": ""f34d7b8f-6aa6-4af4-9056-6f40e3de9c16""
}";

            CreateSpaceRequest request = new CreateSpaceRequest();

            request.Name             = "development";
            request.OrganizationGuid = new Guid("f34d7b8f-6aa6-4af4-9056-6f40e3de9c16");
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        /// <summary>
        /// Creating a Space
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/250/spaces/creating_a_space.html"</para>
        /// </summary>
        public async Task <CreateSpaceResponse> CreateSpace(CreateSpaceRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = "/v2/spaces";
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Post;


            client.Content = ((string)JsonConvert.SerializeObject(value)).ConvertToStream();
            var expectedReturnStatus = 201;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <CreateSpaceResponse>(await response.Content.ReadAsStringAsync()));
        }
Example #11
0
        /// <summary>
        /// Creating a Space
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/spaces/creating_a_space.html"</para>
        /// </summary>
        public async Task <CreateSpaceResponse> CreateSpace(CreateSpaceRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = "/v2/spaces";
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Post;
            client.Headers.Add(await BuildAuthenticationHeader());
            client.ContentType = "application/x-www-form-urlencoded";
            client.Content     = JsonConvert.SerializeObject(value).ConvertToStream();
            var expectedReturnStatus = 201;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <CreateSpaceResponse>(await response.ReadContentAsStringAsync()));
        }
Example #12
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;
        }
Example #13
0
 /// <summary>
 /// Creating a Space
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/spaces/creating_a_space.html"</para>
 /// </summary>
 public async Task<CreateSpaceResponse> CreateSpace(CreateSpaceRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = "/v2/spaces";
     var client = this.GetHttpClient();
     client.Uri = uriBuilder.Uri;
     client.Method = HttpMethod.Post;
     var authHeader = await BuildAuthenticationHeader();
     if (!string.IsNullOrWhiteSpace(authHeader.Key))
     {
         client.Headers.Add(authHeader);
     }
     client.ContentType = "application/x-www-form-urlencoded";
     client.Content = JsonConvert.SerializeObject(value).ConvertToStream();
     var expectedReturnStatus = 201;
     var response = await this.SendAsync(client, expectedReturnStatus);
     return Utilities.DeserializeJson<CreateSpaceResponse>(await response.ReadContentAsStringAsync());
 }
Example #14
0
        public void CreateSpaceTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""bc34f67b-742f-4c95-ba35-6339b4856911"",
    ""url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911"",
    ""created_at"": ""2015-05-19T15:27:11+00:00"",
    ""updated_at"": null
  },
  ""entity"": {
    ""name"": ""development"",
    ""organization_guid"": ""df7cbf3b-1933-4deb-ae48-16457b60f772"",
    ""space_quota_definition_guid"": null,
    ""organization_url"": ""/v2/organizations/df7cbf3b-1933-4deb-ae48-16457b60f772"",
    ""developers_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/developers"",
    ""managers_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/managers"",
    ""auditors_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/auditors"",
    ""apps_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/apps"",
    ""routes_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/routes"",
    ""domains_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/domains"",
    ""service_instances_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/service_instances"",
    ""app_events_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/app_events"",
    ""events_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/events"",
    ""security_groups_url"": ""/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/security_groups""
  }
}";
                clients.JsonResponse = json;

                clients.ExpectedStatusCode = (HttpStatusCode)201;
                var cfClient = clients.CreateCloudFoundryClient();

                CreateSpaceRequest value = new CreateSpaceRequest();


                var obj = cfClient.Spaces.CreateSpace(value).Result;


                Assert.AreEqual("bc34f67b-742f-4c95-ba35-6339b4856911", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-05-19T15:27:11+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("development", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("df7cbf3b-1933-4deb-ae48-16457b60f772", TestUtil.ToTestableString(obj.OrganizationGuid), true);
                Assert.AreEqual("", TestUtil.ToTestableString(obj.SpaceQuotaDefinitionGuid), true);
                Assert.AreEqual("/v2/organizations/df7cbf3b-1933-4deb-ae48-16457b60f772", TestUtil.ToTestableString(obj.OrganizationUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/developers", TestUtil.ToTestableString(obj.DevelopersUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/managers", TestUtil.ToTestableString(obj.ManagersUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/auditors", TestUtil.ToTestableString(obj.AuditorsUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/routes", TestUtil.ToTestableString(obj.RoutesUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/domains", TestUtil.ToTestableString(obj.DomainsUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/service_instances", TestUtil.ToTestableString(obj.ServiceInstancesUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/app_events", TestUtil.ToTestableString(obj.AppEventsUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/events", TestUtil.ToTestableString(obj.EventsUrl), true);
                Assert.AreEqual("/v2/spaces/bc34f67b-742f-4c95-ba35-6339b4856911/security_groups", TestUtil.ToTestableString(obj.SecurityGroupsUrl), true);

            }
        }