@@ -0,0 +1,3758 @@
+package org.apereo.cas.token;%0A%0Aimport com.nimbusds.jwt.JWTClaimsSet;%0Aimport lombok.extern.slf4j.Slf4j;%0Aimport org.apereo.cas.CipherExecutor;%0Aimport org.apereo.cas.authentication.CoreAuthenticationTestUtils;%0Aimport org.apereo.cas.config.CasCoreHttpConfiguration;%0Aimport org.apereo.cas.config.CasCoreTicketCatalogConfiguration;%0Aimport org.apereo.cas.config.CasCoreTicketIdGeneratorsConfiguration;%0Aimport org.apereo.cas.config.CasCoreTicketsConfiguration;%0Aimport org.apereo.cas.config.CasDefaultServiceTicketIdGeneratorsConfiguration;%0Aimport org.apereo.cas.config.TokenCoreConfiguration;%0Aimport org.apereo.cas.util.CollectionUtils;%0Aimport org.jasig.cas.client.authentication.AttributePrincipalImpl;%0Aimport org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator;%0Aimport org.jasig.cas.client.validation.Assertion;%0Aimport org.jasig.cas.client.validation.AssertionImpl;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Qualifier;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.context.TestConfiguration;%0Aimport org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.test.context.TestPropertySource;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport java.net.URL;%0A%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * This is %7B@link JWTTokenTicketBuilderWithoutEncryptionTests%7D.%0A *%0A * @author Misagh Moayyed%0A * @since 5.2.0%0A */%0A@RunWith(SpringRunner.class)%0A@SpringBootTest(classes = %7BRefreshAutoConfiguration.class,%0A        CasCoreTicketsConfiguration.class,%0A        JWTTokenTicketBuilderWithoutEncryptionTests.TokenTicketBuilderTestConfiguration.class,%0A        CasCoreTicketCatalogConfiguration.class,%0A        CasCoreTicketIdGeneratorsConfiguration.class,%0A        CasCoreHttpConfiguration.class,%0A        CasDefaultServiceTicketIdGeneratorsConfiguration.class,%0A        TokenCoreConfiguration.class%7D)%0A@Slf4j%0A@TestPropertySource(properties = %22cas.authn.token.crypto.encryptionEnabled=false%22)%0Apublic class JWTTokenTicketBuilderWithoutEncryptionTests %7B%0A%0A    @Autowired%0A    @Qualifier(%22tokenTicketBuilder%22)%0A    private TokenTicketBuilder tokenTicketBuilder;%0A%0A    @Autowired%0A    @Qualifier(%22tokenCipherExecutor%22)%0A    private CipherExecutor tokenCipherExecutor;%0A%0A    @Test%0A    public void verifyJwtForServiceTicket() throws Exception %7B%0A        final String jwt = tokenTicketBuilder.build(%22ST-123456%22, CoreAuthenticationTestUtils.getService());%0A        assertNotNull(jwt);%0A        final Object result = tokenCipherExecutor.decode(jwt);%0A        final JWTClaimsSet claims = JWTClaimsSet.parse(result.toString());%0A        assertEquals(%22casuser%22, claims.getSubject());%0A    %7D%0A%0A    @TestConfiguration%0A    public static class TokenTicketBuilderTestConfiguration %7B%0A%0A        @Bean%0A        public AbstractUrlBasedTicketValidator casClientTicketValidator() %7B%0A            final AbstractUrlBasedTicketValidator validator = new AbstractUrlBasedTicketValidator(%22https://cas.example.org%22) %7B%0A                @Override%0A                protected String getUrlSuffix() %7B%0A                    return %22/cas%22;%0A                %7D%0A%0A                @Override%0A                protected Assertion parseResponseFromServer(final String s) %7B%0A                    return new AssertionImpl(new AttributePrincipalImpl(%22casuser%22, CollectionUtils.wrap(%22name%22, %22value%22)));%0A                %7D%0A%0A                @Override%0A                protected String retrieveResponseFromServer(final URL url, final String s) %7B%0A                    return %22theresponse%22;%0A                %7D%0A            %7D;%0A            return validator;%0A        %7D%0A    %7D%0A%7D%0A

add tests for encryption=false when generating tokens