mirror of
https://github.com/tiennm99/open-domains.git
synced 2026-10-14 04:16:28 +00:00
Create proxy.test.js
This commit is contained in:
1 file changed
+25
@@ -0,0 +1,25 @@
|
||||
const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const requiredRecordsToProxy = ["A", "AAAA", "CNAME"];
|
||||
// URL records are not listed here because they are proxied by default, so they don't need the proxied flag
|
||||
|
||||
function validateProxiedRecords(t, data, file) {
|
||||
if (data.proxied) {
|
||||
const hasProxiedRecord = Object.keys(data.record).some((key) => requiredRecordsToProxy.includes(key));
|
||||
|
||||
t.true(hasProxiedRecord, `${file}: Proxied is true but there are no records that can be proxied`);
|
||||
}
|
||||
}
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
const files = fs.readdirSync(domainsPath);
|
||||
|
||||
t("Domains with proxy enabled should have have at least one record that can be proxied", (t) => {
|
||||
files.forEach((file) => {
|
||||
const domain = fs.readJsonSync(path.join(domainsPath, file));
|
||||
|
||||
validateProxiedRecords(t, domain, file);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user