mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-13 14:22:49 +00:00
Replaces cpanel edit with remove
This commit is contained in:
@@ -88,6 +88,33 @@ 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=a.b&line=500&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=remove_zone_record&cpanel_jsonapi_apiversion=2');
|
||||
expect(request).toEqual({
|
||||
headers: {
|
||||
Authorization: 'cpanel boy:boybyebye',
|
||||
},
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
});
|
||||
|
||||
const cpanel = CpanelClient({
|
||||
host: 'example.com',
|
||||
port: 2000,
|
||||
username: 'boy',
|
||||
apiKey: 'boybyebye',
|
||||
domain: 'a.b',
|
||||
dependencies: { fetch },
|
||||
});
|
||||
|
||||
await cpanel.zone.remove({
|
||||
line: 500,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchredirections', () => {
|
||||
it('should make the correct request', async () => {
|
||||
const fetch = mockFetch((url, request) => {
|
||||
@@ -139,5 +166,30 @@ describe('Cpanel client', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteredirection', () => {
|
||||
it('should make the correct request', async () => {
|
||||
const fetch = mockFetch((url, request) => {
|
||||
expect(url).toBe('https://example.com:2000/execute/Mime/delete_redirect?domain=googo&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=Mime&cpanel_jsonapi_func=delete_redirect&cpanel_jsonapi_apiversion=2');
|
||||
expect(request).toEqual({
|
||||
headers: {
|
||||
Authorization: 'cpanel boy:boybyebye',
|
||||
},
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
});
|
||||
|
||||
const cpanel = CpanelClient({
|
||||
host: 'example.com',
|
||||
port: 2000,
|
||||
username: 'boy',
|
||||
apiKey: 'boybyebye',
|
||||
domain: 'a.b',
|
||||
dependencies: { fetch },
|
||||
});
|
||||
|
||||
await cpanel.redirection.remove({ domain: 'googo' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+5
-4
@@ -45,10 +45,9 @@ const CpanelClient = (options) => {
|
||||
// { name, type(A|CNAME), cname, address, ttl }
|
||||
// -> {}
|
||||
add: api2('ZoneEdit', 'add_zone_record', { domain: options.domain }),
|
||||
|
||||
// { name, type(A|CNAME), cname, address, ttl }
|
||||
// { line }
|
||||
// -> {}
|
||||
edit: api2('ZoneEdit', 'edit_zone_record', { domain: options.domain }),
|
||||
remove: api2('ZoneEdit', 'remove_zone_record', { domain: options.domain }),
|
||||
},
|
||||
redirection: {
|
||||
// {}
|
||||
@@ -61,7 +60,9 @@ const CpanelClient = (options) => {
|
||||
// { domain, redirect, type(permanent|tmp), redirect_wildcard(0|1), redirect(0|1|2) }
|
||||
// -> {}
|
||||
add: uapi('Mime', 'add_redirect'),
|
||||
edit: uapi('Mime', 'add_redirect'), // NOTE: adding new updates exisiting
|
||||
// { domain }
|
||||
// -> {}
|
||||
remove: uapi('Mime', 'delete_redirect'),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user