use of org.apereo.cas.support.rest.resources.ServiceTicketResource 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();
}
use of org.apereo.cas.support.rest.resources.ServiceTicketResource 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();
}
Aggregations