@Test
    void verifyCasClientCanValidate() throws Throwable {
        val service = getOAuthRegisteredService(REDIRECT_URI, SERVICE_NAME);
        servicesManager.save(service);

        val mockRequest = new MockHttpServletRequest(HttpMethod.GET.name(), CONTEXT + OAuth20Constants.AUTHORIZE_URL);
        mockRequest.setParameter(OAuth20Constants.CLIENT_ID, service.getClientId());
        mockRequest.setParameter(OAuth20Constants.REDIRECT_URI, REDIRECT_URI);
        mockRequest.addHeader(HttpHeaders.USER_AGENT, "MSIE");
        val mockResponse = new MockHttpServletResponse();
        val callContext = new CallContext(new JEEContext(mockRequest, mockResponse),
            oauthDistributedSessionStore, ProfileManagerFactory.DEFAULT);
        val redirect = oauthCasClient.getRedirectionAction(callContext);
        assertTrue(redirect.isPresent());

        val callbackUrl = ((WithLocationAction) redirect.get()).getLocation();
        val callback = RegisteredServiceTestUtils.getRegisteredService(callbackUrl);
        servicesManager.save(callback);
        
        val tgt = new MockTicketGrantingTicket(UUID.randomUUID().toString());
        ticketRegistry.addTicket(tgt);

        val trackingPolicy = mock(TicketTrackingPolicy.class);
        val ticketService = RegisteredServiceTestUtils.getService(REDIRECT_URI);
        ticketService.getAttributes().put(OAuth20Constants.CLIENT_ID, List.of(service.getClientId()));
        val st1 = tgt.grantServiceTicket(ticketService, trackingPolicy);

        ticketRegistry.addTicket(st1);
        ticketRegistry.updateTicket(tgt);
        mockRequest.addParameter(OAuth20Constants.CLIENT_ID, service.getClientId());
        mockRequest.addParameter(CasProtocolConstants.PARAMETER_TICKET, st1.getId());
        mockRequest.addParameter(CasProtocolConstants.PARAMETER_SERVICE, callbackUrl);

        val clientCallContext = new CallContext(new JEEContext(mockRequest, mockResponse),
            oauthDistributedSessionStore, ProfileManagerFactory.DEFAULT);
        val result = oauthCasClient.getCredentials(clientCallContext)
            .map(credentials -> oauthCasClient.validateCredentials(clientCallContext, credentials))
            .orElseThrow();
        assertTrue(result.isPresent());
        assertNotNull(result.get().getUserProfile());
    }
This class tests the {@link OAuth20AuthorizeEndpointController} class.

@author Jerome Leleu
@since 3.5.2
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/web/endpoints/OAuth20AuthorizeEndpointControllerTests.java