Skip to content

Commit

Permalink
Add test for null value in permissions
Browse files Browse the repository at this point in the history
Added a test for MDSALDynamicAuthorizationFilter where permissions are
set to null, previously causing a NullPointerException.

Issue resolved by: https://git.opendaylight.org/gerrit/c/aaa/+/109475

JIRA: AAA-224
Change-Id: Ia9ffcd752760d0bcae35fe8491f505f624668530
Signed-off-by: Matej Sramcik <[email protected]>
  • Loading branch information
Sramcik authored and rovarga committed Aug 6, 2024
1 parent d5d521f commit 496f09b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ void testMultiplePolicies() throws Exception {
assertTrue(filter.isAccessAllowed(request, null, null));
}

@Test
public void testWithoutPermissions() throws Exception {
final var resource = "/**";
when(innerPolicies.getResource()).thenReturn(resource);

// return policy without permissions
when(policies.nonnullPolicies()).thenReturn(List.of(innerPolicies));
when(httpAuthorization.nonnullPolicies()).thenReturn(policies);

final var filter = newFilter(subject, mockDataBroker(httpAuthorization));
when(request.getRequestURI()).thenReturn("/abc");
assertFalse(filter.isAccessAllowed(request, null, null));
}

private static DataBroker mockDataBroker(final Object readData) {
final var readOnlyTransaction = mock(ReadTransaction.class);
if (readData instanceof DataObject dataObject) {
Expand Down

0 comments on commit 496f09b

Please sign in to comment.