Skip to content

Commit

Permalink
Renames tests to be more readable
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Aug 22, 2023
1 parent cbbbf27 commit fd84d3a
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class AuthZinRestLayerTests {
/** Basic Access check */

@Test
public void testShouldFailForUnregisteredUsers() {
public void testShouldNotAllowUnregisteredUsers() {
try (TestRestClient client = cluster.getRestClient(UNREGISTERED)) {
// Legacy plugin
assertThat(client.get(UNPROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_UNAUTHORIZED));
Expand All @@ -96,7 +96,7 @@ public void testShouldFailForUnregisteredUsers() {
}

@Test
public void testShouldFailForBothPlugins() {
public void testAccessDeniedForUserWithNoPermissions() {
try (TestRestClient client = cluster.getRestClient(NO_PERM)) {
// fail at Transport (won't have a rest authz success audit log since this is not a protected endpoint)
assertThat(client.get(UNPROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_FORBIDDEN));
Expand All @@ -113,7 +113,7 @@ public void testShouldFailForBothPlugins() {
/** AuthZ in REST Layer check */

@Test
public void testShouldFailAtTransportLayerWithRestOnlyPermission() {
public void testShouldAllowAtRestAndBlockAtTransport() {
try (TestRestClient client = cluster.getRestClient(REST_ONLY)) {
assertThat(client.get(PROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_FORBIDDEN));
// granted at Rest layer
Expand All @@ -131,7 +131,7 @@ public void testShouldFailAtTransportLayerWithRestOnlyPermission() {
}

@Test
public void testShouldReturnSuccessResponseWithRequiredPermissions() {
public void testShouldAllowAtRestAndTransport() {
try (TestRestClient client = cluster.getRestClient(REST_PLUS_TRANSPORT)) {
assertOKResponseFromProtectedPlugin(client);

Expand All @@ -148,7 +148,7 @@ public void testShouldReturnSuccessResponseWithRequiredPermissions() {
}

@Test
public void testShouldFailForPOST() {
public void testShouldBlockAccessToEndpointForWhichUserHasNoPermission() {
try (TestRestClient client = cluster.getRestClient(REST_ONLY)) {
assertThat(client.post(PROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_UNAUTHORIZED));

Expand All @@ -167,7 +167,7 @@ public void testShouldFailForPOST() {
@Test
public void testBackwardsCompatibility() {

// DUMMY_LEGACY should have access to legacy endpoint, but not protected endpoint
// TRANSPORT_ONLY should have access to legacy endpoint, but not protected endpoint
try (TestRestClient client = cluster.getRestClient(TRANSPORT_ONLY)) {
TestRestClient.HttpResponse res = client.get(PROTECTED_API);
assertThat(res.getStatusCode(), equalTo(HttpStatus.SC_UNAUTHORIZED));
Expand All @@ -182,7 +182,7 @@ public void testBackwardsCompatibility() {
);
}

// DUMMY_REST_ONLY should have access to legacy endpoint (protected endpoint already tested above)
// REST_ONLY should have access to legacy endpoint (protected endpoint already tested above)
try (TestRestClient client = cluster.getRestClient(REST_ONLY)) {
assertOKResponseFromLegacyPlugin(client);
auditLogsRule.assertExactly(0, privilegePredicateRESTLayer(GRANTED_PRIVILEGES, REST_ONLY, GET, UNPROTECTED_API));
Expand All @@ -205,7 +205,7 @@ public void testBackwardsCompatibility() {
);
}

// DUMMY_NO_PERM should not have access to legacy endpoint (protected endpoint already tested above)
// NO_PERM should not have access to legacy endpoint (protected endpoint already tested above)
try (TestRestClient client = cluster.getRestClient(NO_PERM)) {
assertThat(client.get(UNPROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_FORBIDDEN));
auditLogsRule.assertExactly(0, privilegePredicateRESTLayer(MISSING_PRIVILEGES, NO_PERM, GET, UNPROTECTED_API));
Expand All @@ -214,7 +214,7 @@ public void testBackwardsCompatibility() {
);
}

// DUMMY_UNREGISTERED should not have access to legacy endpoint (protected endpoint already tested above)
// UNREGISTERED should not have access to legacy endpoint (protected endpoint already tested above)
try (TestRestClient client = cluster.getRestClient(UNREGISTERED)) {
assertThat(client.get(UNPROTECTED_API).getStatusCode(), equalTo(HttpStatus.SC_UNAUTHORIZED));
auditLogsRule.assertExactly(0, privilegePredicateRESTLayer(MISSING_PRIVILEGES, UNREGISTERED, GET, UNPROTECTED_API));
Expand Down

0 comments on commit fd84d3a

Please sign in to comment.