@Test
        void verifyTicketExpired() throws Throwable {
            val response = new MockHttpServletResponse();
            val request = new MockHttpServletRequest();
            request.setMethod("POST");
            request.setContentType(MediaType.TEXT_XML_VALUE);

            var builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
            var envelope = (Envelope) builder.buildObject();

            builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Header.DEFAULT_ELEMENT_NAME);
            val header = (Header) builder.buildObject();
            envelope.setHeader(header);

            builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Body.DEFAULT_ELEMENT_NAME);
            val body = (Body) builder.buildObject();
            val query = getAttributeQuery(NameIDType.TRANSIENT, "casuser-aq");
            body.getUnknownXMLObjects().add(query);
            envelope.setBody(body);

            val ticketGrantingTicket = new MockTicketGrantingTicket("casuser",
                Map.of("cn", List.of("CAS"), "lastName", List.of("Apereo")),
                Map.of("event-type", List.of("saml1-attr-query")));
            val ticket = samlAttributeQueryTicketFactory.create(
                "casuser-aq", query, "https://cassp.example.org", ticketGrantingTicket);
            ticketRegistry.addTicket(ticket);

            val xml = SamlUtils.transformSamlObject(openSamlConfigBean, envelope).toString();
            request.setContent(xml.getBytes(StandardCharsets.UTF_8));

            ticket.markTicketExpired();
            controller.handlePostRequest(response, request);
            assertNotNull(request.getAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR));
            assertNotNull(request.getAttribute(FaultString.class.getSimpleName()));
            assertEquals(HttpStatus.SC_OK, response.getStatus());
        }
This is {@link SamlIdPSaml2AttributeQueryProfileHandlerControllerTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-saml-idp/src/test/java/org/apereo/cas/support/saml/web/idp/profile/query/SamlIdPSaml2AttributeQueryProfileHandlerControllerTests.java