-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
bug fixed for API to get user's repos #1622
Conversation
LGTM |
@@ -9,7 +9,7 @@ import ( | |||
// listUserRepos - List the repositories owned by the given user. | |||
func listUserRepos(ctx *context.APIContext, u *models.User) { | |||
userID := u.ID | |||
showPrivateRepos := (ctx.User.ID == userID || ctx.User.IsAdmin) && ctx.IsSigned | |||
showPrivateRepos := ctx.IsSigned && (ctx.User.ID == userID || ctx.User.IsAdmin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx.User is also used in getAccessibleRepos
called from https://github.com/lunny/gitea/blob/07ad1e27dd8fbebb90b53590a958115e7c680130/routers/api/v1/user/repo.go#L18
For testing you can make integration test and request the API directly ? |
@lunny Perfect. Still LGTM for me ^^ |
LGTM |
integrations/api_repo_test.go
Outdated
func TestAPIUserReposNotLogin(t *testing.T) { | ||
assert.NoError(t, models.LoadFixtures()) | ||
|
||
req, err := http.NewRequest("GET", "/api/v1/users/user1/repos", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user1 don't have repos in mock value so maybe we could also test user2 repo listing?
https://github.com/go-gitea/gitea/blob/master/models/fixtures/repository.yml
waiting for #1627 |
80ad764
to
8bb4a20
Compare
let L-G-T-M work |
As title. Will fix #1540. And how to test APIs? Maybe we need a framework like intergration test to do that?