Search in sources :

Example 1 with CasProtocolServiceTicketResourceEntityResponseFactory

use of org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory 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 2 with CasProtocolServiceTicketResourceEntityResponseFactory

use of org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory 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)

Aggregations

AuthenticationTransaction (org.apereo.cas.authentication.AuthenticationTransaction)2 DefaultAuthenticationSystemSupport (org.apereo.cas.authentication.DefaultAuthenticationSystemSupport)2 DefaultAuthenticationTransactionManager (org.apereo.cas.authentication.DefaultAuthenticationTransactionManager)2 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)2 CasProtocolServiceTicketResourceEntityResponseFactory (org.apereo.cas.rest.factory.CasProtocolServiceTicketResourceEntityResponseFactory)2 ServiceTicketResource (org.apereo.cas.support.rest.resources.ServiceTicketResource)2 DefaultArgumentExtractor (org.apereo.cas.web.support.DefaultArgumentExtractor)2 lombok.val (lombok.val)1 AuthenticationManager (org.apereo.cas.authentication.AuthenticationManager)1 DefaultAuthenticationResultBuilderFactory (org.apereo.cas.authentication.DefaultAuthenticationResultBuilderFactory)1 DefaultAuthenticationTransactionFactory (org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory)1 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.DefaultPrincipalElectionStrategy)1 DefaultPrincipalElectionStrategy (org.apereo.cas.authentication.principal.DefaultPrincipalElectionStrategy)1 UsernamePasswordRestHttpRequestCredentialFactory (org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1