Chore: Add context to org users (#39526)

* Add context to org users

* Fix go lint

* Roll back xorm refactor

* Use WithTransactionalDbSession

* Update sqlstore.go

Fix typo

* Update org_users.go

Fix typo
This commit is contained in:
idafurjes
2021-09-27 16:43:16 +02:00
committed by GitHub
parent 60f5bceda5
commit 65ebb04cf3
8 changed files with 194 additions and 175 deletions
+3 -3
View File
@@ -38,6 +38,7 @@ func TestOrgUsersAPIEndpoint_userLoggedIn(t *testing.T) {
hs := &HTTPServer{Cfg: settings}
sqlStore := sqlstore.InitTestDB(t)
hs.SQLStore = sqlStore
loggedInUserScenario(t, "When calling GET on", "api/org/users", func(sc *scenarioContext) {
setUpGetOrgUsersDB(t, sqlStore)
@@ -56,7 +57,7 @@ func TestOrgUsersAPIEndpoint_userLoggedIn(t *testing.T) {
loggedInUserScenario(t, "When calling GET on", "api/org/users/search", func(sc *scenarioContext) {
setUpGetOrgUsersDB(t, sqlStore)
sc.handlerFunc = hs.SearchOrgUsersWithPaging
sc.handlerFuncCtx = hs.SearchOrgUsersWithPaging
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
require.Equal(t, http.StatusOK, sc.resp.Code)
@@ -74,7 +75,7 @@ func TestOrgUsersAPIEndpoint_userLoggedIn(t *testing.T) {
loggedInUserScenario(t, "When calling GET with page and limit query parameters on", "api/org/users/search", func(sc *scenarioContext) {
setUpGetOrgUsersDB(t, sqlStore)
sc.handlerFunc = hs.SearchOrgUsersWithPaging
sc.handlerFuncCtx = hs.SearchOrgUsersWithPaging
sc.fakeReqWithParams("GET", sc.url, map[string]string{"perpage": "2", "page": "2"}).exec()
require.Equal(t, http.StatusOK, sc.resp.Code)
@@ -254,7 +255,6 @@ func TestOrgUsersAPIEndpoint_AccessControl(t *testing.T) {
permissions: []*accesscontrol.Permission{{Action: accesscontrol.ActionOrgUsersRead, Scope: accesscontrol.ScopeUsersAll}},
},
{
expectedCode: http.StatusForbidden,
desc: "UsersLookupGet should return 403 for user without required permissions",
url: "/api/org/users/lookup",