use of org.apache.nifi.web.api.entity.LabelEntity in project nifi by apache.
the class ITLabelAccessControl method testReadWriteUserPutLabelThroughInheritedPolicy.
/**
* Ensures the READ_WRITE user can put a label.
*
* @throws Exception ex
*/
@Test
public void testReadWriteUserPutLabelThroughInheritedPolicy() throws Exception {
final LabelEntity entity = createLabel(NiFiTestAuthorizer.NO_POLICY_COMPONENT_NAME);
final String updatedLabel = "Updated name";
// attempt to update the name
final long version = entity.getRevision().getVersion();
entity.getRevision().setClientId(READ_WRITE_CLIENT_ID);
entity.getComponent().setLabel(updatedLabel);
// perform the request
final Response response = updateLabel(helper.getReadWriteUser(), entity);
// ensure successful response
assertEquals(200, response.getStatus());
// get the response
final LabelEntity responseEntity = response.readEntity(LabelEntity.class);
// verify
assertEquals(AccessControlHelper.READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
assertEquals(updatedLabel, responseEntity.getComponent().getLabel());
}
use of org.apache.nifi.web.api.entity.LabelEntity in project nifi by apache.
the class ITLabelAccessControl method testWriteUserPutLabel.
/**
* Ensures the WRITE user can put a label.
*
* @throws Exception ex
*/
@Test
public void testWriteUserPutLabel() throws Exception {
final LabelEntity entity = getRandomLabel(helper.getWriteUser());
assertFalse(entity.getPermissions().getCanRead());
assertTrue(entity.getPermissions().getCanWrite());
assertNull(entity.getComponent());
final String updatedLabel = "Updated Name";
// attempt to update the label
final LabelDTO requestDto = new LabelDTO();
requestDto.setId(entity.getId());
requestDto.setLabel(updatedLabel);
final long version = entity.getRevision().getVersion();
final RevisionDTO requestRevision = new RevisionDTO();
requestRevision.setVersion(version);
requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
final LabelEntity requestEntity = new LabelEntity();
requestEntity.setId(entity.getId());
requestEntity.setRevision(requestRevision);
requestEntity.setComponent(requestDto);
// perform the request
final Response response = updateLabel(helper.getWriteUser(), requestEntity);
// ensure successful response
assertEquals(200, response.getStatus());
// get the response
final LabelEntity responseEntity = response.readEntity(LabelEntity.class);
// verify
assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
Aggregations