BREAKING CHANGE(SmartAcme): Refactor challenge handling by removing legacy setChallenge/removeChallenge in favor of pluggable challengeHandlers and update documentation and tests accordingly
This commit is contained in:
32
test/test.smartacme.ts
Normal file
32
test/test.smartacme.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import { SmartAcme } from '../ts/index.js';
|
||||
import type { IChallengeHandler } from '../ts/handlers/IChallengeHandler.js';
|
||||
|
||||
// Dummy handler for testing
|
||||
class DummyHandler implements IChallengeHandler<any> {
|
||||
getSupportedTypes(): string[] { return ['dns-01']; }
|
||||
async prepare(_: any): Promise<void> { /* no-op */ }
|
||||
async cleanup(_: any): Promise<void> { /* no-op */ }
|
||||
}
|
||||
|
||||
tap.test('constructor throws without challengeHandlers', async () => {
|
||||
expect(() => new SmartAcme({
|
||||
accountEmail: 'test@example.com',
|
||||
mongoDescriptor: { mongoDbName: 'db', mongoDbPass: 'pass', mongoDbUrl: 'url' },
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
} as any)).toThrow();
|
||||
});
|
||||
|
||||
tap.test('constructor accepts valid challengeHandlers', async () => {
|
||||
const sa = new SmartAcme({
|
||||
accountEmail: 'test@example.com',
|
||||
mongoDescriptor: { mongoDbName: 'db', mongoDbPass: 'pass', mongoDbUrl: 'url' },
|
||||
environment: 'integration',
|
||||
retryOptions: {},
|
||||
challengeHandlers: [new DummyHandler()],
|
||||
});
|
||||
expect(sa).toBeInstanceOf(SmartAcme);
|
||||
});
|
||||
|
||||
export default tap.start();
|
Reference in New Issue
Block a user