mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-13 10:15:47 +00:00
Removes forceHttps flag
This commit is contained in:
1 parent
12010f3007
commit
4844a7bbe1
6 files changed
+6
-37
No files matched your search
@@ -5,7 +5,6 @@
|
||||
"username": "phenax",
|
||||
"email": "phenax5@gmail.com"
|
||||
},
|
||||
"forceHttps": true,
|
||||
"record": {
|
||||
"CNAME": "phenax.github.io"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"username": "phenax",
|
||||
"email": "phenax5@gmail.com"
|
||||
},
|
||||
"forceHttps": true,
|
||||
"record": {
|
||||
"CNAME": "duckduckgo.com"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const R = require('ramda');
|
||||
const { VALID_RECORD_TYPES, NC_DOMAIN, TTL } = require('../utils/constants');
|
||||
const { VALID_RECORD_TYPES, TTL } = require('../utils/constants');
|
||||
const { domainService: domain } = require('../utils/domain-service');
|
||||
const { getDomains } = require('../utils/domain');
|
||||
|
||||
@@ -8,7 +8,7 @@ const getRecords = R.compose(R.toPairs, R.pick(VALID_RECORD_TYPES));
|
||||
const toHostList = R.chain(data => {
|
||||
const rs = getRecords(data.record);
|
||||
|
||||
const records = R.chain(([recordType, urls]) =>
|
||||
return R.chain(([recordType, urls]) =>
|
||||
(Array.isArray(urls) ? urls : [urls]).map(url => ({
|
||||
HostName: data.name,
|
||||
RecordType: recordType,
|
||||
@@ -16,10 +16,6 @@ const toHostList = R.chain(data => {
|
||||
TTL,
|
||||
}))
|
||||
, rs);
|
||||
|
||||
return !data.forceHttps ? records : records.concat([
|
||||
{ HostName: data.name, RecordType: 'URL', Address: `https://${data.name}.${NC_DOMAIN}` },
|
||||
]);
|
||||
});
|
||||
|
||||
const registerDomains = async ({ domainService, getDomains }) => {
|
||||
|
||||
@@ -9,7 +9,6 @@ describe('getDomains', () => {
|
||||
|
||||
const defaultDomain = {
|
||||
name: 'aaa',
|
||||
forceHttps: false,
|
||||
record: {
|
||||
A: ['121.121.121.121']
|
||||
},
|
||||
@@ -24,8 +23,6 @@ const getstroflen = len => Array(len).fill('a').join('');
|
||||
describe('validateDomainData', () => {
|
||||
const invalidCases = [
|
||||
{},
|
||||
{ forceHttps: false },
|
||||
{ forceHttps: 1 },
|
||||
{ name: 'helo' },
|
||||
{ name: 'wwow', record: { A: ['12312'] } },
|
||||
...['', ' ', undefined, 'hlo wld', 'g32++13', 'ajsdD_123yq', 'khsda%', '122*dsd', getstroflen(101)].map(name => ({
|
||||
|
||||
+4
-22
@@ -1,12 +1,12 @@
|
||||
const { toHostList } = require('../scripts/register-domains');
|
||||
const { NC_DOMAIN, TTL } = require('../utils/constants');
|
||||
const { TTL } = require('../utils/constants');
|
||||
|
||||
describe('toHostList', () => {
|
||||
it('should flatten domain data to list of hosts (without https)', () => {
|
||||
const res = toHostList([
|
||||
{ name: 'akshay', forceHttps: false, record: { CNAME: 'phenax.github.io' } },
|
||||
{ name: 'foobar', forceHttps: false, record: { CNAME: 'v.io' } },
|
||||
{ name: 'xx', forceHttps: false, record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } },
|
||||
{ name: 'akshay', record: { CNAME: 'phenax.github.io' } },
|
||||
{ name: 'foobar', record: { CNAME: 'v.io' } },
|
||||
{ name: 'xx', record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } },
|
||||
]);
|
||||
|
||||
expect(res).toEqual([
|
||||
@@ -17,22 +17,4 @@ describe('toHostList', () => {
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should flatten domain data to list of hosts (with https)', () => {
|
||||
const res = toHostList([
|
||||
{ name: 'akshay', forceHttps: true, record: { CNAME: 'phenax.github.io' } },
|
||||
{ name: 'foobar', forceHttps: false, record: { CNAME: 'v.io' } },
|
||||
{ name: 'xx', forceHttps: true, record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } },
|
||||
]);
|
||||
|
||||
expect(res).toEqual([
|
||||
{ HostName: 'akshay', RecordType: 'CNAME', Address: 'phenax.github.io', TTL },
|
||||
{ HostName: 'akshay', RecordType: 'URL', Address: `https://akshay.${NC_DOMAIN}` },
|
||||
{ HostName: 'foobar', RecordType: 'CNAME', Address: 'v.io', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.3.4', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '5.6.3.2', TTL },
|
||||
{ HostName: 'xx', RecordType: 'A', Address: '1.2.31.1', TTL },
|
||||
{ HostName: 'xx', RecordType: 'URL', Address: `https://xx.${NC_DOMAIN}` },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -52,10 +52,6 @@ const validateDomainData = validate({
|
||||
}),
|
||||
]),
|
||||
},
|
||||
forceHttps: {
|
||||
reason: '`forceHttp` is required to be true or false',
|
||||
fn: R.is(Boolean),
|
||||
},
|
||||
record: {
|
||||
reason: 'Invalid record',
|
||||
fn: R.allPass([
|
||||
|
||||
Reference in new issue
Block a user