Add test for malformed domains (#836)

This commit is contained in:
Jaco
2021-12-20 09:58:53 +01:00
committed by GitHub
parent 5315dcf6f6
commit 8fa6d050c5
4 changed files with 101 additions and 111 deletions
+3 -3
View File
@@ -18,9 +18,9 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.16.5",
"@polkadot/util": "^8.1.2",
"@polkadot/util-crypto": "^8.1.2",
"@polkadot/x-fetch": "^8.1.2"
"@polkadot/util": "^8.2.2",
"@polkadot/util-crypto": "^8.2.2",
"@polkadot/x-fetch": "^8.2.2"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
+10
View File
@@ -9,6 +9,7 @@ import { checkAddress, checkIfDenied } from '.';
const addresses = JSON.parse(fs.readFileSync('address.json', 'utf-8')) as Record<string, string[]>;
const allowed = JSON.parse(fs.readFileSync('known.json', 'utf-8')) as Record<string, string[]>;
const all = JSON.parse(fs.readFileSync('all.json', 'utf8')) as { deny: string[] };
describe('checkIfDenied', (): void => {
it('returns false when host is not listed', async (): Promise<void> => {
@@ -107,4 +108,13 @@ describe('check additions', (): void => {
expect(dupes).toEqual([]);
});
it('has no malformed domain-only entries', (): void => {
const invalids = all.deny.filter((u) =>
u.includes('/') ||
u.includes('?')
);
expect(invalids).toEqual([]);
});
});