Search in sources :

Example 1 with DefaultAuthenticationSystemSupport

use of org.apereo.cas.authentication.DefaultAuthenticationSystemSupport in project cas by apereo.

the class TicketsResourceTests method setUp.

@Before
public void setUp() throws Exception {
    final AuthenticationManager mgmr = mock(AuthenticationManager.class);
    when(mgmr.authenticate(any(AuthenticationTransaction.class))).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    when(ticketSupport.getAuthenticationFrom(anyString())).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    this.ticketsResourceUnderTest = new TicketsResource(new DefaultAuthenticationSystemSupport(new DefaultAuthenticationTransactionManager(mgmr), new DefaultPrincipalElectionStrategy()), new DefaultCredentialFactory(), ticketSupport, new WebApplicationServiceFactory(), casMock);
    this.mockMvc = MockMvcBuilders.standaloneSetup(this.ticketsResourceUnderTest).defaultRequest(get("/").contextPath("/cas").contentType(MediaType.APPLICATION_FORM_URLENCODED)).build();
}
Also used : AuthenticationManager(org.apereo.cas.authentication.AuthenticationManager) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.DefaultPrincipalElectionStrategy) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) AuthenticationTransaction(org.apereo.cas.authentication.AuthenticationTransaction) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager) Before(org.junit.Before)

Example 2 with DefaultAuthenticationSystemSupport

use of org.apereo.cas.authentication.DefaultAuthenticationSystemSupport in project cas by apereo.

the class ServiceTicketResourceTests method setUp.

@Before
public void setUp() {
    final AuthenticationManager mgmr = mock(AuthenticationManager.class);
    when(mgmr.authenticate(any(AuthenticationTransaction.class))).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    when(ticketSupport.getAuthenticationFrom(anyString())).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    this.serviceTicketResource = new ServiceTicketResource(new DefaultAuthenticationSystemSupport(new DefaultAuthenticationTransactionManager(mgmr), new DefaultPrincipalElectionStrategy()), ticketSupport, new DefaultArgumentExtractor(new WebApplicationServiceFactory()), new CasProtocolServiceTicketResourceEntityResponseFactory(casMock));
    this.mockMvc = MockMvcBuilders.standaloneSetup(this.serviceTicketResource).defaultRequest(get("/").contextPath("/cas").contentType(MediaType.APPLICATION_FORM_URLENCODED)).build();
}
Also used : AuthenticationManager(org.apereo.cas.authentication.AuthenticationManager) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.DefaultPrincipalElectionStrategy) DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) CasProtocolServiceTicketResourceEntityResponseFactory(org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) AuthenticationTransaction(org.apereo.cas.authentication.AuthenticationTransaction) ServiceTicketResource(org.apereo.cas.support.rest.resources.ServiceTicketResource) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager) Before(org.junit.Before)

Example 3 with DefaultAuthenticationSystemSupport

use of org.apereo.cas.authentication.DefaultAuthenticationSystemSupport in project cas by apereo.

the class TicketGrantingTicketResourceTests method setUp.

@Before
public void setUp() {
    final AuthenticationManager mgmr = mock(AuthenticationManager.class);
    when(mgmr.authenticate(any(AuthenticationTransaction.class))).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    when(ticketSupport.getAuthenticationFrom(anyString())).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    this.ticketGrantingTicketResourceUnderTest = new TicketGrantingTicketResource(new DefaultAuthenticationSystemSupport(new DefaultAuthenticationTransactionManager(mgmr), new DefaultPrincipalElectionStrategy()), new UsernamePasswordRestHttpRequestCredentialFactory(), casMock, new WebApplicationServiceFactory(), new DefaultTicketGrantingTicketResourceEntityResponseFactory());
    this.mockMvc = MockMvcBuilders.standaloneSetup(this.ticketGrantingTicketResourceUnderTest).defaultRequest(get("/").contextPath("/cas").contentType(MediaType.APPLICATION_FORM_URLENCODED)).build();
}
Also used : AuthenticationManager(org.apereo.cas.authentication.AuthenticationManager) TicketGrantingTicketResource(org.apereo.cas.support.rest.resources.TicketGrantingTicketResource) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.DefaultPrincipalElectionStrategy) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) UsernamePasswordRestHttpRequestCredentialFactory(org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory) DefaultTicketGrantingTicketResourceEntityResponseFactory(org.apereo.cas.rest.factory.DefaultTicketGrantingTicketResourceEntityResponseFactory) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) AuthenticationTransaction(org.apereo.cas.authentication.AuthenticationTransaction) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager) Before(org.junit.Before)

Example 4 with DefaultAuthenticationSystemSupport

use of org.apereo.cas.authentication.DefaultAuthenticationSystemSupport in project cas by apereo.

the class ServiceTicketResourceTests method initialize.

