v0.3.2
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { evidenceFromManifestStore, FirefoxExtensionWorkerUrl } from '../src/background/c2pa';
|
||||
|
||||
describe('C2PA evidence interpretation', () => {
|
||||
it('recognises a trusted AI digital source type', () => {
|
||||
const result = evidenceFromManifestStore({
|
||||
active_manifest: 'example:claim',
|
||||
validation_state: 'Trusted',
|
||||
manifests: {
|
||||
'example:claim': {
|
||||
signature_info: { issuer: 'Example CA' },
|
||||
assertions: [{ data: { digitalSourceType: 'http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia' } }]
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
expect(result[0]).toMatchObject({ strength: 'verified', verdict: 'ai', issuer: 'Example CA' });
|
||||
});
|
||||
|
||||
it('does not claim trusted status for a merely valid signer', () => {
|
||||
const result = evidenceFromManifestStore({
|
||||
active_manifest: 'example:claim',
|
||||
validation_state: 'Valid',
|
||||
manifests: {
|
||||
'example:claim': { source_type: 'trainedAlgorithmicMedia' }
|
||||
}
|
||||
}, false);
|
||||
expect(result[0]).toMatchObject({ strength: 'detected', verdict: 'ai' });
|
||||
});
|
||||
|
||||
it('prioritises a failed integrity status', () => {
|
||||
const result = evidenceFromManifestStore({
|
||||
active_manifest: 'example:claim',
|
||||
validation_state: 'Invalid',
|
||||
manifests: { 'example:claim': {} },
|
||||
validation_status: [{ code: 'assertion.dataHash.mismatch' }]
|
||||
}, false);
|
||||
expect(result[0]).toMatchObject({ strength: 'invalid', verdict: 'invalid' });
|
||||
});
|
||||
|
||||
it('returns no evidence when a manifest is absent', () => {
|
||||
expect(evidenceFromManifestStore({ validation_state: 'Valid' }, false)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Firefox worker URL compatibility', () => {
|
||||
it('passes the pinned SDK HTTPS guard but resolves to the packaged extension worker', () => {
|
||||
const packaged = 'moz-extension://12345678-1234-1234-1234-123456789abc/c2pa_worker.js';
|
||||
const workerUrl = new FirefoxExtensionWorkerUrl(packaged);
|
||||
expect(workerUrl.protocol).toBe('https:');
|
||||
expect(workerUrl.toString()).toBe(packaged);
|
||||
});
|
||||
|
||||
it('refuses non-extension worker resources', () => {
|
||||
expect(() => new FirefoxExtensionWorkerUrl('https://example.com/worker.js')).toThrow(/packaged Firefox extension resource/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user