Skip to content
Merged
Show file tree
Hide file tree
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 @@ -641,7 +641,7 @@ public void testInvalidPrefixAcl() throws IOException {
// add acl with invalid prefix name
Exception ex = assertThrows(OMException.class,
() -> writeClient.addAcl(ozInvalidPrefix, ozAcl1));
assertTrue(ex.getMessage().startsWith("Invalid prefix name"));
assertTrue(ex.getMessage().startsWith("Missing trailing slash"));

OzoneObj ozPrefix1 = new OzoneObjInfo.Builder()
.setVolumeName(volumeName)
Expand All @@ -659,20 +659,20 @@ public void testInvalidPrefixAcl() throws IOException {
// get acl with invalid prefix name
ex = assertThrows(OMException.class,
() -> writeClient.getAcl(ozInvalidPrefix));
assertTrue(ex.getMessage().startsWith("Invalid prefix name"));
assertTrue(ex.getMessage().startsWith("Missing trailing slash"));

// set acl with invalid prefix name
List<OzoneAcl> ozoneAcls = new ArrayList<OzoneAcl>();
ozoneAcls.add(ozAcl1);

ex = assertThrows(OMException.class,
() -> writeClient.setAcl(ozInvalidPrefix, ozoneAcls));
assertTrue(ex.getMessage().startsWith("Invalid prefix name"));
assertTrue(ex.getMessage().startsWith("Missing trailing slash"));

// remove acl with invalid prefix name
ex = assertThrows(OMException.class,
() -> writeClient.removeAcl(ozInvalidPrefix, ozAcl1));
assertTrue(ex.getMessage().startsWith("Invalid prefix name"));
assertTrue(ex.getMessage().startsWith("Missing trailing slash"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.PREFIX_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_PATH_IN_ACL_REQUEST;
import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.PREFIX_LOCK;
import static org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType.PREFIX;

Expand Down Expand Up @@ -218,8 +219,8 @@ public void validateOzoneObj(OzoneObj obj) throws OMException {
throw new OMException("Prefix name is required.", PREFIX_NOT_FOUND);
}
if (!prefixName.endsWith("/")) {
throw new OMException("Invalid prefix name: " + prefixName,
PREFIX_NOT_FOUND);
throw new OMException("Missing trailing slash '/' in prefix name: " + prefixName,
INVALID_PATH_IN_ACL_REQUEST);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void testValidationFailure() {
);
OMClientResponse response1 =
invalidRequest1.validateAndUpdateCache(ozoneManager, 1);
assertEquals(OzoneManagerProtocolProtos.Status.PREFIX_NOT_FOUND,
assertEquals(OzoneManagerProtocolProtos.Status.INVALID_PATH_IN_ACL_REQUEST,
response1.getOMResponse().getStatus());

// Not a valid FS path
Expand Down