Merge branch 'main' into main

This commit is contained in:
William Harrison authored and GitHub committed 2023-09-18 10:11:26 +08:00
commit bbc3c6104a
60 files changed
+578 -4143

No files matched your search

View File
File renamed without changes.
+5 -12
View File
@@ -1,5 +1,5 @@
name: Checks name: Checks
on: [pull_request] on: [pull_request, workflow_dispatch]
jobs: jobs:
validation: validation:
@@ -9,15 +9,8 @@ jobs:
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 fetch-depth: 0
- name: Setup node v16 - uses: oven-sh/setup-bun@v1
uses: actions/setup-node@v1
with: with:
node-version: '16' bun-version: 1.0.0
- name: Install dependencies - run: bun install
uses: borales/actions-yarn@v2.0.0 - run: bun test
with:
cmd: install --ignore-engines --frozen-lockfile
- name: Run tests
uses: borales/actions-yarn@v2.0.0
with:
cmd: test
+6 -9
View File
@@ -12,16 +12,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: borales/actions-yarn@v2.0.0 - uses: oven-sh/setup-bun@v1
with: with:
cmd: install --ignore-engines bun-version: 1.0.0
- name: Running tests - run: bun install
uses: borales/actions-yarn@v2.0.0 - run: bun test
with:
cmd: test
- name: Publishing records - name: Publishing records
env: env:
CI: 1 CI: 1
NODE_ENV: production
ENV: production ENV: production
DOMAIN_USER: ${{ secrets.DOMAIN_USER }} DOMAIN_USER: ${{ secrets.DOMAIN_USER }}
DOMAIN_API_KEY: ${{ secrets.DOMAIN_API_KEY }} DOMAIN_API_KEY: ${{ secrets.DOMAIN_API_KEY }}
@@ -29,6 +28,4 @@ jobs:
DOMAIN_API_PORT: ${{ secrets.DOMAIN_API_PORT }} DOMAIN_API_PORT: ${{ secrets.DOMAIN_API_PORT }}
DOMAIN_DOMAIN: ${{ secrets.DOMAIN_DOMAIN }} DOMAIN_DOMAIN: ${{ secrets.DOMAIN_DOMAIN }}
DOMAIN_HOST_IP: ${{ secrets.DOMAIN_HOST_IP }} DOMAIN_HOST_IP: ${{ secrets.DOMAIN_HOST_IP }}
uses: borales/actions-yarn@v2.0.0 run: bun run publish-records
with:
cmd: publish-records
+2 -1
View File
@@ -1,3 +1,4 @@
node_modules/ node_modules/
*.env.* *.env.production
*.log *.log
is-a-dev-cert/
Executable
BIN
View File
Binary file not shown.
+1 -2
View File
@@ -3,11 +3,10 @@ let
inherit (nixpkgs) pkgs; inherit (nixpkgs) pkgs;
nixPackages = with pkgs; [ nixPackages = with pkgs; [
nodejs-18_x
yarn yarn
docker-compose docker-compose
dnsutils dnsutils
#certbot bun
]; ];
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "70A5",
"email": "joas.van.der.eerden@outlook.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+3 -1
View File
@@ -4,6 +4,8 @@
"email": "squaresmp@asia.com" "email": "squaresmp@asia.com"
}, },
"record": { "record": {
"CNAME": "8e7e5199-15ef-4f4d-8350-68c025df6616.id.repl.co" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+2 -1
View File
@@ -6,6 +6,7 @@
"email": "phenax5@gmail.com" "email": "phenax5@gmail.com"
}, },
"record": { "record": {
"URL": "https://phenax.github.io" "URL": "https://phenax.github.io",
"TXT": [ "Hello there!", "It's me, Akshay" ]
} }
} }
+3 -1
View File
@@ -4,6 +4,8 @@
"email": "sweepalf@gmail.com" "email": "sweepalf@gmail.com"
}, },
"record": { "record": {
"URL": "http://youfoundalpha.vercel.app" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "obstructed",
"email": "scamstur@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "MrBogdanYT",
"email": "hysbskyblockgod@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "Bruhxz54",
"email": "pollyx73@gmail.com"
},
"record": {
"CNAME": "f2b3938b-4d54-4d87-b941-49461b9d3541.id.repl.co"
}
}
+2 -4
View File
@@ -1,11 +1,9 @@
{ {
"description": "testing",
"owner": { "owner": {
"username": "Chris8889", "username": "Chris8889",
"email": "chris88892@protonmail.com", "email": "chris88892@protonmail.com"
"twitter": "Chris8889"
}, },
"record": { "record": {
"CNAME": "5d931f3a-d63d-4ccf-b14c-5b566fd0c5f0.id.repl.co" "CNAME": "hosts.is-a.dev"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "DenDanskeMine",
"email": "christianhrose@outlook.dk"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "CycloneAddons",
"email": "cycloneaddon@gmail.com"
},
"record": {
"CNAME": "7a4c31e0-a7b1-498a-a264-5bda0a7d5c45.id.repl.co"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "dinhqvn99",
"email": "trinhdinhquy@iesschool.edu.vn"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "kaio-lord",
"email": "mataerick855@gmail.com"
},
"record": {
"CNAME": "2ecfaa94-1335-4e48-82a2-0c93451c2c30.id.repl.co"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"description": "Portfolio/blog of Durlav Kalita",
"repo": "https://github.com/durlavkalita/durlavkalita.github.io",
"owner": {
"username": "durlavkalita",
"email": "durlavk98@gmail.com"
},
"record": {
"CNAME": "durlavkalita.github.io"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "pindang-cloud",
"email": "gavinku890@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "Stef-00012",
"email": "stefano.delprete.08@gmail.com"
},
"record": {
"CNAME": "nl2-4.deploy.sbs"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "Givaa",
"email": "rapagiovanni@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+3 -1
View File
@@ -4,6 +4,8 @@
"email": "midoayoub778@gmail.com" "email": "midoayoub778@gmail.com"
}, },
"record": { "record": {
"CNAME": "joythejoystick1.github.io" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "HunterAPI",
"email": "forsynapse123@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "httphypixelnet",
"email": "intenstudios369@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+5 -5
View File
@@ -1,11 +1,11 @@
{ {
"owner": { "owner": {
"username": "ShadowPlayzYT22", "username": "ShadowPlayzYT22",
"email": "peterwyneg@gmail.com", "email": "peterwyneg@gmail.com"
"discord": "1038747272701292584"
}, },
"record": { "record": {
"CNAME": "shadowplayzyt22.github.io" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "pythonhuman",
"email": "sai.pasumarthi@stu.argyleisd.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "Kamek437",
"email": "hidden_tuetle427@protonmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "kks007",
"email": "kaushalkishor10702@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "CycloneAddons",
"email": "cycloneaddon@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "Rahib777-7",
"email": "rahibrahman1210@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "ModelVNN",
"email": "modelvnn@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+1 -1
View File
@@ -4,6 +4,6 @@
"email": "mj@naous.eu.org" "email": "mj@naous.eu.org"
}, },
"record": { "record": {
"CNAME": "mohamadev.github.io" "CNAME": "mjnaous.github.io"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "mohdjariullah",
"email": "mohdjariullah@gmail.com"
},
"record": {
"CNAME": "fdf28412-bb15-46fb-97b5-e4ea905c949b.id.repl.co"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "NCCoder1",
"email": "nikhilchhawacharia@gmail.com"
},
"record": {
"A": ["192.168.1.100"]
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"owner": {
"username": "NoahPrm",
"email": "noah.parmentier@icloud.com"
},
"record": {
"A": ["185.143.241.106"]
}
}
+4 -4
View File
@@ -1,11 +1,11 @@
{ {
"description": "NotArya",
"repo": "https://github.com/not-arya/not-arya.github.io",
"owner": { "owner": {
"username": "not-arya", "username": "not-arya",
"email": "abiix.messanger@gmail.com" "email": "abiixmessanger@gmail.com"
}, },
"record": { "record": {
"CNAME": "not-arya.github.io" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "npc-123",
"email": "aziznasrul85@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "Oxidiu",
"email": "oxidiu777@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "CycloneAddons",
"email": "cycloneaddon@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "PrathameshhW",
"email": "prathameshj0407@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "Robskan5300",
"email": "rrsnijder@yahoo.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "saumonarcenciel",
"email": "viala38000@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+1 -1
View File
@@ -5,6 +5,6 @@
}, },
"record": { "record": {
"A": ["159.89.214.31"], "A": ["159.89.214.31"],
"TXT": "authkeyfp=SHA256:VVj2L3ejMtwZzCYYUrAKNvRrus1c6LIBm9rXhMY8A4M" "TXT": "authkeyfp=SHA256:71tAcZSCVkBU0hFT/HYO4jt/ZWwSa7/br0nvvf3ustY"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "CycloneAddons",
"email": "cycloneaddon@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "nebula4564",
"email": "reeseb1660@outlook.com"
},
"record": {
"A": ["216.24.57.1"]
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "SquareSmp",
"email": "squaresmp@asia.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "CycloneAddons",
"email": "cycloneaddon@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+3 -1
View File
@@ -4,6 +4,8 @@
"email": "stanasarts@gmail.com" "email": "stanasarts@gmail.com"
}, },
"record": { "record": {
"CNAME": "stanasxd.github.io" "A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
} }
} }
+11
View File
@@ -0,0 +1,11 @@
{
"owner": {
"username": "tzvio",
"email": "tzvika.ofek@gmail.com"
},
"record": {
"A": ["217.174.245.249"],
"MX": ["hosts.is-a.dev"],
"TXT": "v=spf1 a mx ip4:217.174.245.249 ~all"
}
}
+3 -11
View File
@@ -3,27 +3,19 @@
"version": "1.0.0", "version": "1.0.0",
"description": "Register *.is-a.dev domains for free", "description": "Register *.is-a.dev domains for free",
"scripts": { "scripts": {
"test": "ENV=test jest",
"lint": "eslint utils scripts domains --ext .json,.js", "lint": "eslint utils scripts domains --ext .json,.js",
"publish-records": "node ./scripts/register-domains.js", "publish-records": "bun run -b ./scripts/register-domains.js",
"dc": "docker-compose -p is-a-dev", "dc": "docker-compose -p is-a-dev",
"dc:start": "yarn dc up", "dc:start": "bun run dc up",
"dc:shell": "yarn dc run dev /bin/bash" "dc:shell": "bun run dc run dev /bin/bash"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/is-a-dev/register" "url": "https://github.com/is-a-dev/register"
}, },
"keywords": [
"subdomain"
],
"author": "Akshay Nair <phenax5@gmail.com>", "author": "Akshay Nair <phenax5@gmail.com>",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"dotenv": "^8.2.0",
"jest": "^26.4.2",
"node-fetch": "^2.6.1",
"qs": "^6.9.4",
"ramda": "^0.27.1" "ramda": "^0.27.1"
}, },
"devDependencies": { "devDependencies": {
+4 -2
View File
@@ -6,10 +6,12 @@ echo "AUTH ::[$CERTBOT_VALIDATION]::[$CERTBOT_TOKEN]::[$CERTBOT_REMAINING_CHALLE
echo "[$CERTBOT_DOMAIN]"; echo "[$CERTBOT_DOMAIN]";
sleep 1; sleep 1;
./scripts/certbot.sh acme_txt "$CERTBOT_VALIDATION"; ./scripts/certbot.sh acme_txt "$CERTBOT_VALIDATION";
sleep $((5*60)); echo "Going to sleep for a few minutes...";
# TODO: Check if $CERTBOT_VALIDATION == $(./scripts/certbot.sh get-acme)?
sleep $((3*60));
./scripts/certbot.sh check; ./scripts/certbot.sh check;
+5 -2
View File
@@ -18,7 +18,6 @@ generate_certificate() {
-m 'phenax5@gmail.com' \ -m 'phenax5@gmail.com' \
-d '*.is-a.dev,is-a.dev' \ -d '*.is-a.dev,is-a.dev' \
--agree-tos \ --agree-tos \
--dry-run \
$(if_dry_run "--dry-run" ""); $(if_dry_run "--dry-run" "");
echo "+-----------------------------------------------+"; echo "+-----------------------------------------------+";
@@ -68,10 +67,14 @@ update_acme_txt_record() {
reset_acme() { reset_acme() {
sleep 1; sleep 1;
update_record remove TXT '_acme-challenge' ''; update_record remove TXT '_acme-challenge' '';
update_record remove TXT '_acme-challenge' '';
} }
get_acme() { dig +noall +answer _acme-challenge.is-a.dev TXT | awk '{print $5}'; }
case "$1" in case "$1" in
check) echo "TXT record:: $(dig +noall +answer _acme-challenge.is-a.dev TXT | awk '{print $5}')" ;; check) echo "TXT record:: $(get_acme)" ;;
get-acme) get_acme ;;
cert) generate_certificate ;; cert) generate_certificate ;;
acme_txt) update_acme_txt_record "$2" ;; acme_txt) update_acme_txt_record "$2" ;;
reset) reset_acme ;; reset) reset_acme ;;
+14 -14
View File
@@ -204,18 +204,18 @@ describe('Domain service', () => {
{ name: 'c', type: 'MX', address: 'foobar.com', priority: 2 }, { name: 'c', type: 'MX', address: 'foobar.com', priority: 2 },
]); ]);
expect(addZone).toBeCalledTimes(1); expect(addZone).toHaveBeenCalledTimes(1);
expect(getRecordCalls(addZone)).toEqual([ expect(getRecordCalls(addZone)).toEqual([
{ name: 'c', type: 'A', address: '12.131321.213' }, { name: 'c', type: 'A', address: '12.131321.213' },
]); ]);
expect(addEmail).toBeCalledTimes(1); expect(addEmail).toHaveBeenCalledTimes(1);
expect(getRecordCalls(addEmail)).toEqual([ expect(getRecordCalls(addEmail)).toEqual([
{ domain: 'c.is-a.dev', exchanger: 'foobar.com', priority: 2 }, { domain: 'c.is-a.dev', exchanger: 'foobar.com', priority: 2 },
]); ]);
expect(removeZone).toBeCalledTimes(0); expect(removeZone).toHaveBeenCalledTimes(0);
expect(removeEmail).toBeCalledTimes(0); expect(removeEmail).toHaveBeenCalledTimes(0);
}); });
it('should update matching host and set it', async () => { it('should update matching host and set it', async () => {
@@ -231,11 +231,11 @@ describe('Domain service', () => {
{ name: 'b', type: 'CNAME', address: 'googoogaga' }, { name: 'b', type: 'CNAME', address: 'googoogaga' },
]); ]);
expect(addZone).toBeCalledTimes(1); expect(addZone).toHaveBeenCalledTimes(1);
expect(getRecordCalls(addZone)).toEqual([ expect(getRecordCalls(addZone)).toEqual([
{ name: 'b', type: 'CNAME', address: 'googoogaga' }, { name: 'b', type: 'CNAME', address: 'googoogaga' },
]); ]);
expect(removeZone).toBeCalledTimes(1); expect(removeZone).toHaveBeenCalledTimes(1);
expect(getRecordCalls(removeZone)).toEqual([ expect(getRecordCalls(removeZone)).toEqual([
{ line: 2 }, { line: 2 },
]); ]);
@@ -256,12 +256,12 @@ describe('Domain service', () => {
{ name: 'b', type: 'CNAME', address: 'farboo' }, { name: 'b', type: 'CNAME', address: 'farboo' },
]); ]);
expect(addZone).toBeCalledTimes(2); expect(addZone).toHaveBeenCalledTimes(2);
expect(getRecordCalls(addZone)).toEqual([ expect(getRecordCalls(addZone)).toEqual([
{ name: 'b', type: 'CNAME', address: 'googoogaga' }, { name: 'b', type: 'CNAME', address: 'googoogaga' },
{ name: 'b', type: 'CNAME', address: 'farboo' }, { name: 'b', type: 'CNAME', address: 'farboo' },
]); ]);
expect(removeZone).toBeCalledTimes(2); expect(removeZone).toHaveBeenCalledTimes(2);
expect(getRecordCalls(removeZone)).toEqual([ expect(getRecordCalls(removeZone)).toEqual([
{ line: 2 }, { line: 2 },
{ line: 3 }, { line: 3 },
@@ -300,34 +300,34 @@ describe('Domain service', () => {
{ name: 'a', type: 'MX', address: 'example.com', priority: 20 }, { name: 'a', type: 'MX', address: 'example.com', priority: 20 },
]); ]);
expect(addZone).toBeCalledTimes(3); expect(addZone).toHaveBeenCalledTimes(3);
expect(getRecordCalls(addZone)).toEqual([ expect(getRecordCalls(addZone)).toEqual([
{ name: 'a', type: 'CNAME', address: 'boo' }, { name: 'a', type: 'CNAME', address: 'boo' },
{ name: 'b', type: 'A', address: '3' }, { name: 'b', type: 'A', address: '3' },
{ name: 'd', type: 'CNAME', address: 'helo.com' }, { name: 'd', type: 'CNAME', address: 'helo.com' },
]); ]);
expect(removeZone).toBeCalledTimes(1); expect(removeZone).toHaveBeenCalledTimes(1);
expect(getRecordCalls(removeZone)).toEqual([ expect(getRecordCalls(removeZone)).toEqual([
{ line: 1 }, { line: 1 },
]); ]);
expect(addEmail).toBeCalledTimes(1); expect(addEmail).toHaveBeenCalledTimes(1);
expect(getRecordCalls(addEmail)).toEqual([ expect(getRecordCalls(addEmail)).toEqual([
{ domain: 'a.is-a.dev', exchanger: 'example.com', priority: 20 }, { domain: 'a.is-a.dev', exchanger: 'example.com', priority: 20 },
]); ]);
expect(removeEmail).toBeCalledTimes(2); expect(removeEmail).toHaveBeenCalledTimes(2);
expect(getRecordCalls(removeEmail)).toEqual([ expect(getRecordCalls(removeEmail)).toEqual([
{ domain: 'c.is-a.dev', exchanger: 'mx1.hello.com', priority: 20 }, { domain: 'c.is-a.dev', exchanger: 'mx1.hello.com', priority: 20 },
{ domain: 'b.is-a.dev', exchanger: 'foo.bar', priority: 20 }, { domain: 'b.is-a.dev', exchanger: 'foo.bar', priority: 20 },
]); ]);
expect(addRedir).toBeCalledTimes(3); expect(addRedir).toHaveBeenCalledTimes(3);
expect(getRecordCalls(addRedir)).toEqual([ expect(getRecordCalls(addRedir)).toEqual([
{ domain: `b.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://wowow.com' }, { domain: `b.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://wowow.com' },
{ domain: `d.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://hhh.com' }, { domain: `d.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://hhh.com' },
{ domain: `x.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://example69.com' }, { domain: `x.${DOMAIN_DOMAIN}`, type: 'permanent', redirect: 'https://example69.com' },
]); ]);
expect(removeRedir).toBeCalledTimes(2); expect(removeRedir).toHaveBeenCalledTimes(2);
expect(getRecordCalls(removeRedir)).toEqual([ expect(getRecordCalls(removeRedir)).toEqual([
{ domain: `b.${DOMAIN_DOMAIN}` }, { domain: `b.${DOMAIN_DOMAIN}` },
{ domain: `x.${DOMAIN_DOMAIN}` }, { domain: `x.${DOMAIN_DOMAIN}` },
+148 -59
View File
@@ -1,9 +1,18 @@
const R = require('ramda'); const R = require('ramda')
const { toHostList, registerDomains } = require('../scripts/register-domains'); const { toHostList, registerDomains } = require('../scripts/register-domains')
const { TTL, DOMAIN_DOMAIN } = require('../utils/constants'); const { TTL, DOMAIN_DOMAIN } = require('../utils/constants')
const { getDomainService } = require('../utils/domain-service'); const { getDomainService } = require('../utils/domain-service')
const getCpanel = ({ zone, addZone, removeZone, redir, addRedir, removeRedir } = {}) => ({ const getCpanel = ({
zone,
addZone,
removeZone,
redir,
addRedir,
removeRedir,
addEmail,
removeEmail,
} = {}) => ({
zone: { zone: {
fetch: (_) => zone(), fetch: (_) => zone(),
add: (rec) => addZone(rec), add: (rec) => addZone(rec),
@@ -18,7 +27,7 @@ const getCpanel = ({ zone, addZone, removeZone, redir, addRedir, removeRedir } =
add: (rec) => addEmail(rec), add: (rec) => addEmail(rec),
remove: (rec) => removeEmail(rec), remove: (rec) => removeEmail(rec),
}, },
}); })
describe('toHostList', () => { describe('toHostList', () => {
it('should flatten domain data to list of hosts (without https)', () => { it('should flatten domain data to list of hosts (without https)', () => {
@@ -27,7 +36,7 @@ describe('toHostList', () => {
{ name: 'foobar', record: { CNAME: 'v.io' } }, { name: 'foobar', record: { CNAME: 'v.io' } },
{ name: 'xx', record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } }, { name: 'xx', record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } },
{ name: 'xx', record: { CNAME: 'foobar.com', MX: ['as.com', 'f.com'] } }, { name: 'xx', record: { CNAME: 'foobar.com', MX: ['as.com', 'f.com'] } },
]); ])
expect(res).toEqual([ expect(res).toEqual([
{ name: 'akshay', type: 'CNAME', address: 'phenax.github.io', ttl: TTL }, { name: 'akshay', type: 'CNAME', address: 'phenax.github.io', ttl: TTL },
@@ -38,83 +47,163 @@ describe('toHostList', () => {
{ name: 'xx', type: 'CNAME', address: 'foobar.com', ttl: TTL }, { name: 'xx', type: 'CNAME', address: 'foobar.com', ttl: TTL },
{ name: 'xx', type: 'MX', address: 'as.com', priority: 20, ttl: TTL }, { name: 'xx', type: 'MX', address: 'as.com', priority: 20, ttl: TTL },
{ name: 'xx', type: 'MX', address: 'f.com', priority: 21, ttl: TTL }, { name: 'xx', type: 'MX', address: 'f.com', priority: 21, ttl: TTL },
]); ])
}); })
}); })
describe('registerDomains', () => { describe('registerDomains', () => {
const addZone = jest.fn(async () => ({})); const addZone = jest.fn(async () => ({}))
const removeZone = jest.fn(async () => ({})); const removeZone = jest.fn(async () => ({}))
const addRedir = jest.fn(async () => ({})); const addRedir = jest.fn(async () => ({}))
const removeRedir = jest.fn(async () => ({})); const removeRedir = jest.fn(async () => ({}))
const addEmail = jest.fn(async () => ({})); const addEmail = jest.fn(async () => ({}))
const removeEmail = jest.fn(async () => ({})); const removeEmail = jest.fn(async () => ({}))
const mockDS = ({ zones, redirections }) => getDomainService({ const mockDS = ({ zones, redirections }) =>
cpanel: getCpanel({ getDomainService({
zone: async () => zones, cpanel: getCpanel({
redir: async () => redirections, zone: async () => zones,
addZone, redir: async () => redirections,
addEmail, addZone,
addRedir, addEmail,
removeZone, addRedir,
removeRedir, removeZone,
removeEmail, removeRedir,
removeEmail,
}),
}) })
});
beforeEach(() => { beforeEach(() => {
addZone.mockClear(); addZone.mockClear()
removeZone.mockClear(); removeZone.mockClear()
addRedir.mockClear(); addRedir.mockClear()
removeRedir.mockClear(); removeRedir.mockClear()
addEmail.mockClear(); addEmail.mockClear()
removeEmail.mockClear(); removeEmail.mockClear()
}); })
it('should register the new set of hosts generated from domains list', async () => { it('should register the new set of hosts generated from domains list', async () => {
const localHosts = [ const localHosts = [
{ name: 'a', record: { CNAME: 'hello' } }, { name: 'a', record: { CNAME: 'hello' } },
{ name: 'b', record: { CNAME: 'xaa' } }, { name: 'b', record: { CNAME: 'xaa' } },
]; ]
const remoteHosts = [ const remoteHosts = [
{ line: 1, name: 'a', type: 'CNAME', address: 'hello' }, { line: 1, name: 'a', type: 'CNAME', address: 'hello' },
{ line: 2, name: 'b', type: 'CNAME', address: 'goo' }, { line: 2, name: 'b', type: 'CNAME', address: 'goo' },
{ line: 3, name: 'b', type: 'CNAME', address: 'xaa' }, { line: 3, name: 'b', type: 'CNAME', address: 'xaa' },
]; ]
const remoteRedirections = []; const remoteRedirections = []
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections }); const domainService = mockDS({
await registerDomains({ getDomains: async () => localHosts, domainService }); zones: remoteHosts,
redirections: remoteRedirections,
})
await registerDomains({ getDomains: async () => localHosts, domainService })
expect(addZone).toBeCalledTimes(0); expect(addZone).toHaveBeenCalledTimes(0)
expect(removeZone).toBeCalledTimes(1); expect(removeZone).toHaveBeenCalledTimes(1)
expect(addRedir).toBeCalledTimes(0); expect(addRedir).toHaveBeenCalledTimes(0)
expect(removeRedir).toBeCalledTimes(0); expect(removeRedir).toHaveBeenCalledTimes(0)
}); })
it('should add the new set hosts', async () => { it('should add the new set hosts', async () => {
const localHosts = [ const localHosts = [
{ name: 'a', record: { CNAME: 'boo', URL: 'z' } }, { name: 'a', record: { CNAME: 'boo' } },
{ name: 'b', record: { CNAME: 'xaa', URL: 'x' } }, {
{ name: 'c', record: { CNAME: 'yello', URL: 'https://google.com' } }, name: 'b',
]; record: { A: ['1.1.1.1', '1.1.1.2'], MX: 'somemx', TXT: 'some txt' },
},
{ name: 'c', record: { URL: 'https://google.com' } },
{ name: 'd', record: { CNAME: 'foobar' } },
{ name: 'e', record: { A: ['2.2.2.2'], TXT: ['some', 'extra', 'txt'] } },
]
const remoteHosts = [ const remoteHosts = [
{ line: 1, name: 'a', type: 'CNAME', address: 'boo' }, { line: 1, name: 'a', type: 'CNAME', address: 'boo' },
{ line: 2, name: 'b', type: 'CNAME', address: 'xaa' }, { line: 2, name: 'b', type: 'MX', address: 'othermx' },
]; { line: 3, name: 'd', type: 'CNAME', address: 'foobaz' },
]
const remoteRedirections = [ const remoteRedirections = [
{ domain: `b.${DOMAIN_DOMAIN}`, destination: 'x' }, { domain: `b.${DOMAIN_DOMAIN}`, destination: 'x' },
{ domain: `a.${DOMAIN_DOMAIN}`, destination: 'y' }, { domain: `a.${DOMAIN_DOMAIN}`, destination: 'y' },
]; ]
const domainService = mockDS({ zones: remoteHosts, redirections: remoteRedirections }); const domainService = mockDS({
await registerDomains({ getDomains: async () => localHosts, domainService }); zones: remoteHosts,
redirections: remoteRedirections,
})
await registerDomains({ getDomains: async () => localHosts, domainService })
expect(addZone).toBeCalledTimes(1); expect(addZone).toHaveBeenCalledTimes(8)
expect(removeZone).toBeCalledTimes(0); expect(addZone.mock.calls).toEqual([
expect(addRedir).toBeCalledTimes(2); [{ name: 'b', type: 'A', address: '1.1.1.1', line: undefined }],
expect(removeRedir).toBeCalledTimes(1); [{ name: 'b', type: 'A', address: '1.1.1.2', line: undefined }],
}); [
}); {
name: 'b',
type: 'TXT',
address: 'some txt',
txtdata: 'some txt',
line: undefined,
},
],
[
{
name: 'd',
type: 'CNAME',
cname: 'foobar',
address: 'foobar',
line: undefined,
},
],
[{ name: 'e', type: 'A', address: '2.2.2.2', line: undefined }],
[
{
name: 'e',
type: 'TXT',
address: 'some',
txtdata: 'some',
line: undefined,
},
],
[
{
name: 'e',
type: 'TXT',
address: 'extra',
txtdata: 'extra',
line: undefined,
},
],
[
{
name: 'e',
type: 'TXT',
address: 'txt',
txtdata: 'txt',
line: undefined,
},
],
])
expect(removeZone).toHaveBeenCalledTimes(1)
expect(removeZone.mock.calls).toEqual([[{ line: 3 }]])
expect(addRedir).toHaveBeenCalledTimes(1)
expect(addRedir.mock.calls).toEqual([
[
{
domain: 'c.booboo.xyz',
redirect: 'https://google.com',
redirect_wildcard: 1,
redirect_www: 1,
type: 'permanent',
},
],
])
expect(addEmail).toHaveBeenCalledTimes(1)
expect(addEmail.mock.calls).toEqual([
[{ domain: 'b.is-a.dev', exchanger: 'somemx', priority: 20 }],
])
})
})
+1 -1
View File
@@ -54,7 +54,6 @@ describe('validateDomainData', () => {
{ ...defaultDomain, record: { CNAME: 'foobar.com', A: ['11.22.22.33'] } }, { ...defaultDomain, record: { CNAME: 'foobar.com', A: ['11.22.22.33'] } },
{ ...defaultDomain, record: { CNAME: 'foobar.com', MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } }, { ...defaultDomain, record: { CNAME: 'foobar.com', MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } },
...INVALID_NAMES.map(name => ({ ...defaultDomain, name })).slice(0, 1), ...INVALID_NAMES.map(name => ({ ...defaultDomain, name })).slice(0, 1),
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!'] } },
{ ...defaultDomain, name: 'a.b' }, { ...defaultDomain, name: 'a.b' },
{ ...defaultDomain, name: 'ww2.baa' }, { ...defaultDomain, name: 'ww2.baa' },
{ ...defaultDomain, name: 'help.baa' }, { ...defaultDomain, name: 'help.baa' },
@@ -86,6 +85,7 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: '_github-challenge-phenax.akshay' }, { ...defaultDomain, name: '_github-challenge-phenax.akshay' },
{ ...defaultDomain, name: '_github-challenge-hello01-ga' }, { ...defaultDomain, name: '_github-challenge-hello01-ga' },
{ ...defaultDomain, name: '_github-challenge-hello01_ga' }, { ...defaultDomain, name: '_github-challenge-hello01_ga' },
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!', 'more text'] } },
]; ];
it('should return false for invalid data', () => { it('should return false for invalid data', () => {
+1 -5
View File
@@ -1,10 +1,6 @@
const path = require('path'); const path = require('path');
const { ENV = 'test', CI } = process.env; const { NODE_ENV: ENV = 'test' } = process.env;
if (!CI) {
require('dotenv').config({ path: path.resolve(`.env.${ENV}`) });
}
const { const {
DOMAIN_USER, DOMAIN_USER,
+1 -2
View File
@@ -1,6 +1,5 @@
const R = require('ramda'); const R = require('ramda');
const fetch = require('node-fetch'); const qs = require('querystring');
const qs = require('qs');
const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN } = require('../constants'); const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN } = require('../constants');
const CpanelClient = (options) => { const CpanelClient = (options) => {
+1 -1
View File
@@ -74,7 +74,7 @@ const validateDomainData = validate({
[R.has('A'), validateARecord('A')], [R.has('A'), validateARecord('A')],
[R.has('URL'), R.propSatisfies(isValidURL, 'URL')], [R.has('URL'), R.propSatisfies(isValidURL, 'URL')],
[R.has('MX'), validateMXRecord('MX')], [R.has('MX'), validateMXRecord('MX')],
[R.has('TXT'), R.propSatisfies(R.is(String), 'TXT')], [R.has('TXT'), R.propSatisfies(or([ R.is(String), R.is(Array) ]), 'TXT')],
[R.T, R.T], [R.T, R.T],
]), ]),
]), ]),
-4002
View File
File diff suppressed because it is too large. Load diff