Skip to content

Commit

Permalink
PT-14520: ForbidResult should return 403 http status code (#2727)
Browse files Browse the repository at this point in the history
fix: ForbidResult from API controller returned 401 http status code instead of 403, it forced redirect to login page.
fix: Platform can be crashed with FormatException on start if build with Visual Studio to 17.8.0, because Product Version in the executable is v3.400.0+72b91b3d2477062c7d246464a41fcd79221312c5.
  • Loading branch information
OlegoO committed Nov 17, 2023
1 parent b4ea46b commit 211dbfa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/VirtoCommerce.Platform.Core/Common/SemanticVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class SemanticVersion : IComparable

public static readonly Regex SemanticVersionStrictRegex = new Regex(
@"^(?<Version>([0-9]|[1-9][0-9]*)(\.([0-9]|[1-9][0-9]*)){2,3})" +
@"(?>\-(?<Prerelease>[0-9A-Za-z\-\.]+))?$"
, RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Compiled);
@"(?>\-(?<Prerelease>[0-9A-Za-z\-\.]+))?(?<Metadata>\+[0-9A-Za-z-]+)?$",
RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Compiled);

public SemanticVersion(Version version)
{
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.Platform.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public void ConfigureServices(IServiceCollection services)
};
options.Events.OnRedirectToAccessDenied = context =>
{
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return Task.CompletedTask;
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SemanticVersionTests
[InlineData("14.9.12", "10.5.7", true)]
[InlineData("4.9.12", "10.5.7", false)]
[InlineData("5.5.5", "5.5.5", true)]
[InlineData("3.439.0+d49dbefbc3e4d944dcffcd2933ada237dd84eaa2", "3.439.0", true)]
public void OperatorGreaterOrZero(string firstVersion, string secondVersion, bool expected)
{
// Arrange
Expand All @@ -33,6 +34,7 @@ public void OperatorGreaterOrZero(string firstVersion, string secondVersion, boo
[InlineData("14.9.12", "10.5.7", false)]
[InlineData("4.9.12", "10.5.7", true)]
[InlineData("5.5.5", "5.5.5", true)]
[InlineData("3.439.0+d49dbefbc3e4d944dcffcd2933ada237dd84eaa2", "3.439.0", true)]
public void OperatorLessOrZero(string firstVersion, string secondVersion, bool expected)
{
// Arrange
Expand All @@ -53,6 +55,7 @@ public void OperatorLessOrZero(string firstVersion, string secondVersion, bool e
[InlineData("14.9.12", "10.5.7", true)]
[InlineData("4.9.12", "10.5.7", false)]
[InlineData("5.5.5", "5.5.5", false)]
[InlineData("3.439.0+d49dbefbc3e4d944dcffcd2933ada237dd84eaa2", "3.439.0", false)]
public void OperatorGreater(string firstVersion, string secondVersion, bool expected)
{
// Arrange
Expand All @@ -73,6 +76,7 @@ public void OperatorGreater(string firstVersion, string secondVersion, bool expe
[InlineData("14.9.12", "10.5.7", false)]
[InlineData("4.9.12", "10.5.7", true)]
[InlineData("5.5.5", "5.5.5", false)]
[InlineData("3.439.0+d49dbefbc3e4d944dcffcd2933ada237dd84eaa2", "3.439.0", false)]
public void OperatorLess(string firstVersion, string secondVersion, bool expected)
{
// Arrange
Expand Down

0 comments on commit 211dbfa

Please sign in to comment.