mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-12 22:14:49 +00:00
Fixes cpanel test cases and constants
This commit is contained in:
1 parent
addf748158
commit
c20f6d7673
3 files changed
+15
-10
No files matched your search
@@ -12,7 +12,7 @@ describe('Cpanel client', () => {
|
||||
describe('fetchzonerecords', () => {
|
||||
it('should make the correct request', async () => {
|
||||
const fetch = mockFetch((url, request) => {
|
||||
expect(url).toBe('https://example.com:2000//json-api/cpanel?customonly=1&domain=is-a.dev&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzone_records&cpanel_jsonapi_apiversion=2');
|
||||
expect(url).toBe('https://example.com:2000//json-api/cpanel?customonly=1&domain=a.b&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzone_records&cpanel_jsonapi_apiversion=2');
|
||||
expect(request).toEqual({
|
||||
headers: {
|
||||
Authorization: 'cpanel boy:boybyebye',
|
||||
@@ -26,6 +26,7 @@ describe('Cpanel client', () => {
|
||||
port: 2000,
|
||||
username: 'boy',
|
||||
apiKey: 'boybyebye',
|
||||
domain: 'a.b',
|
||||
dependencies: { fetch },
|
||||
});
|
||||
|
||||
@@ -48,6 +49,7 @@ describe('Cpanel client', () => {
|
||||
port: 2000,
|
||||
username: 'boy',
|
||||
apiKey: 'boybyebye',
|
||||
domain: 'a.b',
|
||||
dependencies: { fetch },
|
||||
});
|
||||
|
||||
@@ -58,7 +60,7 @@ describe('Cpanel client', () => {
|
||||
describe('addzonerecord', () => {
|
||||
it('should make the correct request', async () => {
|
||||
const fetch = mockFetch((url, request) => {
|
||||
expect(url).toBe('https://example.com:2000//json-api/cpanel?domain=is-a.dev&name=googo&type=CNAME&cname=beey&ttl=2020&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=add_zone_record&cpanel_jsonapi_apiversion=2');
|
||||
expect(url).toBe('https://example.com:2000//json-api/cpanel?domain=a.b&name=googo&type=CNAME&cname=beey&ttl=2020&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=add_zone_record&cpanel_jsonapi_apiversion=2');
|
||||
expect(request).toEqual({
|
||||
headers: {
|
||||
Authorization: 'cpanel boy:boybyebye',
|
||||
@@ -72,6 +74,7 @@ describe('Cpanel client', () => {
|
||||
port: 2000,
|
||||
username: 'boy',
|
||||
apiKey: 'boybyebye',
|
||||
domain: 'a.b',
|
||||
dependencies: { fetch },
|
||||
});
|
||||
|
||||
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
const path = require('path');
|
||||
|
||||
const { ENV = 'sandbox', CI } = process.env;
|
||||
const { ENV = 'test', CI } = process.env;
|
||||
|
||||
if (!CI) {
|
||||
require('dotenv').config({ path: path.resolve(`.env.${ENV}`) });
|
||||
}
|
||||
|
||||
const { NC_USER, NC_API_KEY, NC_DOMAIN, IP_ADDRESS } = process.env;
|
||||
const { DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN, DOMAIN_API_HOST, DOMAIN_API_PORT } = process.env;
|
||||
|
||||
const IS_TEST = ENV === 'test';
|
||||
|
||||
module.exports = {
|
||||
ENV,
|
||||
VALID_RECORD_TYPES: ['CNAME', 'A', 'ALIAS', 'URL'],
|
||||
NC_DOMAIN: NC_DOMAIN || 'booboo.xyz',
|
||||
NC_USER: IS_TEST ? 'testuser' : NC_USER,
|
||||
NC_API_KEY: IS_TEST ? 'testkey' : NC_API_KEY,
|
||||
IP_ADDRESS,
|
||||
TTL: 5*60,
|
||||
DOMAIN_DOMAIN: DOMAIN_DOMAIN || 'booboo.xyz',
|
||||
DOMAIN_USER: IS_TEST ? 'testuser' : DOMAIN_USER,
|
||||
DOMAIN_API_KEY: IS_TEST ? 'testkey' : DOMAIN_API_KEY,
|
||||
DOMAIN_API_HOST: IS_TEST ? 'example.com' : DOMAIN_API_HOST,
|
||||
DOMAIN_API_PORT: IS_TEST ? 6969 : DOMAIN_API_PORT,
|
||||
TTL: 5*60, // TODO: Increase ttl
|
||||
};
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
const R = require('ramda');
|
||||
const fetch = require('node-fetch');
|
||||
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, ...c } = require('../constants');
|
||||
|
||||
const CpanelClient = (options) => {
|
||||
// TODO: Make defaultQuery functional
|
||||
const api = (module, func, defaultQuery = {}) => (q = {}) => {
|
||||
const query = {
|
||||
...defaultQuery,
|
||||
|
||||
Reference in new issue
Block a user