public async Task TestEditCustomHostnameAsync()
        {
            var zone           = ZoneTestData.Zones.First();
            var customHostname = CustomHostnameTestData.CustomHostnames.First();
            var modified       = new ModifiedCustomHostname
            {
                Ssl = SslTestData.Ssls.First().DeepClone()
            };

            modified.Ssl.Settings.Tls13 = FeatureStatus.Off;

            _wireMockServer
            .Given(Request.Create().WithPath($"/{ZoneEndpoints.Base}/{zone.Id}/{CustomHostnameEndpoints.Base}/{customHostname.Id}").UsingPatch())
            .RespondWith(Response.Create().WithStatusCode(200)
                         .WithBody(x =>
            {
                var body     = JsonConvert.DeserializeObject <NewCustomHostname>(x.Body);
                var response = CustomHostnameTestData.CustomHostnames.First(y => y.Id == x.PathSegments[3]).DeepClone();
                response.Ssl = body.Ssl;

                return(WireMockResponseHelper.CreateTestResponse(response));
            }));

            using var client = new CloudFlareClient(WireMockConnection.ApiKeyAuthentication, _connectionInfo);

            var editCustomHostname = await client.Zones.CustomHostnames.UpdateAsync(zone.Id, customHostname.Id, modified);

            editCustomHostname.Result.Should().BeEquivalentTo(customHostname, opt => opt.Excluding(y => y.Ssl.Settings.Tls13));
            editCustomHostname.Result.Ssl.Settings.Tls13.Should().BeEquivalentTo(FeatureStatus.Off);
        }
        public void TestSerialization()
        {
            var sut = new ModifiedCustomHostname();

            JsonHelper.GetSerializedKeys(sut).Should().BeEquivalentTo(new SortedSet <string> {
                "ssl", "custom_origin_server", "custom_metadata"
            });
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public async Task <CloudFlareResult <CustomHostname> > UpdateAsync(string zoneId, string customHostnameId, ModifiedCustomHostname modifiedCustomHostname, CancellationToken cancellationToken = default)
        {
            var requestUri = $"{ZoneEndpoints.Base}/{zoneId}/{CustomHostnameEndpoints.Base}/{customHostnameId}";

            return(await Connection.PatchAsync <CustomHostname, ModifiedCustomHostname>(requestUri, modifiedCustomHostname, cancellationToken).ConfigureAwait(false));
        }