/** * Constructs a request object wrapping the given request. * * @param request The request to wrap * @throws IllegalArgumentException if the request is null */ public LdapRoleCheckingRequest(final HttpServletRequest request, final LDAPInterface ldapInterface, final String userDN, final LdapProperties ldapProperties) throws LDAPException { super(request); this.ldapInterface = ldapInterface; this.userDN = userDN; this.roleBaseDN = ldapProperties.getRoleBaseDn(); this.userRoles = getRoles(); }
@Test public void shouldReturnUserRoles() throws LDAPException { final HttpServletRequest mockRequest = mock(HttpServletRequest.class); final LDAPInterface ldap = someLdapInterfaceReturning("foo"); final LdapRoleCheckingRequest request = new LdapRoleCheckingRequest(mockRequest, ldap, "uid=test", someLdapProperties()); assertThat(request.getRoles()).contains("foo"); }