diff --git a/test/validate/index.js b/test/validate/index.js index 15d736b8f..613396e4b 100644 --- a/test/validate/index.js +++ b/test/validate/index.js @@ -13,11 +13,21 @@ describe('Validate', () => { }); }); - it('vendors', () => { + it('vendors', async() => { + const { createHash } = require('crypto'); + const { getVendors } = require('../../scripts/events/lib/utils'); const vendorsFile = fs.readFileSync(path.join(__dirname, '../../_vendors.yml')); - should.not.throw(() => { - yaml.load(vendorsFile); - }); + (await Promise.all(Object.entries(yaml.load(vendorsFile)).map(async([key, vendor]) => { + vendor.minified = vendor.file || ''; + const { cdnjs } = getVendors(vendor); + // fetch content and check sha256 + return await fetch(cdnjs) + .then(response => response.text()) + .then(body => { + const integrity = Buffer.from(createHash('sha256').update(body, 'utf8').digest()).toString('base64'); + return !vendor.integrity || 'sha256-' + integrity === vendor.integrity; + }); + })))[0].should.all.equal(true); }); it('language', () => {