Add regression coverage for legacy CA identifier parsing

Open Beginner friendly
#9,472 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
testing

Research direction

Start with the existing CaIdentifierServiceTest in tests/php/Unit/Service/CaIdentifierServiceTest.php, then read lib/Service/CaIdentifierService.php to see what getCaIdParsed() and generatePkiDirectoryName() return for _e:o and _e:c IDs. Add named data-provider cases that assert every parsed field and the exact directory names, plus malformed-ID rejections. Done when composer test:unit -- --filter CaIdentifierServiceTest passes and the new assertions would fail if the parsing contract changed.

Written by the indexing model from the issue text.

Description

backend enhancement good first issue php

Goal

Add deterministic regression tests for legacy LibreSign CA identifiers, protecting current OpenSSL and CFSSL behavior before the multi-CA registry is introduced.

Current implementation

Start with:

  • lib/Service/CaIdentifierService.php
  • tests/php/Unit/Service/CaIdentifierServiceTest.php

Existing tests already cover CA ID generation, some validation cases and one OpenSSL PKI-directory name. They do not thoroughly assert the parsed fields returned by getCaIdParsed() or cover both engine types in directory-name generation.

Scope

Extend the existing unit test class with named data providers where helpful. Verify:

  • Correct parsing through public getCaIdParsed() for legacy OpenSSL (_e:o) and CFSSL (_e:c) IDs, including instanceId, generation, engineType and engineName.
  • Expected directory paths from generatePkiDirectoryName() for both engine types and representative generations.
  • Rejection of malformed or unsupported IDs by the public parsing path.
  • Preservation of the existing ID shape and output without modifying production code.

Use synthetic identifiers and mocked IAppConfig. Do not invoke private methods directly or generate real CA keys.

Acceptance criteria

  • Tests cover both engines and at least one positive and negative parsing scenario.
  • Assertions compare all important parsed fields and exact directory-name outputs, not just non-null values.
  • Tests fail when the legacy parsing or directory-path contract is unintentionally changed.
  • Existing CaIdentifierServiceTest remains deterministic and passes.
  • No production CA logic, public identifier format, storage layout or CRL URL is modified.

Tests

Run composer test:unit -- --filter CaIdentifierServiceTest and applicable PHP syntax/static checks. Include the command results in the PR.

Next steps in the parent epic (not this task)

The multi-CA epic will later create a persistent issuer registry, retain compatibility with these legacy identifiers, and introduce context-aware CA operations and CRL routing. These tests are a baseline for compatibility, not the new registry implementation.

Good first issue

All work stays inside an established PHPUnit test class with a small public service contract. Follow its existing DataProvider examples. No database, encryption, authorization or CA lifecycle changes are required. Check for an active PR; questions and coordination are optional.

Additional context
Dominant language
PHP
Stars
844
Forks
176
Avg merge
13h 46m
Merged PRs (30d)
299

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LibreSign/libresign

All issues in LibreSign/libresign

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.