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

auth error code and some unit tests #201

Merged
merged 15 commits into from
Dec 9, 2024
4 changes: 4 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ dir: "_mocks/{{.PackagePath}}"
# https://github.com/vektra/mockery/commit/13fc60740a1eab3fc705fcc131a4b9a6eacfd0fe#diff-4bc8f03915f15ecf2cb9965592fcf933bb06986003613b5633a8dea7962c31a9R40
resolve-type-alias: false
packages:
io:
config:
interfaces:
Reader:
opencsg.com/csghub-server/component:
config:
interfaces:
Expand Down
88 changes: 88 additions & 0 deletions _mocks/io/mock_Reader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions _mocks/opencsg.com/csghub-server/builder/rsa/mock_KeysReader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/handler/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (h *RepoHandler) LastCommit(ctx *gin.Context) {
}
commit, err := h.c.LastCommit(ctx, req)
if err != nil {
if errors.Is(err, component.ErrForbidden) {
httpbase.ForbiddenError(ctx, err)
return
}
slog.Error("Failed to get repo last commit", slog.String("repo_type", string(req.RepoType)), slog.Any("error", err))
httpbase.ServerError(ctx, err)
return
Expand Down Expand Up @@ -577,6 +581,10 @@ func (h *RepoHandler) Tree(ctx *gin.Context) {
}
tree, err := h.c.Tree(ctx, req)
if err != nil {
if errors.Is(err, component.ErrForbidden) {
httpbase.ForbiddenError(ctx, err)
return
}
slog.Error("Failed to get repo file tree", slog.String("repo_type", string(req.RepoType)), slog.Any("error", err))
httpbase.ServerError(ctx, err)
return
Expand Down
Loading
Loading