Skip to content

Commit 619816f

Browse files
committed
Add coverage tests for issueOrRenew() renewal path and savePrivateKey() invalid PEM
1 parent e2944e6 commit 619816f

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

tests/Unit/CoyoteCertTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ public function cleanup(string $d, string $tok): void {}
193193
expect($result->certificate)->toBe('cert-pem');
194194
});
195195

196+
it('issueOrRenew() calls issue() when renewal is needed', function () {
197+
// needsRenewal() returns true (no storage) → line 380 `return $this->issue()` is hit
198+
// → issue() throws at the "No domains" guard
199+
expect(fn () => makeCoyote()->challenge(makeNoOpHandler())->issueOrRenew())
200+
->toThrow(AcmeException::class, 'No domains');
201+
});
202+
196203
// ── renew() alias ─────────────────────────────────────────────────────────────
197204

198205
it('renew() is an alias for issue() and throws when no domains are configured', function () {

tests/Unit/Support/LocalFileAccountTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124
}
125125
});
126126

127+
it('savePrivateKey() throws CryptoException when the PEM is not a valid private key', function () {
128+
$this->account->generateNewKeys(); // ensure directory exists
129+
130+
expect(fn () => $this->account->savePrivateKey('not-a-pem', KeyType::RSA_2048))
131+
->toThrow(\CoyoteCert\Exceptions\CryptoException::class, 'Cannot load private key');
132+
});
133+
127134
it('getKey() throws StorageException when file exists but cannot be read (mode 0000)', function () {
128135
$this->account->generateNewKeys();
129136

0 commit comments

Comments
 (0)