Skip to content

Commit

Permalink
NIFI-6302:
Browse files Browse the repository at this point in the history
- Updating integration tests to verify pruned results.

This closes #3487.

Signed-off-by: Andy LoPresto <alopresto@apache.org>
  • Loading branch information
mcgilman authored and alopresto committed May 29, 2019
1 parent e6c843f commit 999cfdc
Showing 1 changed file with 30 additions and 4 deletions.
Expand Up @@ -67,6 +67,9 @@ public void testReadUserGetProcessGroup() throws Exception {
assertTrue(entity.getPermissions().getCanRead());
assertFalse(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());

// ensure the contents are not included
assertNull(entity.getComponent().getContents());
}

/**
Expand All @@ -80,6 +83,9 @@ public void testReadWriteUserGetProcessGroup() throws Exception {
assertTrue(entity.getPermissions().getCanRead());
assertTrue(entity.getPermissions().getCanWrite());
assertNotNull(entity.getComponent());

// ensure the contents are not included
assertNull(entity.getComponent().getContents());
}

/**
Expand Down Expand Up @@ -163,6 +169,9 @@ public void testReadWriteUserPutProcessGroup() throws Exception {
assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
assertEquals(updatedName, responseEntity.getComponent().getName());

// ensure the contents are not included
assertNull(responseEntity.getComponent().getContents());
}

/**
Expand Down Expand Up @@ -194,6 +203,9 @@ public void testReadWriteUserPutProcessGroupThroughInheritedPolicy() throws Exce
assertEquals(AccessControlHelper.READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
assertEquals(updatedName, responseEntity.getComponent().getName());

// ensure the contents are not included
assertNull(responseEntity.getComponent().getContents());
}

/**
Expand Down Expand Up @@ -237,6 +249,7 @@ public void testWriteUserPutProcessGroup() throws Exception {
// verify
assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
assertNull(responseEntity.getComponent());
}

/**
Expand Down Expand Up @@ -292,7 +305,14 @@ public void testReadUserDeleteProcessGroup() throws Exception {
*/
@Test
public void testReadWriteUserDeleteProcessGroup() throws Exception {
verifyDelete(helper.getReadWriteUser(), AccessControlHelper.READ_WRITE_CLIENT_ID, 200);
final Response response = verifyDelete(helper.getReadWriteUser(), AccessControlHelper.READ_WRITE_CLIENT_ID, 200);

// verify
final ProcessGroupEntity entity = response.readEntity(ProcessGroupEntity.class);
assertNotNull(entity.getComponent());

// ensure the contents are not included
assertNull(entity.getComponent().getContents());
}

/**
Expand All @@ -302,7 +322,11 @@ public void testReadWriteUserDeleteProcessGroup() throws Exception {
*/
@Test
public void testWriteUserDeleteProcessGroup() throws Exception {
verifyDelete(helper.getWriteUser(), AccessControlHelper.WRITE_CLIENT_ID, 200);
final Response response = verifyDelete(helper.getWriteUser(), AccessControlHelper.WRITE_CLIENT_ID, 200);

// verify
final ProcessGroupEntity entity = response.readEntity(ProcessGroupEntity.class);
assertNull(entity.getComponent());
}

/**
Expand Down Expand Up @@ -417,7 +441,7 @@ private ProcessGroupEntity createProcessGroup(final String name) throws Exceptio
return entity;
}

private void verifyDelete(final NiFiTestUser user, final String clientId, final int responseCode) throws Exception {
private Response verifyDelete(final NiFiTestUser user, final String clientId, final int responseCode) throws Exception {
final ProcessGroupEntity entity = createProcessGroup("Copy");

// create the entity body
Expand All @@ -426,10 +450,12 @@ private void verifyDelete(final NiFiTestUser user, final String clientId, final
queryParams.put("clientId", clientId);

// perform the request
Response response = user.testDelete(entity.getUri(), queryParams);
final Response response = user.testDelete(entity.getUri(), queryParams);

// ensure the request is failed with a forbidden status code
assertEquals(responseCode, response.getStatus());

return response;
}

@AfterClass
Expand Down

0 comments on commit 999cfdc

Please sign in to comment.