suite('healthcheck', () => { suite('/', () => { test('should return a status message', async () => { const response = await got(`http://localhost:${instance.server.address().port}`, { json: true }); response.statusCode.should.be.equal(200); response.body.status.should.be.equal('ok'); }); }); });
static getTrash(callback) { Logger.verbose('Requesting tash:list endpoint'); Logger.debug(`HTTP Request: GET '${account.metadataUrl}trash'`); got.get(`${account.metadataUrl}trash`, { headers: { Authorization: `Bearer ${account.token.access_token}`, }, }) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); return callback(null, JSON.parse(response.body)); }) .catch(err => { return callback(err); }); }
(async () => { try { const response = await client.delete(resource); fine(`DELETE ${resource} received a: ${response.statusCode}`); switch (response.statusCode) { case 204: break; // we're good, let's proceed case 401: debug("Webex authentication failed: 401, bad token"); if (cb) cb(new Error("response status: " + response.statusCode + ", bad token"), null); return; default: debug("could not delete Webhook, status code: " + response.statusCode); if (cb) cb(new Error("response status: " + response.statusCode), null); return; } if (cb) cb(null, 204); } catch (error) { fine(`error in ${resource}, code: ${error.code}`) ddebug("cannot delete the webhook, error: " + error.message); if (cb) cb(new Error("cannot delete the webhook"), null); } })();
}) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true; this.replace(retval.data);
got.head(file, {throwHttpErrors: false}).then(head => { if (head.statusCode !== 200) { return callback();
}) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true;
getEndpoints(callback) { let retval = { success: false, data: { metadataUrl: this.metadataUrl, contentUrl: this.contentUrl, }, }; Logger.verbose('Requesting account:endpoints endpoint'); Logger.debug(`HTTP Request: GET 'https://cdws.us-east-1.amazonaws.com/drive/v1/account/endpoint'`); got.get('https://cdws.us-east-1.amazonaws.com/drive/v1/account/endpoint', { headers: { Authorization: `Bearer ${this.token.access_token}`, }, }) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true; } return callback(null, retval); }) .catch(err => { return callback(err); }); }
suite('example2', () => { suite('/', () => { test('should return an example message', async () => { const response = await got(`http://localhost:${instance.server.address().port}/v1/example2`, { json: true }); response.statusCode.should.be.equal(200); response.body.message.should.be.equal('example2'); }); }); suite('/another', () => { test('should return another example message', async () => { const response = await got(`http://localhost:${instance.server.address().port}/v1/example2/another`, { json: true }); response.statusCode.should.be.equal(200); response.body.message.should.be.equal('another example'); }); }); });
responseType: 'json' }); fine(`POST ${path} received a: ${response.statusCode}`); switch (response.statusCode) { case 200: break; // we're good, let's proceed if (cb) cb(new Error("response status: " + response.statusCode + ", bad token"), null); return; debug("could not create WebHook, status code: " + response.statusCode); if (cb) cb(new Error("response status: " + response.statusCode), null); return;
}) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true; this.replace(retval.data);
getUsage(callback) { let retval = { success: false, data: {}, }; Logger.verbose('Requesting account:usage endpoint'); Logger.debug(`HTTP Request: GET '${this.metadataUrl}account/usage'`); got.get(`${this.metadataUrl}account/usage`, { headers: { Authorization: `Bearer ${this.token.access_token}`, }, }) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.debug(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true; } return callback(null, retval); }) .catch(err => { return callback(err); }); }
suite('example', () => { suite('/', () => { test('should return an example message', async () => { const response = await got(`http://localhost:${instance.server.address().port}/v1/example`, { json: true }); response.statusCode.should.be.equal(200); response.body.message.should.be.equal('example'); }); }); });
getQuota(callback) { let retval = { success: false, data: {}, }; Logger.verbose('Requesting account:quota endpoint'); Logger.debug(`HTTP Request: GET '${this.metadataUrl}account/quota'`); got.get(`${this.metadataUrl}account/quota`, { headers: { Authorization: `Bearer ${this.token.access_token}`, }, }) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (retval.statusCode === 200) { retval.success = true; } return callback(null, retval); }) .catch(err => { return callback(err); }); }
getInfo(callback) { let retval = { success: false, data: {}, }; Logger.verbose('Requesting account:info endpoint'); Logger.debug(`HTTP Request: GET '${this.metadataUrl}account/info'`); got.get(`${this.metadataUrl}account/info`, { headers: { Authorization: `Bearer ${this.token.access_token}`, }, }) .then(response => { Logger.debug(`Response returned with status code ${response.statusCode}.`); Logger.silly(`Response body: ${response.body}`); retval.data = JSON.parse(response.body); if (response.statusCode === 200) { retval.success = true; } return callback(null, retval); }) .catch(err => { return callback(err); }); }
got.head(file, {throwHttpErrors: false}).then(head => { if (head.statusCode !== 200) { return callback();