From 12010f3007cff3553671a68617ee0a400aaa7bc6 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 5 Oct 2020 00:57:34 +0530 Subject: [PATCH] Blocks invalid record types --- tests/domain-utils.test.js | 2 +- utils/domain.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/domain-utils.test.js b/tests/domain-utils.test.js index dabbda53b..2420494ed 100644 --- a/tests/domain-utils.test.js +++ b/tests/domain-utils.test.js @@ -33,7 +33,7 @@ describe('validateDomainData', () => { name, })), { ...defaultDomain, record: { CNAME: 'sd', A: ['121,3213'] } }, - //{ ...defaultDomain, record: { FOOBAR: ['sd'] } }, + { ...defaultDomain, record: { A: ['121', '12'], FOOBAR: ['sd'] } }, { ...defaultDomain, owner: {}, }, { ...defaultDomain, owner: { username: 'hwelo', }, }, { ...defaultDomain, owner: { email: 'hwelo' }, }, diff --git a/utils/domain.js b/utils/domain.js index ff33ece72..19fa942a5 100644 --- a/utils/domain.js +++ b/utils/domain.js @@ -1,6 +1,7 @@ const fs = require('fs'); const path = require('path'); const R = require('ramda'); +const { VALID_RECORD_TYPES } = require('./constants'); const DOMAINS_PATH = path.resolve('domains'); @@ -59,7 +60,7 @@ const validateDomainData = validate({ reason: 'Invalid record', fn: R.allPass([ R.is(Object), - //r => R.keys(r). + R.compose(R.isEmpty, R.flip(R.difference)(VALID_RECORD_TYPES), R.keys), R.cond([ [R.prop('CNAME'), validateNameRecord('CNAME')], [R.prop('ALIAS'), validateNameRecord('ALIAS')],