use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderGroupsBasedTests method verifyAuthorizedByGroup.
@Test
public void verifyAuthorizedByGroup() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("ROLE_888"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertNotNull(provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "123456")));
assertAll(provider::destroy);
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderDefaultRolesTests method verifyEmptyRoles.
@Test
public void verifyEmptyRoles() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of());
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
val token = provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "123456"));
assertNotNull(token);
assertTrue(token.getAuthorities().isEmpty());
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderRolesBasedTests method verifyAuthorizedByRole.
@Test
public void verifyAuthorizedByRole() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("ROLE_888"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertTrue(provider.supports(UsernamePasswordAuthenticationToken.class));
val token = provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "123456"));
assertNotNull(token);
assertAll(provider::destroy);
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderRolesBasedTests method verifyUnauthorizedByRole.
@Test
public void verifyUnauthorizedByRole() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("SOME_BAD_ROLE"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertThrows(BadCredentialsException.class, () -> provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "123456")));
assertAll(provider::destroy);
}
use of org.springframework.boot.autoconfigure.security.SecurityProperties in project cas by apereo.
the class EndpointLdapAuthenticationProviderRolesBasedTests method verifyUserBadPassword.
@Test
public void verifyUserBadPassword() {
val securityProperties = new SecurityProperties();
securityProperties.getUser().setRoles(List.of("SOME_BAD_ROLE"));
val ldap = casProperties.getMonitor().getEndpoints().getLdap();
val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
val authenticator = LdapUtils.newLdaptiveAuthenticator(ldap);
val provider = new EndpointLdapAuthenticationProvider(ldap, securityProperties, connectionFactory, authenticator);
assertThrows(BadCredentialsException.class, () -> provider.authenticate(new UsernamePasswordAuthenticationToken("authzcas", "BAD_PASSWORD")));
assertAll(provider::destroy);
}
Aggregations