Exemplo n.º 1
0
        public void TestLockOrUnlockBuildpackRequest()
        {
            string json = @"{
  ""locked"": true
}";

            LockOrUnlockBuildpackRequest request = new LockOrUnlockBuildpackRequest();

            request.Locked = true;
            string result = JsonConvert.SerializeObject(request, Formatting.None);
            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
Exemplo n.º 2
0
        public void TestLockOrUnlockBuildpackRequest()
        {
            string json = @"{
  ""locked"": true
}";

            LockOrUnlockBuildpackRequest request = new LockOrUnlockBuildpackRequest();

            request.Locked = true;
            string result = JsonConvert.SerializeObject(request, Formatting.None);

            Assert.AreEqual(TestUtil.ToUnformatedJsonString(json), result);
        }
        public void LockOrUnlockBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""fd1965ac-0ff8-4e6e-8a86-bd0cae7128b8"",
    ""url"": ""/v2/buildpacks/fd1965ac-0ff8-4e6e-8a86-bd0cae7128b8"",
    ""created_at"": ""2015-04-16T12:04:19+00:00"",
    ""updated_at"": ""2015-04-16T12:04:19+00:00""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": true,
    ""locked"": true,
    ""filename"": ""name-251""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                LockOrUnlockBuildpackRequest value = new LockOrUnlockBuildpackRequest();


                var obj = cfClient.Buildpacks.LockOrUnlockBuildpack(guid, value).Result;


                Assert.AreEqual("fd1965ac-0ff8-4e6e-8a86-bd0cae7128b8", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/fd1965ac-0ff8-4e6e-8a86-bd0cae7128b8", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-04-16T12:04:19+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2015-04-16T12:04:19+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-251", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
Exemplo n.º 4
0
        public void LockOrUnlockBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""cb52394e-1eae-424c-92d9-4c5916bf6ae8"",
    ""url"": ""/v2/buildpacks/cb52394e-1eae-424c-92d9-4c5916bf6ae8"",
    ""created_at"": ""2016-02-09T10:21:42Z"",
    ""updated_at"": ""2016-02-09T10:21:42Z""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": true,
    ""locked"": true,
    ""filename"": ""name-137""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                LockOrUnlockBuildpackRequest value = new LockOrUnlockBuildpackRequest();


                var obj = cfClient.Buildpacks.LockOrUnlockBuildpack(guid, value).Result;


                Assert.AreEqual("cb52394e-1eae-424c-92d9-4c5916bf6ae8", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/cb52394e-1eae-424c-92d9-4c5916bf6ae8", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-02-09T10:21:42Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-02-09T10:21:42Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-137", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
Exemplo n.º 5
0
        public void LockOrUnlockBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""84605e49-21ef-4f1e-b64c-bc1088ed159b"",
    ""url"": ""/v2/buildpacks/2384415c-855d-4b60-a332-27ad854b1aa6"",
    ""created_at"": ""2016-09-02T11:52:12Z"",
    ""updated_at"": ""2016-09-02T11:52:12Z""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": true,
    ""locked"": true,
    ""filename"": ""name-872""
  }
}";
                clients.JsonResponse = json;

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

                Guid?guid = Guid.NewGuid();

                LockOrUnlockBuildpackRequest value = new LockOrUnlockBuildpackRequest();


                var obj = cfClient.Buildpacks.LockOrUnlockBuildpack(guid, value).Result;


                Assert.AreEqual("84605e49-21ef-4f1e-b64c-bc1088ed159b", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/2384415c-855d-4b60-a332-27ad854b1aa6", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2016-09-02T11:52:12Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2016-09-02T11:52:12Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-872", TestUtil.ToTestableString(obj.Filename), true);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Lock or unlock a Buildpack
 /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/lock_or_unlock_a_buildpack.html"</para>
 /// </summary>
 public async Task<LockOrUnlockBuildpackResponse> LockOrUnlockBuildpack(Guid? guid, LockOrUnlockBuildpackRequest value)
 {
     UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);
     uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/buildpacks/{0}", guid);
     var client = this.GetHttpClient();
     client.Uri = uriBuilder.Uri;
     client.Method = HttpMethod.Put;
     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<LockOrUnlockBuildpackResponse>(await response.ReadContentAsStringAsync());
 }
Exemplo n.º 7
0
        /// <summary>
        /// Lock or unlock a Buildpack
        /// <para>For detailed information, see online documentation at: "http://apidocs.cloudfoundry.org/195/buildpacks/lock_or_unlock_a_buildpack.html"</para>
        /// </summary>
        public async Task <LockOrUnlockBuildpackResponse> LockOrUnlockBuildpack(Guid?guid, LockOrUnlockBuildpackRequest value)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            uriBuilder.Path = string.Format(CultureInfo.InvariantCulture, "/v2/buildpacks/{0}", guid);
            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Put;
            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 <LockOrUnlockBuildpackResponse>(await response.ReadContentAsStringAsync()));
        }
Exemplo n.º 8
0
        public void LockOrUnlockBuildpackTest()
        {
            using (ShimsContext.Create())
            {
                MockClients clients = new MockClients();

                string json = @"{
  ""metadata"": {
    ""guid"": ""c41f5fe4-c689-4f46-9897-398bd9370a96"",
    ""url"": ""/v2/buildpacks/c41f5fe4-c689-4f46-9897-398bd9370a96"",
    ""created_at"": ""2015-05-19T15:27:21+00:00"",
    ""updated_at"": ""2015-05-19T15:27:21+00:00""
  },
  ""entity"": {
    ""name"": ""name_1"",
    ""position"": 1,
    ""enabled"": true,
    ""locked"": true,
    ""filename"": ""name-1686""
  }
}";
                clients.JsonResponse = json;

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

                Guid? guid = Guid.NewGuid();

                LockOrUnlockBuildpackRequest value = new LockOrUnlockBuildpackRequest();


                var obj = cfClient.Buildpacks.LockOrUnlockBuildpack(guid, value).Result;


                Assert.AreEqual("c41f5fe4-c689-4f46-9897-398bd9370a96", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
                Assert.AreEqual("/v2/buildpacks/c41f5fe4-c689-4f46-9897-398bd9370a96", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
                Assert.AreEqual("2015-05-19T15:27:21+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
                Assert.AreEqual("2015-05-19T15:27:21+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
                Assert.AreEqual("name_1", TestUtil.ToTestableString(obj.Name), true);
                Assert.AreEqual("1", TestUtil.ToTestableString(obj.Position), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Enabled), true);
                Assert.AreEqual("true", TestUtil.ToTestableString(obj.Locked), true);
                Assert.AreEqual("name-1686", TestUtil.ToTestableString(obj.Filename), true);

            }
        }