diff --git a/WireMock.Net Solution.sln b/WireMock.Net Solution.sln index 0692eae1b..8fabcff04 100644 --- a/WireMock.Net Solution.sln +++ b/WireMock.Net Solution.sln @@ -36,8 +36,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp3", "examples\WireMock.Net.Console.NETCoreApp3\WireMock.Net.Console.NETCoreApp3.csproj", "{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp2", "examples\WireMock.Net.Console.Proxy.NETCoreApp2\WireMock.Net.Console.Proxy.NETCoreApp2.csproj", "{41C19451-E980-4ED4-A011-DA7A1C23FC05}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Client", "examples\WireMock.Net.Client\WireMock.Net.Client.csproj", "{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp", "examples\WireMock.Net.Console.NETCoreApp\WireMock.Net.Console.NETCoreApp.csproj", "{FE281639-B014-4C8A-96FA-141164A74713}" @@ -50,8 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net461 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net452.Classic", "examples\WireMock.Net.Console.Net452.Classic\WireMock.Net.Console.Net452.Classic.csproj", "{668F689E-57B4-422E-8846-C0FF643CA268}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp2", "examples\WireMock.Net.Console.NETCoreApp2\WireMock.Net.Console.NETCoreApp2.csproj", "{83645809-9E01-4E81-8733-BA9497554ABF}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.RequestLogTest", "examples\WireMock.Net.Console.RequestLogTest\WireMock.Net.Console.RequestLogTest.csproj", "{A9D039B9-7509-4CF1-9EFD-87EB82998575}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser", "src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj", "{D3804228-91F4-4502-9595-39584E5AADAD}" @@ -60,8 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication.NETCore2\WireMock.Net.WebApplication.NETCore2.csproj", "{6F38CB3A-6DA1-408A-AECD-E434523C2838}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore3", "examples\WireMock.Net.WebApplication.NETCore3\WireMock.Net.WebApplication.NETCore3.csproj", "{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp3WithCertificate", "examples\WireMock.Net.Console.NETCoreApp3WithCertificate\WireMock.Net.Console.NETCoreApp3WithCertificate.csproj", "{925E421A-1B3F-4202-B48F-734743573A4B}" @@ -104,8 +98,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET6.W EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueExample", "examples\WireMockAzureQueueExample\WireMockAzureQueueExample.csproj", "{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueProxy", "examples\WireMockAzureQueueProxy\WireMockAzureQueueProxy.csproj", "{ADB557D8-D66B-4387-912B-3F73E290B478}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Testcontainers", "src\WireMock.Net.Testcontainers\WireMock.Net.Testcontainers.csproj", "{12B016A5-9D8B-4EFE-96C2-CA51BE43367D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.TestcontainersExample", "examples\WireMock.Net.TestcontainersExample\WireMock.Net.TestcontainersExample.csproj", "{56A38798-C48B-4A4A-B805-071E05C02CE1}" @@ -118,6 +110,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.NET7.U EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET8", "examples\WireMock.Net.Console.NET8\WireMock.Net.Console.NET8.csproj", "{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueProxy", "examples\WireMockAzureQueueProxy\WireMockAzureQueueProxy.csproj", "{7FC0B409-2682-40EE-B3B9-3930D6769D01}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -148,10 +142,6 @@ Global {8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.Build.0 = Release|Any CPU - {41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.Build.0 = Release|Any CPU {74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -176,10 +166,6 @@ Global {668F689E-57B4-422E-8846-C0FF643CA268}.Debug|Any CPU.Build.0 = Debug|Any CPU {668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.ActiveCfg = Release|Any CPU {668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.Build.0 = Release|Any CPU - {83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.Build.0 = Release|Any CPU {A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.Build.0 = Debug|Any CPU {A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -196,10 +182,6 @@ Global {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU - {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.Build.0 = Release|Any CPU {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -256,10 +238,6 @@ Global {BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Release|Any CPU.Build.0 = Release|Any CPU - {ADB557D8-D66B-4387-912B-3F73E290B478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ADB557D8-D66B-4387-912B-3F73E290B478}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ADB557D8-D66B-4387-912B-3F73E290B478}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ADB557D8-D66B-4387-912B-3F73E290B478}.Release|Any CPU.Build.0 = Release|Any CPU {12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Debug|Any CPU.Build.0 = Debug|Any CPU {12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -280,6 +258,10 @@ Global {1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.Build.0 = Release|Any CPU + {7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FC0B409-2682-40EE-B3B9-3930D6769D01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FC0B409-2682-40EE-B3B9-3930D6769D01}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -291,19 +273,16 @@ Global {B6269AAC-170A-43D5-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {31DC2EF8-C3FE-467D-84BE-FB5D956E612E} = {0BB8B634-407A-4610-A91F-11586990767A} {8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5} = {985E0ADB-D4B4-473A-AA40-567E279B7946} - {41C19451-E980-4ED4-A011-DA7A1C23FC05} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {74D91AD0-D96D-4FD2-AEC5-CC49D38346C0} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {FE281639-B014-4C8A-96FA-141164A74713} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {1261BB9B-A7D4-456C-8985-3CE560361B8E} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {668F689E-57B4-422E-8846-C0FF643CA268} = {985E0ADB-D4B4-473A-AA40-567E279B7946} - {83645809-9E01-4E81-8733-BA9497554ABF} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {A9D039B9-7509-4CF1-9EFD-87EB82998575} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} - {6F38CB3A-6DA1-408A-AECD-E434523C2838} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {E1C56967-3DC7-46CB-A1DF-B13167A0D9D4} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {925E421A-1B3F-4202-B48F-734743573A4B} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {40BF24B5-12E6-4610-9489-138798632E28} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} @@ -320,12 +299,12 @@ Global {0DE0954F-8C00-4E8D-B94A-4361FC1CBE44} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {7C2A9DE8-C89F-4841-9058-6B9BF81E5E34} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {BAA9EC2A-874B-45CE-8E51-A73622DC7F3D} = {985E0ADB-D4B4-473A-AA40-567E279B7946} - {ADB557D8-D66B-4387-912B-3F73E290B478} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {12B016A5-9D8B-4EFE-96C2-CA51BE43367D} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2} {56A38798-C48B-4A4A-B805-071E05C02CE1} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {07C30227-ADEC-4BDE-8CDC-849D85A690BB} = {0147029F-FA4A-44B3-B79A-3C3574054EE4} {941229D6-191B-4B5E-AC81-0905EBF4F19D} = {985E0ADB-D4B4-473A-AA40-567E279B7946} {1EA72C0F-92E9-486B-8FFE-53F992BFC4AA} = {985E0ADB-D4B4-473A-AA40-567E279B7946} + {7FC0B409-2682-40EE-B3B9-3930D6769D01} = {985E0ADB-D4B4-473A-AA40-567E279B7946} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458} diff --git a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj index 600bcdc7f..bf5ea660b 100644 --- a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj +++ b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj @@ -28,7 +28,6 @@ - diff --git a/examples/WireMock.Net.Console.NET7.UsingNuGet/WireMock.Net.Console.NET7.UsingNuGet.csproj b/examples/WireMock.Net.Console.NET7.UsingNuGet/WireMock.Net.Console.NET7.UsingNuGet.csproj index f18680d9e..092f1b035 100644 --- a/examples/WireMock.Net.Console.NET7.UsingNuGet/WireMock.Net.Console.NET7.UsingNuGet.csproj +++ b/examples/WireMock.Net.Console.NET7.UsingNuGet/WireMock.Net.Console.NET7.UsingNuGet.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj index 2267f5cf6..fdba0459d 100644 --- a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj @@ -19,12 +19,12 @@ - - - - - - + diff --git a/examples/WireMock.Net.Console.NETCoreApp2/Program.cs b/examples/WireMock.Net.Console.NETCoreApp2/Program.cs deleted file mode 100644 index 36f574708..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/Program.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.IO; -using System.Linq; -using System.Reflection; -using log4net; -using log4net.Config; -using log4net.Repository; -using WireMock.Net.ConsoleApplication; - -namespace WireMock.Net.Console.NETCoreApp2 -{ - static class Program - { - private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); - private static readonly ILog Log = LogManager.GetLogger(typeof(Program)); - - static void Main(params string[] args) - { - XmlConfigurator.Configure(LogRepository, new FileInfo("log4net.config")); - - foreach (var file in Directory.GetFiles("__admin").Where(f => !f.StartsWith("wiremock"))) - { - File.Delete(file); - } - - MainApp.Run(); - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj b/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj deleted file mode 100644 index 7e86155b6..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Exe - netcoreapp2.1 - ../../resources/WireMock.Net-Logo.ico - - - - - - - - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - Never - - - PreserveNewest - - - PreserveNewest - - - - \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/1.cs b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/1.cs deleted file mode 100644 index c8143e099..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/1.cs +++ /dev/null @@ -1 +0,0 @@ -// C# Hello \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json deleted file mode 100644 index 9c761369d..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/11111110-a633-40e8-a244-5cb80bc0ab66.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Request": { - "Path": { - "Matchers": [ - { - "Name": "WildcardMatcher", - "Pattern": "/static/mapping" - } - ] - }, - "Methods": [ - "get" - ] - }, - "Response": { - "BodyAsJson": { "body": "static mapping" }, - "Headers": { - "Content-Type": "application/json", - "Test-X": [ "test 1", "test 2" ] - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json deleted file mode 100644 index d7a6cbdd7..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/791a3f31-6946-4ce7-8e6f-0237c7443275.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "Guid": "791a3f31-6946-4ce7-8e6f-0237c7443275", - "Title": "", - "Priority": 0, - "Request": { - "Path": "/proxy-google-test-post", - "Methods": [ - "post" - ], - "Body": {} - }, - "Response": { - "StatusCode": 404, - "Body": "\n\n \n \n Error 404 (Not Found)!!1\n \n \n

404. That’s an error.\n

The requested URL /proxy-google-test-post was not found on this server. That’s all we know.\n", - "BodyAsBytes": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+CiAgPG1ldGEgY2hhcnNldD11dGYtOD4KICA8bWV0YSBuYW1lPXZpZXdwb3J0IGNvbnRlbnQ9ImluaXRpYWwtc2NhbGU9MSwgbWluaW11bS1zY2FsZT0xLCB3aWR0aD1kZXZpY2Utd2lkdGgiPgogIDx0aXRsZT5FcnJvciA0MDQgKE5vdCBGb3VuZCkhITE8L3RpdGxlPgogIDxzdHlsZT4KICAgICp7bWFyZ2luOjA7cGFkZGluZzowfWh0bWwsY29kZXtmb250OjE1cHgvMjJweCBhcmlhbCxzYW5zLXNlcmlmfWh0bWx7YmFja2dyb3VuZDojZmZmO2NvbG9yOiMyMjI7cGFkZGluZzoxNXB4fWJvZHl7bWFyZ2luOjclIGF1dG8gMDttYXgtd2lkdGg6MzkwcHg7bWluLWhlaWdodDoxODBweDtwYWRkaW5nOjMwcHggMCAxNXB4fSogPiBib2R5e2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2Vycm9ycy9yb2JvdC5wbmcpIDEwMCUgNXB4IG5vLXJlcGVhdDtwYWRkaW5nLXJpZ2h0OjIwNXB4fXB7bWFyZ2luOjExcHggMCAyMnB4O292ZXJmbG93OmhpZGRlbn1pbnN7Y29sb3I6Izc3Nzt0ZXh0LWRlY29yYXRpb246bm9uZX1hIGltZ3tib3JkZXI6MH1AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOjc3MnB4KXtib2R5e2JhY2tncm91bmQ6bm9uZTttYXJnaW4tdG9wOjA7bWF4LXdpZHRoOm5vbmU7cGFkZGluZy1yaWdodDowfX0jbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzF4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7bWFyZ2luLWxlZnQ6LTVweH1AbWVkaWEgb25seSBzY3JlZW4gYW5kIChtaW4tcmVzb2x1dGlvbjoxOTJkcGkpeyNsb2dve2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIG5vLXJlcGVhdCAwJSAwJS8xMDAlIDEwMCU7LW1vei1ib3JkZXItaW1hZ2U6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIDB9fUBtZWRpYSBvbmx5IHNjcmVlbiBhbmQgKC13ZWJraXQtbWluLWRldmljZS1waXhlbC1yYXRpbzoyKXsjbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzJ4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7LXdlYmtpdC1iYWNrZ3JvdW5kLXNpemU6MTAwJSAxMDAlfX0jbG9nb3tkaXNwbGF5OmlubGluZS1ibG9jaztoZWlnaHQ6NTRweDt3aWR0aDoxNTBweH0KICA8L3N0eWxlPgogIDxhIGhyZWY9Ly93d3cuZ29vZ2xlLmNvbS8+PHNwYW4gaWQ9bG9nbyBhcmlhLWxhYmVsPUdvb2dsZT48L3NwYW4+PC9hPgogIDxwPjxiPjQwNC48L2I+IDxpbnM+VGhhdOKAmXMgYW4gZXJyb3IuPC9pbnM+CiAgPHA+VGhlIHJlcXVlc3RlZCBVUkwgPGNvZGU+L3Byb3h5LWdvb2dsZS10ZXN0LXBvc3Q8L2NvZGU+IHdhcyBub3QgZm91bmQgb24gdGhpcyBzZXJ2ZXIuICA8aW5zPlRoYXTigJlzIGFsbCB3ZSBrbm93LjwvaW5zPgo=", - "BodyEncoding": { - "CodePage": 65001, - "EncodingName": "Unicode (UTF-8)", - "WebName": "utf-8" - }, - "UseTransformer": false, - "Headers": { - "Date": "Wed, 27 Oct 2017 18:57:40 GMT", - "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"39,38,37,35\"", - "Referrer-Policy": "no-referrer", - "Connection": "close" - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json deleted file mode 100644 index dd5018000..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/873d495f-940e-4b86-a1f4-4f0fc7be8b8b.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Guid": "873d495f-940e-4b86-a1f4-4f0fc7be8b8b", - "Priority": 4, - "Request": { - "Path": {}, - "Methods": [ - "get" - ] - }, - "Response": { - "StatusCode": 200, - "BodyDestination": "SameAsSource", - "Body": "NO PATH OR URL", - "UseTransformer": false, - "Headers": { - "Content-Type": "application/json" - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/BodyAsFileExample.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/BodyAsFileExample.json deleted file mode 100644 index 633db99eb..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/BodyAsFileExample.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Request": { - "Path": { - "Matchers": [ - { - "Name": "WildcardMatcher", - "Pattern": "/bodyasfilexmltest", - "IgnoreCase": false - } - ] - }, - "Methods": [ - "get" - ] - }, - "Response": { - "StatusCode": 200, - "Headers": {"Content-Type": "application/xml"}, - "BodyAsFile": "MyXmlResponse.xml", - "UseTransformer": false - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/MyXmlResponse.xml b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/MyXmlResponse.xml deleted file mode 100644 index 24fd28d33..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/MyXmlResponse.xml +++ /dev/null @@ -1,3 +0,0 @@ - -world - \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/array.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/array.json deleted file mode 100644 index 79f338ae7..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/array.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "Title": "1", - "Request": { - "Path": { - "Matchers": [ - { - "Name": "WildcardMatcher", - "Pattern": "/mappings_static_1" - } - ] - }, - "Methods": [ - "get" - ] - }, - "Response": { - "BodyAsJson": { "result": "mappings static_1" }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Title": "2", - "Request": { - "Path": { - "Matchers": [ - { - "Name": "WildcardMatcher", - "Pattern": "/mappings_static_2" - } - ] - }, - "Methods": [ - "get" - ] - }, - "Response": { - "BodyAsJson": { "result": "mappings static_2" }, - "Headers": { - "Content-Type": "application/json" - } - } - } -] \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/wiremock-petstore-openapi3.json b/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/wiremock-petstore-openapi3.json deleted file mode 100644 index e80050758..000000000 --- a/examples/WireMock.Net.Console.NETCoreApp2/__admin/mappings/wiremock-petstore-openapi3.json +++ /dev/null @@ -1,602 +0,0 @@ -[ - { - "Guid": "9d2fde55-e420-4724-bf40-616e8aeaf53e", - "Request": { - "Path": "/pet", - "Methods": [ - "PUT" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": "example-string", - "tags": "example-string", - "status": "example-string" - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "1f7acffa-05f4-4640-bda4-4c71c8d5e6e3", - "Request": { - "Path": "/pet", - "Methods": [ - "POST" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": "example-string", - "tags": "example-string", - "status": "example-string" - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "a04ed51d-ad5b-4c69-b22f-d0eaeea18bc1", - "Request": { - "Path": "/pet/findByStatus", - "Methods": [ - "GET" - ], - "Params": [ - { - "Name": "status", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - } - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": [ - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - }, - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - }, - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - } - ], - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "8d5df48a-05fb-4861-816f-3f77adf5562f", - "Request": { - "Path": "/pet/findByTags", - "Methods": [ - "GET" - ], - "Params": [ - { - "Name": "tags", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - } - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": [ - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - }, - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - }, - { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": [ - "example-string", - "example-string", - "example-string" - ], - "tags": [ - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - }, - { - "id": 42, - "name": "example-string" - } - ], - "status": "example-string" - } - ], - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "065f790b-125c-419e-8fbd-3616bf09b142", - "Request": { - "Path": "/pet/42", - "Methods": [ - "GET" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "name": "example-string", - "category": { - "id": 42, - "name": "example-string" - }, - "photoUrls": "example-string", - "tags": "example-string", - "status": "example-string" - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "737aaddd-5bab-489d-914b-deb4ba773539", - "Request": { - "Path": "/pet/42", - "Methods": [ - "POST" - ], - "Params": [ - { - "Name": "name", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - }, - { - "Name": "status", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - } - ] - }, - "Response": { - "StatusCode": 200 - } - }, - { - "Guid": "0619896c-c3b3-4a30-903e-59792134898c", - "Request": { - "Path": "/pet/42", - "Methods": [ - "DELETE" - ] - }, - "Response": { - "StatusCode": 200 - } - }, - { - "Guid": "9aaa6a6d-ca4b-4da3-8a9a-844e3af02272", - "Request": { - "Path": "/pet/42/uploadImage", - "Methods": [ - "POST" - ], - "Params": [ - { - "Name": "additionalMetadata", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - } - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "code": 42, - "type": "example-string", - "message": "example-string" - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "085ef9c2-425d-45c2-9311-d3e4697c407f", - "Request": { - "Path": "/store/inventory", - "Methods": [ - "GET" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": {}, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "a68c50e9-418c-45e7-8340-c0426cf5b87c", - "Request": { - "Path": "/store/order", - "Methods": [ - "POST" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "petId": 42, - "quantity": 42, - "shipDate": "2020-06-16T12:54:18.885+00:00", - "status": "example-string", - "complete": true - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "16061ffc-97a5-4419-874f-66d857998f76", - "Request": { - "Path": "/store/order/42", - "Methods": [ - "GET" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "petId": 42, - "quantity": 42, - "shipDate": "2020-06-16T12:54:18.887+00:00", - "status": "example-string", - "complete": true - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "55c071d3-eeb5-4a9c-8692-486585e45e2e", - "Request": { - "Path": "/store/order/42", - "Methods": [ - "DELETE" - ] - }, - "Response": { - "StatusCode": 200 - } - }, - { - "Guid": "2d9d895d-58e9-4734-92f4-903e2b364dda", - "Request": { - "Path": "/user", - "Methods": [ - "POST" - ] - }, - "Response": { - "StatusCode": 0, - "BodyAsJson": { - "id": 42, - "username": "example-string", - "firstName": "example-string", - "lastName": "example-string", - "email": "example-string", - "password": "example-string", - "phone": "example-string", - "userStatus": 42 - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "c17eeba0-da58-4128-9ae6-33a6a31971e2", - "Request": { - "Path": "/user/createWithList", - "Methods": [ - "POST" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "username": "example-string", - "firstName": "example-string", - "lastName": "example-string", - "email": "example-string", - "password": "example-string", - "phone": "example-string", - "userStatus": 42 - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "c95da645-9449-438e-a8c8-0278ea514558", - "Request": { - "Path": "/user/login", - "Methods": [ - "GET" - ], - "Params": [ - { - "Name": "username", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - }, - { - "Name": "password", - "Matchers": [ - { - "Name": "ExactMatcher", - "Pattern": "example-string" - } - ] - } - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": "example-string", - "Headers": { - "X-Rate-Limit": "example-string", - "X-Expires-After": "example-string", - "Content-Type": "application/json" - } - } - }, - { - "Guid": "bd05033f-1189-4d89-8cdc-f681399a46b3", - "Request": { - "Path": "/user/logout", - "Methods": [ - "GET" - ] - }, - "Response": { - "StatusCode": 0 - } - }, - { - "Guid": "7c1d49d4-e9f0-49b9-b898-f8c7d55ae472", - "Request": { - "Path": "/user/example-string", - "Methods": [ - "GET" - ] - }, - "Response": { - "StatusCode": 200, - "BodyAsJson": { - "id": 42, - "username": "example-string", - "firstName": "example-string", - "lastName": "example-string", - "email": "example-string", - "password": "example-string", - "phone": "example-string", - "userStatus": 42 - }, - "Headers": { - "Content-Type": "application/json" - } - } - }, - { - "Guid": "1b7c4cd8-b251-480a-982e-c42d40dbfd4e", - "Request": { - "Path": "/user/example-string", - "Methods": [ - "PUT" - ] - }, - "Response": { - "StatusCode": 0 - } - }, - { - "Guid": "8a86e775-4bf9-490d-a52f-641458c256f7", - "Request": { - "Path": "/user/example-string", - "Methods": [ - "DELETE" - ] - }, - "Response": { - "StatusCode": 200 - } - } -] \ No newline at end of file diff --git a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj index cf7d2988d..043a83f89 100644 --- a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj @@ -28,12 +28,12 @@ - + diff --git a/examples/WireMock.Net.Console.Net472.Classic/App.config b/examples/WireMock.Net.Console.Net472.Classic/App.config index f4ed63852..b52d4e9c7 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/App.config +++ b/examples/WireMock.Net.Console.Net472.Classic/App.config @@ -55,11 +55,11 @@ - + - + @@ -67,7 +67,7 @@ - + diff --git a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj index f4451462b..76191168d 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj +++ b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj @@ -49,29 +49,29 @@ ..\..\packages\Handlebars.Net.2.1.4\lib\net46\Handlebars.dll - - ..\..\packages\Handlebars.Net.Helpers.2.4.0\lib\net46\Handlebars.Net.Helpers.dll + + ..\..\packages\Handlebars.Net.Helpers.2.4.1.2\lib\net46\Handlebars.Net.Helpers.dll - - ..\..\packages\Handlebars.Net.Helpers.Core.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Core.dll + + ..\..\packages\Handlebars.Net.Helpers.Core.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Core.dll - - ..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.0\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll + + ..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll - - ..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll + + ..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll - - ..\..\packages\Handlebars.Net.Helpers.Json.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Json.dll + + ..\..\packages\Handlebars.Net.Helpers.Json.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Json.dll - - ..\..\packages\Handlebars.Net.Helpers.Random.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Random.dll + + ..\..\packages\Handlebars.Net.Helpers.Random.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Random.dll - - ..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll + + ..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll - - ..\..\packages\Handlebars.Net.Helpers.XPath.2.4.0\lib\net46\HandlebarsDotNet.Helpers.XPath.dll + + ..\..\packages\Handlebars.Net.Helpers.XPath.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.XPath.dll ..\..\packages\Humanizer.Core.2.14.1\lib\netstandard2.0\Humanizer.dll @@ -352,11 +352,11 @@ ..\..\packages\TinyMapper.3.0.3\lib\net40\TinyMapper.dll - - ..\..\packages\XPath2.1.1.3\lib\net452\XPath2.dll + + ..\..\packages\XPath2.1.1.4\lib\net452\XPath2.dll - - ..\..\packages\XPath2.Extensions.1.1.3\lib\net452\XPath2.Extensions.dll + + ..\..\packages\XPath2.Extensions.1.1.4\lib\net452\XPath2.Extensions.dll diff --git a/examples/WireMock.Net.Console.Net472.Classic/packages.config b/examples/WireMock.Net.Console.Net472.Classic/packages.config index ce6d332f9..cf523e010 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net472.Classic/packages.config @@ -3,14 +3,14 @@ - - - - - - - - + + + + + + + + @@ -151,6 +151,6 @@ - - + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs deleted file mode 100644 index 73c9e3403..000000000 --- a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; -using WireMock.Logging; -using WireMock.RequestBuilders; -using WireMock.ResponseBuilders; -using WireMock.Server; -using WireMock.Settings; - -namespace WireMock.Net.Console.Proxy.NETCoreApp2 -{ - class Program - { - static void Main(string[] args) - { - var server = WireMockServer.Start(new WireMockServerSettings - { - Urls = new[] { "http://localhost:9091", "https://localhost:9443" }, - StartAdminInterface = true, - ReadStaticMappings = false, - ProxyAndRecordSettings = new ProxyAndRecordSettings - { - Url = "http://postman-echo.com/post", - //ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)", - SaveMapping = true, - SaveMappingToFile = false, - ExcludedHeaders = new[] { "dnt", "Content-Length" } - }, - Logger= new WireMockConsoleLogger() - }); - - //server.LogEntriesChanged += (sender, eventRecordArgs) => - //{ - // System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented)); - //}; - - System.Console.WriteLine("Press any key to stop the server"); - System.Console.ReadKey(); - server.Stop(); - } - } -} diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json deleted file mode 100644 index 616b68b05..000000000 --- a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:63377/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "WireMock.Net.Console.Proxy.NETCoreApp2": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:63378/" - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj deleted file mode 100644 index a3a3be3cc..000000000 --- a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - Exe - netcoreapp2.1;netcoreapp3.1;net5.0 - ../../resources/WireMock.Net-Logo.ico - - - - - - - - - - - diff --git a/examples/WireMock.Net.Console.RequestLogTest/WireMock.Net.Console.RequestLogTest.csproj b/examples/WireMock.Net.Console.RequestLogTest/WireMock.Net.Console.RequestLogTest.csproj index c11086051..5bc07bc82 100644 --- a/examples/WireMock.Net.Console.RequestLogTest/WireMock.Net.Console.RequestLogTest.csproj +++ b/examples/WireMock.Net.Console.RequestLogTest/WireMock.Net.Console.RequestLogTest.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.2 + net8.0 diff --git a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj index fd80b1e16..96e8eafb5 100644 --- a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj +++ b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj @@ -79,8 +79,8 @@ - - ..\..\packages\XPath2.1.1.3\lib\net452\XPath2.dll + + ..\..\packages\XPath2.1.1.4\lib\net452\XPath2.dll diff --git a/examples/WireMock.Net.Service/packages.config b/examples/WireMock.Net.Service/packages.config index cac759f21..eed78af08 100644 --- a/examples/WireMock.Net.Service/packages.config +++ b/examples/WireMock.Net.Service/packages.config @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/App.cs b/examples/WireMock.Net.WebApplication.NETCore2/App.cs deleted file mode 100644 index 2575335bb..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/App.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Extensions.Logging; - -namespace WireMock.Net.WebApplication -{ - public class App - { - private readonly IWireMockService _service; - private readonly ILogger _logger; - - public App(IWireMockService service, ILogger logger) - { - _service = service; - _logger = logger; - } - - public void Run() - { - _logger.LogInformation("WireMock.Net App running"); - _service.Run(); - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs deleted file mode 100644 index de3ac175f..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/IWireMockService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace WireMock.Net.WebApplication -{ - public interface IWireMockService - { - void Run(); - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/Program.cs b/examples/WireMock.Net.WebApplication.NETCore2/Program.cs deleted file mode 100644 index ad5f0b2f6..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/Program.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using WireMock.Settings; - -namespace WireMock.Net.WebApplication -{ - public class Program - { - public static void Main(string[] args) - { - // Create service collection - var serviceCollection = new ServiceCollection(); - ConfigureServices(serviceCollection); - - // Create service provider - var serviceProvider = serviceCollection.BuildServiceProvider(); - - // Run app - serviceProvider.GetService().Run(); - } - - private static void ConfigureServices(IServiceCollection serviceCollection) - { - // Build configuration - var configuration = new ConfigurationBuilder() - .SetBasePath(AppContext.BaseDirectory) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddEnvironmentVariables() // <-- this is needed to to override settings via the Azure Portal App Settings - .Build(); - - // Add LoggerFactory - var factory = new LoggerFactory(); - serviceCollection.AddSingleton(factory - .AddConsole(configuration.GetSection("Logging")) - .AddDebug() - .AddAzureWebAppDiagnostics() - ); - - serviceCollection.AddSingleton(factory.CreateLogger("WireMock.Net Logger")); - - // Add access to generic IConfigurationRoot - serviceCollection.AddSingleton(configuration); - - // Add access to WireMockServerSettings - var settings = configuration.GetSection("WireMockServerSettings").Get(); - serviceCollection.AddSingleton(settings); - - // Add services - serviceCollection.AddTransient(); - - // Add app - serviceCollection.AddTransient(); - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json b/examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json deleted file mode 100644 index 1ff6dab6a..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/Properties/launchSettings.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:60097/", - "sslPort": 44321 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchUrl": "__admin/settings", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "WireMock.Net.WebApplication": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "__admin/settings", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:56514/" - }, - "IIS": { - "commandName": "IIS", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "development" - } - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/WireMock.Net.WebApplication.NETCore2.csproj b/examples/WireMock.Net.WebApplication.NETCore2/WireMock.Net.WebApplication.NETCore2.csproj deleted file mode 100644 index 2379ea6fb..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/WireMock.Net.WebApplication.NETCore2.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - netcoreapp2.1 - win10-x64 - WireMock.Net.WebApplication.Program - WireMock.Net.WebApplication - WireMock.Net.WebApplication - efcf4a18-fd7c-4622-825d-336d65290599 - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/WireMockService.cs b/examples/WireMock.Net.WebApplication.NETCore2/WireMockService.cs deleted file mode 100644 index 4aa28e142..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/WireMockService.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Threading; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using WireMock.Admin.Requests; -using WireMock.Logging; -using WireMock.Server; -using WireMock.Settings; - -namespace WireMock.Net.WebApplication -{ - public class WireMockService : IWireMockService - { - private static int sleepTime = 30000; - - private readonly ILogger _logger; - private readonly WireMockServerSettings _settings; - - private class Logger : IWireMockLogger - { - private readonly ILogger _logger; - - public Logger(ILogger logger) - { - _logger = logger; - } - - public void Debug(string formatString, params object[] args) - { - _logger.LogDebug(formatString, args); - } - - public void Info(string formatString, params object[] args) - { - _logger.LogInformation(formatString, args); - } - - public void Warn(string formatString, params object[] args) - { - _logger.LogWarning(formatString, args); - } - - public void Error(string formatString, params object[] args) - { - _logger.LogError(formatString, args); - } - - public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest) - { - string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented); - _logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message); - } - - public void Error(string formatString, Exception exception) - { - _logger.LogError(formatString, exception.Message); - } - } - - public WireMockService(ILogger logger, WireMockServerSettings settings) - { - _logger = logger; - _settings = settings; - - _settings.Logger = new Logger(logger); - } - - public void Run() - { - _logger.LogInformation("WireMock.Net server starting"); - - WireMockServer.Start(_settings); - - _logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}"); - - while (true) - { - _logger.LogInformation("WireMock.Net server running"); - Thread.Sleep(sleepTime); - } - } - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/appsettings.json b/examples/WireMock.Net.WebApplication.NETCore2/appsettings.json deleted file mode 100644 index 4b33bb6af..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/appsettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Logging": { - "IncludeScopes": false, - "Debug": { - "LogLevel": { - "Default": "Debug" - } - }, - "Console": { - "LogLevel": { - "Default": "Debug" - } - } - }, - "WireMockServerSettings": { - "AdminUsername": "a", - "AdminPassword": "b", - "StartAdminInterface": true - } -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/libman.json b/examples/WireMock.Net.WebApplication.NETCore2/libman.json deleted file mode 100644 index b0b3b9a4e..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/libman.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0", - "defaultProvider": "cdnjs", - "libraries": [] -} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.NETCore2/readme.md b/examples/WireMock.Net.WebApplication.NETCore2/readme.md deleted file mode 100644 index 00ebec628..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# Running in IIS - -Follow these links / steps: -* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS -* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1 -* Create a `web.config` file - -## IIS Sites -![IIS Multiple](resources/iis-wiremock1and2.png) - -## App Pool settings -![IIS Multiple](resources/iis-apppool.png) - -## Publish Profiles -Two example publish profiles are created: -* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml) -* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml) - -## Debugging -Select the debug "IIS" if you want to debug in IIS. -![IIS Debug](resources/iis-debug.png) diff --git a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-apppool.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-apppool.png deleted file mode 100644 index 119df1950..000000000 Binary files a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-apppool.png and /dev/null differ diff --git a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-debug.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-debug.png deleted file mode 100644 index 0aa1936f2..000000000 Binary files a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-debug.png and /dev/null differ diff --git a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-wiremock1and2.png b/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-wiremock1and2.png deleted file mode 100644 index 6d50b12dd..000000000 Binary files a/examples/WireMock.Net.WebApplication.NETCore2/resources/iis-wiremock1and2.png and /dev/null differ diff --git a/examples/WireMock.Net.WebApplication.NETCore2/web.config b/examples/WireMock.Net.WebApplication.NETCore2/web.config deleted file mode 100644 index d2f21cf22..000000000 --- a/examples/WireMock.Net.WebApplication.NETCore2/web.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/WireMock.Net.Abstractions/Types/ReplaceNodeOptions.cs b/src/WireMock.Net.Abstractions/Types/ReplaceNodeOptions.cs index 3f8cb3186..40960016e 100644 --- a/src/WireMock.Net.Abstractions/Types/ReplaceNodeOptions.cs +++ b/src/WireMock.Net.Abstractions/Types/ReplaceNodeOptions.cs @@ -7,19 +7,16 @@ public enum ReplaceNodeOptions { ///

/// Try to evaluate a templated value. - /// In case this is valid, return the value and if the value can be converted to a primitive type, use that value. + /// In case this is valid, return the value and if the value can be converted to a supported (primitive) type, use that value. + /// + /// [Default behaviour] /// EvaluateAndTryToConvert = 0, - /// - /// Try to evaluate a templated value. - /// In case this is valid, return the value, else fallback to the parse behavior. - /// - Evaluate = 1, - /// /// Parse templated string to a templated string. - /// (keep a templated string value as string value). + /// For example: keep a templated string value (which is always the case) as a string value. /// - Parse = 2 + Evaluate = 1, + EvaluateAndKeep = Evaluate } \ No newline at end of file diff --git a/src/WireMock.Net/RequestBuilders/IBodyRequestBuilder.cs b/src/WireMock.Net/RequestBuilders/IBodyRequestBuilder.cs index ae91756ad..8bb6e92ef 100644 --- a/src/WireMock.Net/RequestBuilders/IBodyRequestBuilder.cs +++ b/src/WireMock.Net/RequestBuilders/IBodyRequestBuilder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using JsonConverter.Abstractions; using WireMock.Matchers; -using WireMock.Matchers.Request; using WireMock.Util; namespace WireMock.RequestBuilders; diff --git a/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs index 729f8894f..6e7a8ed81 100644 --- a/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs +++ b/src/WireMock.Net/ResponseBuilders/ITransformResponseBuilder.cs @@ -29,5 +29,5 @@ public interface ITransformResponseBuilder : IDelayResponseBuilder /// /// The . /// - IResponseBuilder WithTransformer(TransformerType transformerType = TransformerType.Handlebars, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.Evaluate); + IResponseBuilder WithTransformer(TransformerType transformerType = TransformerType.Handlebars, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.EvaluateAndTryToConvert); } \ No newline at end of file diff --git a/src/WireMock.Net/ResponseBuilders/Response.cs b/src/WireMock.Net/ResponseBuilders/Response.cs index 00e2de48d..9540aa621 100644 --- a/src/WireMock.Net/ResponseBuilders/Response.cs +++ b/src/WireMock.Net/ResponseBuilders/Response.cs @@ -205,7 +205,7 @@ public IResponseBuilder WithTransformer(ReplaceNodeOptions options) } /// - public IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.Evaluate) + public IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.EvaluateAndTryToConvert) { UseTransformer = true; TransformerType = transformerType; diff --git a/src/WireMock.Net/Serialization/WebhookMapper.cs b/src/WireMock.Net/Serialization/WebhookMapper.cs index bcd45c9fb..557f05dbf 100644 --- a/src/WireMock.Net/Serialization/WebhookMapper.cs +++ b/src/WireMock.Net/Serialization/WebhookMapper.cs @@ -39,7 +39,7 @@ public static IWebhook Map(WebhookModel model) if (!Enum.TryParse(model.Request.TransformerReplaceNodeOptions, out var option)) { - option = ReplaceNodeOptions.Evaluate; + option = ReplaceNodeOptions.EvaluateAndTryToConvert; } webhook.Request.TransformerReplaceNodeOptions = option; } diff --git a/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs b/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs index cb1639948..67d5d2722 100644 --- a/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs +++ b/src/WireMock.Net/Server/WireMockServer.ConvertMapping.cs @@ -264,14 +264,16 @@ private static IResponseBuilder InitResponseBuilder(ResponseModel responseModel) transformerType = TransformerType.Handlebars; } - if (!Enum.TryParse(responseModel.TransformerReplaceNodeOptions, out var option)) + if (!Enum.TryParse(responseModel.TransformerReplaceNodeOptions, out var replaceNodeOptions)) { - option = ReplaceNodeOptions.Evaluate; + replaceNodeOptions = ReplaceNodeOptions.EvaluateAndTryToConvert; } + responseBuilder = responseBuilder.WithTransformer( transformerType, responseModel.UseTransformerForBodyAsFile == true, - option); + replaceNodeOptions + ); } if (!string.IsNullOrEmpty(responseModel.ProxyUrl)) diff --git a/src/WireMock.Net/Transformers/Transformer.cs b/src/WireMock.Net/Transformers/Transformer.cs index c6943629d..f8d47d1fc 100644 --- a/src/WireMock.Net/Transformers/Transformer.cs +++ b/src/WireMock.Net/Transformers/Transformer.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; +using HandlebarsDotNet.Helpers.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Stef.Validation; @@ -13,8 +13,6 @@ namespace WireMock.Transformers; internal class Transformer : ITransformer { - private static readonly Type[] SupportedTypes = { typeof(bool), typeof(long), typeof(int), typeof(double), typeof(Guid), typeof(DateTime), typeof(TimeSpan), typeof(Uri) }; - private readonly JsonSerializer _jsonSerializer; private readonly ITransformerContextFactory _factory; @@ -268,9 +266,10 @@ private void ReplaceNodeValue(ReplaceNodeOptions options, JToken node, object? t return; case string transformedString: - if (TryConvert(transformedString, out var convertedFromStringValue)) + var (isConvertedFromString, convertedValueFromString) = TryConvert(options, transformedString); + if (isConvertedFromString) { - node.Replace(JToken.FromObject(convertedFromStringValue, _jsonSerializer)); + node.Replace(JToken.FromObject(convertedValueFromString, _jsonSerializer)); } else { @@ -292,7 +291,8 @@ private void ReplaceNodeValue(ReplaceNodeOptions options, JToken node, object? t break; case { }: - if (TryConvert(transformedValue, out var convertedValue)) + var (isConverted, convertedValue) = TryConvert(options, transformedValue); + if (isConverted) { node.Replace(JToken.FromObject(convertedValue, _jsonSerializer)); } @@ -308,23 +308,28 @@ private static JToken ParseAsJObject(string stringValue) return JsonUtils.TryParseAsJObject(stringValue, out var parsedAsjObject) ? parsedAsjObject : stringValue; } - private static bool TryConvert(object? transformedValue, [NotNullWhen(true)] out object? convertedValue) + private static (bool IsConverted, object ConvertedValue) TryConvert(ReplaceNodeOptions options, object value) { - foreach (var supportedType in SupportedTypes) + var valueAsString = value as string; + + if (options == ReplaceNodeOptions.Evaluate) { - try - { - convertedValue = Convert.ChangeType(transformedValue, supportedType); - return convertedValue is not null; - } - catch + if (valueAsString != null && WrappedString.TryDecode(valueAsString, out var decoded)) { - // Ignore + return (true, decoded); } + + return (false, value); + } + + if (valueAsString != null) + { + return WrappedString.TryDecode(valueAsString, out var decoded) ? + (true, decoded) : + StringUtils.TryConvertToKnownType(valueAsString); } - convertedValue = null; - return false; + return (false, value); } private static IBodyData TransformBodyAsString(ITransformerContext transformerContext, object model, IBodyData original) diff --git a/src/WireMock.Net/Util/StringUtils.cs b/src/WireMock.Net/Util/StringUtils.cs index 161c4aac2..586781d76 100644 --- a/src/WireMock.Net/Util/StringUtils.cs +++ b/src/WireMock.Net/Util/StringUtils.cs @@ -8,6 +8,48 @@ namespace WireMock.Util; internal static class StringUtils { + private static readonly string[] ValidUriSchemes = + { + "ftp://", + "http://", + "https://" + }; + + private static readonly Func[] ConversionsFunctions = + { + s => bool.TryParse(s, out var result) ? (true, result) : (false, s), + s => int.TryParse(s, out var result) ? (true, result) : (false, s), + s => long.TryParse(s, out var result) ? (true, result) : (false, s), + s => double.TryParse(s, out var result) ? (true, result) : (false, s), + s => Guid.TryParse(s, out var result) ? (true, result) : (false, s), + s => TimeSpan.TryParse(s, out var result) ? (true, result) : (false, s), + s => DateTime.TryParse(s, out var result) ? (true, result) : (false, s), + s => + { + if (ValidUriSchemes.Any(u => s.StartsWith(u, StringComparison.OrdinalIgnoreCase)) && + Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out var uri)) + { + return (true, uri); + } + + return (false, s); + } + }; + + public static (bool IsConverted, object ConvertedValue) TryConvertToKnownType(string value) + { + foreach (var func in ConversionsFunctions) + { + var result = func(value); + if (result.IsConverted) + { + return result; + } + } + + return (false, value); + } + public static MatchOperator ParseMatchOperator(string? value) { return value != null && Enum.TryParse(value, out var matchOperator) diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 895c5acf4..2f60036e9 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -189,13 +189,13 @@
- - - - - - - + + + + + + + diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsDateTimeTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsDateTimeTests.cs index e9b106af8..22f919cf3 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsDateTimeTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsDateTimeTests.cs @@ -7,6 +7,7 @@ using WireMock.Models; using WireMock.ResponseBuilders; using WireMock.Settings; +using WireMock.Types; using Xunit; namespace WireMock.Net.Tests.ResponseBuilders; @@ -28,8 +29,10 @@ public ResponseWithHandlebarsDateTimeTests() _settings.FileSystemHandler = filesystemHandlerMock.Object; } - [Fact] - public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTime() + [Theory] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)] + [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)] + public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTimeYear(ReplaceNodeOptions options, JTokenType expected) { // Assign var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp); @@ -39,14 +42,61 @@ public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTi { DateTimeYear = "{{ DateTime.UtcNow \"yyyy\" }}" }) - .WithTransformer(); + .WithTransformer(options); // Act var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); // Assert - var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); - j["DateTimeYear"]!.Value().Should().Be(DateTime.Now.Year.ToString()); + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["DateTimeYear"]!.Type.Should().Be(expected); + jObject["DateTimeYear"]!.Value().Should().Be(DateTime.Now.Year.ToString()); + } + + [Theory] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Date)] + [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)] + public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTime(ReplaceNodeOptions options, JTokenType expected) + { + // Assign + var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp); + + var responseBuilder = Response.Create() + .WithBodyAsJson(new + { + DateTime = "{{ DateTime.UtcNow }}" + }) + .WithTransformer(options); + + // Act + var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); + + // Assert + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["DateTime"]!.Type.Should().Be(expected); + } + + [Theory] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)] + [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)] + public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTimeWithStringFormat(ReplaceNodeOptions options, JTokenType expected) + { + // Assign + var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp); + + var responseBuilder = Response.Create() + .WithBodyAsJson(new + { + StringFormatDateTime = "{{ String.Format (DateTime.UtcNow) \"yyMMddhhmmss\" }}" + }) + .WithTransformer(options); + + // Act + var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); + + // Assert + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["StringFormatDateTime"]!.Type.Should().Be(expected); } [Fact] @@ -65,4 +115,39 @@ public async Task Response_WithBody_ProvideResponseAsync_Handlebars_DateTime() // Assert response.Message.BodyData!.BodyAsString.Should().Contain($"DateTimeYear = \"{DateTime.Now.Year}\""); } + + [Theory] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert)] + [InlineData(ReplaceNodeOptions.Evaluate)] + public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_WithStringFormatAsString(ReplaceNodeOptions options) + { + // Assign + var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp); + + var responseBuilder = Response.Create() + .WithBodyAsJson(new + { + FormatAsString1 = "{{ String.FormatAsString (DateTime.UtcNow) \"yyMMddhhmmss\" }}", + FormatAsString2 = "{{ String.FormatAsString (DateTime.UtcNow) }}", + FormatAsString3 = "{{ String.FormatAsString 42 \"X\" }}", + FormatAsString4 = "{{ String.FormatAsString 42 }}" + }) + .WithTransformer(options); + + // Act + var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); + + // Assert + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["FormatAsString1"]!.Type.Should().Be(JTokenType.String); + jObject["FormatAsString2"]!.Type.Should().Be(JTokenType.String); + + var formatAsString3 = jObject["FormatAsString3"]!; + formatAsString3.Type.Should().Be(JTokenType.String); + formatAsString3.Value().Should().Be("2A"); + + var formatAsString4 = jObject["FormatAsString4"]!; + formatAsString4.Type.Should().Be(JTokenType.String); + formatAsString4.Value().Should().Be("42"); + } } \ No newline at end of file diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsRandomTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsRandomTests.cs index 8f6c7dcf2..6492f5994 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsRandomTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsRandomTests.cs @@ -78,10 +78,8 @@ public async Task Response_ProvideResponseAsync_Handlebars_Random1_Boolean() } [Theory] - [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.Integer)] - //[InlineData(ReplaceNodeOptions.Bool, JTokenType.String)] - //[InlineData(ReplaceNodeOptions.Integer, JTokenType.Integer)] - //[InlineData(ReplaceNodeOptions.Bool | ReplaceNodeOptions.Integer, JTokenType.Integer)] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)] + [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)] public async Task Response_ProvideResponseAsync_Handlebars_Random1_Integer(ReplaceNodeOptions options, JTokenType expected) { // Assign @@ -98,12 +96,14 @@ public async Task Response_ProvideResponseAsync_Handlebars_Random1_Integer(Repla var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); // Assert - JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson); - Check.That(j["Value"].Type).IsEqualTo(expected); + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["Value"]!.Type.Should().Be(expected); } - [Fact] - public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid() + [Theory] + [InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Guid)] + [InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)] + public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid(ReplaceNodeOptions options, JTokenType expected) { // Assign var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp); @@ -114,17 +114,15 @@ public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid() Guid1 = "{{Random Type=\"Guid\" Uppercase=false}}", Guid2 = "{{Random Type=\"Guid\"}}" }) - .WithTransformer(); + .WithTransformer(options); // Act var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); // Assert - JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson); - string guid1 = j["Guid1"].Value(); - Check.That(guid1.ToUpper()).IsNotEqualTo(guid1); - string guid2 = j["Guid2"].Value(); - Check.That(guid2.ToUpper()).IsEqualTo(guid2); + var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!); + jObject["Guid1"]!.Type.Should().Be(expected); + jObject["Guid2"]!.Type.Should().Be(expected); } [Fact] diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs index e520df3e5..d5a4dc262 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs @@ -500,34 +500,6 @@ public async Task Response_ProvideResponse_Transformer_ResultAsJArray(Transforme JsonConvert.SerializeObject(response.Message.BodyData!.BodyAsJson).Should().Be("[{\"x\":\"test\"}]"); } - //[Theory] - //[InlineData(TransformerType.Handlebars, "a")] - //[InlineData(TransformerType.Handlebars, "42")] - //[InlineData(TransformerType.Handlebars, "{")] - //[InlineData(TransformerType.Handlebars, "]")] - //[InlineData(TransformerType.Handlebars, " ")] - //public async Task Response_ProvideResponse_Transformer_WithBodyAsJsonWithExtraQuotes_AndSpecialOption_MakesAString_ResultAsObject(TransformerType transformerType, string text) - //{ - // string jsonString = $"{{ \"x\": \"{text}\" }}"; - // var bodyData = new BodyData - // { - // BodyAsJson = JsonConvert.DeserializeObject(jsonString), - // DetectedBodyType = BodyType.Json, - // Encoding = Encoding.UTF8 - // }; - // var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData); - - // var responseBuilder = Response.Create() - // .WithBodyAsJson(new { text = "\"{{request.bodyAsJson.x}}\"" }) - // .WithTransformer(transformerType, false, ReplaceNodeOptions.Default); - - // // Act - // var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); - - // // Assert - // JsonConvert.SerializeObject(response.Message.BodyData.BodyAsJson).Should().Be($"{{\"text\":\"{text}\"}}"); - //} - [Theory] [InlineData(TransformerType.Handlebars, "\"\"", "\"\"")] [InlineData(TransformerType.Handlebars, "\"a\"", "\"a\"")] @@ -543,7 +515,7 @@ public async Task Response_ProvideResponse_Transformer_ResultAsJArray(Transforme [InlineData(TransformerType.Handlebars, "2147483647", "2147483647")] [InlineData(TransformerType.Handlebars, "\"9223372036854775807\"", "\"9223372036854775807\"")] [InlineData(TransformerType.Handlebars, "9223372036854775807", "9223372036854775807")] - public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_And_ReplaceNodeOptionsKeep(TransformerType transformerType, string value, string expected) + public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_And_ReplaceNodeOptionsEvaluate(TransformerType transformerType, string value, string expected) { string jsonString = $"{{ \"x\": {value} }}"; var bodyData = new BodyData diff --git a/test/WireMock.Net.Tests/Serialization/MappingConverterTests.ToMappingModel_WithPriority_ReturnsPriority.verified.txt b/test/WireMock.Net.Tests/Serialization/MappingConverterTests.ToMappingModel_WithPriority_ReturnsPriority.verified.txt index 8c23c1f92..8b59422a8 100644 --- a/test/WireMock.Net.Tests/Serialization/MappingConverterTests.ToMappingModel_WithPriority_ReturnsPriority.verified.txt +++ b/test/WireMock.Net.Tests/Serialization/MappingConverterTests.ToMappingModel_WithPriority_ReturnsPriority.verified.txt @@ -11,7 +11,7 @@ }, UseTransformer: true, TransformerType: Handlebars, - TransformerReplaceNodeOptions: Evaluate + TransformerReplaceNodeOptions: EvaluateAndTryToConvert }, UseWebhooksFireAndForget: false } \ No newline at end of file diff --git a/test/WireMock.Net.Tests/Serialization/WebhookMapperTests.WebhookMapper_Map_WebhookModel_BodyAsString_And_UseTransformerIsTrue.verified.txt b/test/WireMock.Net.Tests/Serialization/WebhookMapperTests.WebhookMapper_Map_WebhookModel_BodyAsString_And_UseTransformerIsTrue.verified.txt index a05372321..8793295e8 100644 --- a/test/WireMock.Net.Tests/Serialization/WebhookMapperTests.WebhookMapper_Map_WebhookModel_BodyAsString_And_UseTransformerIsTrue.verified.txt +++ b/test/WireMock.Net.Tests/Serialization/WebhookMapperTests.WebhookMapper_Map_WebhookModel_BodyAsString_And_UseTransformerIsTrue.verified.txt @@ -12,7 +12,6 @@ DetectedBodyType: String, DetectedBodyTypeFromContentType: Bytes }, - UseTransformer: true, - TransformerReplaceNodeOptions: Evaluate + UseTransformer: true } } \ No newline at end of file diff --git a/test/WireMock.Net.Tests/Util/StringUtilsTests.cs b/test/WireMock.Net.Tests/Util/StringUtilsTests.cs index 657dd369f..375924fc7 100644 --- a/test/WireMock.Net.Tests/Util/StringUtilsTests.cs +++ b/test/WireMock.Net.Tests/Util/StringUtilsTests.cs @@ -1,3 +1,5 @@ +using System; +using CultureAwareTesting.xUnit; using FluentAssertions; using WireMock.Matchers; using WireMock.Util; @@ -7,6 +9,179 @@ namespace WireMock.Net.Tests.Util; public class StringUtilsTests { + [Theory] + [InlineData("", "")] + [InlineData("x", "x")] + public void TryConvertToString_ShouldWorkCorrectly(string input, string expectedValue) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(false); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Be(expectedValue); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("true", true, true)] + [InlineData("false", false, true)] + [InlineData("not a bool", false, false)] // Invalid case + public void TryConvertToBool_ShouldWorkCorrectly(string input, bool expectedValue, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Be(expectedValue); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("123", 123, true)] + [InlineData("-456", -456, true)] + [InlineData("not an int", 0, false)] // Invalid case + public void TryConvertToInt_ShouldWorkCorrectly(string input, int expectedValue, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Be(expectedValue); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("12345678901", 12345678901L, true)] + [InlineData("-9876543210", -9876543210L, true)] + [InlineData("not a long", 0L, false)] // Invalid case + public void TryConvertToLong_ShouldWorkCorrectly(string input, long expectedValue, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Be(expectedValue); + } + else + { + convertedValue.Should().Be(input); + } + } + + [CulturedTheory("en-US")] + [InlineData("123.1", 123.1, true)] + [InlineData("-456.1", -456.1, true)] + [InlineData("not a double", 0.0, false)] // Invalid case + public void TryConvertToDouble_ShouldWorkCorrectly(string input, double expectedValue, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + ((double) convertedValue).Should().BeApproximately(expectedValue, 0.01); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("3F2504E0-4F89-11D3-9A0C-0305E82C3301", true)] + [InlineData("00000000-0000-0000-0000-000000000000", true)] + [InlineData("3f2504e0-4f89-11d3-9a0c-0305e82c3301", true)] // Lowercase Guid + [InlineData("not a guid", false)] // Invalid case + public void TryConvertToGuid_ShouldWorkCorrectly(string input, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType(); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("2023-04-01", true)] + [InlineData("01/01/2000", true)] + [InlineData("not a date", false)] // Invalid case + public void TryConvertToDateTime_ShouldWorkCorrectly(string input, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Subject.As().Date.Should().Be(DateTime.Parse(input).Date); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("1.00:00:00", true)] // 1 day + [InlineData("00:30:00", true)] // 30 minutes + [InlineData("not a timespan", false)] // Invalid case + public void TryConvertToTimeSpan_ShouldWorkCorrectly(string input, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Subject.As().Should().Be(TimeSpan.Parse(input)); + } + else + { + convertedValue.Should().Be(input); + } + } + + [Theory] + [InlineData("http://example.com", true)] + [InlineData("https://example.com/path?query=string#fragment", true)] + [InlineData("ftp://example.com", true)] + [InlineData("file://example.com", false)] + [InlineData("not a uri", false)] // Invalid case + public void TryConvertToUri_ShouldWorkCorrectly(string input, bool expectedConversion) + { + var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input); + + isConverted.Should().Be(expectedConversion); + if (isConverted) + { + convertedValue.Should().BeOfType().And.Subject.As().AbsoluteUri.Should().Be(new Uri(input).AbsoluteUri); + } + else + { + convertedValue.Should().Be(input); + } + } + [Theory] [InlineData("And", MatchOperator.And)] [InlineData("Or", MatchOperator.Or)]