Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void listDrafts(HttpServiceRequest request, HttpServiceResponder responde
@QueryParam("sortOrder") @DefaultValue("ASC") String sortOrder,
@QueryParam("filter") @Nullable String filter) {

contextAccessEnforcer.enforce(new NamespaceId(namespaceName), StandardPermission.LIST);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Enforcing StandardPermission.LIST here is correct and aligns with ConnectionHandler. However, this change will cause the existing test testDraftAuthorization in DraftServiceTest.java to fail.

In DraftServiceTest.java (lines 180-183), the test only grants StandardPermission.GET to ALICE_PRINCIPAL before calling listDrafts and expecting HTTP_OK:

getPermissionManager().grant(namespaceAuthorizable,
                            ALICE_PRINCIPAL,
                            EnumSet.of(StandardPermission.GET));

Since listDrafts now enforces StandardPermission.LIST, this call will return HTTP_FORBIDDEN (403) and fail the test. Please update DraftServiceTest.java to also grant StandardPermission.LIST to Alice:

getPermissionManager().grant(namespaceAuthorizable,
                            ALICE_PRINCIPAL,
                            EnumSet.of(StandardPermission.GET, StandardPermission.LIST));

respond(namespaceName, responder, (namespace) -> {
if (!draftService.fieldExists(sortBy)) {
throw new IllegalArgumentException(String.format(
Expand All @@ -103,6 +104,7 @@ public void listDrafts(HttpServiceRequest request, HttpServiceResponder responde
public void getDraft(HttpServiceRequest request, HttpServiceResponder responder,
@PathParam("context") String namespaceName,
@PathParam("draft") String draftId) {
contextAccessEnforcer.enforce(new NamespaceId(namespaceName), StandardPermission.GET);
respond(namespaceName, responder, (namespace) -> {
String userId = "";
DraftId id = new DraftId(namespace, draftId, userId);
Expand Down