@Test
    void verifyAction() {
        val servicesManager = mock(ServicesManager.class);
        val registeredService = CoreAuthenticationTestUtils.getRegisteredService();
        val policy = new DefaultRegisteredServiceDelegatedAuthenticationPolicy();
        policy.setAllowedProviders(CollectionUtils.wrapList("SomeClient"));
        when(registeredService.getAccessStrategy().getDelegatedAuthenticationPolicy()).thenReturn(policy);

        when(servicesManager.findServiceBy(any(Service.class))).thenReturn(registeredService);
        val assertion = mock(Assertion.class);
        val principal = CoreAuthenticationTestUtils
            .getPrincipal("casuser", CollectionUtils.wrap(ClientCredential.AUTHENTICATION_ATTRIBUTE_CLIENT_NAME, List.of("CasClient")));
        when(assertion.getPrimaryAuthentication()).thenReturn(CoreAuthenticationTestUtils.getAuthentication(principal, principal.getAttributes()));

        val az = new DelegatedAuthenticationServiceTicketValidationAuthorizer(servicesManager,
            new RegisteredServiceDelegatedAuthenticationPolicyAuditableEnforcer());
        assertThrows(UnauthorizedServiceException.class,
            () -> az.authorize(new MockHttpServletRequest(), CoreAuthenticationTestUtils.getService(), assertion));
    }
This is {@link DelegatedAuthenticationServiceTicketValidationAuthorizerTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-pac4j-core/src/test/java/org/apereo/cas/validation/DelegatedAuthenticationServiceTicketValidationAuthorizerTests.java