cas-testing
Skill11k starsChanged yesterdayApache-2.0View on GitHub
Run and write tests in the CAS Gradle monorepo: testcas.sh categories, JUnit tags, single-module test tasks, fast compile checks, how tests stay correct under JUnit parallel execution (shared registries, ports, pac4j clients, negative assertions), test authentications and principal attributes, and ticket-granting cookies in MockMvc tests. Use when running tests, choosing a test category, writing or fixing a *Tests.java class, or chasing a flaky test.
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Run repository test categories through the project script, not gradle test:
- Distinctive: line 22
Run one module or one class directly when narrowing a change:
- Very specific: line 31
Use assemble for artifacts and testClasses explicitly for test compilation.
- Very specific: line 40
Never add @Execution(ExecutionMode.SAME_THREAD) to a test class.
- Very specific: line 42
Write registry predicates as expected.equals(service.getClientId()) rather than the reverse: once the registry is no longer cleared, …
- Very specific: line 102
Call ClientInfoHolder.setClientInfo(ClientInfo.from(request)) right before addCookie, and send the same User-Agent with the MockMvc request.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Running and writing CAS tests
Workflows that matter here
- List supported test buckets:
./gradlew -q testCategories - Run repository test categories through the project script, not
gradle test:./testcas.sh --category authentication ./testcas.sh --category tickets --with-coverage ./testcas.sh --category oidc --debug ./testcas.sh --category changedreads tags only from changed or untracked*/src/test/java/*Tests.javafiles. It does not infer test categories from production-source changes; select the relevant categories explicitly for those.- Run one module or one class directly when narrowing a change:
./gradlew :core:cas-server-core-authentication:testAuthenticationHandler --tests "*AcceptUsersAuthenticationHandlerTests" - Compile production sources without assembling archives or compiling tests when you only need a fast validation pass:
Use./gradlew classes --parallel ./gradlew :support:cas-server-support-json-service-registry:classesassemblefor artifacts andtestClassesexplicitly for test compilation. Ordinaryassembledoes not depend ontestJar; non-minimal publishing and consumers of thetestsconfiguration still build it on demand. - Many
./testcas.shcategories shell out toci/tests/**/run-*.shand require Docker on Linux; the script will refuse those categories when that prerequisite is missing.
Parallel test execution and shared registries
- Initialize shared pac4j clients with
DelegatedIdentityProviders.initialize(client), never a bareclient.init(): pac4j returns immediately, uninitialized, while another thread is initializing the same instance. The helper waits lock-free onisInitializing(). - Most categories in
buildSrc/.../TestCategories.groovyare declared parallel, and JUnit's default mode there isconcurrentfor classes and methods, so sibling@Testmethods in one class run at the same time against the same Spring context. A test that clears a shared registry wholesale --servicesManager.getAllServicesOfType(...).forEach(servicesManager::delete)in a setup step, say -- deletes what its siblings just saved, and the failure surfaces in whichever method lost the race rather than in the one that did the clearing. - The symptom to recognize: a test asserting on a service it saved itself gets the value that belongs to the "service was missing" code path.
OpenIdFederationAuthorizationCodeResponseTypeAuthorizationRequestValidatorTestsfailed exactly that way, reportingexpected: <old-service> but was: <new-service>, because another method's clear removed the saved service and the validator then resolved a fresh one. - Never add
@Execution(ExecutionMode.SAME_THREAD)to a test class; rework the test to isolate its own state instead. - Isolate by identifier, not by emptying the registry: give each test a UUID-bearing client id and assert only on that id.
@Execution(ExecutionMode.SAME_THREAD)fixes the within-class case but not another class sharing the context, so prefer removing the global mutation. - Write registry predicates as
expected.equals(service.getClientId())rather than the reverse: once the registry is no longer cleared, entries from other tests flow through the same stream. - The mirror image of that symptom is a test asserting a negative that only holds while the registry
happens to contain no match for its service id.
servicesManager.findServiceBy(<random id>)returning null is a property of the shared registry, not of the test's own fixture, and it stops holding the moment a sibling saves a catch-all definition.SamlIdPServicesManagerRegisteredServiceLocatorTestssaves several (.+,callbackUrl + ".*") into the registry shared by every@Tag("SAML2")class and callsservicesManager.deleteAll()in its@BeforeEach, so it is both halves of this hazard at once.SamlIdPDelegatedClientAuthenticationRequestCustomizerTests.verifyAuthorizationfailed on it, reportingexpected: <false> but was: <true>only in a full run. - Two facts make that failure mode sharper than it looks.
SamlRegisteredService.getEvaluationPriority()returns0whileRegisteredService's default isOrdered.LOWEST_PRECEDENCE, and priority is the first key inBaseRegisteredService's comparator, so one leftover catch-allSamlRegisteredServiceoutranks every non-SAML definition for every lookup in that context no matter what evaluation order the other test sets. AndBaseRegisteredServiceAccessStrategyinitialises a non-nullDefaultRegisteredServiceDelegatedAuthenticationPolicywhosepermitUndefineddefaults totruewith emptyallowedProviders, soisProviderAllowedanswers true for any service that resolves. Together: "some service matched" is the same as "delegated authentication is permitted", and no evaluation order a test can set will win the race. - So a negative assertion that depends on a registry lookup cannot be made deterministic by registering
a better-ranked service of its own. Isolate the lookup instead -- construct the component under test
with a stubbed
ServicesManagerfor exactly the assertions that reach it, and leave the wired bean for the assertions that do not. That is what the customizer test now does, and it gained the policy-permits branch as a second assertion in the process. - A clear can sit in an abstract base class, out of sight of the class that fails.
BaseThemeTestsemptied the services registry in a@BeforeEach, which ran before every method of every subclass, and two subclasses in different files (RegisteredServiceThemeResolverTests.ExampleThemeTests,ChainingThemeResolverTests.ThemeDefinitionTests) share one context. The symptom is the resolver's fallback (expected: <some-theme> but was: <example>, the default theme) instead of the value on the test's own service. A test that empties the registry to prove a result is remembered (verifyThemeIsResolvedOncePerRequest) proves the same thing by deleting only its own service. - Ports are shared state too, and the trap has a specific shape.
MockWebServer.getRandomPort()now draws from 21000-24999, a band nothing else in the repository binds, and a Checkstyle rule (reservedMockWebServerPorts) keeps it that way. It used to draw from 4000-9999, which overlapped about 150 ports the tests and CI containers already use -- 5432, 6379, 8080, 8443, 9042 and 9092 among them -- as well as the${random.int[3000,9000]}convention test property sources use for their own servers. A test that hardcodes a port inside the mock range and depends on nothing listening there is racing every mock server in its category:HttpUtilsTests.verifyExecandverifyBearerTokendid exactly that on 8080 and 8081, asserting that an unreachable proxy yields an error response, and a sibling test's mock server landing on 8080 turned "connection refused" into200 OKand inverted the assertion. The symptom is one of two identical tests failing, which is the giveaway that it is timing rather than logic. Moving the band fixed that class of failure wholesale; hardcoded 8080/8081 elsewhere in the tree is mostly harmless string-building and serialization anyway, and only tests that actually open a connection were ever exposed.
Test authentications and principal attributes
CoreAuthenticationTestUtils.getAuthentication(name, attributes)puts the attributes on the authentication; its principal keeps the default test attributes (cn=TEST,givenName=test, ...). Anything that merges the two with the principal last (JWT claims of token authentication, released attributes) sees the principal's values, and a service fromRegisteredServiceTestUtils.getRegisteredServicerequiresuid=uid,givenName=CASUserand thememberOfvalues on the principal. Pass them withgetAuthentication(getPrincipal(name, attributes)).- A test whose outcome depends on its own registered service's properties (secrets, policies) must register a URL nobody
else uses (
"https://token.example.org/" + UUID.randomUUID()), notRegisteredServiceTestUtils.CONST_TEST_URL: other services in the shared context match that URL too, and which onefindServiceByreturns depends on test order.
Ticket-granting cookies in MockMvc tests
- A TGC is pinned to the client address and user agent read from
ClientInfoHolderand the request when it is built. MockMvc's filters clearClientInfoHolderafter every request, so a cookie built afterwards in the test thread carries no address, fails validation silently (retrieveCookieValuereturnsnull) and the request behaves as if no one signed in. CallClientInfoHolder.setClientInfo(ClientInfo.from(request))right beforeaddCookie, and send the sameUser-Agentwith the MockMvc request. A test that expects SSO but sees the login page has usually hit this; do not "fix" it by asserting the login redirect.
Puppeteer scenario init scripts
- Mockito: never call another mock inside
thenReturn(...)(thenReturn(accessToken.getAuthentication())with a mocked token is an UnfinishedStubbingException); read the values into locals first.
Queue-backed ticket registries (Kafka, AMQP, Pulsar, GCP Pub/Sub)
- MariaDB runs on host port 3307 (
ci/tests/mariadb/run-mariadb-server.shmaps3307:3306), MySQL on 3306, sotestJDBCcan run both. Every MariaDB test class usesjdbc:mariadb://localhost:3307with@EnabledIfListeningOnPort(port = 3307), as do themfa-gauth-login-encrypted,mfa-webauthn-register-logout-loginandmfa-yubikey-storagescenarios (theirdockerExeccalls run inside the container and are unaffected). A MariaDB test pointed at 3306 reaches MySQL and fails withcaching_sha2_password ... sslMode=trust.
Google Authenticator credential repositories (all backends)
MockWebServer.requestLineConsumerexposes the request line, for asserting the HTTP method a client sends.MockRequestContext.create(...)throwsException; a test method that calls it must declarethrows Throwable.
Hazelcast ticket registry
- The Gradle build runs Error Prone with warnings as errors on main and test sources (e.g.
CanonicalDuration:Duration.ofMinutes(-1), notofSeconds(-60)); compile-check tests with Error Prone too, not only main. NullAway reports the same pre-existing errors onHazelcastTicketRegistrybefore and after a change, so compare against the old sources rather than expecting zero.
Trending
Quiet since August.about the whole repository
Who's talking about apereo/cas
- Stack Overflow“What is the relation between CAS vs SAML?”Stack Overflow · Apr 28, 2017 · 23 votes
- strapi/strapi“Add support for login via cas - github.com/apereo/cas”GitHub · Sep 26, 2020 · 8 reactions
- Stack Overflow“Opensaml error receiving correct unmarshaller”Stack Overflow · Apr 10, 2017 · 6 votes
- Stack Overflow“How to enable file-based authentication in CAS 5”Stack Overflow · Apr 14, 2017 · 5 votes
- google/error-prone“ErrorProne 2.37: StringConcatToTextBlock causes java.util.NoSuchElementException”GitHub · Mar 19, 2025 · 3 reactions
The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 27
Talked about on Stack Overflow, GitHub, Hacker News and the web (27 times).
On Stack Overflow · 14
- Apr 28, 2017What is the relation between CAS vs SAML?23 votes
- Apr 10, 2017Opensaml error receiving correct unmarshaller6 votes
- Apr 14, 2017How to enable file-based authentication in CAS 55 votes
- Aug 2, 2021How to create a SAML IDP that authenticates with an API from scratch2 votes
- Feb 3, 2020CAS 6.1 - State Parameter null with Pac4J2 votes
9 more on Stack Overflow
- Jul 4, 2017CAS Spnego - KrbException: Checksum failed2 votes · 3 answers
- Dec 11, 2023What happened "org.apereo.cas.web.security" in 7.0.0-RC9 of org.apereo.cas?1 vote
- Jul 23, 2020Cas - configure Principal transformation1 vote · 1 answer
- Nov 25, 2019CAS Disable Service X-Frame-Options not work1 vote
- Apr 24, 2019inject model data into spring webflow in cas1 vote
- Mar 4, 2019Prevent CAS authentication if X.509 user isn't registered1 vote
- Nov 10, 2021CAS Apereo 6.1.x importing PasswordEncoderUtils0 votes · 1 answer
- Aug 2, 2021How to SSO to a directory server from a python application0 votes
- Nov 7, 2016using CAS with with custom login page0 votes
On GitHub · 9
- Sep 26, 2020Add support for login via cas - github.com/apereo/cas — strapi/strapi8 reactions · 21 comments
- Mar 19, 2025ErrorProne 2.37: StringConcatToTextBlock causes java.util.NoSuchElementException — google/error-prone3 reactions · 3 comments
- Mar 26, 2020Renovate crash: JavaScript heap out of memory (many Gradle dependencies) — renovatebot/renovate1 reaction · 8 comments
- Aug 10, 2026Add Apereo CAS project to regression testing project lists — checkstyle/test-configssays it tested it0 reactions · 1 comment
- Jul 17, 2026[Argus] CVE-2026-59099: Apereo CAS 7.3.0 < 8.0.0-RC6 - AES-GCM 논스(Nonce) 재사용으로 인한 정보 노출 — LEEKIYOON-SEC/Argus-DEV0 reactions
4 more on GitHub
- Dec 5, 2024Extract Attr within moved file — pouryafard75/RM-ASTDiff0 reactions · 14 comments
- Jan 18, 2023Authentication/Authorization: We need a API-friendly strategy — wolpert/svarm0 reactions · 1 comment
- Apr 19, 2020COMPARAISON KEYCLOAK / CAS — pegasus-io/belenios-containers0 reactions
- Mar 20, 2018apereo/cas OAuth endpoints need @Controller annotations — easy-software-ufal/annotations_repos0 reactions
On Hacker News · 3
- Feb 20, 2017Enterprise Single Sign on for all3 points
- Aug 8, 2023The Central Authentication Service Project2 points
- Oct 16, 2016Apereo CAS: Single Sign-On for the Web1 point
On the web · 1
- Apr 11, 2025apereo/cas - Where software is built — google.com
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- cas-actuatorsSkill
- cas-attribute-consentSkill
- cas-build-ciSkill
- cas-docs-siteSkill
- cas-google-authenticatorSkill
- cas-groovy-scriptingSkill
- cas-handoffSkill
- cas-heimdall-authzenSkill
- cas-import-prSkill
- cas-interrupt-notificationsSkill
- cas-ldapSkill
- cas-mcp-serverSkill
- cas-oauth-oidc-authenticationSkill
- cas-oauth-oidcSkill
- cas-oid4vcSkill
- cas-passwordless-webauthnSkill
- cas-protocolSkill
- cas-puppeteer-scenariosSkill
- cas-samlSkill
- cas-sandbox-verificationSkill
- cas-service-registriesSkill
- cas-session-storesSkill
- cas-startup-performanceSkill
- cas-storage-backendsSkill
- cas-ticket-registriesSkill
- cas-uiSkill
- cas-web-securitySkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

