blob: b92bdb1dfbee4c0730ff3728dc4f22b26099a8a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { assertEquals } from 'https://deno.land/std@0.198.0/assert/mod.ts';
import { SettingsService } from './settingsService.ts';
import { convertPEMToBytes } from '../helpers/convertPEMToBytes.ts';
import { GlobalSign_Root_CA } from './defaultRootCerts/android-safetynet.ts';
import { Apple_WebAuthn_Root_CA } from './defaultRootCerts/apple.ts';
Deno.test('should accept cert as Buffer', () => {
const gsr1Buffer = convertPEMToBytes(GlobalSign_Root_CA);
SettingsService.setRootCertificates({
identifier: 'android-safetynet',
certificates: [gsr1Buffer],
});
const certs = SettingsService.getRootCertificates({
identifier: 'android-safetynet',
});
assertEquals(certs, [GlobalSign_Root_CA]);
});
Deno.test('should accept cert as PEM string', () => {
SettingsService.setRootCertificates({
identifier: 'apple',
certificates: [Apple_WebAuthn_Root_CA],
});
const certs = SettingsService.getRootCertificates({ identifier: 'apple' });
assertEquals(certs, [Apple_WebAuthn_Root_CA]);
});
Deno.test('should return empty array when certificate is not set', () => {
const certs = SettingsService.getRootCertificates({ identifier: 'none' });
assertEquals(Array.isArray(certs), true);
assertEquals(certs.length, 0);
});
|