use of org.finra.herd.model.dto.SecurityUserWrapper in project herd by FINRAOS.
the class NamespaceSecurityHelperTest method getAuthorizedNamespacesWhenUserHasPermissionAssertReturnNamespace.
@Test
public void getAuthorizedNamespacesWhenUserHasPermissionAssertReturnNamespace() {
ApplicationUser applicationUser = new ApplicationUser(getClass());
applicationUser.setNamespaceAuthorizations(new HashSet<>(Arrays.asList(new NamespaceAuthorization("namespace", Arrays.asList(NamespacePermissionEnum.READ)))));
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(new SecurityUserWrapper("username", "", true, true, true, true, Collections.emptyList(), applicationUser), null));
Set<String> authorizedNamespaces = namespaceSecurityHelper.getAuthorizedNamespaces(NamespacePermissionEnum.READ);
assertEquals(1, authorizedNamespaces.size());
assertTrue(authorizedNamespaces.contains("namespace"));
}
use of org.finra.herd.model.dto.SecurityUserWrapper in project herd by FINRAOS.
the class NamespaceSecurityHelperTest method getAuthorizedNamespacesWhenUserHasNoPermissionAssertReturnEmpty.
@Test
public void getAuthorizedNamespacesWhenUserHasNoPermissionAssertReturnEmpty() {
ApplicationUser applicationUser = new ApplicationUser(getClass());
applicationUser.setNamespaceAuthorizations(new HashSet<>(Arrays.asList(new NamespaceAuthorization("namespace", Arrays.asList(NamespacePermissionEnum.WRITE)))));
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(new SecurityUserWrapper("username", "", true, true, true, true, Collections.emptyList(), applicationUser), null));
Set<String> authorizedNamespaces = namespaceSecurityHelper.getAuthorizedNamespaces(NamespacePermissionEnum.READ);
assertEquals(0, authorizedNamespaces.size());
}
use of org.finra.herd.model.dto.SecurityUserWrapper in project herd by FINRAOS.
the class NamespaceSecurityHelperTest method getAuthorizedNamespacesWhenNoApplicationUserInContextReturnEmpty.
@Test
public void getAuthorizedNamespacesWhenNoApplicationUserInContextReturnEmpty() {
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(new SecurityUserWrapper("username", "", true, true, true, true, Collections.emptyList(), null), null));
Set<String> authorizedNamespaces = namespaceSecurityHelper.getAuthorizedNamespaces(NamespacePermissionEnum.READ);
assertEquals(0, authorizedNamespaces.size());
}
Aggregations