Unverified Commit 8f6bb157 authored by JoramWilander's avatar JoramWilander
Browse files

Fix oauth app update

parent 4bc4ae16
......@@ -100,7 +100,7 @@ func updateOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if c.Session.UserId != oauthApp.CreatorId && !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH) {
if c.Session.UserId != oldOauthApp.CreatorId && !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH)
return
}
......
......@@ -101,7 +101,7 @@ func TestUpdateOAuthApp(t *testing.T) {
IsTrusted: false,
IconURL: "https://nowhere.com/img",
Homepage: "https://nowhere.com",
Description: "test",
Description: "test",
CallbackUrls: []string{"https://callback.com"},
}
......@@ -112,7 +112,7 @@ func TestUpdateOAuthApp(t *testing.T) {
oapp.IconURL = "https://nowhere.com/img_update"
oapp.Homepage = "https://nowhere_update.com"
oapp.Description = "test_update"
oapp.CallbackUrls = []string{"https://callback_update.com","https://another_callback.com"}
oapp.CallbackUrls = []string{"https://callback_update.com", "https://another_callback.com"}
updatedApp, resp := AdminClient.UpdateOAuthApp(oapp)
CheckNoError(t, resp)
......@@ -153,7 +153,7 @@ func TestUpdateOAuthApp(t *testing.T) {
for i, callbackUrl := range updatedApp.CallbackUrls {
if callbackUrl != oapp.CallbackUrls[i] {
t.Fatal("Description should have updated")
}
}
}
}
......@@ -165,6 +165,13 @@ func TestUpdateOAuthApp(t *testing.T) {
t.Fatal("IsTrusted should have updated")
}
th.LoginBasic2()
updatedApp.CreatorId = th.BasicUser2.Id
_, resp = Client.UpdateOAuthApp(oapp)
CheckForbiddenStatus(t, resp)
th.LoginBasic()
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
utils.SetDefaultRolesBasedOnConfig()
_, resp = Client.UpdateOAuthApp(oapp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment