1 parent
c6071414df
commit
cc47447ddd
4 files changed
+13
-8
No files matched your search
@@ -19,7 +19,7 @@ const (
|
||||
)
|
||||
|
||||
func GetPluginList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
if !authenticatedPluginUser(ctx) || authorizeCapability(ctx, access.CapabilityPluginRead, "", false) != nil {
|
||||
if !authenticatedPluginUser(ctx) || authorizeCapability(ctx, access.CapabilityPluginReadGlobal, "", false) != nil {
|
||||
response.NewErrorResponse(response.NoAccessPrivileges, "\u65e0\u6743\u8bbf\u95ee", "").FPrint(w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ func TestPluginConfigurationRejectsNonAdminAccess(t *testing.T) {
|
||||
|
||||
userListRecorder := httptest.NewRecorder()
|
||||
GetPluginList(&context.Context{UserID: 2, Role: access.RoleUser}, userListRecorder, httptest.NewRequest(http.MethodGet, "/api/plugin/list", nil))
|
||||
if !strings.Contains(userListRecorder.Body.String(), "PluginTest") {
|
||||
t.Fatalf("authenticated user cannot read plugin list: body=%s", userListRecorder.Body.String())
|
||||
if !strings.Contains(userListRecorder.Body.String(), "无权访问") {
|
||||
t.Fatalf("ordinary user can read global plugin list: body=%s", userListRecorder.Body.String())
|
||||
}
|
||||
|
||||
pageRecorder := httptest.NewRecorder()
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestManagementEndpointCatalog(t *testing.T) {
|
||||
}
|
||||
}
|
||||
endpoint, ok := LookupEndpoint("POST", "/api/plugin/settings/example")
|
||||
if !ok || endpoint.Capability != CapabilityPluginWriteOwn {
|
||||
if !ok || endpoint.Capability != CapabilityPluginReadGlobal {
|
||||
t.Fatal("plugin settings endpoint was not matched")
|
||||
}
|
||||
endpoint, ok = LookupEndpoint("GET", "/api/v1/logs")
|
||||
|
||||
Reference in new issue
Block a user