@BeforeEach
public void initialize() {
    val mgmr = mock(AuthenticationManager.class);
    lenient().when(mgmr.authenticate(any(AuthenticationTransaction.class))).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    lenient().when(ticketSupport.getAuthenticationFrom(anyString())).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    val publisher = mock(ApplicationEventPublisher.class);
    this.serviceTicketResource = new ServiceTicketResource(new DefaultAuthenticationSystemSupport(new DefaultAuthenticationTransactionManager(publisher, mgmr), new DefaultPrincipalElectionStrategy(), new DefaultAuthenticationResultBuilderFactory(), new DefaultAuthenticationTransactionFactory()), ticketSupport, new DefaultArgumentExtractor(new WebApplicationServiceFactory()), new CasProtocolServiceTicketResourceEntityResponseFactory(casMock), new UsernamePasswordRestHttpRequestCredentialFactory(), new GenericApplicationContext());
    this.mockMvc = MockMvcBuilders.standaloneSetup(this.serviceTicketResource).defaultRequest(get("/").contextPath("/cas").accept(MediaType.APPLICATION_FORM_URLENCODED, MediaType.TEXT_PLAIN).contentType(MediaType.APPLICATION_FORM_URLENCODED)).build();
}
Also used : lombok.val(lombok.val) UsernamePasswordRestHttpRequestCredentialFactory(org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory) ServiceTicketResource(org.apereo.cas.support.rest.resources.ServiceTicketResource) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy) DefaultAuthenticationResultBuilderFactory(org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory) DefaultArgumentExtractor(org.apereo.cas.web.support.DefaultArgumentExtractor) CasProtocolServiceTicketResourceEntityResponseFactory(org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) AuthenticationTransaction(org.apereo.cas.authentication.AuthenticationTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with DefaultAuthenticationSystemSupport

use of org.apereo.cas.authentication.DefaultAuthenticationSystemSupport in project cas by apereo.

the class RegisteredServiceResourceTests method getRegisteredServiceResource.

private RegisteredServiceResource getRegisteredServiceResource(final String attrName, final String attrValue) {
    val mgmr = mock(AuthenticationManager.class);
    lenient().when(mgmr.authenticate(argThat(new AuthenticationCredentialMatcher("test")))).thenReturn(CoreAuthenticationTestUtils.getAuthentication());
    lenient().when(mgmr.authenticate(argThat(new AuthenticationCredentialMatcher("testfail")))).thenThrow(AuthenticationException.class);
    val publisher = mock(ApplicationEventPublisher.class);
    return new RegisteredServiceResource(new DefaultAuthenticationSystemSupport(new DefaultAuthenticationTransactionManager(publisher, mgmr), new DefaultPrincipalElectionStrategy(), new DefaultAuthenticationResultBuilderFactory(), new DefaultAuthenticationTransactionFactory()), new WebApplicationServiceFactory(), servicesManager, attrName, attrValue);
}
Also used : lombok.val(lombok.val) DefaultPrincipalElectionStrategy(org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy) DefaultAuthenticationResultBuilderFactory(org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) DefaultAuthenticationSystemSupport(org.apereo.cas.authentication.DefaultAuthenticationSystemSupport) DefaultAuthenticationTransactionFactory(org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory) DefaultAuthenticationTransactionManager(org.apereo.cas.authentication.DefaultAuthenticationTransactionManager)

Aggregations

DefaultAuthenticationSystemSupport (org.apereo.cas.authentication.DefaultAuthenticationSystemSupport)7 DefaultAuthenticationTransactionManager (org.apereo.cas.authentication.DefaultAuthenticationTransactionManager)7 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)6 AuthenticationTransaction (org.apereo.cas.authentication.AuthenticationTransaction)5 lombok.val (lombok.val)4 DefaultAuthenticationResultBuilderFactory (org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory)4 DefaultAuthenticationTransactionFactory (org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory)4 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy)4 AuthenticationManager (org.apereo.cas.authentication.AuthenticationManager)3 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.DefaultPrincipalElectionStrategy)3 UsernamePasswordRestHttpRequestCredentialFactory (org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory)3 Before (org.junit.Before)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 CasProtocolServiceTicketResourceEntityResponseFactory (org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory)2 DefaultTicketGrantingTicketResourceEntityResponseFactory (org.apereo.cas.rest.factory.DefaultTicketGrantingTicketResourceEntityResponseFactory)2 ServiceTicketResource (org.apereo.cas.support.rest.resources.ServiceTicketResource)2 TicketGrantingTicketResource (org.apereo.cas.support.rest.resources.TicketGrantingTicketResource)2 DefaultArgumentExtractor (org.apereo.cas.web.support.DefaultArgumentExtractor)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 MessageFormat (java.text.MessageFormat)1