-
-
Notifications
You must be signed in to change notification settings - Fork 241
Fix: Fully respect configured custom admin path (merge PR #1483) #1490
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ab6ca5
Fix: Fully respect configured custom admin path
PeterBenko 0933a12
Add tests for custom admin path behaviour
PeterBenko b7406f1
Merge PR #1483 (bugfix/1482) into copilot/fix-merge-conflicts and res…
Copilot ad86db7
Potential fix for pull request finding
StefH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using WireMock.Matchers; | ||
|
|
||
| namespace WireMock.Owin; | ||
|
|
||
| internal interface IAdminPaths | ||
| { | ||
| string Files { get; } | ||
| string Health { get; } | ||
| string Mappings { get; } | ||
| string MappingsCode { get; } | ||
| string MappingsWireMockOrg { get; } | ||
| RegexMatcher MappingsGuidPathMatcher { get; } | ||
| RegexMatcher MappingsGuidEnablePathMatcher { get; } | ||
| RegexMatcher MappingsGuidDisablePathMatcher { get; } | ||
| RegexMatcher MappingsCodeGuidPathMatcher { get; } | ||
| RegexMatcher RequestsGuidPathMatcher { get; } | ||
| RegexMatcher ScenariosNameMatcher { get; } | ||
| RegexMatcher ScenariosNameWithStateMatcher { get; } | ||
| RegexMatcher ScenariosNameWithResetMatcher { get; } | ||
| RegexMatcher FilesFilenamePathMatcher { get; } | ||
| RegexMatcher ProtoDefinitionsIdPathMatcher { get; } | ||
| string Requests { get; } | ||
| string Settings { get; } | ||
| string Scenarios { get; } | ||
| string OpenApi { get; } | ||
| string ProtoDefinitions { get; } | ||
| bool Includes(string? path); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright © WireMock.Net | ||
|
|
||
| using System.Text.RegularExpressions; | ||
| using WireMock.Matchers; | ||
|
|
||
| namespace WireMock.Owin; | ||
|
|
||
| internal sealed class AdminPaths(string? adminPath) : IAdminPaths | ||
| { | ||
| private const string DefaultAdminPathPrefix = "/__admin"; | ||
|
|
||
| private readonly string _prefix = adminPath ?? DefaultAdminPathPrefix; | ||
|
|
||
| public string Files => $"{_prefix}/files"; | ||
| public string Health => $"{_prefix}/health"; | ||
| public string Mappings => $"{_prefix}/mappings"; | ||
| public string MappingsCode => $"{_prefix}/mappings/code"; | ||
| public string MappingsWireMockOrg => $"{_prefix}mappings/wiremock.org"; | ||
| public string Requests => $"{_prefix}/requests"; | ||
| public string Settings => $"{_prefix}/settings"; | ||
| public string Scenarios => $"{_prefix}/scenarios"; | ||
| public string OpenApi => $"{_prefix}/openapi"; | ||
| public string ProtoDefinitions => $"{_prefix}/protodefinitions"; | ||
|
|
||
| private string PrefixRegexEscaped => Regex.Escape(_prefix); | ||
| public RegexMatcher MappingsGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$"); | ||
| public RegexMatcher MappingsGuidEnablePathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})\/enable$"); | ||
| public RegexMatcher MappingsGuidDisablePathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})\/disable$"); | ||
| public RegexMatcher MappingsCodeGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/code\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$"); | ||
| public RegexMatcher RequestsGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/requests\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$"); | ||
| public RegexMatcher ScenariosNameMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+$"); | ||
| public RegexMatcher ScenariosNameWithStateMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+\/state$"); | ||
| public RegexMatcher ScenariosNameWithResetMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+\/reset$"); | ||
| public RegexMatcher FilesFilenamePathMatcher => new($@"^{PrefixRegexEscaped}\/files\/.+$"); | ||
| public RegexMatcher ProtoDefinitionsIdPathMatcher => new($@"^{PrefixRegexEscaped}\/protodefinitions\/.+$"); | ||
|
|
||
| public bool Includes(string? path) => !string.IsNullOrEmpty(path) && path.StartsWith($"{_prefix}/"); | ||
|
Check warning on line 37 in src/WireMock.Net.Minimal/Server/AdminPaths.cs
|
||
|
|
||
| public override string ToString() => _prefix; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.