Update REST Admin interface to support "Get Mapping(s) as C# Code" (#878)

* Add /__admin/mappings/code endpoint

* api

* fix

* .

* fix

* .

* .

* .
This commit is contained in:
Stef Heyenrath
2023-01-29 10:24:58 +01:00
committed by GitHub
parent 0fc664b404
commit 7fe2c8af78
45 changed files with 900 additions and 448 deletions

View File

@@ -20,7 +20,7 @@ public class LogEntryMapperTests
private static readonly VerifySettings VerifySettings = new();
static LogEntryMapperTests()
{
VerifySettings.Init<LogEntryMapperTests>();
VerifySettings.Init();
}
private readonly IWireMockMiddlewareOptions _options = new WireMockMiddlewareOptions();

View File

@@ -1,10 +1,10 @@
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using FluentAssertions;
using VerifyTests;
using VerifyXunit;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Serialization;
@@ -16,12 +16,10 @@ namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public partial class MappingConverterTests
{
[ModuleInitializer]
public static void ModuleInitializer()
private static readonly VerifySettings VerifySettings = new();
static MappingConverterTests()
{
VerifierSettings.DontScrubGuids();
VerifierSettings.DontScrubDateTimes();
VerifySettings.Init();
}
[Fact]
@@ -41,7 +39,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code);
return Verifier.Verify(code, VerifySettings);
}
[Fact]
@@ -61,7 +59,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code);
return Verifier.Verify(code, VerifySettings);
}
[Fact]
@@ -81,7 +79,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code);
return Verifier.Verify(code, VerifySettings);
}
[Fact]
@@ -101,7 +99,7 @@ public partial class MappingConverterTests
code.Should().NotBeEmpty();
// Verify
return Verifier.Verify(code);
return Verifier.Verify(code, VerifySettings);
}
private Mapping CreateMapping()

View File

@@ -1,12 +1 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Title: ,
Description: ,
Priority: 42,
Request: {},
Response: {
Delay: 1000
},
UseWebhooksFireAndForget: false
}

View File

@@ -0,0 +1,12 @@
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,
Request: {},
Response: {
Delay: 1000
},
UseWebhooksFireAndForget: false
}

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,

View File

@@ -1,5 +1,5 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
Guid: Guid_1,
UpdatedAt: 2022-12-04 11:12:13,
TimeSettings: {
Start: 2023-01-14 15:16:17,

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: my-title,
Description: my-description,
Request: {},

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Request: {},

View File

@@ -1,6 +1,6 @@
{
Guid: c8eeaf99-d5c4-4341-8543-4597c3fd40d9,
UpdatedAt: 2022-12-04 11:12:13,
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Request: {},

View File

@@ -1,11 +1,9 @@
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using VerifyTests;
using VerifyXunit;
using WireMock.Models;
using WireMock.RequestBuilders;
@@ -232,7 +230,7 @@ public partial class MappingConverterTests
model.TimeSettings.TTL.Should().Be(ttl);
// Verify
return Verifier.Verify(model);
return Verifier.Verify(model, VerifySettings);
}
[Fact]
@@ -262,7 +260,7 @@ public partial class MappingConverterTests
}
[Fact]
public Task ToMappingModel_WithDelayAsMilleSeconds_ReturnsCorrectModel()
public Task ToMappingModel_WithDelayAsMilliSeconds_ReturnsCorrectModel()
{
// Assign
var delay = 1000;

View File

@@ -1,5 +1,5 @@
{
Guid: ff55ac0a-fea9-4d7b-be74-5e483a2c1305,
{
Guid: Guid_1,
UpdatedAt: 2022-12-04,
Title: my title,
Description: my description,

View File

@@ -1,11 +1,11 @@
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Moq;
using VerifyTests;
using VerifyXunit;
using WireMock.Matchers;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.RequestBuilders;
using WireMock.Serialization;
using WireMock.Settings;
@@ -17,6 +17,12 @@ namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public class ProxyMappingConverterTests
{
private static readonly VerifySettings VerifySettings = new();
static ProxyMappingConverterTests()
{
VerifySettings.Init();
}
private readonly WireMockServerSettings _settings = new();
private readonly MappingConverter _mappingConverter;
@@ -36,13 +42,6 @@ public class ProxyMappingConverterTests
_sut = new ProxyMappingConverter(_settings, guidUtilsMock.Object, dateTimeUtilsMock.Object);
}
[ModuleInitializer]
public static void ModuleInitializer()
{
VerifierSettings.DontScrubGuids();
VerifierSettings.DontScrubDateTimes();
}
[Fact]
public Task ToMapping_UseDefinedRequestMatchers_True()
{
@@ -77,7 +76,7 @@ public class ProxyMappingConverterTests
var model = _mappingConverter.ToMappingModel(proxyMapping);
// Verify
return Verifier.Verify(model);
return Verifier.Verify(model, VerifySettings);
}
}
#endif

View File

@@ -1,11 +1,11 @@
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using VerifyTests;
using VerifyXunit;
using WireMock.Admin.Mappings;
using WireMock.Models;
using WireMock.Net.Tests.VerifyExtensions;
using WireMock.Serialization;
using WireMock.Types;
using WireMock.Util;
@@ -16,11 +16,10 @@ namespace WireMock.Net.Tests.Serialization;
[UsesVerify]
public class WebhookMapperTests
{
[ModuleInitializer]
public static void ModuleInitializer()
private static readonly VerifySettings VerifySettings = new();
static WebhookMapperTests()
{
VerifierSettings.DontScrubGuids();
VerifierSettings.DontScrubDateTimes();
VerifySettings.Init();
}
[Fact]
@@ -45,7 +44,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result);
return Verifier.Verify(result, VerifySettings);
}
[Fact]
@@ -70,7 +69,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result);
return Verifier.Verify(result, VerifySettings);
}
[Fact]
@@ -97,7 +96,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(model);
// Verify
return Verifier.Verify(result);
return Verifier.Verify(result, VerifySettings);
}
[Fact]
@@ -129,7 +128,7 @@ public class WebhookMapperTests
var result = WebhookMapper.Map(webhook);
// Verify
return Verifier.Verify(result);
return Verifier.Verify(result, VerifySettings);
}
}
#endif