Skip to content

Run OpenFM unit tests and fix NotCondition.equals reflexivity#1071

Open
vharseko wants to merge 3 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/openfm-tests
Open

Run OpenFM unit tests and fix NotCondition.equals reflexivity#1071
vharseko wants to merge 3 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/openfm-tests

Conversation

@vharseko

Copy link
Copy Markdown
Member

OpenFM has carried a blanket <skipTests>true</skipTests> since 2bbaf3849b (2013), hiding all 178 of its tests. mvn test on the module now runs 48 tests, all green.

Why the flag was there

The OpenSSO-era tests obtain an Application SSO token via AdminTokenAction and drive ServiceManager/IdRepo directly. Outside a configured server they fail in the constructor or @BeforeClass, and TestNG aborts the entire suite when one class cannot be instantiated — so a single server-dependent test hid all the others. CreateSoapSTSDeploymentTest documented this in a comment.

This replaces the blanket flag with an explicit surefire exclude list for the 53 server-dependent classes. excludes rather than includes is deliberate: a newly added test is still picked up by the default patterns, instead of silently not running — the trap that created this situation.

A real defect in openam-core

Once running, NotConditionTest caught exactly what it was written for in 2014. LogicalCondition.equals read this.eConditions directly but called object.getEConditions(). NotCondition overrides that getter and keeps its condition in a separate field, which is always null in the parent — so the comparison always failed:

NotCondition.equals(self) = false      ->  true
List.contains(n)          = false      ->  true
List.remove(n)            = false      ->  true

This violates the reflexivity contract of Object.equals. HashSet happened to work only because it compares references first. AndCondition/OrCondition are unaffected — they do not override the getter. Present since 2012, invisible because the test never ran.

Test-side fixes

  • Restored six fixtures left behind in the OpenSSO tree during the Maven migration (resourceNameIndex*, resourceNameSplit*, eUnitTest.data).
  • ResourceNameSplitTest declared @Test public boolean testHost(); TestNG silently ignores non-void methods — a leftover from the OpenSSO harness where true meant pass. Made them void.
  • resourceNameSplitHost.properties expected scheme-carrying host indexes (http://www.sun.com), but every implementation in history emits scheme-agnostic ://www.sun.com. The fixture was stale before it was ever run; updated to the real contract.
  • CreateSoapSTSDeploymentTest: supply the retry params added in OPENAM-8772 (2016).
  • ConfigureSocialAuthNTest: the crypto value was intentionally removed in OPENAM-5851 (2015) — the same commit documented "If client_secret entered, entry is ignored". The product is right here; the test expectation was stale.

Verification

Module Tests
OpenFM (mvn test, no flags) 48 ✅ (was 0)
openam-core 1797 ✅
openam-entitlements 564 ✅
openam-federation-library 43 ✅

Not in scope

The 53 excluded classes were designed to run inside a deployed OpenAM: TestHarness.execute(HttpServletResponse, String) was invoked by a servlet in the webapp and ran TestNG in-container. That servlet no longer exists — TestHarness is an orphan with no caller. Reviving them needs a new harness (rebuild the in-container entry point, rewrite as black-box REST/Selenium, or bootstrap the server stack in-JVM) and is a separate project. The exclude list is the inventory to work from.

OpenFM carried a blanket <skipTests>true</skipTests> since 2013, hiding all
178 of its tests. The property was there because the OpenSSO-era tests need a
live in-container OpenAM and abort the whole TestNG suite when they cannot be
instantiated.

Replace it with an explicit exclude list for the 53 server-dependent classes,
so the 48 unit tests now run by default. Restore six test fixtures that were
left behind in the OpenSSO tree during the Maven migration, and make
ResourceNameSplitTest's methods void so TestNG stops ignoring them.

Once running, NotConditionTest surfaced a real defect: LogicalCondition.equals
read this.eConditions directly but called object.getEConditions(). NotCondition
overrides that getter and keeps its condition in a separate field, so equals
always returned false -- including n.equals(n), breaking List.contains/remove.
Read both sides through the accessors.

Update CreateSoapSTSDeploymentTest for the retry params added in OPENAM-8772
and ConfigureSocialAuthNTest for the crypto value removed in OPENAM-5851.
@vharseko vharseko requested a review from maximthomas July 15, 2026 08:16
@vharseko vharseko added bug tests Test suite: coverage, fixtures, or test infrastructure build labels Jul 15, 2026
vharseko added 2 commits July 15, 2026 11:51
The test built classpath resource names with Paths.get(), which yields
backslash separators on Windows. getResourceAsStream() then returns null and
the test dies with "NPE: in is null". These are resource names, not filesystem
paths, so use plain string constants that keep '/' on every platform.

Latent since 2015 and only visible now that the module's tests actually run.
The class validated PrivilegeManager.isNameValid() -- letters, digits,
underscore, dash, and rejection of special characters -- but a typo in its
name ("Priivlege", and no Test suffix) kept it outside surefire's default
patterns, so its six tests had never run. Rename to
PrivilegeNameValidationTest.

Also fix withSpecialChar reporting itself as withDash on failure.

OpenFM: 48 -> 54 tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug build tests Test suite: coverage, fixtures, or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants