Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code reformatting #346

Merged
merged 75 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
847bd56
Updated Nuget packages
Mar 17, 2024
d0bdd11
Code analysis
Mar 17, 2024
1482c2b
Fixed warnings
Mar 17, 2024
64e80db
Updated NPM packages
Mar 17, 2024
66c0405
Modal fix
Mar 17, 2024
f2a5b69
Refactoring 1
Mar 17, 2024
bfb9cf4
Use collection expression
Mar 17, 2024
25d05d6
Fixed unit tests
Mar 17, 2024
8b9c39a
Merged command/query and handlers
Mar 17, 2024
d2741b6
Added tests for ObjectUtilities.cs
Mar 17, 2024
4e22586
Constructor fixes
Mar 17, 2024
e354a48
Code analysis fixes
Mar 18, 2024
006da0e
Controller refactoring
Mar 18, 2024
c187a54
Code analysis fixes
Mar 18, 2024
01278e8
Code analysis fixes
Mar 18, 2024
d937d6a
Refactoring in file watching
Mar 22, 2024
bd1610e
Several refactorings
Mar 22, 2024
0719bb9
Config refactoring
Mar 23, 2024
b36dd11
Config refactoring
Mar 23, 2024
0ca0233
Config refactoring
Mar 23, 2024
a444487
Moved config models
Mar 23, 2024
3938f33
RequestToCurlCommandService.cs refactoring
Mar 23, 2024
f32416e
Added ThrowHelper
Mar 23, 2024
c07c82e
Refactoring
Mar 23, 2024
3973cac
Refactoring of import command
Mar 23, 2024
cb17205
Refactored ScrutorUtilities.cs
Mar 23, 2024
afe6910
Bug fix
Mar 23, 2024
370e633
Removed audit behavior
Mar 23, 2024
5d08606
Refactorings
Mar 23, 2024
2d68475
Namespace refactoring
Mar 23, 2024
151b2d3
Move around classes
Mar 23, 2024
e4a26e4
Move around classes
Mar 23, 2024
740225f
Test fix
Mar 23, 2024
d81466d
BasicAuthenticationConditionChecker.cs refactoring
Mar 23, 2024
b128da0
Condition checker refactoring
Mar 24, 2024
503a696
Fixed tests
Mar 24, 2024
cb4c95d
Added condition checker base class
Mar 24, 2024
1c5f664
Condition checker refactoring
Mar 24, 2024
03034b6
Condition checker refactoring
Mar 24, 2024
33552ef
Added unit tests for BaseConditionChecker
Mar 24, 2024
83e4330
Several refactorings
Mar 24, 2024
3ec4ecb
Several refactorings
Mar 24, 2024
d8fbbe1
Variable parsing handlers refactoring
Mar 24, 2024
ba5fe30
Response writer refactorings
Mar 24, 2024
e969f90
StringHelper refactoring
Mar 25, 2024
8340b63
Moved DB entity classes
Mar 29, 2024
d8d82ed
Added WebResources
Mar 29, 2024
de6190b
Moved response variable MD files to resources file
Mar 29, 2024
5c1deb2
Use new resources file for variable parsing handlers
Mar 29, 2024
d45004e
Removed unnecessary test
Mar 29, 2024
295c3f0
Removed Resources project
Mar 29, 2024
8209588
DB refactoring
Mar 30, 2024
9f9be77
Stub sources refactoring
Mar 30, 2024
6d3bc9b
Removed WebInfrastructure project
Mar 30, 2024
897bd18
Added helper for retrieving HttpContext
Mar 30, 2024
aab6c8b
Added tests for WebHelper
Mar 30, 2024
ce24b1c
Added helper method for converting object to completed task
Mar 30, 2024
e311031
Code cleanup
Mar 30, 2024
7c67170
Add assembly version to UI index.html
Mar 30, 2024
69eea41
Removed ph-static folder and added version to "501" page
Mar 30, 2024
bf0ba53
Return JSON when no stub is found and "Accept" header is JSON
Mar 30, 2024
8006086
Code analysis fixes
Mar 30, 2024
8d09e4c
Code analysis fixes
Mar 30, 2024
74b0b57
Logging fixes
Mar 30, 2024
f4d28bd
Using fixes
Mar 30, 2024
a558b07
Test fixes
Mar 30, 2024
93a87fb
Web resource fixes
Mar 31, 2024
849ba73
501 page styling
Mar 31, 2024
119a562
501 page refactoring
Mar 31, 2024
42f79b2
Refactoring
Mar 31, 2024
bf25b02
Program.cs refactoring
Mar 31, 2024
fb29d25
Fix test
Mar 31, 2024
fffcc96
Code cleanup
Mar 31, 2024
1319231
Removed attribute
Mar 31, 2024
8a2ba34
Updated CHANGELOG
Mar 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[vnext]
- Did a complete code cleanup and refactoring in the .NET project (https://github.com/dukeofharen/httplaceholder/pull/346/files).

[2024.2.24]
- Upgraded application to .NET 8 (https://github.com/dukeofharen/httplaceholder/pull/338).
- Use file watches to check if the .yml stub files are updated on disk (https://github.com/dukeofharen/httplaceholder/pull/339).
Expand Down
1,198 changes: 845 additions & 353 deletions gui/package-lock.json

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,57 @@
"lint": "eslint . --ext .vue,.js,.jsx,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@codemirror/lang-html": "^6.4.7",
"@codemirror/lang-html": "^6.4.8",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-markdown": "^6.2.3",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/language": "^6.9.3",
"@codemirror/lang-markdown": "^6.2.4",
"@codemirror/lang-xml": "^6.1.0",
"@codemirror/language": "^6.10.1",
"@codemirror/legacy-modes": "^6.3.3",
"@codemirror/view": "^6.22.1",
"@fontsource/roboto-mono": "^5.0.16",
"@codemirror/view": "^6.26.0",
"@fontsource/roboto-mono": "^5.0.17",
"@lezer/highlight": "^1.2.0",
"@microsoft/signalr": "^8.0.0",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.2",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"codemirror": "^6.0.1",
"dayjs": "^1.11.10",
"highlight.js": "^11.9.0",
"js-yaml": "^4.1.0",
"marked": "^11.0.0",
"marked": "^12.0.1",
"mime-types": "^2.1.35",
"pinia": "^2.1.7",
"sprintf-js": "^1.1.3",
"toastr": "^2.1.4",
"vue": "^3.3.10",
"vue-pdf-embed": "^1.2.1",
"vue-router": "^4.2.5",
"vue": "^3.4.21",
"vue-pdf-embed": "^2.0.2",
"vue-router": "^4.3.0",
"vue3-slide-up-down": "^2.0.1",
"xml-formatter": "^3.6.0"
"xml-formatter": "^3.6.2"
},
"devDependencies": {
"@babel/types": "^7.23.5",
"@rushstack/eslint-patch": "^1.6.0",
"@babel/types": "^7.24.0",
"@rushstack/eslint-patch": "^1.7.2",
"@types/bootstrap": "^5.2.10",
"@types/js-yaml": "^4.0.9",
"@types/jsdom": "^21.1.6",
"@types/marked": "^5.0.2",
"@types/mime-types": "^2.1.4",
"@types/node": "^20.10.3",
"@types/node": "^20.11.28",
"@types/sprintf-js": "^1.1.4",
"@types/toastr": "^2.1.43",
"@vitejs/plugin-vue": "^4.5.1",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.4.0",
"eslint": "^8.55.0",
"eslint-plugin-vue": "^9.19.2",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.23.0",
"fs-extra": "^11.2.0",
"jsdom": "^23.0.1",
"jsdom": "^24.0.0",
"mustache": "^4.2.0",
"prettier": "^3.1.0",
"sass": "^1.69.5",
"typescript": "~5.3.3",
"vite": "^5.0.6",
"vue-tsc": "^1.8.25"
"prettier": "^3.2.5",
"sass": "^1.72.0",
"typescript": "~5.4.2",
"vite": "^5.1.6",
"vue-tsc": "^2.0.6"
}
}
2 changes: 1 addition & 1 deletion gui/src/components/bootstrap/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal fade" tabindex="-1" ref="modal" @keyup.enter="onYesClick">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="modal-header d-flex justify-content-between">
<h5 class="modal-title">{{ title }}</h5>
<button
type="button"
Expand Down
11 changes: 7 additions & 4 deletions scripts/Install-Windows.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This is added to ensure that the whole script is downloaded before running it.
if ($True) {
if ($True)
{
$global:ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = "Stop"
$tempDir = [System.IO.Path]::GetTempPath()
Expand All @@ -21,8 +22,9 @@ if ($True) {
Invoke-WebRequest -Uri $downloadUrl -UseBasicParsing -OutFile $downloadPath

$mainDrive = (Get-Item $env:windir).PSDrive.Name
$installLocation = "$($mainDrive):\httplaceholder"
if (Test-Path $installLocation) {
$installLocation = "$( $mainDrive ):\httplaceholder"
if (Test-Path $installLocation)
{
Write-Host "Removing directory $installLocation"
Remove-Item -Path $installLocation -Recurse -Force
}
Expand All @@ -31,7 +33,8 @@ if ($True) {
Expand-Archive -Path $downloadPath -DestinationPath $installLocation

$pathVar = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if (!($pathVar -match [regex]::Escape($installLocation))) {
if (!($pathVar -match [regex]::Escape($installLocation)))
{
Write-Host "Adding path $installLocation to the path variable"
$newPath = "$pathVar;$installLocation"
[Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
Expand Down
8 changes: 4 additions & 4 deletions scripts/buildscript/installscripts/windows/Add-Path-Var.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Make sure the install folder is added to the system path variable after install.
Param(
[Parameter(Mandatory=$True)]
[Parameter(Mandatory = $True)]
[string]$installFolder
)

$environmentLocation = "hklm:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$environment = Get-ItemProperty $environmentLocation
$pathVar = $environment.Path
if(!($pathVar -like "*$installFolder*"))
if (!($pathVar -like "*$installFolder*"))
{
$pathVar = "$pathVar;$installFolder"
New-ItemProperty -Path $environmentLocation -Name "Path" -Value $pathVar -Force
$pathVar = "$pathVar;$installFolder"
New-ItemProperty -Path $environmentLocation -Name "Path" -Value $pathVar -Force
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$pfxFile = Join-Path -Path $PSScriptRoot "key.pfx"
if(!(Test-Path $pfxFile)) {
if (!(Test-Path $pfxFile))
{
Write-Error "File $pfxFile not found."
Exit -1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Make sure the install folder is removed from the path variable after deinstallation.
Param(
[Parameter(Mandatory=$True)]
[Parameter(Mandatory = $True)]
[string]$installFolder
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HttPlaceholder.Application.Configuration.Commands.UpdateConfigurationValue;
using HttPlaceholder.Application.Configuration.Provider;
using HttPlaceholder.Application.Configuration.Commands;
using HttPlaceholder.Application.Exceptions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
Expand All @@ -11,7 +10,7 @@ public class UpdateConfigurationValueCommandHandlerFacts
{
private readonly Mock<IConfigurationRoot> _configurationRootMock = new();
private readonly AutoMocker _mocker = new();
private readonly HttPlaceholderConfigurationProvider _provider = new(new MemoryConfigurationSource());
private readonly MemoryConfigurationProvider _provider = new(new MemoryConfigurationSource());

[TestInitialize]
public void Initialize() => _mocker.Use<IConfiguration>(_configurationRootMock.Object);
Expand Down Expand Up @@ -94,13 +93,14 @@ public async Task Handle_HappyFlow(string value)

_configurationRootMock
.Setup(m => m.Providers)
.Returns(new[] {_provider});
.Returns(new[] { _provider });

// Act
await handler.Handle(request, CancellationToken.None);

// Assert
Assert.IsTrue(_provider.TryGet("Storage:StoreResponses", out var foundValue));
Assert.AreEqual(value, foundValue);
_configurationRootMock.Verify(m => m.Reload());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using HttPlaceholder.Application.Configuration.Queries.GetConfiguration;
using HttPlaceholder.Application.Configuration.Queries;
using HttPlaceholder.Domain.Enums;
using Microsoft.Extensions.Configuration;

Expand All @@ -20,7 +20,7 @@ public async Task Handle_HappyFlow()
// Arrange
var testConfig = new Dictionary<string, string>
{
{"Authentication:ApiUsername", "value1"}, {"Authentication:ApiPassword", "value2"}
{ "Authentication:ApiUsername", "value1" }, { "Authentication:ApiPassword", "value2" }
};
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(testConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ public class RequestToCurlCommandServiceFacts
public static IEnumerable<object[]> TestData =>
new[]
{
new object[]
{
[
CreateModel("GET", "http://localhost:5000/url",
new Dictionary<string, string> {{"Accept", "*/*"}}),
new Dictionary<string, string> { { "Accept", "*/*" } }),
"curl 'http://localhost:5000/url' -H 'Accept: */*'"
},
new object[]
{
],
[
CreateModel("DELETE", "http://localhost:5000/url",
new Dictionary<string, string> {{"Accept", "*/*"}}),
new Dictionary<string, string> { { "Accept", "*/*" } }),
"curl -X DELETE 'http://localhost:5000/url' -H 'Accept: */*'"
},
new object[]
{
],
[
CreateModel("POST", "http://localhost:5000/url",
new Dictionary<string, string> {{"Accept", "*/*"}, {"Content-Type", "application/json"}, {"Content-Length", "100"}},
new Dictionary<string, string>
{
{ "Accept", "*/*" }, { "Content-Type", "application/json" }, { "Content-Length", "100" }
},
"""
{
"key": "val"
Expand All @@ -38,11 +38,14 @@ public class RequestToCurlCommandServiceFacts
"key": "val"
}'
"""
},
],
new object[]
{
CreateModel("PUT", "http://localhost:5000/url",
new Dictionary<string, string> {{"Accept", "*/*"}, {"Content-Type", "application/json"}, {"Content-Length", "100"}},
new Dictionary<string, string>
{
{ "Accept", "*/*" }, { "Content-Type", "application/json" }, { "Content-Length", "100" }
},
"""
{
"key": "val"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public void Convert_HappyFlow()
Method = "POST",
Headers = new Dictionary<string, string>
{
{HeaderKeys.ContentType, "application/json"}, {"X-Some-Header", "SomeValue"}
{ HeaderKeys.ContentType, "application/json" }, { "X-Some-Header", "SomeValue" }
},
BinaryBody = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new {key = "val"})),
BinaryBody = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { key = "val" })),
Url = "http://localhost:5000/some-url?q1=v1&q2=v2"
}
};
var response = new ResponseModel
{
Headers = new Dictionary<string, string>
{
{HeaderKeys.ContentType, "application/json"}, {"X-Some-Header", "SomeValue"}
{ HeaderKeys.ContentType, "application/json" }, { "X-Some-Header", "SomeValue" }
},
Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new {key = "responsevalue"})),
Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { key = "responsevalue" })),
BodyIsBinary = false,
StatusCode = 200
};
Expand Down Expand Up @@ -129,21 +129,15 @@ public void Convert_HappyFlow_BinaryResponse()
RequestParameters = new RequestParametersModel
{
Method = "POST",
Headers = new Dictionary<string, string>
{
{HeaderKeys.ContentType, "application/json"}
},
BinaryBody = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new {key = "val"})),
Headers = new Dictionary<string, string> { { HeaderKeys.ContentType, "application/json" } },
BinaryBody = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { key = "val" })),
Url = "http://localhost:5000/some-url?q1=v1&q2=v2"
}
};
var response = new ResponseModel
{
Headers = new Dictionary<string, string>
{
{HeaderKeys.ContentType, "image/png"}
},
Body = new byte[] {1, 2, 3},
Headers = new Dictionary<string, string> { { HeaderKeys.ContentType, "image/png" } },
Body = [1, 2, 3],
BodyIsBinary = true,
StatusCode = 200
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using HttPlaceholder.Application.Exceptions;
using HttPlaceholder.Application.Export;
using HttPlaceholder.Application.Export.Queries.ExportRequest;
using HttPlaceholder.Application.Export.Queries;
using HttPlaceholder.Application.StubExecution;
using HttPlaceholder.Domain.Enums;

Expand Down Expand Up @@ -38,7 +38,8 @@ public async Task Handle_RequestNotFound_ShouldThrowNotFoundException()
[DataTestMethod]
[DataRow(RequestExportType.Hurl)]
[DataRow(RequestExportType.NotSet)]
public async Task Handle_RequestExportTypeNotSupported_ShouldThrowNotImplementedException(RequestExportType requestExportType)
public async Task Handle_RequestExportTypeNotSupported_ShouldThrowNotImplementedException(
RequestExportType requestExportType)
{
// Arrange
var stubContextMock = _mocker.GetMock<IStubContext>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Application\HttPlaceholder.Application.csproj" />
<ProjectReference Include="..\HttPlaceholder.Infrastructure\HttPlaceholder.Infrastructure.csproj" />
<ProjectReference Include="..\HttPlaceholder.Resources\HttPlaceholder.Resources.csproj" />
<ProjectReference Include="..\HttPlaceholder.TestUtilities\HttPlaceholder.TestUtilities.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HttPlaceholder.Application.Import.Commands.CreateCurlStub;
using HttPlaceholder.Application.Import.Commands;
using HttPlaceholder.Application.StubExecution;

namespace HttPlaceholder.Application.Tests.Import.Commands;
Expand All @@ -20,7 +20,7 @@ public async Task Handle_HappyFlow_TenantSet()

const string tenant = "tenant1";
var request = new CreateCurlStubCommand("curl bladibla", true, tenant, "prefix");
var expectedResult = new[] {new FullStubModel()};
var expectedResult = new[] { new FullStubModel() };
curlStubGeneratorMock
.Setup(m => m.GenerateStubsAsync(request.Input, request.DoNotCreateStub, tenant, "prefix",
It.IsAny<CancellationToken>()))
Expand All @@ -41,7 +41,7 @@ public async Task Handle_HappyFlow_TenantNotSet()
var handler = _mocker.CreateInstance<CreateCurlStubCommandHandler>();

var request = new CreateCurlStubCommand("curl bladibla", true, null, "prefix");
var expectedResult = new[] {new FullStubModel()};
var expectedResult = new[] { new FullStubModel() };
string capturedTenant = null;
curlStubGeneratorMock
.Setup(m => m.GenerateStubsAsync(request.Input, request.DoNotCreateStub, It.IsAny<string>(), "prefix",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HttPlaceholder.Application.Import.Commands.CreateHarStub;
using HttPlaceholder.Application.Import.Commands;
using HttPlaceholder.Application.StubExecution;

namespace HttPlaceholder.Application.Tests.Import.Commands;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HttPlaceholder.Application.Import.Commands.CreateOpenApiStub;
using HttPlaceholder.Application.Import.Commands;
using HttPlaceholder.Application.StubExecution;

namespace HttPlaceholder.Application.Tests.Import.Commands;
Expand Down
Loading