Skip to content

Add comprehensive unit tests for model and service classes#1

Merged
hadamrd merged 4 commits intomainfrom
claude/review-codebase-features-WV4PF
Feb 19, 2026
Merged

Add comprehensive unit tests for model and service classes#1
hadamrd merged 4 commits intomainfrom
claude/review-codebase-features-WV4PF

Conversation

@hadamrd
Copy link
Owner

@hadamrd hadamrd commented Feb 19, 2026

Summary

This PR adds extensive unit test coverage for core model classes and the ACL evaluation engine, enabling thorough testing of business logic without requiring a running Jenkins instance.

Key Changes

Test Coverage Added

  • EnvironmentACLCheckerTest (570 lines): Comprehensive tests for the ACL evaluation engine covering:

    • Default deny behavior
    • Allow and deny rule evaluation
    • Priority-based rule ordering (deny-first evaluation)
    • Environment group and tag matching
    • Job pattern matching (exact, regex, wildcard)
    • Complex real-world scenarios (multi-group membership, organizational policies)
    • Unit tests for helper methods like matchesJob()
  • Model class tests: New test suites for:

    • ACLRuleTest: Rule construction, field setters, null-safety
    • EnvironmentGroupTest: Group configuration, vault credential lookup, node label handling
    • SshEnvironmentTest: SSH environment validation, display formatting
    • SshConfigTest: SSH configuration bounds validation, JSch properties generation, factory methods
    • PromptDefinitionTest: Parameter type conversion (string, choice, boolean, password)
    • DeploymentJobTest: Job parameter handling and map conversion
    • JobParameterTest: Parameter immutability and serialization
    • VaultCredentialMappingTest: Vault credential mapping configuration

Source Code Modifications

  • EnvironmentACLChecker.java: Refactored hasAccess() method to expose a package-private overload that accepts rules and environment groups directly, enabling unit testing without Jenkins configuration. The public API remains unchanged.

Testing Infrastructure

  • Added JUnit 5 (Jupiter) dependency to pom.xml for modern test framework support
  • Tests use @Nested and @DisplayName annotations for clear test organization and documentation
  • Comprehensive test scenarios including edge cases, null handling, and validation boundaries

Implementation Details

  • The ACL checker refactoring maintains backward compatibility while enabling testability through a package-private method overload
  • Tests follow the Arrange-Act-Assert pattern with descriptive names
  • Model tests verify both happy paths and error conditions (validation, bounds checking)
  • No changes to public APIs or existing functionality

https://claude.ai/code/session_01Uut1RD3VXAuMMuMZcxdPcw

…ility

Introduces 9 test classes covering the security-critical ACL engine,
deployment models, SSH configuration, and prompt type conversion logic.
Refactors EnvironmentACLChecker to extract pure evaluation logic from
Jenkins singletons, enabling direct unit testing without a running
Jenkins instance. Adds JUnit 5 and Mockito test dependencies.

Test coverage includes:
- EnvironmentACLChecker: deny-first evaluation, priority ordering,
  environment group/tag matching, regex job patterns, complex org policies
- ACLRule, EnvironmentGroup, VaultCredentialMapping: model construction,
  null safety, vault credential lookup, node label formatting
- DeploymentJob, JobParameter: param-to-map conversion, duplicate handling
- PromptDefinition: type conversion for string/choice/boolean/password
- SshConfig: bounds validation, JSch property generation, factory methods
- SshEnvironment: validation, display formatting

https://claude.ai/code/session_01Uut1RD3VXAuMMuMZcxdPcw
The .hpi binary was tracked in git (162KB). Build artifacts should be
distributed via GitHub Releases (already supported by make github-release),
not checked into version control. Also ignores .vscode/ and .idea/.

https://claude.ai/code/session_01Uut1RD3VXAuMMuMZcxdPcw
GitHub Actions:
- CI workflow runs mvn verify with spotless + spotbugs on every PR to main

Security (AnsiblePlaybookCommandBuilder):
- Fix shell injection via single-quote breakout in escapeValue(). The old
  escape (\') does not work inside single-quoted strings in POSIX shell.
  Replaced with the correct '\'' idiom.
- Add requireSafeIdentifier() validation that rejects shell metacharacters
  (;, $, `, |, &, spaces) in playbook paths, usernames, inventory paths,
  and extra var keys.
- Calls validate() at build time rather than relying on callers.

Makefile:
- Add `make test` and `make verify` targets.
- Improve `make help` to list all available commands.

https://claude.ai/code/session_01Uut1RD3VXAuMMuMZcxdPcw
This is the breaking rename that should happen at v1.0.0 before adoption.
Every reference to "pulsar" across the entire codebase is now "jerakin":

Package rename (58 Java files + 12 Jelly resource files):
- io.jenkins.plugins.pulsar → io.jenkins.plugins.jerakin
- All imports, package declarations, and resource directory paths updated

JCasC symbol rename:
- @symbol("pulsarDeployments") → @symbol("jerakinDeployments")
- YAML configs updated to match

Job naming convention:
- PulsarJob_ prefix → JerakinJob_ prefix in DeploymentJobManager

README rewrite:
- Shorter, action-oriented structure with Quick Start section
- All examples use consistent jerakin naming
- Added Development section with make targets

Open-source infrastructure:
- Dependabot for Maven + GitHub Actions dependency updates
- GitHub issue templates (bug report, feature request)
- Fixed broken `make release` target (removed non-existent lint/update-center)

Config updates:
- pom.xml: display name → "Jerakin Plugin"
- log.properties: updated package paths
- libraries.yml: pulsar-library → jerakin-library

https://claude.ai/code/session_01Uut1RD3VXAuMMuMZcxdPcw
@hadamrd hadamrd merged commit a3f6820 into main Feb 19, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants