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

Implementing 404 error when repo is not found #11449

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/Designer/Filters/Git/GitErrorCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public class GitErrorCodes
{
public const string NonFastForwardError = "GT_01";
public const string RepositoryNotFound = "GT_02";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public override void OnException(ExceptionContext context)
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, GitErrorCodes.NonFastForwardError, HttpStatusCode.Conflict)) { StatusCode = (int)HttpStatusCode.Conflict };
}

if (context.Exception is LibGit2Sharp.RepositoryNotFoundException)
{
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, GitErrorCodes.RepositoryNotFound, HttpStatusCode.NotFound)) { StatusCode = (int)HttpStatusCode.NotFound };
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ public async Task MetadataAndStatus_ShouldBehaveAsExpected(string org)
deserializedRepoStatusModel.RepositoryStatus.Should().Be(RepositoryStatus.Ok);
}

[Theory]
[Trait("Category", "GiteaIntegrationTest")]
[InlineData(GiteaConstants.TestOrgUsername)]
public async Task RepoStatus_ShouldReturn404NotFoundWhenInvalidRepo(string org)
{
// Call status endpoint
using HttpResponseMessage statusResponse = await HttpClient.GetAsync($"designer/api/repos/repo/{org}/123/status");
statusResponse.StatusCode.Should().Be(HttpStatusCode.NotFound);
}

[Theory]
[Trait("Category", "GiteaIntegrationTest")]
[InlineData(GiteaConstants.TestOrgUsername)]
Expand Down
Loading