mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-13 00:14:42 +00:00
remove services from tests
This commit is contained in:
1 parent
21dc3e5351
commit
a75c5c24d5
3 files changed
+2
-105
No files matched your search
@@ -102,40 +102,3 @@ t("Users are limited to one single character subdomain", (t) => {
|
||||
|
||||
t.pass();
|
||||
});
|
||||
|
||||
t("Disallow nested subdomains when parent has specific service records", (t) => {
|
||||
files.forEach((file) => {
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
const data = getDomainData(subdomain);
|
||||
|
||||
if (data?.services?.discord) {
|
||||
t.false(
|
||||
files.includes(`_discord.${file}`),
|
||||
`${file}: Nested subdomain "_discord.${subdomain}" should not exist when services.discord is present`
|
||||
);
|
||||
}
|
||||
|
||||
if (data?.services?.vercel) {
|
||||
t.false(
|
||||
files.includes(`_vercel.${file}`),
|
||||
`${file}: Nested subdomain "_vercel.${subdomain}" should not exist when services.vercel is present`
|
||||
);
|
||||
}
|
||||
|
||||
if (data?.services?.bluesky) {
|
||||
t.false(
|
||||
files.includes(`_atproto.${file}`),
|
||||
`${file}: Nested subdomain "_atproto.${subdomain}" should not exist when services.bluesky is present`
|
||||
);
|
||||
}
|
||||
|
||||
if (data?.services?.gitlab) {
|
||||
t.false(
|
||||
files.includes(`_gitlab-pages-verification-code.${file}`),
|
||||
`${file}: Nested subdomain "_gitlab-pages-verification-code.${subdomain}" should not exist when services.gitlab is present`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
t.pass();
|
||||
});
|
||||
+2
-23
@@ -11,8 +11,7 @@ const requiredFields = {
|
||||
|
||||
const optionalFields = {
|
||||
proxied: "boolean",
|
||||
redirect_config: "object",
|
||||
services: "object"
|
||||
redirect_config: "object"
|
||||
};
|
||||
|
||||
const requiredOwnerFields = {
|
||||
@@ -28,7 +27,7 @@ const optionalRedirectConfigFields = {
|
||||
redirect_paths: "boolean"
|
||||
};
|
||||
|
||||
const blockedFields = ["domain", "internal", "proxy", "reserved", "subdomain"];
|
||||
const blockedFields = ["domain", "internal", "proxy", "reserved", "services", "subdomain"];
|
||||
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
const hostnameRegex = /^(?=.{1,253}$)(?:(?:[_a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+[a-zA-Z]{2,63}$/;
|
||||
@@ -150,26 +149,6 @@ async function processFile(file, t) {
|
||||
validateFields(t, data.redirect_config, optionalRedirectConfigFields, file, "redirect_config");
|
||||
}
|
||||
|
||||
if (data.services) {
|
||||
if (data.services.discord) {
|
||||
t.true(
|
||||
Array.isArray(data.services.discord) || typeof data.services.discord === "string",
|
||||
`${file}: services.discord should be an array or string`
|
||||
);
|
||||
}
|
||||
|
||||
if (data.services.vercel) {
|
||||
t.true(
|
||||
Array.isArray(data.services.vercel) || typeof data.services.vercel === "string",
|
||||
`${file}: services.vercel should be an array or string`
|
||||
);
|
||||
}
|
||||
|
||||
if (data.services.bluesky) {
|
||||
t.true(typeof data.services.bluesky === "string", `${file}: services.bluesky should be a string`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const field of blockedFields) {
|
||||
t.true(!data.hasOwnProperty(field), `${file}: Disallowed field: ${field}`);
|
||||
}
|
||||
|
||||
@@ -286,7 +286,6 @@ t("All files should have valid records", (t) => {
|
||||
recordKeys.length === 1 || (recordKeys.length === 2 && recordKeys.includes("DS")),
|
||||
`${file}: NS records cannot be combined with other records, except for DS records`
|
||||
);
|
||||
t.true(!data.services, `${file}: Service records cannot be present when NS records are defined`);
|
||||
}
|
||||
if (recordKeys.includes("DS")) {
|
||||
t.true(recordKeys.includes("NS"), `${file}: DS records must be combined with NS records`);
|
||||
@@ -329,47 +328,3 @@ t("Root subdomains should have at least one usable record", (t) => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
t("All files should have valid service records", (t) => {
|
||||
files.forEach((file) => {
|
||||
const data = getDomainData(file);
|
||||
|
||||
const discordRegex = /^dh=[a-f0-9]{40}$/;
|
||||
|
||||
if (data?.services?.discord) {
|
||||
const discord = Array.isArray(data.services.discord) ? data.services.discord : [data.services.discord];
|
||||
|
||||
discord.forEach((value) => {
|
||||
t.true(discordRegex.test(value), `${file}: Invalid Discord service record format`);
|
||||
});
|
||||
}
|
||||
|
||||
const vercelRegex = /^vc-domain-verify=([a-z0-9.-]+),([a-f0-9]{20})$/;
|
||||
|
||||
if (data?.services?.vercel) {
|
||||
const vercel = Array.isArray(data.services.vercel) ? data.services.vercel : [data.services.vercel];
|
||||
|
||||
vercel.forEach((value) => {
|
||||
t.true(vercelRegex.test(value), `${file}: Invalid Vercel service record format`);
|
||||
});
|
||||
}
|
||||
|
||||
const atprotoRegex = /^did=did:plc:[a-z0-9]{24}$/;
|
||||
|
||||
if (data?.services?.bluesky) {
|
||||
t.true(atprotoRegex.test(data.services.bluesky), `${file}: Invalid Bluesky service record format`);
|
||||
}
|
||||
|
||||
const gitlabRegex = /^gitlab-pages-verification-code=[a-f0-9]{32}$/;
|
||||
|
||||
if (data?.services?.gitlab) {
|
||||
const gitlab = Array.isArray(data.services.gitlab) ? data.services.gitlab : [data.services.gitlab];
|
||||
|
||||
gitlab.forEach((value) => {
|
||||
t.true(gitlabRegex.test(value), `${file}: Invalid GitLab service record format`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
t.pass();
|
||||
});
|
||||
Reference in new issue
Block a user