@Test
    void verifyNotAuthorized() throws Throwable {
        val context = MockRequestContext.create(applicationContext);
        WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());

        val attributes = new LinkedHashMap<String, List<Object>>();
        attributes.put(SurrogateAuthenticationService.AUTHENTICATION_ATTR_SURROGATE_ENABLED, List.of(true));
        attributes.putAll(CoreAuthenticationTestUtils.getAttributeRepository().getBackingMap());

        val principal = CoreAuthenticationTestUtils.getPrincipal("casuser", attributes);
        WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(principal), context);
        val registeredService = RegisteredServiceTestUtils.getRegisteredService();
        val strategy = new SurrogateRegisteredServiceAccessStrategy();
        strategy.setSurrogateRequiredAttributes(CollectionUtils.wrap("surrogateAttribute", CollectionUtils.wrapSet("someValue")));
        registeredService.setAccessStrategy(strategy);
        WebUtils.putRegisteredService(context, registeredService);
        assertThrows(PrincipalException.class, () -> surrogateAuthorizationCheck.execute(context));
    }
This is {@link SurrogateAuthorizationActionTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-surrogate-webflow/src/test/java/org/apereo/cas/web/flow/action/SurrogateAuthorizationActionTests.java