<commit_before>package org.apereo.cas.ticket.registry;

import org.apereo.cas.authentication.Authentication;
import org.apereo.cas.authentication.CoreAuthenticationTestUtils;
import org.apereo.cas.config.CasCoreAuthenticationConfiguration;
import org.apereo.cas.config.CasCoreServicesConfiguration;
import org.apereo.cas.config.CasCoreTicketsConfiguration;
import org.apereo.cas.config.CasCoreUtilConfiguration;
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.logout.config.CasCoreLogoutConfiguration;
import org.apereo.cas.ticket.TicketGrantingTicket;
import org.apereo.cas.ticket.TicketGrantingTicketFactory;
import org.apereo.cas.ticket.registry.config.JwtTicketRegistryConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Map;

import static org.junit.Assert.*;

/**
 * This is {@link JwtTicketRegistryTests}.
 *
 * @author <NAME>
 * @since 5.1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest(
        classes = {RefreshAutoConfiguration.class,
                CasCoreUtilConfiguration.class,
                CasCoreAuthenticationConfiguration.class,
                CasCoreServicesConfiguration.class,
                CasPersonDirectoryConfiguration.class,
                CasCoreLogoutConfiguration.class,
                CasCoreTicketsConfiguration.class,
                JwtTicketRegistryConfiguration.class})
@EnableScheduling
public class JwtTicketRegistryTests {

    @Autowired
    @Qualifier("defaultTicketGrantingTicketFactory")
    private TicketGrantingTicketFactory defaultTicketGrantingTicketFactory;

    @Test
    public void verifyTicketGrantingTicketAsJwt() {
        final Map attrs = CoreAuthenticationTestUtils.getAttributeRepository()
                .getPerson(CoreAuthenticationTestUtils.CONST_USERNAME)
                .getAttributes();
        final Authentication authn =
                CoreAuthenticationTestUtils.getAuthentication(
                        CoreAuthenticationTestUtils.getPrincipal(CoreAuthenticationTestUtils.CONST_USERNAME, attrs), attrs);
        final TicketGrantingTicket ticket = defaultTicketGrantingTicketFactory.create(authn);
        assertNotNull(ticket);
    }
}<commit_msg>initial pass at jwt<commit_after>package org.apereo.cas.ticket.registry;

import org.apereo.cas.authentication.Authentication;
import org.apereo.cas.authentication.CoreAuthenticationTestUtils;
import org.apereo.cas.config.CasCoreAuthenticationConfiguration;
import org.apereo.cas.config.CasCoreServicesConfiguration;
import org.apereo.cas.config.CasCoreTicketsConfiguration;
import org.apereo.cas.config.CasCoreUtilConfiguration;
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.logout.config.CasCoreLogoutConfiguration;
import org.apereo.cas.ticket.TicketGrantingTicket;
import org.apereo.cas.ticket.TicketGrantingTicketFactory;
import org.apereo.cas.ticket.registry.config.JwtTicketRegistryConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Map;

import static org.junit.Assert.*;

/**
 * This is {@link JwtTicketRegistryTests}.
 *
 * @author <NAME>
 * @since 5.1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest(
        classes = {RefreshAutoConfiguration.class,
                CasCoreUtilConfiguration.class,
                CasCoreAuthenticationConfiguration.class,
                CasCoreServicesConfiguration.class,
                CasPersonDirectoryConfiguration.class,
                CasCoreLogoutConfiguration.class,
                CasCoreTicketsConfiguration.class,
                JwtTicketRegistryConfiguration.class})
@EnableScheduling
public class JwtTicketRegistryTests {

    @Autowired
    @Qualifier("defaultTicketGrantingTicketFactory")
    private TicketGrantingTicketFactory defaultTicketGrantingTicketFactory;

    @Test
    public void verifyTicketGrantingTicketAsJwt() {
        final Map attrs = CoreAuthenticationTestUtils.getAttributeRepository()
                .getPerson(CoreAuthenticationTestUtils.CONST_USERNAME)
                .getAttributes();
        final Authentication authn =
                CoreAuthenticationTestUtils.getAuthentication(
                        CoreAuthenticationTestUtils.getPrincipal(CoreAuthenticationTestUtils.CONST_USERNAME, attrs), attrs);
        final TicketGrantingTicket ticket = defaultTicketGrantingTicketFactory.create(authn);
        assertNotNull(ticket);
    }

    1. complete other ticket factories into JWT
    2. write tests for all
    3. complete ticket registry
    4. how do we handle expiration policy? Must go inside JWT. How to calculate date?
    5. Smoke test at runtime?
    6. Docs?
    7. Logout? Admin UIs, etc? How is the registry affected?

    
}
{'fraction_non_alphanumeric': 0.07737014166363966, 'fraction_numerical': 0.0027243007628042137, 'mean_word_length': 4.23977164605138, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5634516', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1425, 'n_words': 241}