fix request and response types

This commit is contained in:
Nawaz Dhandala
2022-03-15 22:36:40 +00:00
parent 9ba8e13e61
commit 8cd2d19f31
79 changed files with 2293 additions and 2299 deletions

View File

@@ -9,9 +9,9 @@ import compression from 'compression';
app.use(compression());
app.get(['/env.js', '/accounts/env.js'], function(
req: $TSFixMe,
res: $TSFixMe
app.get(['/env.js', '/accounts/env.js'], function (
req: Request,
req: Response
) {
const env = {
REACT_APP_IS_SAAS_SERVICE: process.env.IS_SAAS_SERVICE,
@@ -69,7 +69,7 @@ app.use(
app.use('/accounts', express.static(path.join(__dirname, 'build')));
app.get('/*', function(req: Request, res: Response) {
app.get('/*', function (req: Request, res: Response) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

View File

@@ -240,7 +240,7 @@ export class Component extends React.Component {
smtpToUse,
};
return testSmtp(payload).then((res: $TSFixMe) => {
return testSmtp(payload).then((req: Response) => {
if (res && typeof res === 'string') {
// prevent dismissal of modal if errored
// res will only be a string if errored
@@ -352,7 +352,7 @@ export class Component extends React.Component {
settings.requesting
}
/>
// @ts-expect-error ts-migrate(2339) FIXME: Property 'explanation' does not exist on type '{ k... Remove this comment to see the full error message
// @ts-expect-error ts-migrate(2339) FIXME: Property 'explanation' does not exist on type '{k... Remove this comment to see the full error message
{field.explanation && (
<p className="bs-Fieldset-explanation">
{
@@ -366,12 +366,12 @@ export class Component extends React.Component {
))}
{smtpForm.values &&
smtpForm.values[
'email-enabled'
'email-enabled'
] &&
smtpOptions.map(field => {
if (
field.key ===
'internalSmtp' &&
'internalSmtp' &&
!IS_INTERNAL_SMTP_DEPLOYED
) {
return null;
@@ -428,7 +428,7 @@ export class Component extends React.Component {
})}
{smtpForm.values &&
smtpForm.values[
'email-enabled'
'email-enabled'
] &&
smtpForm.values.customSmtp &&
fields.map(field => (

View File

@@ -29,7 +29,7 @@
"ping": "^0.4.1",
"simple-git": "^2.40.0",
"ssh2": "^0.8.9",
"uuid": "^3.4.0",
"uuid": "^8.3.2",
"winston": "^3.3.3",
"winston-slack-transport": "^2.0.0"
}

View File

@@ -36,7 +36,7 @@ const httpsAgent = new https.Agent({
// Params:
// Param 1: req.params-> {projectId}; req.body -> {[_id], name, type, data, visibleOnStatusPage} <- Check MonitorMoal for description.
// Returns: response status, error message
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
req,
res
) {
@@ -274,7 +274,7 @@ router.post('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
}
});
router.post('/:projectId/identityFile', async function(
router.post('/:projectId/identityFile', async function (
req: Request,
res: Response
) {
@@ -287,7 +287,7 @@ router.post('/:projectId/identityFile', async function(
maxCount: 1,
},
]);
upload(req, res, async function(error: $TSFixMe) {
upload(req, res, async function (error: $TSFixMe) {
let identityFile;
if (error) {
return sendErrorResponse(req, res, error);
@@ -306,7 +306,7 @@ router.post('/:projectId/identityFile', async function(
}
});
router.post('/:projectId/configurationFile', async function(
router.post('/:projectId/configurationFile', async function (
req: Request,
res: Response
) {
@@ -319,7 +319,7 @@ router.post('/:projectId/configurationFile', async function(
maxCount: 1,
},
]);
upload(req, res, async function(error: $TSFixMe) {
upload(req, res, async function (error: $TSFixMe) {
let configurationFile;
if (error) {
return sendErrorResponse(req, res, error);
@@ -343,7 +343,7 @@ router.put(
getUser,
isAuthorized,
isUserAdmin,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const data = req.body;
const { monitorId } = req.params;
@@ -434,7 +434,7 @@ router.put(
// Route
// Description: Get all Monitors by projectId.
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function (
req,
res
) {
@@ -456,7 +456,7 @@ router.get('/:projectId', getUser, isAuthorized, getSubProjects, async function(
}
});
router.get('/:projectId/paginated', getUser, isAuthorized, async function(
router.get('/:projectId/paginated', getUser, isAuthorized, async function (
req,
res
) {
@@ -504,7 +504,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const type = req.query.type;
@@ -549,7 +549,7 @@ router.get(
getUser,
isAuthorized,
getSubProjects,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const monitorId = req.params.monitorId;
const type = req.query.type;
@@ -589,7 +589,7 @@ router.post(
'/:projectId/monitorLogs/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const {
skip,
@@ -645,7 +645,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
const { monitorId, projectId } = req.params;
try {
const monitor = await MonitorService.deleteBy(
@@ -676,7 +676,7 @@ router.post(
getUser,
isAuthorized,
isUserAdmin,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const monitorId = req.params.monitorId || req.body._id;
const data = req.body;
@@ -695,10 +695,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
data
)
monitor.type,
monitor.criteria.up,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
const {
stat: validDegraded,
@@ -707,10 +707,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
data
)
monitor.type,
monitor.criteria.degraded,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
const {
stat: validDown,
@@ -719,10 +719,10 @@ router.post(
} =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
monitor.criteria.down,
data
)
monitor.type,
monitor.criteria.down,
data
)
: { stat: false, failedReasons: [], successReasons: [] };
if (validUp) {
@@ -771,7 +771,7 @@ router.post(
'/:projectId/monitorLog/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -793,7 +793,7 @@ router.post(
'/:projectId/monitorStatuses/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { startDate, endDate } = req.body;
const monitorId = req.params.monitorId;
@@ -815,7 +815,7 @@ router.get(
'/:projectId/lighthouseLog/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { skip, limit, url } = req.query;
const monitorId = req.params.monitorId;
@@ -841,7 +841,7 @@ router.get(
'/:projectId/lighthouseIssue/:issueId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const selectLighthouseLogs =
'monitorId probeId data url performance accessibility bestPractices seo pwa createdAt scanning';
@@ -870,7 +870,7 @@ router.post(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
return await _updateDeviceMonitorPingTime(req, res);
}
);
@@ -879,14 +879,14 @@ router.get(
'/:projectId/inbound/:deviceId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
return await _updateDeviceMonitorPingTime(req, res);
}
);
const _updateDeviceMonitorPingTime = async function(
req: $TSFixMe,
res: $TSFixMe
const _updateDeviceMonitorPingTime = async function (
req: Request,
req: Response
) {
try {
const projectId = req.params.projectId;
@@ -924,7 +924,7 @@ const _updateDeviceMonitorPingTime = async function(
}
};
router.post('/:projectId/addseat', getUser, isAuthorized, async function(
router.post('/:projectId/addseat', getUser, isAuthorized, async function (
req,
res
) {
@@ -942,7 +942,7 @@ router.post(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.addSiteUrl(
@@ -962,7 +962,7 @@ router.delete(
'/:projectId/siteUrl/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { siteUrl } = req.body;
const monitor = await MonitorService.removeSiteUrl(
@@ -982,7 +982,7 @@ router.get(
'/:projectId/monitorSlaBreaches',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId } = req.params;
const select =
@@ -1002,7 +1002,7 @@ router.post(
'/:projectId/closeSla/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, monitorId } = req.params;
@@ -1024,7 +1024,7 @@ router.post(
'/:projectId/disableMonitor/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { monitorId } = req.params;
const select = 'disabled';
@@ -1059,7 +1059,7 @@ router.post(
'/:projectId/changeComponent/:monitorId',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, monitorId } = req.params;
const { newComponentId } = req.body;
@@ -1076,7 +1076,7 @@ router.post(
);
// api to calculate time for monitorInfo (status page)
router.post('/:monitorId/calculate-time', async function(
router.post('/:monitorId/calculate-time', async function (
req: Request,
res: Response
) {

View File

@@ -359,7 +359,7 @@ router.put(
}
);
router.post('/:projectId/certFile', async function(
router.post('/:projectId/certFile', async function (
req: Request,
res: Response
) {
@@ -372,7 +372,7 @@ router.post('/:projectId/certFile', async function(
maxCount: 1,
},
]);
upload(req, res, async function(error: $TSFixMe) {
upload(req, res, async function (error: $TSFixMe) {
let cert;
if (error) {
return sendErrorResponse(req, res, error);
@@ -388,7 +388,7 @@ router.post('/:projectId/certFile', async function(
}
});
router.post('/:projectId/privateKeyFile', async function(
router.post('/:projectId/privateKeyFile', async function (
req: Request,
res: Response
) {
@@ -401,7 +401,7 @@ router.post('/:projectId/privateKeyFile', async function(
maxCount: 1,
},
]);
upload(req, res, async function(error: $TSFixMe) {
upload(req, res, async function (error: $TSFixMe) {
let privateKey;
if (error) {
return sendErrorResponse(req, res, error);
@@ -422,7 +422,7 @@ router.post('/:projectId/privateKeyFile', async function(
// fetch details about a custom domain
// to be consumed by the status page
router.get('/tlsCredential', async function(req: Request, res: Response) {
router.get('/tlsCredential', async function (req: Request, res: Response) {
try {
const { domain } = req.query;
@@ -502,7 +502,7 @@ router.delete(
// Params:
// Param1:
// Returns: response status, error message
router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function (
req,
res
) {
@@ -575,7 +575,7 @@ router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
}
}
upload(req, res, async function(error: $TSFixMe) {
upload(req, res, async function (error: $TSFixMe) {
const files = req.files || {};
const data = req.body;
data.projectId = req.params.projectId;
@@ -698,7 +698,7 @@ router.put('/:projectId', getUser, isAuthorized, isUserAdmin, async function(
});
});
router.get('/statusBubble', async function(req: Request, res: Response) {
router.get('/statusBubble', async function (req: Request, res: Response) {
const statusPageId = req.query.statusPageId;
const statusBubbleId = req.query.statusBubbleId;
try {
@@ -776,7 +776,7 @@ router.get('/statusBubble', async function(req: Request, res: Response) {
// Param1: req.params-> {projectId};
// Returns: response status, error message
router.get('/:projectId/dashboard', getUser, isAuthorized, async function(
router.get('/:projectId/dashboard', getUser, isAuthorized, async function (
req,
res
) {
@@ -824,7 +824,7 @@ router.get('/:projectId/dashboard', getUser, isAuthorized, async function(
}
});
router.get('/:projectId/status-pages', getUser, isAuthorized, async function(
router.get('/:projectId/status-pages', getUser, isAuthorized, async function (
req,
res
) {
@@ -843,7 +843,7 @@ router.get('/:projectId/status-pages', getUser, isAuthorized, async function(
}
});
router.get('/:projectId/statuspage', getUser, isAuthorized, async function(
router.get('/:projectId/statuspage', getUser, isAuthorized, async function (
req,
res
) {
@@ -890,7 +890,7 @@ router.get('/:projectId/statuspage', getUser, isAuthorized, async function(
});
// External status page api - get the data to show on status page using Slug
router.get('/:statusPageSlug', checkUser, ipWhitelist, async function(
router.get('/:statusPageSlug', checkUser, ipWhitelist, async function (
req,
res
) {
@@ -962,7 +962,7 @@ router.post(
'/:projectId/:statusPageSlug/duplicateStatusPage',
getUser,
isAuthorized,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, statusPageSlug } = req.params;
const { subProjectId } = req.query;
@@ -996,7 +996,7 @@ router.post(
}
);
router.get('/:statusPageId/rss', checkUser, async function(
router.get('/:statusPageId/rss', checkUser, async function (
req: Request,
res: Response
) {
@@ -1044,17 +1044,14 @@ router.get('/:statusPageId/rss', checkUser, async function(
guid: `${global.apiHost}/status-page/${statusPageId}/rss/${incident._id}`,
pubDate: new Date(incident.createdAt).toUTCString(),
description: `<![CDATA[Description: ${
incident.description
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
incident.monitors
)}<br>Acknowledge Time: ${
incident.acknowledgedAt
}<br>Resolve Time: ${incident.resolvedAt}<br>${
incident.investigationNote
description: `<![CDATA[Description: ${incident.description
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
incident.monitors
)}<br>Acknowledge Time: ${incident.acknowledgedAt
}<br>Resolve Time: ${incident.resolvedAt}<br>${incident.investigationNote
? `Investigation Note: ${incident.investigationNote}`
: ''
}]]>`,
}]]>`,
},
});
}
@@ -1104,7 +1101,7 @@ router.get(
'/:projectId/:statusPageSlug/notes',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
let result;
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
@@ -1152,7 +1149,7 @@ router.get(
}
);
router.get('/:projectId/incident/:incidentSlug', checkUser, async function(
router.get('/:projectId/incident/:incidentSlug', checkUser, async function (
req,
res
) {
@@ -1173,7 +1170,7 @@ router.get('/:projectId/incident/:incidentSlug', checkUser, async function(
}
});
router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function(
router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function (
req,
res
) {
@@ -1198,7 +1195,7 @@ router.get('/:projectId/:incidentSlug/incidentNotes', checkUser, async function(
}
});
router.get('/:projectId/:monitorId/individualnotes', checkUser, async function(
router.get('/:projectId/:monitorId/individualnotes', checkUser, async function (
req,
res
) {
@@ -1275,7 +1272,7 @@ router.get(
'/:projectId/:statusPageSlug/events',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
const statusPageSlug = req.params.statusPageSlug;
const skip = req.query.skip || 0;
const limit = req.query.limit || 5;
@@ -1307,7 +1304,7 @@ router.get(
'/:projectId/:statusPageSlug/futureEvents',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1332,7 +1329,7 @@ router.get(
'/:projectId/:statusPageSlug/pastEvents',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { skip = 0, limit = 5, theme } = req.query;
@@ -1375,7 +1372,7 @@ const fetchNotes = async (events: $TSFixMe, limit: $TSFixMe) => {
}
};
router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function(
router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function (
req,
res
) {
@@ -1401,7 +1398,7 @@ router.get('/:projectId/notes/:scheduledEventSlug', checkUser, async function(
}
});
router.get('/:projectId/:monitorId/individualevents', checkUser, async function(
router.get('/:projectId/:monitorId/individualevents', checkUser, async function (
req,
res
) {
@@ -1460,7 +1457,7 @@ router.get('/:projectId/:monitorId/individualevents', checkUser, async function(
router.get(
'/:projectId/scheduledEvent/:scheduledEventId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
const { scheduledEventId } = req.params;
try {
@@ -1475,7 +1472,7 @@ router.get(
);
// Route
// Description: Get all Monitor Statuses by monitorId
router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function(
router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function (
req,
res
) {
@@ -1493,7 +1490,7 @@ router.post('/:projectId/:monitorId/monitorStatuses', checkUser, async function(
}
});
router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function(
router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function (
req,
res
) {
@@ -1537,7 +1534,7 @@ router.post('/:projectId/:monitorId/monitorLogs', checkUser, async function(
}
});
router.get('/:projectId/probes', checkUser, async function(
router.get('/:projectId/probes', checkUser, async function (
req: Request,
res: Response
) {
@@ -1566,7 +1563,7 @@ router.delete(
getUser,
isAuthorized,
isUserAdmin,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
const statusPageSlug = req.params.statusPageSlug;
const userId = req.user ? req.user.id : null;
@@ -1583,7 +1580,7 @@ router.delete(
}
);
router.get('/:projectId/timeline/:incidentSlug', checkUser, async function(
router.get('/:projectId/timeline/:incidentSlug', checkUser, async function (
req,
res
) {
@@ -1624,7 +1621,7 @@ router.get(
'/:projectId/:statusPageSlug/timelines',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -1644,7 +1641,7 @@ router.get(
//get subscribers by monitorId in a statuspage
// req.params-> {projectId, monitorId, statusPageId};
// Returns: response subscribers, error message
router.get('/:projectId/monitor/:statusPageId', checkUser, async function(
router.get('/:projectId/monitor/:statusPageId', checkUser, async function (
req,
res
) {
@@ -1696,7 +1693,7 @@ router.get('/:projectId/monitor/:statusPageId', checkUser, async function(
router.post(
'/:projectId/createExternalstatus-page/:statusPageId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, statusPageId } = req.params;
const { name, url } = req.body;
@@ -1811,7 +1808,7 @@ router.post(
router.post(
'/:projectId/updateExternalstatus-page/:externalStatusPageId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, externalStatusPageId } = req.params;
const { name, url } = req.body;
@@ -1905,7 +1902,7 @@ router.post(
router.get(
'/:projectId/fetchExternalStatusPages/:statusPageId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, statusPageId } = req.params;
@@ -1939,7 +1936,7 @@ router.get(
router.post(
'/:projectId/deleteExternalstatus-page/:externalStatusPageId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, externalStatusPageId } = req.params;
@@ -1973,7 +1970,7 @@ router.post(
}
);
router.post('/:projectId/announcement/:statusPageId', checkUser, async function(
router.post('/:projectId/announcement/:statusPageId', checkUser, async function (
req,
res
) {
@@ -2025,7 +2022,7 @@ router.post('/:projectId/announcement/:statusPageId', checkUser, async function(
router.put(
'/:projectId/announcement/:statusPageId/:announcementId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, statusPageId, announcementId } = req.params;
const { data } = req.body;
@@ -2111,7 +2108,7 @@ router.put(
router.get(
'/:projectId/announcementLogs/:statusPageId',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageId } = req.params;
const { skip, limit, theme } = req.query;
@@ -2151,7 +2148,7 @@ router.get(
}
);
router.get('/:projectId/announcement/:statusPageId', checkUser, async function(
router.get('/:projectId/announcement/:statusPageId', checkUser, async function (
req,
res
) {
@@ -2181,7 +2178,7 @@ router.get('/:projectId/announcement/:statusPageId', checkUser, async function(
router.get(
'/:projectId/announcement/:statusPageSlug/single/:announcementSlug',
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, statusPageSlug, announcementSlug } = req.params;
@@ -2204,7 +2201,7 @@ router.get(
router.delete(
`/:projectId/announcement/:announcementId/delete`,
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { projectId, announcementId } = req.params;
@@ -2226,7 +2223,7 @@ router.delete(
router.delete(
`/:projectId/announcementLog/:announcementLogId/delete`,
checkUser,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { announcementLogId } = req.params;
@@ -2307,9 +2304,8 @@ function handleMonitorList(monitors: $TSFixMe) {
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name} and ${monitors[2].monitorId.name}`;
}
if (monitors.length > 3) {
return `${monitors[0].monitorId.name}, ${
monitors[1].monitorId.name
} and ${monitors.length - 2} others`;
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name
} and ${monitors.length - 2} others`;
}
}
@@ -2317,7 +2313,7 @@ router.get(
'/resources/:statusPageSlug/ongoing-events',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2345,7 +2341,7 @@ router.get(
'/resources/:statusPageSlug/future-events',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2369,7 +2365,7 @@ router.get(
'/resources/:statusPageSlug/past-events',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2393,7 +2389,7 @@ router.get(
'/resources/:statusPageSlug/probes',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2417,7 +2413,7 @@ router.get(
'/resources/:statusPageSlug/monitor-logs',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2441,7 +2437,7 @@ router.get(
'/resources/:statusPageSlug/announcements',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2471,7 +2467,7 @@ router.get(
'/resources/:statusPageSlug/announcement-logs',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2495,7 +2491,7 @@ router.get(
'/resources/:statusPageSlug/monitor-timelines',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2519,7 +2515,7 @@ router.get(
'/resources/:statusPageSlug/statuspage-notes',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
@@ -2549,7 +2545,7 @@ router.get(
'/resources/:statusPageSlug/monitor-statuses',
checkUser,
ipWhitelist,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { statusPageSlug } = req.params;
const { range } = req.query;
@@ -2591,7 +2587,7 @@ router.get(
}
);
async function getStatusPage(req: $TSFixMe, statusPageSlug: $TSFixMe) {
async function getStatusPage(req: Request, statusPageSlug: $TSFixMe) {
const url = req.query.url;
const user = req.user;
let statusPage = {};
@@ -2657,7 +2653,7 @@ async function getStatusPage(req: $TSFixMe, statusPageSlug: $TSFixMe) {
}
async function getOngoingScheduledEvents(
req: $TSFixMe,
req: Request,
statusPageSlug: $TSFixMe
) {
const { skip = 0, limit = 5, theme = false } = req.query;
@@ -2678,7 +2674,7 @@ async function getOngoingScheduledEvents(
}
return { events, count };
}
async function getFutureEvents(req: $TSFixMe, statusPageSlug: $TSFixMe) {
async function getFutureEvents(req: Request, statusPageSlug: $TSFixMe) {
const { skip = 0, limit = 5, theme = false } = req.query;
const response = await StatusPageService.getFutureEvents(
{ slug: statusPageSlug },
@@ -2691,7 +2687,7 @@ async function getFutureEvents(req: $TSFixMe, statusPageSlug: $TSFixMe) {
}
return response;
}
async function getPastEvents(req: $TSFixMe, statusPageSlug: $TSFixMe) {
async function getPastEvents(req: Request, statusPageSlug: $TSFixMe) {
const { skip = 0, limit = 5, theme = false } = req.query;
const response = await StatusPageService.getPastEvents(
@@ -2721,7 +2717,7 @@ async function getProbes(req: $TSFixMe) {
const count = await ProbeService.countBy({});
return { probes, count };
}
async function getMonitorLogs(req: $TSFixMe, monitors: $TSFixMe) {
async function getMonitorLogs(req: Request, monitors: $TSFixMe) {
const logs: $TSFixMe = [];
await Promise.all(
monitors.map(async (monitor: $TSFixMe) => {
@@ -2775,7 +2771,7 @@ async function getMonitorLogs(req: $TSFixMe, monitors: $TSFixMe) {
}
async function getAnnouncements(
req: $TSFixMe,
req: Request,
statusPageId: $TSFixMe,
projectId: $TSFixMe
) {
@@ -2800,7 +2796,7 @@ async function getAnnouncements(
};
}
//get monitor status
async function getMonitorStatuses(req: $TSFixMe, monitors: $TSFixMe) {
async function getMonitorStatuses(req: Request, monitors: $TSFixMe) {
const status = {};
const endDate = moment(Date.now());
const startDate = moment(Date.now()).subtract(90, 'days');
@@ -2829,7 +2825,7 @@ async function getMonitorTimelines(statusPageSlug: $TSFixMe) {
}
//get status page notes
async function getStatusPageNote(
req: $TSFixMe,
req: Request,
statusPageSlug: $TSFixMe,
theme: $TSFixMe
) {
@@ -2957,18 +2953,18 @@ const filterProbeData = (
monitorStatuses && monitorStatuses.length > 0
? probe
? monitorStatuses.filter((probeStatuses: $TSFixMe) => {
return (
probeStatuses._id === null ||
String(probeStatuses._id) === String(probe._id)
);
})
return (
probeStatuses._id === null ||
String(probeStatuses._id) === String(probe._id)
);
})
: monitorStatuses
: [];
const statuses =
probesStatus &&
probesStatus[0] &&
probesStatus[0].statuses &&
probesStatus[0].statuses.length > 0
probesStatus[0] &&
probesStatus[0].statuses &&
probesStatus[0].statuses.length > 0
? probesStatus[0].statuses
: [];

View File

@@ -4,7 +4,7 @@ export default {
//Param 1: projectId: Project id.
//Param 2: subProjectId: SubProject id
//Returns: list of team members
getTeamMembersBy: async function(query: $TSFixMe) {
getTeamMembersBy: async function (query: $TSFixMe) {
let projectMembers: $TSFixMe = [];
const projects = await ProjectService.findBy({
@@ -65,7 +65,7 @@ export default {
return response;
},
getTeamMemberBy: async function(
getTeamMemberBy: async function (
projectId: $TSFixMe,
teamMemberUserId: $TSFixMe
) {
@@ -120,7 +120,7 @@ export default {
}
},
getSeats: async function(members: $TSFixMe) {
getSeats: async function (members: $TSFixMe) {
let seats = members.filter(async (user: $TSFixMe) => {
let count = 0;
const user_member = await UserService.findOneBy({
@@ -149,7 +149,7 @@ export default {
//Param 2: emails: Emails of new user added by Admin.
//Param 3: role: Role set by Admin.
//Returns: promise
inviteTeamMembers: async function(
inviteTeamMembers: async function (
addedByUserId: $TSFixMe,
projectId: $TSFixMe,
emails: $TSFixMe,
@@ -165,7 +165,7 @@ export default {
//Checks if users to be added to project are not duplicate.
let duplicateEmail = false;
emails.forEach(function(element: $TSFixMe, index: $TSFixMe) {
emails.forEach(function (element: $TSFixMe, index: $TSFixMe) {
// Find if there is a duplicate or not
if (emails.indexOf(element, index + 1) > -1) {
duplicateEmail = true;
@@ -255,7 +255,7 @@ export default {
//Params:
//Param 1: projectId: Project id.
//Returns: promise
getTeamMembers: async function(projectId: $TSFixMe) {
getTeamMembers: async function (projectId: $TSFixMe) {
const _this = this;
const subProject = await ProjectService.findOneBy({
@@ -279,7 +279,7 @@ export default {
return [];
},
isValidBusinessEmails: function(emails: $TSFixMe) {
isValidBusinessEmails: function (emails: $TSFixMe) {
let valid = true;
if (emails && emails.length > 0) {
for (let i = 0; i < emails.length; i++) {
@@ -323,7 +323,7 @@ export default {
//Param 4: addedBy: Admin who added the user.
//Param 5: project: Project.
//Returns: promise
inviteTeamMembersMethod: async function(
inviteTeamMembersMethod: async function (
projectId: $TSFixMe,
emails: $TSFixMe,
role: $TSFixMe,
@@ -579,7 +579,7 @@ export default {
//Param 2: userId: User id of admin.
//Param 3: teamMemberUserId: Team Member Id of user to delete by Owner.
//Returns: promise
removeTeamMember: async function(
removeTeamMember: async function (
projectId: $TSFixMe,
userId: $TSFixMe,
teamMemberUserId: $TSFixMe
@@ -767,7 +767,7 @@ export default {
//Param 3: teamMemberUserId: id of Team Member.
//Param 4: nextRole: Role of user to updated by Admin.
//Returns: promise
updateTeamMemberRole: async function(
updateTeamMemberRole: async function (
projectId: $TSFixMe,
userId: $TSFixMe,
teamMemberUserId: $TSFixMe,
@@ -809,7 +809,7 @@ export default {
});
const prevTeams = subProjects
.concat(project)
.map((res: $TSFixMe) => res.users);
.map((req: Response) => res.users);
const prevFlatTeams = flatten(prevTeams);
const prevTeamArr = prevFlatTeams.filter(
user => String(user.userId) === String(teamMemberUserId)

View File

@@ -31,7 +31,7 @@ export default {
},
};
const job = async (monitor: $TSFixMe, res: $TSFixMe) => {
const job = async (monitor: $TSFixMe, req: Response) => {
try {
const populate = [
{

View File

@@ -17,43 +17,43 @@ import AirtableService from '../backend/services/airtableService';
let token;
describe('Admin process.env login API', function() {
describe('Admin process.env login API', function () {
this.timeout(30000);
before(async function() {
before(async function () {
this.timeout(40000);
await UserService.hardDeleteBy({});
await GlobalConfig.initTestConfig();
});
after(async function() {
after(async function () {
await UserService.hardDeleteBy({});
await AirtableService.deleteAll({ tableName: 'User' });
await GlobalConfig.removeTestConfig();
await AuditLogsService.hardDeleteBy({});
});
it('should NOT log in the admin user with invalid credentials', function(done: $TSFixMe) {
it('should NOT log in the admin user with invalid credentials', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: process.env.ADMIN_EMAIL,
password: process.env.ADMIN_PASSWORD + '1',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should log in the admin user', function(done: $TSFixMe) {
it('should log in the admin user', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: process.env.ADMIN_EMAIL,
password: process.env.ADMIN_PASSWORD,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
if (token) {
done();

View File

@@ -37,20 +37,20 @@ const monitor = {
data: { url: 'http://www.tests.org' },
};
describe('Alert API', function() {
after(async function() {
describe('Alert API', function () {
after(async function () {
await UserService.hardDeleteBy({});
});
describe('Alert API without subprojects', function() {
describe('Alert API without subprojects', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -61,16 +61,16 @@ describe('Alert API', function() {
UserModel.findByIdAndUpdate(
userId,
{ $set: { isVerified: true } },
function() {
function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
token =
res.body.tokens.jwtAccessToken;
@@ -85,9 +85,9 @@ describe('Alert API', function() {
...monitor,
componentId: component._id,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
incidentData.monitors = [
@@ -111,7 +111,7 @@ describe('Alert API', function() {
});
});
after(async function() {
after(async function () {
await StatusPageService.hardDeleteBy({ projectId: projectId });
await NotificationService.hardDeleteBy({ projectId: projectId });
await AlertService.hardDeleteBy({ _id: alertId });
@@ -124,13 +124,13 @@ describe('Alert API', function() {
// 'post /:projectId'
it('should register with valid projectId, monitorId, incidentId, alertVia', function(done: $TSFixMe) {
it('should register with valid projectId, monitorId, incidentId, alertVia', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/incident/${projectId}/create-incident`)
.set('Authorization', authorization)
.send(incidentData)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
incidentId = res.body._id;
monitorId = res.body.monitors[0].monitorId._id;
request
@@ -142,7 +142,7 @@ describe('Alert API', function() {
incidentId: incidentId,
eventType: 'identified',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
alertId = res.body._id;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -151,12 +151,12 @@ describe('Alert API', function() {
});
});
it('should get an array of alerts by valid projectId', function(done: $TSFixMe) {
it('should get an array of alerts by valid projectId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/alert/${projectId}/alert`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -165,12 +165,12 @@ describe('Alert API', function() {
});
});
it('should get an array alerts of by valid incidentId', function(done: $TSFixMe) {
it('should get an array alerts of by valid incidentId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/alert/${projectId}/incident/${incidentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -179,23 +179,23 @@ describe('Alert API', function() {
});
});
it('should deleted alert', function(done: $TSFixMe) {
it('should deleted alert', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/alert/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should not delete alert with non-existing projectId', function(done: $TSFixMe) {
it('should not delete alert with non-existing projectId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete('/alert/5f71e52737c855f7c5b347d3')
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
@@ -204,39 +204,39 @@ describe('Alert API', function() {
let newUserToken: $TSFixMe;
describe('Alert API with Sub-Projects', function() {
describe('Alert API with Sub-Projects', function () {
this.timeout(40000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
const authorization = `Basic ${token}`;
// create a subproject for parent project
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.initTestConfig().then(function () {
request
.post(`/project/${projectId}/subProject`)
.set('Authorization', authorization)
.send({ subProjectName: 'New SubProject' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
subProjectId = res.body[0]._id;
// sign up second user (subproject user)
createUser(request, userData.newUser, function(
createUser(request, userData.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
UserModel.findByIdAndUpdate(
userId,
{ $set: { isVerified: true } },
function() {
function () {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
newUserToken =
res.body.tokens.jwtAccessToken;
@@ -253,7 +253,7 @@ describe('Alert API', function() {
userData.newUser.email,
role: 'Member',
})
.end(function() {
.end(function () {
done();
});
});
@@ -264,7 +264,7 @@ describe('Alert API', function() {
});
});
after(async function() {
after(async function () {
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, subProjectId] },
});
@@ -283,23 +283,23 @@ describe('Alert API', function() {
await GlobalConfig.removeTestConfig();
});
it('should not create alert for user not in the project.', function(done: $TSFixMe) {
createUser(request, userData.anotherUser, function(
it('should not create alert for user not in the project.', function (done: $TSFixMe) {
createUser(request, userData.anotherUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
UserModel.findByIdAndUpdate(
userId,
{ $set: { isVerified: true } },
function() {
function () {
request
.post('/user/login')
.send({
email: userData.anotherUser.email,
password: userData.anotherUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const authorization = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.post(`/alert/${projectId}`)
@@ -309,9 +309,9 @@ describe('Alert API', function() {
alertVia: 'email',
incidentId: incidentId,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
alertId = res.body._id;
expect(res).to.have.status(400);
@@ -326,7 +326,7 @@ describe('Alert API', function() {
});
});
it('should create alert in parent project', function(done: $TSFixMe) {
it('should create alert in parent project', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/alert/${projectId}`)
@@ -337,7 +337,7 @@ describe('Alert API', function() {
incidentId: incidentId,
eventType: 'identified',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
alertId = res.body._id;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -345,7 +345,7 @@ describe('Alert API', function() {
});
});
it('should create alert in sub-project', function(done: $TSFixMe) {
it('should create alert in sub-project', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.post(`/alert/${subProjectId}`)
@@ -356,19 +356,19 @@ describe('Alert API', function() {
incidentId: incidentId,
eventType: 'identified',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();
});
});
it('should get only sub-project alerts for valid user.', function(done: $TSFixMe) {
it('should get only sub-project alerts for valid user.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.get(`/alert/${subProjectId}/alert`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -377,12 +377,12 @@ describe('Alert API', function() {
});
});
it('should get both project and sub-project alerts for valid user.', function(done: $TSFixMe) {
it('should get both project and sub-project alerts for valid user.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/alert/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body[0]).to.have.property('alerts');
@@ -393,23 +393,23 @@ describe('Alert API', function() {
});
});
it('should delete sub-project alert', function(done: $TSFixMe) {
it('should delete sub-project alert', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/alert/${subProjectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should delete project alert', function(done: $TSFixMe) {
it('should delete project alert', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/alert/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});

View File

@@ -35,35 +35,35 @@ const logCount = {
warning: 0,
};
describe('Application Log API', function() {
describe('Application Log API', function () {
this.timeout(80000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(90000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
@@ -72,9 +72,9 @@ describe('Application Log API', function() {
.send({
name: 'New Component',
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
componentId = res.body._id;
expect(res).to.have.status(200);
@@ -90,19 +90,19 @@ describe('Application Log API', function() {
});
});
it('should reject the request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject the request of an unauthenticated user', function (done: $TSFixMe) {
request
.post(`/application-log/${projectId}/${componentId}/create`)
.send({
name: 'New Application Log',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject the request of an empty application log name', function(done: $TSFixMe) {
it('should reject the request of an empty application log name', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/application-log/${projectId}/${componentId}/create`)
@@ -110,13 +110,13 @@ describe('Application Log API', function() {
.send({
name: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create the application log', function(done: $TSFixMe) {
it('should create the application log', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/application-log/${projectId}/${componentId}/create`)
@@ -124,7 +124,7 @@ describe('Application Log API', function() {
.send({
name: 'Travis Watcher',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
applicationLog = res.body;
expect(res).to.have.status(200);
expect(res.body).to.include({ name: 'Travis Watcher' });
@@ -132,24 +132,24 @@ describe('Application Log API', function() {
});
});
it('should return a list of application logs under component', function(done: $TSFixMe) {
it('should return a list of application logs under component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/application-log/${projectId}/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.applicationLogs).to.be.an('array');
done();
});
});
it('should not return a list of application logs under wrong component', function(done: $TSFixMe) {
it('should not return a list of application logs under wrong component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/application-log/${projectId}/5ee8d7cc8701d678901ab908`) // wrong component ID
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Component does not exist.'
@@ -158,13 +158,13 @@ describe('Application Log API', function() {
});
});
it('should not create a log with wrong application key', function(done: $TSFixMe) {
it('should not create a log with wrong application key', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Log does not exist.'
@@ -173,14 +173,14 @@ describe('Application Log API', function() {
});
});
it('should create a log with correct application log key', function(done: $TSFixMe) {
it('should create a log with correct application log key', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
request
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.include({ content: log.content });
expect(res.body).to.include({ type: log.type });
@@ -192,7 +192,7 @@ describe('Application Log API', function() {
});
});
it('should create a log with correct application log key with type error', function(done: $TSFixMe) {
it('should create a log with correct application log key with type error', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
log.type = 'error';
@@ -200,7 +200,7 @@ describe('Application Log API', function() {
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.include({ content: log.content });
expect(res.body).to.include({ type: log.type });
@@ -212,7 +212,7 @@ describe('Application Log API', function() {
});
});
it('should create a log with correct application log key with type error and one tag', function(done: $TSFixMe) {
it('should create a log with correct application log key with type error and one tag', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
log.type = 'error';
@@ -222,7 +222,7 @@ describe('Application Log API', function() {
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.include({ content: log.content });
expect(res.body).to.include({ type: log.type });
@@ -235,7 +235,7 @@ describe('Application Log API', function() {
});
});
it('should not create a log with correct application log key with type error but invalid tag', function(done: $TSFixMe) {
it('should not create a log with correct application log key with type error but invalid tag', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
log.type = 'error';
@@ -245,7 +245,7 @@ describe('Application Log API', function() {
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Log Tags must be of type String or Array of Strings'
@@ -257,7 +257,7 @@ describe('Application Log API', function() {
});
});
it('should create a log with correct application log key with type error and 5 tags', function(done: $TSFixMe) {
it('should create a log with correct application log key with type error and 5 tags', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
log.type = 'error';
@@ -267,7 +267,7 @@ describe('Application Log API', function() {
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.include({ content: log.content });
expect(res.body).to.include({ type: log.type });
@@ -281,7 +281,7 @@ describe('Application Log API', function() {
});
});
it('should fetch logs related to application log with tag search params', function(done: $TSFixMe) {
it('should fetch logs related to application log with tag search params', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
// create a log
log.applicationLogKey = applicationLog.key;
@@ -301,7 +301,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ filter: 'server' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.logs).to.be.an('array');
@@ -311,7 +311,7 @@ describe('Application Log API', function() {
});
});
it('should not create a log with correct application log key and invalid type', function(done: $TSFixMe) {
it('should not create a log with correct application log key and invalid type', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
log.applicationLogKey = applicationLog.key;
log.type = 'any type';
@@ -319,7 +319,7 @@ describe('Application Log API', function() {
.post(`/application-log/${applicationLog._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Log Type must be of the allowed types.'
@@ -328,14 +328,14 @@ describe('Application Log API', function() {
});
});
it('should not reset the application log key for wrong application log id', function(done: $TSFixMe) {
it('should not reset the application log key for wrong application log id', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/application-log/${projectId}/${componentId}/5ee8d7cc8701d678901ab908/reset-key`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(404);
expect(res.body.message).to.be.equal(
'Application Log not found'
@@ -346,14 +346,14 @@ describe('Application Log API', function() {
});
});
it('should reset the application log key', function(done: $TSFixMe) {
it('should reset the application log key', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/application-log/${projectId}/${componentId}/${applicationLog._id}/reset-key`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
// confirm that the new key is not the same with the old key
expect(res.body.key).to.not.be.equal(applicationLog.key);
@@ -365,14 +365,14 @@ describe('Application Log API', function() {
});
});
it('should fetch logs related to application log', function(done: $TSFixMe) {
it('should fetch logs related to application log', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/application-log/${projectId}/${componentId}/${applicationLog._id}/logs`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.logs).to.be.an('array');
@@ -384,7 +384,7 @@ describe('Application Log API', function() {
});
});
it('should fetch logs related to application log with search params', function(done: $TSFixMe) {
it('should fetch logs related to application log with search params', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
// create a log
log.applicationLogKey = applicationLog.key;
@@ -402,7 +402,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ type: 'warning' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.logs).to.be.an('array');
@@ -412,7 +412,7 @@ describe('Application Log API', function() {
});
});
it('should fetch logs related to application log with search params related to content', function(done: $TSFixMe) {
it('should fetch logs related to application log with search params related to content', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
// create a log
log.applicationLogKey = applicationLog.key;
@@ -431,7 +431,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ type: 'error' }) // filter by error
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.logs).to.be.an('array');
@@ -444,7 +444,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ type: 'error', filter: 'james' }) // filter by error and keyword from content
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.logs).to.be.an('array');
@@ -454,7 +454,7 @@ describe('Application Log API', function() {
});
});
it('should fetch logs all log stat related to application log', function(done: $TSFixMe) {
it('should fetch logs all log stat related to application log', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
// create a log
log.applicationLogKey = applicationLog.key;
@@ -473,7 +473,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('object');
expect(res.body.data.all).to.be.equal(
@@ -486,7 +486,7 @@ describe('Application Log API', function() {
});
});
it('should not edit an application log with empty name', function(done: $TSFixMe) {
it('should not edit an application log with empty name', function (done: $TSFixMe) {
const newName = '';
const authorization = `Basic ${token}`;
request
@@ -495,7 +495,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ name: newName })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'New Application Log Name is required.'
@@ -504,7 +504,7 @@ describe('Application Log API', function() {
});
});
it('should not edit an application log with same name as existing application log', function(done: $TSFixMe) {
it('should not edit an application log with same name as existing application log', function (done: $TSFixMe) {
const newName = 'Astro';
const authorization = `Basic ${token}`;
request
@@ -513,7 +513,7 @@ describe('Application Log API', function() {
.send({
name: newName,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
applicationLog = res.body;
expect(res).to.have.status(200);
expect(res.body).to.include({ name: newName });
@@ -523,7 +523,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ name: newName })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Log with that name already exists.'
@@ -533,7 +533,7 @@ describe('Application Log API', function() {
});
});
it('should edit an application log', function(done: $TSFixMe) {
it('should edit an application log', function (done: $TSFixMe) {
const newName = 'Rodeo';
const authorization = `Basic ${token}`;
request
@@ -542,7 +542,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ name: newName })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.id).to.be.equal(applicationLog.id);
expect(res.body.name).to.be.equal(newName);
@@ -550,7 +550,7 @@ describe('Application Log API', function() {
});
});
it('should edit an application log but not change application log key', function(done: $TSFixMe) {
it('should edit an application log but not change application log key', function (done: $TSFixMe) {
const newName = 'Rodeo II';
const authorization = `Basic ${token}`;
request
@@ -559,7 +559,7 @@ describe('Application Log API', function() {
)
.set('Authorization', authorization)
.send({ name: newName })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.id).to.be.equal(applicationLog.id);
expect(res.body.name).to.be.equal(newName);
@@ -568,14 +568,14 @@ describe('Application Log API', function() {
});
});
it('should delete an application log', function(done: $TSFixMe) {
it('should delete an application log', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(
`/application-log/${projectId}/${componentId}/${applicationLog._id}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.id).to.be.equal(applicationLog.id);
expect(res.body.deleted).to.be.equal(true);
@@ -585,7 +585,7 @@ describe('Application Log API', function() {
// Yet to figure out how thi works
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await ApplicationLogService.hardDeleteBy({

View File

@@ -22,7 +22,7 @@ import ApplicationSecurities from '../backend/services/applicationSecurityServic
import ApplicationSecurityLogService from '../backend/services/applicationSecurityLogService';
import AirtableService from '../backend/services/airtableService';
describe('Application Security API', function() {
describe('Application Security API', function () {
const timeout = 300000;
let projectId: $TSFixMe,
componentId: $TSFixMe,
@@ -33,11 +33,11 @@ describe('Application Security API', function() {
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -46,8 +46,8 @@ describe('Application Security API', function() {
UserService.updateOneBy(
{ _id: userId },
{ role: 'master-admin' }
).then(function() {
VerificationTokenModel.findOne({ userId }, function(
).then(function () {
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -56,16 +56,16 @@ describe('Application Security API', function() {
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
@@ -74,9 +74,9 @@ describe('Application Security API', function() {
.post(`/component/${projectId}`)
.set('Authorization', authorization)
.send({ name: 'newComponent' })
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
componentId = res.body._id;
done();
@@ -89,7 +89,7 @@ describe('Application Security API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -102,14 +102,14 @@ describe('Application Security API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should create an application security', function(done: $TSFixMe) {
it('should create an application security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
GitCredentialService.create({
gitUsername: gitCredential.gitUsername,
gitPassword: gitCredential.gitPassword,
projectId,
}).then(function(credential) {
}).then(function (credential) {
credentialId = credential._id;
const data = {
name: 'Test',
@@ -122,7 +122,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
applicationSecurityId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.componentId).to.be.equal(componentId);
@@ -138,7 +138,7 @@ describe('Application Security API', function() {
});
});
it('should update an application security', function(done: $TSFixMe) {
it('should update an application security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const update = { name: 'newname' };
@@ -148,14 +148,14 @@ describe('Application Security API', function() {
)
.set('Authorization', authorization)
.send(update)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(update.name);
done();
});
});
it('should get a particular application security in a component', function(done: $TSFixMe) {
it('should get a particular application security in a component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -163,7 +163,7 @@ describe('Application Security API', function() {
`/security/${projectId}/${componentId}/application/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(String(res.body._id)).to.be.equal(
String(applicationSecurityId)
@@ -175,33 +175,33 @@ describe('Application Security API', function() {
});
});
it('should get all the application security in a component', function(done: $TSFixMe) {
it('should get all the application security in a component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
});
});
it('should get all the application security with a particular credential', function(done: $TSFixMe) {
it('should get all the application security with a particular credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/security/${projectId}/application/${credentialId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
});
});
it('should scan an application security', function(done: $TSFixMe) {
it('should scan an application security', function (done: $TSFixMe) {
this.timeout(300000);
const authorization = `Basic ${token}`;
@@ -210,13 +210,13 @@ describe('Application Security API', function() {
`/security/${projectId}/application/scan/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should not create an application security if name already exist in the component', function(done: $TSFixMe) {
it('should not create an application security if name already exist in the component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -229,7 +229,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application security with this name already exist in this component'
@@ -238,7 +238,7 @@ describe('Application Security API', function() {
});
});
it('should not create an application security if git repository url already exist in the component', function(done: $TSFixMe) {
it('should not create an application security if git repository url already exist in the component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -251,7 +251,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application security with this git repository url already exist in this component'
@@ -260,7 +260,7 @@ describe('Application Security API', function() {
});
});
it('should delete a particular application security', function(done: $TSFixMe) {
it('should delete a particular application security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -268,14 +268,14 @@ describe('Application Security API', function() {
`/security/${projectId}/${componentId}/application/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.deleted).to.be.true;
done();
});
});
it('should not create an application security if name is missing', function(done: $TSFixMe) {
it('should not create an application security if name is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -288,7 +288,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Security Name is required'
@@ -297,7 +297,7 @@ describe('Application Security API', function() {
});
});
it('should not create an application security if git repository url is missing', function(done: $TSFixMe) {
it('should not create an application security if git repository url is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -310,7 +310,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Repository URL is required'
@@ -319,7 +319,7 @@ describe('Application Security API', function() {
});
});
it('should not create an application security if git credential is missing', function(done: $TSFixMe) {
it('should not create an application security if git credential is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -332,7 +332,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Credential is required'
@@ -341,7 +341,7 @@ describe('Application Security API', function() {
});
});
it('should not scan an application security if it does not exist', function(done: $TSFixMe) {
it('should not scan an application security if it does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const applicationSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -350,7 +350,7 @@ describe('Application Security API', function() {
`/security/${projectId}/application/scan/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Security not found or does not exist'
@@ -359,7 +359,7 @@ describe('Application Security API', function() {
});
});
it('should not delete a non-existing application security', function(done: $TSFixMe) {
it('should not delete a non-existing application security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const applicationSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -368,7 +368,7 @@ describe('Application Security API', function() {
`/security/${projectId}/${componentId}/application/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application Security not found or does not exist'
@@ -377,7 +377,7 @@ describe('Application Security API', function() {
});
});
it('should not get a non-existing application security', function(done: $TSFixMe) {
it('should not get a non-existing application security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const applicationSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -386,7 +386,7 @@ describe('Application Security API', function() {
`/security/${projectId}/${componentId}/application/${applicationSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Application security not found or does not exist'
@@ -395,7 +395,7 @@ describe('Application Security API', function() {
});
});
it('should not create an application security if git credential does not exist', function(done: $TSFixMe) {
it('should not create an application security if git credential does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
@@ -408,7 +408,7 @@ describe('Application Security API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Credential not found or does not exist'

View File

@@ -20,36 +20,36 @@ import VerificationTokenModel from '../backend/models/verificationToken';
let token: $TSFixMe, projectId: $TSFixMe, userId: $TSFixMe;
let testSuiteStartTime: $TSFixMe, testCaseStartTime: $TSFixMe;
describe('Audit Logs API', function() {
describe('Audit Logs API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
testSuiteStartTime = new Date();
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -59,7 +59,7 @@ describe('Audit Logs API', function() {
});
});
after(async function() {
after(async function () {
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
email: {
@@ -89,11 +89,11 @@ describe('Audit Logs API', function() {
await AuditLogsService.hardDeleteBy({ query: deleteQuery });
});
beforeEach(async function() {
beforeEach(async function () {
testCaseStartTime = new Date();
});
afterEach(async function() {
afterEach(async function () {
// Deleting any auditLogs created between each test case in this suite.
// Note that using timeStamp between this test suite to remove some logs, Beacuse some audit logs dont contain specific 'userId'. (Ex. /login)
const deleteQuery = {
@@ -112,25 +112,25 @@ describe('Audit Logs API', function() {
});
});
it('should reject get audit logs request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject get audit logs request of an unauthenticated user', function (done: $TSFixMe) {
request
.get('/audit-logs')
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject get audit logs request of NON master-admin user', function(done: $TSFixMe) {
createUser(request, userData.newUser, function() {
it('should reject get audit logs request of NON master-admin user', function (done: $TSFixMe) {
createUser(request, userData.newUser, function () {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
@@ -138,7 +138,7 @@ describe('Audit Logs API', function() {
.get('/audit-logs/')
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
@@ -146,7 +146,7 @@ describe('Audit Logs API', function() {
});
});
it('should send get audit logs data for master-admin user', async function() {
it('should send get audit logs data for master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -163,7 +163,7 @@ describe('Audit Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send appopriate data set when limit is provided', async function() {
it('should send appopriate data set when limit is provided', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -187,7 +187,7 @@ describe('Audit Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send appopriate data set when skip is provided', async function() {
it('should send appopriate data set when skip is provided', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -213,17 +213,17 @@ describe('Audit Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should reject search request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject search request of an unauthenticated user', function (done: $TSFixMe) {
request
.post('/audit-logs/search')
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject search request of NON master-admin user', async function() {
it('should reject search request of NON master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'user' }); // Resetting user to normal USER.
const authorization = `Basic ${token}`;
@@ -237,7 +237,7 @@ describe('Audit Logs API', function() {
}
});
it('should send Searched AuditLogs data for master-admin user', async function() {
it('should send Searched AuditLogs data for master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -254,7 +254,7 @@ describe('Audit Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send only matched result to provided search string when searched.', async function() {
it('should send only matched result to provided search string when searched.', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;

View File

@@ -31,35 +31,35 @@ let token: $TSFixMe,
monitorId: $TSFixMe,
resourceCount = 0;
describe('Component API', function() {
describe('Component API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(80000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -69,19 +69,19 @@ describe('Component API', function() {
});
});
it('should reject the request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject the request of an unauthenticated user', function (done: $TSFixMe) {
request
.post(`/component/${projectId}`)
.send({
name: 'New Component',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should not create a component when the `name` field is null', function(done: $TSFixMe) {
it('should not create a component when the `name` field is null', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/component/${projectId}`)
@@ -89,13 +89,13 @@ describe('Component API', function() {
.send({
name: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create a new component when the correct data is given by an authenticated user', function(done: $TSFixMe) {
it('should create a new component when the correct data is given by an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/component/${projectId}`)
@@ -103,7 +103,7 @@ describe('Component API', function() {
.send({
name: 'New Component',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
componentId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Component');
@@ -111,7 +111,7 @@ describe('Component API', function() {
});
});
it('should update a component when the correct data is given by an authenticated user', function(done: $TSFixMe) {
it('should update a component when the correct data is given by an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/component/${projectId}/${componentId}`)
@@ -119,19 +119,19 @@ describe('Component API', function() {
.send({
name: 'Updated Component',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body._id).to.be.equal(componentId);
done();
});
});
it('should get components for an authenticated user by ProjectId', function(done: $TSFixMe) {
it('should get components for an authenticated user by ProjectId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/component/${projectId}/component`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -140,12 +140,12 @@ describe('Component API', function() {
});
});
it('should get a component for an authenticated user with valid componentId', function(done: $TSFixMe) {
it('should get a component for an authenticated user with valid componentId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/component/${projectId}/component/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body._id).to.be.equal(componentId);
@@ -153,7 +153,7 @@ describe('Component API', function() {
});
});
it('should create a new monitor when `componentId` is given`', function(done: $TSFixMe) {
it('should create a new monitor when `componentId` is given`', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/monitor/${projectId}`)
@@ -164,7 +164,7 @@ describe('Component API', function() {
data: { url: 'http://www.tests.org' },
componentId,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
monitorId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Monitor');
@@ -173,12 +173,12 @@ describe('Component API', function() {
});
});
it('should return a list of all resources under component', function(done: $TSFixMe) {
it('should return a list of all resources under component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/component/${projectId}/resources/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.totalResources).to.be.an('array');
expect(res.body.totalResources[0].type).to.be.a('string'); // type of the monitor
@@ -187,7 +187,7 @@ describe('Component API', function() {
});
});
it('should create a new application log when `componentId` is given then get list of resources`', function(done: $TSFixMe) {
it('should create a new application log when `componentId` is given then get list of resources`', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/application-log/${projectId}/${componentId}/create`)
@@ -195,14 +195,14 @@ describe('Component API', function() {
.send({
name: 'New Application Log',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Application Log');
resourceCount++; // Increment Resource Count
request
.get(`/component/${projectId}/resources/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.totalResources).to.be.an('array');
expect(res.body.totalResources[1].status).to.be.a(
@@ -219,7 +219,7 @@ describe('Component API', function() {
});
});
it('should create a new application log then creater a log when `componentId` is given then get list of resources`', function(done: $TSFixMe) {
it('should create a new application log then creater a log when `componentId` is given then get list of resources`', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/application-log/${projectId}/${componentId}/create`)
@@ -227,7 +227,7 @@ describe('Component API', function() {
.send({
name: 'New Application Log II',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
resourceCount++; // Increment Resource Count
expect(res.body.name).to.be.equal('New Application Log II');
@@ -240,7 +240,7 @@ describe('Component API', function() {
.post(`/application-log/${res.body._id}/log`)
.set('Authorization', authorization)
.send(log)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
request
@@ -248,7 +248,7 @@ describe('Component API', function() {
`/component/${projectId}/resources/${componentId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.totalResources).to.be.an(
'array'
@@ -268,14 +268,14 @@ describe('Component API', function() {
});
});
it('should create an application security then get list of resources', function(done: $TSFixMe) {
it('should create an application security then get list of resources', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
GitCredentialService.create({
gitUsername: gitCredential.gitUsername,
gitPassword: gitCredential.gitPassword,
projectId,
}).then(function(credential) {
}).then(function (credential) {
const data = {
name: 'Test',
gitRepositoryUrl: gitCredential.gitRepositoryUrl,
@@ -287,7 +287,7 @@ describe('Component API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
resourceCount++; // Increment Resource Count
expect(res.body.componentId).to.be.equal(componentId);
@@ -301,7 +301,7 @@ describe('Component API', function() {
request
.get(`/component/${projectId}/resources/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.totalResources).to.be.an('array');
expect(res.body.totalResources).to.have.lengthOf(
@@ -313,7 +313,7 @@ describe('Component API', function() {
});
});
it('should create a container security', function(done: $TSFixMe) {
it('should create a container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
DockerCredentialService.create({
@@ -321,7 +321,7 @@ describe('Component API', function() {
dockerPassword: dockerCredential.dockerPassword,
dockerRegistryUrl: dockerCredential.dockerRegistryUrl,
projectId,
}).then(function(credential) {
}).then(function (credential) {
const data = {
name: 'Test Container',
dockerCredential: credential._id,
@@ -333,7 +333,7 @@ describe('Component API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
resourceCount++; // Increment Resource Count
expect(res.body.componentId).to.be.equal(componentId);
@@ -343,7 +343,7 @@ describe('Component API', function() {
request
.get(`/component/${projectId}/resources/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.totalResources).to.be.an('array');
expect(res.body.totalResources).to.have.lengthOf(
@@ -355,17 +355,17 @@ describe('Component API', function() {
});
});
it('should delete a component and its monitor when componentId is valid', function(done: $TSFixMe) {
it('should delete a component and its monitor when componentId is valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/component/${projectId}/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
request
.get(`/monitor/${projectId}/monitor/${monitorId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res.body).to.be.an('object');
expect(res.body).to.not.have.property('_id');
done();
@@ -384,24 +384,24 @@ let subProjectId: $TSFixMe,
subProjectComponentId: $TSFixMe,
newComponentId: $TSFixMe;
describe('Component API with Sub-Projects', function() {
describe('Component API with Sub-Projects', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
const authorization = `Basic ${token}`;
// create a subproject for parent project
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.initTestConfig().then(function () {
request
.post(`/project/${projectId}/subProject`)
.set('Authorization', authorization)
.send({ subProjectName: 'New SubProject' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
subProjectId = res.body[0]._id;
// sign up second user (subproject user)
createUser(request, userData.newUser, function(
createUser(request, userData.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
newProjectId = project._id;
@@ -409,7 +409,7 @@ describe('Component API with Sub-Projects', function() {
VerificationTokenModel.findOne(
{ userId: newUserId },
function(
function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -418,7 +418,7 @@ describe('Component API with Sub-Projects', function() {
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
@@ -426,9 +426,9 @@ describe('Component API with Sub-Projects', function() {
password:
userData.newUser.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
newUserToken =
res.body.tokens
@@ -449,7 +449,7 @@ describe('Component API with Sub-Projects', function() {
.email,
role: 'Member',
})
.end(function() {
.end(function () {
done();
});
});
@@ -461,7 +461,7 @@ describe('Component API with Sub-Projects', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: {
@@ -488,38 +488,38 @@ describe('Component API with Sub-Projects', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should not create a component for user not present in project', function(done: $TSFixMe) {
createUser(request, userData.anotherUser, function(
it('should not create a component for user not present in project', function (done: $TSFixMe) {
createUser(request, userData.anotherUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
otherProjectId = project._id;
otherUserId = res.body.id;
VerificationTokenModel.findOne({ userId: otherUserId }, function(
VerificationTokenModel.findOne({ userId: otherUserId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.anotherUser.email,
password: userData.anotherUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const authorization = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.post(`/component/${projectId}`)
.set('Authorization', authorization)
.send({ name: 'New Component 1' })
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -533,7 +533,7 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should not create a component for user that is not `admin` in project.', function(done: $TSFixMe) {
it('should not create a component for user that is not `admin` in project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.post(`/component/${subProjectId}`)
@@ -541,7 +541,7 @@ describe('Component API with Sub-Projects', function() {
.send({
name: 'New Component 1',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
"You cannot edit the project because you're not an admin."
@@ -550,7 +550,7 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should create a component in parent project by valid admin.', function(done: $TSFixMe) {
it('should create a component in parent project by valid admin.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/component/${projectId}`)
@@ -558,7 +558,7 @@ describe('Component API with Sub-Projects', function() {
.send({
name: 'New Component 1',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
newComponentId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Component 1');
@@ -566,7 +566,7 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should not create a component with exisiting name in sub-project.', function(done: $TSFixMe) {
it('should not create a component with exisiting name in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/component/${subProjectId}`)
@@ -574,7 +574,7 @@ describe('Component API with Sub-Projects', function() {
.send({
name: 'New Component 1',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Component with that name already exists.'
@@ -583,7 +583,7 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should create a component in sub-project.', function(done: $TSFixMe) {
it('should create a component in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/component/${subProjectId}`)
@@ -591,7 +591,7 @@ describe('Component API with Sub-Projects', function() {
.send({
name: 'New Component 2',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
subProjectComponentId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Component 2');
@@ -599,12 +599,12 @@ describe('Component API with Sub-Projects', function() {
});
});
it("should get only sub-project's components for valid sub-project user", function(done: $TSFixMe) {
it("should get only sub-project's components for valid sub-project user", function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.get(`/component/${subProjectId}/component`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -615,12 +615,12 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should get project components for valid parent project user.', function(done: $TSFixMe) {
it('should get project components for valid parent project user.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/component/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body[0]).to.have.property('components');
@@ -630,12 +630,12 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should get sub-project components for valid parent project user.', function(done: $TSFixMe) {
it('should get sub-project components for valid parent project user.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/component/${subProjectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body[0]).to.have.property('components');
@@ -645,12 +645,12 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should not delete a component for user that is not `admin` in sub-project.', function(done: $TSFixMe) {
it('should not delete a component for user that is not `admin` in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.delete(`/component/${subProjectId}/${subProjectComponentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
"You cannot edit the project because you're not an admin."
@@ -659,23 +659,23 @@ describe('Component API with Sub-Projects', function() {
});
});
it('should delete sub-project component', function(done: $TSFixMe) {
it('should delete sub-project component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/component/${subProjectId}/${subProjectComponentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should delete project component', function(done: $TSFixMe) {
it('should delete project component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/component/${projectId}/${newComponentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});

View File

@@ -22,7 +22,7 @@ import ContainerSecurityService from '../backend/services/containerSecurityServi
import ContainerSecurityLogService from '../backend/services/containerSecurityLogService';
import AirtableService from '../backend/services/airtableService';
describe('Container Security API', function() {
describe('Container Security API', function () {
const timeout = 30000;
let projectId: $TSFixMe,
componentId: $TSFixMe,
@@ -33,11 +33,11 @@ describe('Container Security API', function() {
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -46,8 +46,8 @@ describe('Container Security API', function() {
UserService.updateOneBy(
{ _id: userId },
{ role: 'master-admin' }
).then(function() {
VerificationTokenModel.findOne({ userId }, function(
).then(function () {
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -56,16 +56,16 @@ describe('Container Security API', function() {
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
@@ -74,9 +74,9 @@ describe('Container Security API', function() {
.post(`/component/${projectId}`)
.set('Authorization', authorization)
.send({ name: 'Test Component' })
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
componentId = res.body._id;
done();
@@ -89,7 +89,7 @@ describe('Container Security API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -102,7 +102,7 @@ describe('Container Security API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should create a container security', function(done: $TSFixMe) {
it('should create a container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
DockerCredentialService.create({
@@ -110,7 +110,7 @@ describe('Container Security API', function() {
dockerPassword: dockerCredential.dockerPassword,
dockerRegistryUrl: dockerCredential.dockerRegistryUrl,
projectId,
}).then(function(credential) {
}).then(function (credential) {
credentialId = credential._id;
const data = {
name: 'Test Container',
@@ -123,7 +123,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
containerSecurityId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.componentId).to.be.equal(componentId);
@@ -135,7 +135,7 @@ describe('Container Security API', function() {
});
});
it('should update a container security', function(done: $TSFixMe) {
it('should update a container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const update = { name: 'Container Test' };
@@ -145,14 +145,14 @@ describe('Container Security API', function() {
)
.set('Authorization', authorization)
.send(update)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(update.name);
done();
});
});
it('should get a particular container security in a component', function(done: $TSFixMe) {
it('should get a particular container security in a component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -160,7 +160,7 @@ describe('Container Security API', function() {
`/security/${projectId}/${componentId}/container/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(String(res.body._id)).to.be.equal(
String(containerSecurityId)
@@ -172,33 +172,33 @@ describe('Container Security API', function() {
});
});
it('should get all the container security in a component', function(done: $TSFixMe) {
it('should get all the container security in a component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
});
});
it('should get all the container security with a particular credential', function(done: $TSFixMe) {
it('should get all the container security with a particular credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/security/${projectId}/container/${credentialId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
});
});
it('should scan a container security', function(done: $TSFixMe) {
it('should scan a container security', function (done: $TSFixMe) {
this.timeout(300000);
const authorization = `Basic ${token}`;
@@ -207,13 +207,13 @@ describe('Container Security API', function() {
`/security/${projectId}/container/scan/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should throw error if scanning with an invalid docker credentials or invalid image path', function(done: $TSFixMe) {
it('should throw error if scanning with an invalid docker credentials or invalid image path', function (done: $TSFixMe) {
this.timeout(500000);
const authorization = `Basic ${token}`;
const data = {
@@ -227,14 +227,14 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const containerSecurityId = res.body._id;
request
.post(
`/security/${projectId}/container/scan/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Scanning failed please check your docker credential or image path/tag'
@@ -244,7 +244,7 @@ describe('Container Security API', function() {
});
});
it('should not create a container security if name already exist in the component', function(done: $TSFixMe) {
it('should not create a container security if name already exist in the component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
name: 'Container Test',
@@ -257,7 +257,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container security with this name already exist in this component'
@@ -266,7 +266,7 @@ describe('Container Security API', function() {
});
});
it('should not create a container security if image path already exist in the component', function(done: $TSFixMe) {
it('should not create a container security if image path already exist in the component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
name: 'Another Container',
@@ -279,7 +279,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container security with this image path already exist in this component'
@@ -288,7 +288,7 @@ describe('Container Security API', function() {
});
});
it('should not create a container security if name is missing or undefined in the request body', function(done: $TSFixMe) {
it('should not create a container security if name is missing or undefined in the request body', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
dockerCredential: credentialId,
@@ -300,7 +300,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container Security Name is required'
@@ -309,7 +309,7 @@ describe('Container Security API', function() {
});
});
it('should not create a container security if image path is missing or undefined in the request body', function(done: $TSFixMe) {
it('should not create a container security if image path is missing or undefined in the request body', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
name: 'Another Container',
@@ -321,14 +321,14 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Image Path is required');
done();
});
});
it('should not create a container security if dockerCredential is missing or undefined in the request body', function(done: $TSFixMe) {
it('should not create a container security if dockerCredential is missing or undefined in the request body', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
name: 'Another Container',
@@ -340,7 +340,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Docker Credential is required'
@@ -349,7 +349,7 @@ describe('Container Security API', function() {
});
});
it('should delete a particular container security', function(done: $TSFixMe) {
it('should delete a particular container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -357,14 +357,14 @@ describe('Container Security API', function() {
`/security/${projectId}/${componentId}/container/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.deleted).to.be.true;
done();
});
});
it('should not scan a container security if it does not exist', function(done: $TSFixMe) {
it('should not scan a container security if it does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const containerSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -373,7 +373,7 @@ describe('Container Security API', function() {
`/security/${projectId}/container/scan/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container Security not found or does not exist'
@@ -382,7 +382,7 @@ describe('Container Security API', function() {
});
});
it('should not delete a non-existing container security', function(done: $TSFixMe) {
it('should not delete a non-existing container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const containerSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -391,7 +391,7 @@ describe('Container Security API', function() {
`/security/${projectId}/${componentId}/container/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container Security not found or does not exist'
@@ -400,7 +400,7 @@ describe('Container Security API', function() {
});
});
it('should not get a non-existing container security', function(done: $TSFixMe) {
it('should not get a non-existing container security', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const containerSecurityId = '5e8db9752cc46e3a229ebc51'; // non-existing ObjectId
@@ -409,7 +409,7 @@ describe('Container Security API', function() {
`/security/${projectId}/${componentId}/container/${containerSecurityId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Container security not found or does not exist'
@@ -418,7 +418,7 @@ describe('Container Security API', function() {
});
});
it('should not create a container security if dockerCredential does not exist', function(done: $TSFixMe) {
it('should not create a container security if dockerCredential does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
name: 'Another Container',
@@ -431,7 +431,7 @@ describe('Container Security API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Docker Credential not found or does not exist'

View File

@@ -19,7 +19,7 @@ import ProjectService from '../backend/services/projectService';
import ComponentService from '../backend/services/componentService';
import IncidentCustomFieldService from '../backend/services/customFieldService';
describe('Incident Custom Field API', function() {
describe('Incident Custom Field API', function () {
const timeout = 30000;
let projectId: $TSFixMe,
userId,
@@ -28,9 +28,9 @@ describe('Incident Custom Field API', function() {
customFieldId: $TSFixMe;
const incidentFieldText = {
fieldName: 'inTextField',
fieldType: 'text',
},
fieldName: 'inTextField',
fieldType: 'text',
},
incidentFieldNumber = {
fieldName: 'inNumField',
fieldType: 'number',
@@ -38,31 +38,31 @@ describe('Incident Custom Field API', function() {
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
authorization = `Basic ${token}`;
done();
@@ -73,7 +73,7 @@ describe('Incident Custom Field API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -84,36 +84,36 @@ describe('Incident Custom Field API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should not create an incident custom field when field name is missing or not specified', function(done: $TSFixMe) {
it('should not create an incident custom field when field name is missing or not specified', function (done: $TSFixMe) {
request
.post(`/customField/${projectId}`)
.send({ fieldType: 'text' })
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Field name is required');
done();
});
});
it('should not create an incident custom field when field type is missing or not specified', function(done: $TSFixMe) {
it('should not create an incident custom field when field type is missing or not specified', function (done: $TSFixMe) {
request
.post(`/customField/${projectId}`)
.send({ fieldName: 'missingType' })
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Field type is required');
done();
});
});
it('should setup custom fields for all incidents in a project (text)', function(done: $TSFixMe) {
it('should setup custom fields for all incidents in a project (text)', function (done: $TSFixMe) {
request
.post(`/customField/${projectId}`)
.send(incidentFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
customFieldId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.fieldName).to.be.equal(
@@ -123,12 +123,12 @@ describe('Incident Custom Field API', function() {
});
});
it('should not create incident custom field with an existing name in a project', function(done: $TSFixMe) {
it('should not create incident custom field with an existing name in a project', function (done: $TSFixMe) {
request
.post(`/customField/${projectId}`)
.send(incidentFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Custom field with this name already exist'
@@ -137,14 +137,14 @@ describe('Incident Custom Field API', function() {
});
});
it('should update a particular incident custom field in a project', function(done: $TSFixMe) {
it('should update a particular incident custom field in a project', function (done: $TSFixMe) {
incidentFieldText.fieldName = 'newName';
request
.put(`/customField/${projectId}/${customFieldId}`)
.send(incidentFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.fieldName).to.be.equal(
incidentFieldText.fieldName
@@ -154,17 +154,17 @@ describe('Incident Custom Field API', function() {
});
});
it('should list all the incident custom fields in a project', function(done: $TSFixMe) {
it('should list all the incident custom fields in a project', function (done: $TSFixMe) {
// add one more monitor custom field
request
.post(`/customField/${projectId}`)
.send(incidentFieldNumber)
.set('Authorization', authorization)
.end(function() {
.end(function () {
request
.get(`/customField/${projectId}?skip=0&limit=10`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.count).to.be.equal(2);
expect(res.body.data).to.be.an('array');
@@ -173,11 +173,11 @@ describe('Incident Custom Field API', function() {
});
});
it('should delete a particular monitor custom field in a project', function(done: $TSFixMe) {
it('should delete a particular monitor custom field in a project', function (done: $TSFixMe) {
request
.delete(`/customField/${projectId}/${customFieldId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(String(res.body._id)).to.be.equal(String(customFieldId));
done();

View File

@@ -24,16 +24,16 @@ let userId: $TSFixMe, projectId: $TSFixMe;
const selectEmailStatus =
'from to subject body createdAt template status content error deleted deletedAt deletedById replyTo smtpServer';
describe('Email verification API', function() {
describe('Email verification API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.enableEmailLog().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
GlobalConfig.enableEmailLog().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
projectId = res.body.project._id;
@@ -44,7 +44,7 @@ describe('Email verification API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -61,7 +61,7 @@ describe('Email verification API', function() {
await EmailStatusService.hardDeleteBy({});
});
it('should send email verification', async function() {
it('should send email verification', async function () {
await sleep(10000);
const emailStatuses = await EmailStatusService.findBy({
@@ -72,7 +72,7 @@ describe('Email verification API', function() {
expect(emailStatuses[0].status).to.equal('Success');
});
it('should not login non-verified user', async function() {
it('should not login non-verified user', async function () {
try {
await request.post('/user/login').send({
email: userData.user.email,
@@ -83,7 +83,7 @@ describe('Email verification API', function() {
}
});
it('should verify the user', async function() {
it('should verify the user', async function () {
const token = await VerificationTokenModel.findOne({ userId });
try {
await request.get(`/user/confirmation/${token.token}`).redirects(0);
@@ -97,7 +97,7 @@ describe('Email verification API', function() {
}
});
it('should login the verified user', async function() {
it('should login the verified user', async function () {
const res = await request.post('/user/login').send({
email: userData.user.email,
password: userData.user.password,

View File

@@ -20,36 +20,36 @@ import VerificationTokenModel from '../backend/models/verificationToken';
let token: $TSFixMe, projectId: $TSFixMe, userId: $TSFixMe;
let testSuiteStartTime: $TSFixMe, testCaseStartTime: $TSFixMe;
describe('Email Logs API', function() {
describe('Email Logs API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
testSuiteStartTime = new Date();
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -59,7 +59,7 @@ describe('Email Logs API', function() {
});
});
after(async function() {
after(async function () {
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
email: {
@@ -89,11 +89,11 @@ describe('Email Logs API', function() {
await EmailLogsService.hardDeleteBy({ query: deleteQuery });
});
beforeEach(async function() {
beforeEach(async function () {
testCaseStartTime = new Date();
});
afterEach(async function() {
afterEach(async function () {
// Deleting any emailLogs created between each test case in this suite.
// Note that using timeStamp between this test suite to remove some logs, Beacuse some email logs dont contain specific 'userId'. (Ex. /login)
const deleteQuery = {
@@ -120,17 +120,17 @@ describe('Email Logs API', function() {
});
});
it('should reject get email logs request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject get email logs request of an unauthenticated user', function (done: $TSFixMe) {
request
.get('/email-logs')
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject get email logs request of NON master-admin user', async function() {
it('should reject get email logs request of NON master-admin user', async function () {
const authorization = `Basic ${token}`;
await UserService.updateBy({ _id: userId }, { role: 'user' }); // Assigning user role
@@ -142,7 +142,7 @@ describe('Email Logs API', function() {
expect(res).to.have.status(400);
});
it('should send get email logs data for master-admin user', async function() {
it('should send get email logs data for master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -159,7 +159,7 @@ describe('Email Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send appopriate data set when limit is provided', async function() {
it('should send appopriate data set when limit is provided', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -182,7 +182,7 @@ describe('Email Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send appopriate data set when skip is provided', async function() {
it('should send appopriate data set when skip is provided', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -208,17 +208,17 @@ describe('Email Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should reject search request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject search request of an unauthenticated user', function (done: $TSFixMe) {
request
.post('/email-logs/search')
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject search request of NON master-admin user', async function() {
it('should reject search request of NON master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'user' }); // Resetting user to normal USER.
const authorization = `Basic ${token}`;
@@ -232,7 +232,7 @@ describe('Email Logs API', function() {
}
});
it('should send Searched EmailLogs data for master-admin user', async function() {
it('should send Searched EmailLogs data for master-admin user', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;
@@ -249,7 +249,7 @@ describe('Email Logs API', function() {
await UserService.updateBy({ _id: userId }, { role: 'null' }); // Resetting user to normal USER.
});
it('should send only matched result to provided search string when searched.', async function() {
it('should send only matched result to provided search string when searched.', async function () {
await UserService.updateBy({ _id: userId }, { role: 'master-admin' }); // Making user a "MASTER-ADMIN"
const authorization = `Basic ${token}`;

View File

@@ -24,15 +24,15 @@ let token: $TSFixMe,
incidentId: $TSFixMe,
alertId: $TSFixMe;
describe('Enterprise Alert API', function() {
describe('Enterprise Alert API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -45,7 +45,7 @@ describe('Enterprise Alert API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
@@ -59,9 +59,9 @@ describe('Enterprise Alert API', function() {
},
componentId: component._id,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
incidentData.monitors = [monitorId];
@@ -74,7 +74,7 @@ describe('Enterprise Alert API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await MonitorService.hardDeleteBy({ _id: monitorId });
@@ -85,13 +85,13 @@ describe('Enterprise Alert API', function() {
await AlertService.hardDeleteBy({ _id: alertId });
});
it('should create alert with valid details for project with no billing plan', function(done: $TSFixMe) {
it('should create alert with valid details for project with no billing plan', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/incident/${projectId}/create-incident`)
.set('Authorization', authorization)
.send(incidentData)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
incidentId = res.body._id;
request
.post(`/alert/${projectId}`)
@@ -102,7 +102,7 @@ describe('Enterprise Alert API', function() {
incidentId,
eventType: 'identified',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
alertId = res.body._id;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');

View File

@@ -19,15 +19,15 @@ let token: $TSFixMe,
newProjectId: $TSFixMe,
componentId: $TSFixMe;
describe('Enterprise Component API', function() {
describe('Enterprise Component API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -38,7 +38,7 @@ describe('Enterprise Component API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -46,7 +46,7 @@ describe('Enterprise Component API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, newProjectId] },
@@ -57,7 +57,7 @@ describe('Enterprise Component API', function() {
});
});
it('should create a new component for project with no billing plan', function(done: $TSFixMe) {
it('should create a new component for project with no billing plan', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post('/project/create')
@@ -65,7 +65,7 @@ describe('Enterprise Component API', function() {
.send({
projectName: 'Test Project',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
newProjectId = res.body._id;
request
.post(`/component/${newProjectId}`)
@@ -73,7 +73,7 @@ describe('Enterprise Component API', function() {
.send({
name: 'New Component',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
componentId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Component');

View File

@@ -13,10 +13,10 @@ import { createUser } from './utils/userSignUp';
import UserService from '../backend/services/userService';
import ProjectService from '../backend/services/projectService';
describe('Disable Sign up test', function() {
describe('Disable Sign up test', function () {
this.timeout(200000);
let token: $TSFixMe = null;
this.beforeAll(async function() {
this.beforeAll(async function () {
this.timeout(400000);
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({});
@@ -38,7 +38,7 @@ describe('Disable Sign up test', function() {
});
it('should not sign up the user when sign up is disabled', (done: $TSFixMe) => {
createUser(request, data.user, function(err: $TSFixMe, res: $TSFixMe) {
createUser(request, data.user, function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Sign up is disabled.');
done();
@@ -53,7 +53,7 @@ describe('Disable Sign up test', function() {
.send({
...data.anotherUser,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('email');
expect(res.body).to.have.property('role');

View File

@@ -48,15 +48,15 @@ let authorization: $TSFixMe,
monitorId: $TSFixMe,
scheduleId;
describe('Incident Alerts', function() {
describe('Incident Alerts', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
GlobalConfig.initTestConfig().then(() => {
createEnterpriseUser(request, userData.user, async function(
createEnterpriseUser(request, userData.user, async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -72,7 +72,7 @@ describe('Incident Alerts', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
authorization = `Basic ${token}`;
@@ -159,7 +159,7 @@ describe('Incident Alerts', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await OnCallScheduleStatusService.hardDeleteBy({ project: projectId });
await SubscriberService.hardDeleteBy({ projectId });
@@ -191,7 +191,7 @@ describe('Incident Alerts', function() {
* Global twilio settings (SMS/Call) enable : true
*/
it('should send SMS/Call alerts to on-call teams and subscribers if the SMS/Call alerts are enabled globally.', async function() {
it('should send SMS/Call alerts to on-call teams and subscribers if the SMS/Call alerts are enabled globally.', async function () {
const globalSettings = await GlobalConfigModel.findOne({
name: 'twilio',
});
@@ -276,7 +276,7 @@ describe('Incident Alerts', function() {
* Global twilio settings Call enable : false
*/
it('should not send Call alerts to on-call teams if the Call alerts are disabled in the global twilio configurations.', async function() {
it('should not send Call alerts to on-call teams if the Call alerts are disabled in the global twilio configurations.', async function () {
const globalSettings = await GlobalConfigModel.findOne({
name: 'twilio',
});
@@ -369,7 +369,7 @@ describe('Incident Alerts', function() {
* Global twilio settings Call enable : true
*/
it('should not send SMS alerts to on-call teams and subscriber if the SMS alerts are disabled in the global twilio configurations.', async function() {
it('should not send SMS alerts to on-call teams and subscriber if the SMS alerts are disabled in the global twilio configurations.', async function () {
const globalSettings = await GlobalConfigModel.findOne({
name: 'twilio',
});
@@ -467,7 +467,7 @@ describe('Incident Alerts', function() {
* Global twilio settings Call enable : false
*/
it('should send SMS/Call alerts to on-call teams and subscriber even if the alerts are disabled in the global twilio settings.', async function() {
it('should send SMS/Call alerts to on-call teams and subscriber even if the alerts are disabled in the global twilio settings.', async function () {
const globalSettings = await GlobalConfigModel.findOne({
name: 'twilio',
});
@@ -573,7 +573,7 @@ describe('Incident Alerts', function() {
* Custom twilio settings: not set
*/
it('should not SMS/Call alerts to on-call teams and subscriber if global and custom twilio settings are removed.', async function() {
it('should not SMS/Call alerts to on-call teams and subscriber if global and custom twilio settings are removed.', async function () {
await GlobalConfigModel.deleteMany({
name: 'twilio',
});

View File

@@ -21,15 +21,15 @@ let token: $TSFixMe,
newProjectId: $TSFixMe,
monitorId: $TSFixMe;
describe('Enterprise Monitor API', function() {
describe('Enterprise Monitor API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -40,7 +40,7 @@ describe('Enterprise Monitor API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -48,7 +48,7 @@ describe('Enterprise Monitor API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, newProjectId] },
@@ -59,7 +59,7 @@ describe('Enterprise Monitor API', function() {
});
});
it('should create a new monitor for project with no billing plan', function(done: $TSFixMe) {
it('should create a new monitor for project with no billing plan', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
ComponentModel.create({ name: 'Test Component' }).then(component => {
@@ -69,7 +69,7 @@ describe('Enterprise Monitor API', function() {
.send({
projectName: 'Test Project',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
newProjectId = res.body._id;
request
.post(`/monitor/${newProjectId}`)
@@ -80,7 +80,7 @@ describe('Enterprise Monitor API', function() {
data: { url: 'http://www.tests.org' },
componentId: component._id,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
monitorId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('New Monitor');

View File

@@ -15,15 +15,15 @@ import ProjectService from '../backend/services/projectService';
let token: $TSFixMe, projectId: $TSFixMe, newProjectId: $TSFixMe;
describe('Enterprise Project API', function() {
describe('Enterprise Project API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -34,7 +34,7 @@ describe('Enterprise Project API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -42,7 +42,7 @@ describe('Enterprise Project API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, newProjectId] },
@@ -52,7 +52,7 @@ describe('Enterprise Project API', function() {
});
});
it('should create a project when `planId` is not given', function(done: $TSFixMe) {
it('should create a project when `planId` is not given', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post('/project/create')
@@ -60,7 +60,7 @@ describe('Enterprise Project API', function() {
.send({
projectName: 'Test Project',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
newProjectId = res.body._id;
expect(res).to.have.status(200);
done();
@@ -72,7 +72,7 @@ describe('Enterprise Project API', function() {
request
.delete(`/project/${projectId}/deleteProject`)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
done();
});
@@ -83,7 +83,7 @@ describe('Enterprise Project API', function() {
request
.put(`/project/${projectId}/restoreProject`)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
done();
});

View File

@@ -17,15 +17,15 @@ let token: $TSFixMe, projectId: $TSFixMe, newProjectId: $TSFixMe;
const teamEmail = 'noreply1@oneuptime.com';
describe('Enterprise Team API', function() {
describe('Enterprise Team API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -36,7 +36,7 @@ describe('Enterprise Team API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -44,7 +44,7 @@ describe('Enterprise Team API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, newProjectId] },
@@ -56,7 +56,7 @@ describe('Enterprise Team API', function() {
});
});
it('should add new user with valid details for project with no billing plan', function(done: $TSFixMe) {
it('should add new user with valid details for project with no billing plan', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/team/${projectId}`)
@@ -65,7 +65,7 @@ describe('Enterprise Team API', function() {
emails: teamEmail,
role: 'Member',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res.body[0].team[0].userId).to.be.a('string');
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');

View File

@@ -18,15 +18,15 @@ let projectId: $TSFixMe,
userRole: $TSFixMe,
token: $TSFixMe;
describe('Enterprise User API', function() {
describe('Enterprise User API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createEnterpriseUser(request, data.user, function(
GlobalConfig.initTestConfig().then(function () {
createEnterpriseUser(request, data.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
@@ -38,7 +38,7 @@ describe('Enterprise User API', function() {
email: data.user.email,
password: data.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -61,14 +61,14 @@ describe('Enterprise User API', function() {
});
});
it('should sign up initial user as `master-admin`', function() {
it('should sign up initial user as `master-admin`', function () {
expect(userRole).to.equal('master-admin');
});
it('should confirm that `master-admin` exists', function(done: $TSFixMe) {
it('should confirm that `master-admin` exists', function (done: $TSFixMe) {
request
.get('/user/masterAdminExists')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).have.property('result');
expect(res.body.result).to.eql(true);
@@ -78,10 +78,10 @@ describe('Enterprise User API', function() {
// 'post /user/signup'
it('should register `user` without stripeToken, stripePlanId', function(done: $TSFixMe) {
createEnterpriseUser(request, data.newUser, function(
it('should register `user` without stripeToken, stripePlanId', function (done: $TSFixMe) {
createEnterpriseUser(request, data.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
newProjectId = project._id;
@@ -94,14 +94,14 @@ describe('Enterprise User API', function() {
});
});
it('should login with valid credentials', function(done: $TSFixMe) {
it('should login with valid credentials', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.newUser.email,
password: data.newUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.email).to.equal(
data.newUser.email.toLocaleLowerCase()
@@ -111,7 +111,7 @@ describe('Enterprise User API', function() {
});
});
it('should login with valid credentials, and return sent redirect url', function(done: $TSFixMe) {
it('should login with valid credentials, and return sent redirect url', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
@@ -119,7 +119,7 @@ describe('Enterprise User API', function() {
password: data.newUser.password,
redirect: 'http://oneuptime.com',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.email).to.equal(
data.newUser.email.toLocaleLowerCase()
@@ -130,12 +130,12 @@ describe('Enterprise User API', function() {
});
});
it('should get list of users without their hashed passwords', function(done: $TSFixMe) {
it('should get list of users without their hashed passwords', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/user/users')
.set('Authorization', authorization)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -150,14 +150,14 @@ describe('Enterprise User API', function() {
});
});
it('should turn off 2fa for a user', function(done: $TSFixMe) {
it('should turn off 2fa for a user', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.newUser.email,
password: data.newUser.password,
})
.then(function(res: $TSFixMe) {
.then(function (req: Response) {
const jwtToken = res.body.tokens.jwtAccessToken;
request
.put('/user/profile')
@@ -166,7 +166,7 @@ describe('Enterprise User API', function() {
twoFactorAuthEnabled: true,
email: data.newUser.email,
})
.then(function(res: $TSFixMe) {
.then(function (req: Response) {
request
.put(`/user/${res.body._id}/2fa`)
.set('Authorization', `Basic ${token}`)
@@ -175,7 +175,7 @@ describe('Enterprise User API', function() {
twoFactorAuthEnabled: !res.body
.twoFactorAuthEnabled,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res.body.twoFactorAuthEnabled).to.eql(
false
);
@@ -185,14 +185,14 @@ describe('Enterprise User API', function() {
});
});
it('should not turn off 2fa for a user if loged in user is not admin', function(done: $TSFixMe) {
it('should not turn off 2fa for a user if loged in user is not admin', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.newUser.email,
password: data.newUser.password,
})
.then(function(res: $TSFixMe) {
.then(function (req: Response) {
const jwtToken = res.body.tokens.jwtAccessToken;
request
.put('/user/profile')
@@ -201,7 +201,7 @@ describe('Enterprise User API', function() {
twoFactorAuthEnabled: true,
email: data.newUser.email,
})
.then(function(res: $TSFixMe) {
.then(function (req: Response) {
request
.put(`/user/${res.body._id}/2fa`)
.set('Authorization', `Basic ${jwtToken}`)
@@ -210,7 +210,7 @@ describe('Enterprise User API', function() {
twoFactorAuthEnabled: !res.body
.twoFactorAuthEnabled,
})
.end(function(err: $TSFixMe, result: $TSFixMe) {
.end(function (err: $TSFixMe, result: $TSFixMe) {
expect(result).to.have.status(400);
done();
});

View File

@@ -25,35 +25,35 @@ let token: $TSFixMe,
errorEventMembers = 0;
const sampleErrorEvent = {};
describe('Error Tracker API', function() {
describe('Error Tracker API', function () {
this.timeout(80000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(95000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
@@ -62,9 +62,9 @@ describe('Error Tracker API', function() {
.send({
name: 'New Component',
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
componentId = res.body._id;
expect(res).to.have.status(200);
@@ -80,19 +80,19 @@ describe('Error Tracker API', function() {
});
});
it('should reject the request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject the request of an unauthenticated user', function (done: $TSFixMe) {
request
.post(`/error-tracker/${projectId}/${componentId}/create`)
.send({
name: 'New Error Tracker',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject the request of an empty error tracker name', function(done: $TSFixMe) {
it('should reject the request of an empty error tracker name', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/error-tracker/${projectId}/${componentId}/create`)
@@ -100,13 +100,13 @@ describe('Error Tracker API', function() {
.send({
name: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create an error tracker', function(done: $TSFixMe) {
it('should create an error tracker', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/error-tracker/${projectId}/${componentId}/create`)
@@ -114,7 +114,7 @@ describe('Error Tracker API', function() {
.send({
name: 'Node Project',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
errorTracker = res.body;
expect(res).to.have.status(200);
expect(res.body).to.include({ name: 'Node Project' });
@@ -122,24 +122,24 @@ describe('Error Tracker API', function() {
});
});
it('should return a list of error trackers under component', function(done: $TSFixMe) {
it('should return a list of error trackers under component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/error-tracker/${projectId}/${componentId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
});
});
it('should not return a list of error trackers under wrong component', function(done: $TSFixMe) {
it('should not return a list of error trackers under wrong component', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/error-tracker/${projectId}/5ee8d7cc8701d678901ab908`) // wrong component ID
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Component does not exist.'
@@ -149,7 +149,7 @@ describe('Error Tracker API', function() {
});
// reset api key
it('should reset error tracker key', function(done: $TSFixMe) {
it('should reset error tracker key', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const currentKey = errorTracker.key;
request
@@ -157,7 +157,7 @@ describe('Error Tracker API', function() {
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/reset-key`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body._id).to.be.equal(errorTracker._id); // same error tracker id
expect(res.body.key).to.not.be.equal(currentKey); // error tracker key has chaged
@@ -167,7 +167,7 @@ describe('Error Tracker API', function() {
});
// edit error tracker details
it('should update the current error tracker name', function(done: $TSFixMe) {
it('should update the current error tracker name', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const appName = 'Python API App';
request
@@ -176,7 +176,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ name: appName })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
const updatedErrorTracker = res.body;
expect(errorTracker._id).to.be.equal(updatedErrorTracker._id); // same id
@@ -187,20 +187,20 @@ describe('Error Tracker API', function() {
});
});
it('should request for eventId for tracking an error event', function(done: $TSFixMe) {
it('should request for eventId for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Event ID is required.');
done();
});
});
it('should request for fingerprint for tracking an error event', function(done: $TSFixMe) {
it('should request for fingerprint for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -208,7 +208,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Fingerprint is required.'
@@ -217,7 +217,7 @@ describe('Error Tracker API', function() {
});
});
it('should request for fingerprint as an array for tracking an error event', function(done: $TSFixMe) {
it('should request for fingerprint as an array for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -227,7 +227,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Fingerprint is to be of type Array.'
@@ -236,7 +236,7 @@ describe('Error Tracker API', function() {
});
});
it('should request for error event type for tracking an error event', function(done: $TSFixMe) {
it('should request for error event type for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -246,7 +246,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Error Event Type must be of the allowed types.'
@@ -255,7 +255,7 @@ describe('Error Tracker API', function() {
});
});
it('should request for tags for tracking an error event', function(done: $TSFixMe) {
it('should request for tags for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -267,14 +267,14 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Tags is required.');
done();
});
});
it('should request for timeline in array format for tracking an error event', function(done: $TSFixMe) {
it('should request for timeline in array format for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -290,7 +290,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Timeline is to be of type Array.'
@@ -299,7 +299,7 @@ describe('Error Tracker API', function() {
});
});
it('should request for exception for tracking an error event', function(done: $TSFixMe) {
it('should request for exception for tracking an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -313,14 +313,14 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Exception is required.');
done();
});
});
it('should declare Error Tracker not existing for an error event', function(done: $TSFixMe) {
it('should declare Error Tracker not existing for an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -338,7 +338,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Error Tracker does not exist.'
@@ -347,7 +347,7 @@ describe('Error Tracker API', function() {
});
});
it('should create an error event and set a fingerprint hash and issueId', function(done: $TSFixMe) {
it('should create an error event and set a fingerprint hash and issueId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -367,7 +367,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
errorEvent = res.body; // save as an error event
@@ -380,7 +380,7 @@ describe('Error Tracker API', function() {
});
});
it('should create a new error event with the old fingerprint, create a new one with a different fingerprint and confirm the two have different issueId', function(done: $TSFixMe) {
it('should create a new error event with the old fingerprint, create a new one with a different fingerprint and confirm the two have different issueId', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
sampleErrorEvent.eventId = 'samplId';
@@ -400,7 +400,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200); // weve created an error event with the existing issue fingerprint
expect(res.body.issueId).to.be.equal(errorEvent.issueId);
@@ -409,7 +409,7 @@ describe('Error Tracker API', function() {
.post(`/error-tracker/${errorTracker._id}/track`)
.set('Authorization', authorization)
.send(sampleErrorEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
issueCount = issueCount + 1; // weve created a new issue entirely
@@ -426,14 +426,14 @@ describe('Error Tracker API', function() {
});
});
it('should return a list of issues under an error event', function(done: $TSFixMe) {
it('should return a list of issues under an error event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/issues`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data.errorTrackerIssues).to.be.an('array');
expect(res.body.data.count).to.be.equal(issueCount); // confirm the issue count is accurate
@@ -441,7 +441,7 @@ describe('Error Tracker API', function() {
});
});
it('should return a list of issues under an error event based on limit', function(done: $TSFixMe) {
it('should return a list of issues under an error event based on limit', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const limit = 1;
request
@@ -450,7 +450,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ limit })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data.errorTrackerIssues).to.be.an('array');
expect(res.body.data.count).to.be.equal(limit); // confirm the issue count is accurate based on the limit
@@ -458,14 +458,14 @@ describe('Error Tracker API', function() {
});
});
it('should return an error event with its next and previous', function(done: $TSFixMe) {
it('should return an error event with its next and previous', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/error-events/${errorEvent._id}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.errorEvent).to.be.an('object');
expect(res.body.previous).to.be.equal(null); // since this error event is the first, nothing should come before it
@@ -475,21 +475,21 @@ describe('Error Tracker API', function() {
});
});
it('should return an error when trying to ignore an issue without passing the IssueID', function(done: $TSFixMe) {
it('should return an error when trying to ignore an issue without passing the IssueID', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/issues/action`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Issue ID is required');
done();
});
});
it('should return an error when trying to ignore an issue without passing an array of issues', function(done: $TSFixMe) {
it('should return an error when trying to ignore an issue without passing an array of issues', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -497,7 +497,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ issueId: errorEvent.issueId })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Issue ID has to be of type array'
@@ -506,7 +506,7 @@ describe('Error Tracker API', function() {
});
});
it('should return an error when trying to ignore an issue without passing a valid action type', function(done: $TSFixMe) {
it('should return an error when trying to ignore an issue without passing a valid action type', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -514,14 +514,14 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ issueId: [errorEvent.issueId], action: 'test' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Action is not allowed');
done();
});
});
it('should ignore an issue successfully', function(done: $TSFixMe) {
it('should ignore an issue successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -529,7 +529,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ issueId: [errorEvent.issueId], action: 'ignore' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('issues');
const currentIssue = res.body.issues.filter(
@@ -542,7 +542,7 @@ describe('Error Tracker API', function() {
});
});
it('should resolve an issue and change the ignore state successfully', function(done: $TSFixMe) {
it('should resolve an issue and change the ignore state successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -550,7 +550,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ issueId: [errorEvent.issueId], action: 'resolve' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('issues');
const currentIssue = res.body.issues.filter(
@@ -566,7 +566,7 @@ describe('Error Tracker API', function() {
});
});
it('should unresolve an issue and change the ignore and resolved state successfully', function(done: $TSFixMe) {
it('should unresolve an issue and change the ignore and resolved state successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -574,7 +574,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ issueId: [errorEvent.issueId], action: 'unresolve' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('issues');
const currentIssue = res.body.issues.filter(
@@ -589,14 +589,14 @@ describe('Error Tracker API', function() {
});
});
it('should not fetch errors attached to a fingerprint if fingerprint is not provided', function(done: $TSFixMe) {
it('should not fetch errors attached to a fingerprint if fingerprint is not provided', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/error-events`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Fingerprint Hash is required'
@@ -605,7 +605,7 @@ describe('Error Tracker API', function() {
});
});
it('should fetch errors attached to a fingerprint successfully', function(done: $TSFixMe) {
it('should fetch errors attached to a fingerprint successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -613,7 +613,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ fingerprintHash: errorEvent.fingerprintHash })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body[res.body.length - 1]._id).to.be.equal(
@@ -623,7 +623,7 @@ describe('Error Tracker API', function() {
});
});
it('should fetch errors attached to a fingerprint successfully based on limit', function(done: $TSFixMe) {
it('should fetch errors attached to a fingerprint successfully based on limit', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const limit = 1;
request
@@ -632,7 +632,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ fingerprintHash: errorEvent.fingerprintHash, limit })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body.length).to.be.equal(limit);
@@ -640,7 +640,7 @@ describe('Error Tracker API', function() {
});
});
it('should fetch members attached to an issue successfully', function(done: $TSFixMe) {
it('should fetch members attached to an issue successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -648,7 +648,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ fingerprintHash: errorEvent.fingerprintHash })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.have.property('issueId');
expect(res.body).to.be.have.property('issueMembers');
@@ -660,14 +660,14 @@ describe('Error Tracker API', function() {
});
});
it('should not assign member to issue due to no member ID passed', function(done: $TSFixMe) {
it('should not assign member to issue due to no member ID passed', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}/assign/${errorEvent.issueId}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Team Member ID is required'
@@ -676,7 +676,7 @@ describe('Error Tracker API', function() {
});
});
it('should not assign member to issue if member ID is not of required type', function(done: $TSFixMe) {
it('should not assign member to issue if member ID is not of required type', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -684,7 +684,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ teamMemberId: userId })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Team Member ID has to be of type array'
@@ -693,7 +693,7 @@ describe('Error Tracker API', function() {
});
});
it('should assign member to issue if member ID is of required type', function(done: $TSFixMe) {
it('should assign member to issue if member ID is of required type', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -701,7 +701,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ teamMemberId: [userId] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
errorEventMembers += 1; // increase the member count
expect(res.body.issueId).to.be.equal(errorEvent.issueId);
@@ -714,7 +714,7 @@ describe('Error Tracker API', function() {
});
});
it('should unassign member to issue if member ID is of required type', function(done: $TSFixMe) {
it('should unassign member to issue if member ID is of required type', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(
@@ -722,7 +722,7 @@ describe('Error Tracker API', function() {
)
.set('Authorization', authorization)
.send({ teamMemberId: [userId] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
errorEventMembers -= 1;
expect(res.body.issueId).to.be.equal(errorEvent.issueId);
@@ -732,14 +732,14 @@ describe('Error Tracker API', function() {
});
// delete error tracker
it('should delete the error tracker', function(done: $TSFixMe) {
it('should delete the error tracker', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(
`/error-tracker/${projectId}/${componentId}/${errorTracker._id}`
)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.deleted).to.be.equal(true);
done();

View File

@@ -21,22 +21,22 @@ const selectEmailStatus =
let token: $TSFixMe, projectId: $TSFixMe, userId: $TSFixMe;
describe('Feedback API', function() {
describe('Feedback API', function () {
this.timeout(50000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.enableEmailLog().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
GlobalConfig.enableEmailLog().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -45,16 +45,16 @@ describe('Feedback API', function() {
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
token = res.body.tokens.jwtAccessToken;
done();
@@ -66,7 +66,7 @@ describe('Feedback API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -82,7 +82,7 @@ describe('Feedback API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should create feedback and check the sent emails to oneuptime team and user', async function() {
it('should create feedback and check the sent emails to oneuptime team and user', async function () {
const authorization = `Basic ${token}`;
const testFeedback = {
feedback: 'test feedback',

View File

@@ -18,37 +18,37 @@ import ProjectService from '../backend/services/projectService';
import GitCredentialService from '../backend/services/gitCredentialService';
import AirtableService from '../backend/services/airtableService';
describe('Git Credential API', function() {
describe('Git Credential API', function () {
const timeout = 30000;
let projectId: $TSFixMe, userId, token: $TSFixMe, credentialId: $TSFixMe;
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -58,7 +58,7 @@ describe('Git Credential API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -70,7 +70,7 @@ describe('Git Credential API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should add git credential', function(done: $TSFixMe) {
it('should add git credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const gitUsername = 'username';
const gitPassword = 'password';
@@ -82,7 +82,7 @@ describe('Git Credential API', function() {
gitUsername,
gitPassword,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
credentialId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.gitUsername).to.be.equal(gitUsername);
@@ -90,7 +90,7 @@ describe('Git Credential API', function() {
});
});
it('should update a git credential', function(done: $TSFixMe) {
it('should update a git credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const newGitUsername = 'newusername';
@@ -100,14 +100,14 @@ describe('Git Credential API', function() {
.send({
gitUsername: newGitUsername,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.gitUsername).to.be.equal(newGitUsername);
done();
});
});
it('should get all the git credentials in a project', function(done: $TSFixMe) {
it('should get all the git credentials in a project', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const gitUsername = 'anotherUsername';
const gitPassword = 'password';
@@ -119,11 +119,11 @@ describe('Git Credential API', function() {
gitUsername,
gitPassword,
})
.end(function() {
.end(function () {
request
.get(`/credential/${projectId}/gitCredential`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
@@ -131,13 +131,13 @@ describe('Git Credential API', function() {
});
});
it('should remove a git credential', function(done: $TSFixMe) {
it('should remove a git credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/credential/${projectId}/gitCredential/${credentialId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body._id).to.be.equal(credentialId);
expect(res.body.deleted).to.be.true;
@@ -145,7 +145,7 @@ describe('Git Credential API', function() {
});
});
it('should not create git credential with an existing git user in a project', function(done: $TSFixMe) {
it('should not create git credential with an existing git user in a project', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const gitUsername = 'anotherUsername'; // an existing username
const gitPassword = 'password';
@@ -157,7 +157,7 @@ describe('Git Credential API', function() {
gitUsername,
gitPassword,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Credential already exist in this project'
@@ -166,7 +166,7 @@ describe('Git Credential API', function() {
});
});
it('should not create git credential if git username is missing', function(done: $TSFixMe) {
it('should not create git credential if git username is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const gitUsername = '';
const gitPassword = 'password';
@@ -178,7 +178,7 @@ describe('Git Credential API', function() {
gitUsername,
gitPassword,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Username is required'
@@ -187,7 +187,7 @@ describe('Git Credential API', function() {
});
});
it('should not create git credential if git password is missing', function(done: $TSFixMe) {
it('should not create git credential if git password is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const gitUsername = 'username';
@@ -197,7 +197,7 @@ describe('Git Credential API', function() {
.send({
gitUsername,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Please provide a password'
@@ -206,14 +206,14 @@ describe('Git Credential API', function() {
});
});
it('should not remove a non-existing git credential', function(done: $TSFixMe) {
it('should not remove a non-existing git credential', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const credentialId = '5e8db97b2cc46e3a229ebc62'; // non-existing credential id
request
.delete(`/credential/${projectId}/gitCredential/${credentialId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Git Credential not found or does not exist'

View File

@@ -17,40 +17,40 @@ import VerificationTokenModel from '../backend/models/verificationToken';
import GlobalConfig from './utils/globalConfig';
let projectId: $TSFixMe, userId: $TSFixMe, token: $TSFixMe;
describe('Global Config API', function() {
describe('Global Config API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(100000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, data.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, data.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: data.user.email,
password: data.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
UserService.updateBy(
{ _id: userId },
{ role: 'master-admin' }
).then(function() {
).then(function () {
done();
});
});
@@ -74,7 +74,7 @@ describe('Global Config API', function() {
});
});
it('should create global config when name and value are valid', function(done: $TSFixMe) {
it('should create global config when name and value are valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const globalConfig = {
name: 'TestName',
@@ -84,7 +84,7 @@ describe('Global Config API', function() {
.post('/globalConfig')
.set('Authorization', authorization)
.send(globalConfig)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.equal(globalConfig.name);
expect(res.body.value).to.equal(globalConfig.value);
@@ -92,7 +92,7 @@ describe('Global Config API', function() {
});
});
it('should create multiple global configs when details are valid', function(done: $TSFixMe) {
it('should create multiple global configs when details are valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const globalConfigs = [
{
@@ -108,7 +108,7 @@ describe('Global Config API', function() {
.post('/globalConfig')
.set('Authorization', authorization)
.send(globalConfigs)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -125,27 +125,27 @@ describe('Global Config API', function() {
});
});
it('should not create global config when name and value are not valid', function(done: $TSFixMe) {
it('should not create global config when name and value are not valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const globalConfig = { name: null };
request
.post('/globalConfig')
.set('Authorization', authorization)
.send(globalConfig)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should get multiple global configs when names are provided', function(done: $TSFixMe) {
it('should get multiple global configs when names are provided', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const globalConfigs = ['TestName', 'Other TestName'];
request
.post('/globalConfig/configs')
.set('Authorization', authorization)
.send(globalConfigs)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -160,24 +160,24 @@ describe('Global Config API', function() {
});
});
it('should get global config by name', function(done: $TSFixMe) {
it('should get global config by name', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/globalConfig/TestName')
.set('Authorization', authorization)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.equal('TestName');
done();
});
});
it('should retrieve global config for audit Log status', function(done: $TSFixMe) {
it('should retrieve global config for audit Log status', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/globalConfig/auditLogMonitoringStatus')
.set('Authorization', authorization)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.equal('auditLogMonitoringStatus');
expect(res.body.value).to.equal(true);
@@ -185,13 +185,13 @@ describe('Global Config API', function() {
});
});
it('should toggle global config for audit Log status', function(done: $TSFixMe) {
it('should toggle global config for audit Log status', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post('/globalConfig')
.set('Authorization', authorization)
.send({ name: 'auditLogMonitoringStatus', value: false })
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.equal('auditLogMonitoringStatus');
expect(res.body.value).to.equal(false);

View File

@@ -22,34 +22,34 @@ let token: $TSFixMe,
defaultIncidentPriorityId: $TSFixMe,
newIncidentPriorityId: $TSFixMe;
describe('Incident Priority API', function() {
describe('Incident Priority API', function () {
this.timeout(500000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(90000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -59,7 +59,7 @@ describe('Incident Priority API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await IncidentSettings.hardDeleteBy({ projectId: projectId });
await UserService.hardDeleteBy({ _id: userId });
@@ -91,7 +91,7 @@ describe('Incident Priority API', function() {
.delete(`/incidentPriorities/${projectId}`)
.set('Authorization', authorization)
.send({ _id: defaultIncidentPriorityId })
.end((error: $TSFixMe, res: $TSFixMe) => {
.end((error: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});

View File

@@ -46,34 +46,34 @@ const incidentSettings = {
name: 'Another update',
};
describe('Incident Settings API', function() {
describe('Incident Settings API', function () {
this.timeout(500000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(90000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
ComponentModel.create({
@@ -85,9 +85,9 @@ describe('Incident Settings API', function() {
.post(`/monitor/${projectId}`)
.set('Authorization', authorization)
.send({ ...monitor, componentId })
.end(async function(
.end(async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
expect(res).to.have.status(200);
@@ -104,7 +104,7 @@ describe('Incident Settings API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await IncidentService.hardDeleteBy({ _id: incidentId });
await IncidentSettings.hardDeleteBy({ projectId });

View File

@@ -32,7 +32,7 @@ const {
acknowledgeRequest,
} = require('./data/incomingHttpRequest');
describe('Incoming HTTP Request API', function() {
describe('Incoming HTTP Request API', function () {
const timeout = 30000;
let projectId: $TSFixMe,
componentId,
@@ -50,31 +50,31 @@ describe('Incoming HTTP Request API', function() {
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
authorization = `Basic ${token}`;
@@ -82,9 +82,9 @@ describe('Incoming HTTP Request API', function() {
.post(`/component/${projectId}`)
.set('Authorization', authorization)
.send({ name: 'Test Component' })
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
componentId = res.body._id;
@@ -110,9 +110,9 @@ describe('Incoming HTTP Request API', function() {
},
],
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
@@ -123,7 +123,7 @@ describe('Incoming HTTP Request API', function() {
'monitorField',
fieldType: 'text',
}
).then(function() {
).then(function () {
done();
});
});
@@ -135,7 +135,7 @@ describe('Incoming HTTP Request API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -150,11 +150,11 @@ describe('Incoming HTTP Request API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should create an incoming http request (Create Incident)', function(done: $TSFixMe) {
it('should create an incoming http request (Create Incident)', function (done: $TSFixMe) {
IncidentPrioritiesService.findOne({
query: { projectId },
select: '_id',
}).then(function(priority) {
}).then(function (priority) {
// fetch one of the priorities
incidentPriorityId = priority._id;
incidentRequest.incidentPriority = incidentPriorityId;
@@ -163,7 +163,7 @@ describe('Incoming HTTP Request API', function() {
.post(`/incoming-request/${projectId}/create-request-url`)
.set('Authorization', authorization)
.send(incidentRequest)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
requestId = res.body._id;
createIncidentUrl = res.body.url;
expect(res).to.have.status(200);
@@ -174,12 +174,12 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should create an incoming http request (Acknowledge Incident)', function(done: $TSFixMe) {
it('should create an incoming http request (Acknowledge Incident)', function (done: $TSFixMe) {
request
.post(`/incoming-request/${projectId}/create-request-url`)
.set('Authorization', authorization)
.send(acknowledgeRequest)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
acknowledgeIncidentUrl = res.body.url;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(acknowledgeRequest.name);
@@ -188,12 +188,12 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should create an incoming http request (Resolve Incident)', function(done: $TSFixMe) {
it('should create an incoming http request (Resolve Incident)', function (done: $TSFixMe) {
request
.post(`/incoming-request/${projectId}/create-request-url`)
.set('Authorization', authorization)
.send(resolveRequest)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
resolveIncidentUrl = res.body.url;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(resolveRequest.name);
@@ -202,12 +202,12 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should create an incoming http request (Update incident note)', function(done: $TSFixMe) {
it('should create an incoming http request (Update incident note)', function (done: $TSFixMe) {
request
.post(`/incoming-request/${projectId}/create-request-url`)
.send(incidentNoteRequest)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
incidentNoteUrl = res.body.url;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(incidentNoteRequest.name);
@@ -219,12 +219,12 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should create an incoming http request (Update internal note)', function(done: $TSFixMe) {
it('should create an incoming http request (Update internal note)', function (done: $TSFixMe) {
request
.post(`/incoming-request/${projectId}/create-request-url`)
.send(internalNoteRequest)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
internalNoteUrl = res.body.url;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(internalNoteRequest.name);
@@ -236,7 +236,7 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should update an incoming http request', function(done: $TSFixMe) {
it('should update an incoming http request', function (done: $TSFixMe) {
const update = {
name: 'updateName',
};
@@ -245,14 +245,14 @@ describe('Incoming HTTP Request API', function() {
.put(`/incoming-request/${projectId}/update/${requestId}`)
.send(update)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(update.name);
done();
});
});
it('should list all the created incoming http request in a project', function(done: $TSFixMe) {
it('should list all the created incoming http request in a project', function (done: $TSFixMe) {
incidentRequest.name = 'anotherOne';
incidentRequest.selectAllMonitors = false;
incidentRequest.monitors = [monitorId];
@@ -261,13 +261,13 @@ describe('Incoming HTTP Request API', function() {
.post(`/incoming-request/${projectId}/create-request-url`)
.set('Authorization', authorization)
.send(incidentRequest)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
requestId = res.body._id;
request
.get(`/incoming-request/${projectId}/all-incoming-request`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('array');
done();
@@ -275,11 +275,11 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should create an incident with incoming http request url', function(done: $TSFixMe) {
it('should create an incident with incoming http request url', function (done: $TSFixMe) {
axios({
method: 'post',
url: createIncidentUrl,
}).then(function(res) {
}).then(function (res) {
expect(res).to.have.status(200);
expect(res.data.status).to.be.equal('success');
expect(res.data.created_incidents).to.be.an('array');
@@ -287,11 +287,11 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should acknowledge an incident with an incoming http request url', function(done: $TSFixMe) {
it('should acknowledge an incident with an incoming http request url', function (done: $TSFixMe) {
axios({
method: 'post',
url: acknowledgeIncidentUrl,
}).then(function(res) {
}).then(function (res) {
expect(res).to.have.status(200);
expect(res.data.status).to.be.equal('success');
expect(res.data.acknowledged_incidents).to.be.an('array');
@@ -299,11 +299,11 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should resolve an incident with an incoming http request url', function(done: $TSFixMe) {
it('should resolve an incident with an incoming http request url', function (done: $TSFixMe) {
axios({
method: 'post',
url: resolveIncidentUrl,
}).then(function(res) {
}).then(function (res) {
expect(res).to.have.status(200);
expect(res.data.status).to.be.equal('success');
expect(res.data.resolved_incidents).to.be.an('array');
@@ -311,12 +311,12 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should add incident note with an incoming http request url', function(done: $TSFixMe) {
it('should add incident note with an incoming http request url', function (done: $TSFixMe) {
// it should also work for a get request
axios({
method: 'get',
url: incidentNoteUrl,
}).then(function(res) {
}).then(function (res) {
expect(res).to.have.status(200);
expect(res.data.status).to.be.equal('success');
expect(res.data.notes_addedTo).to.be.an('array');
@@ -324,11 +324,11 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should add internal note with an incoming http request url', function(done: $TSFixMe) {
it('should add internal note with an incoming http request url', function (done: $TSFixMe) {
axios({
method: 'get',
url: internalNoteUrl,
}).then(function(res) {
}).then(function (res) {
expect(res).to.have.status(200);
expect(res.data.status).to.be.equal('success');
expect(res.data.notes_addedTo).to.be.an('array');
@@ -336,11 +336,11 @@ describe('Incoming HTTP Request API', function() {
});
});
it('should delete an incoming http request in project', function(done: $TSFixMe) {
it('should delete an incoming http request in project', function (done: $TSFixMe) {
request
.delete(`/incoming-request/${projectId}/remove/${requestId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(String(res.body._id)).to.be.equal(String(requestId));
done();

View File

@@ -18,35 +18,35 @@ import { createUser } from './utils/userSignUp';
let token: $TSFixMe, projectId: $TSFixMe, refreshToken: $TSFixMe, userId;
describe('Jwt Token API', function() {
describe('Jwt Token API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
refreshToken =
res.body.tokens.jwtRefreshToken;
@@ -58,7 +58,7 @@ describe('Jwt Token API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -73,13 +73,13 @@ describe('Jwt Token API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should get new access and refresh token when provided a valid jwtRefreshToken', function(done: $TSFixMe) {
it('should get new access and refresh token when provided a valid jwtRefreshToken', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post('/token/new')
.set('Authorization', authorization)
.send({ refreshToken: refreshToken })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});

View File

@@ -24,35 +24,35 @@ const leadData = {
const selectEmailStatus =
'from to subject body createdAt template status content error deleted deletedAt deletedById replyTo smtpServer';
describe('Lead API', function() {
describe('Lead API', function () {
this.timeout(20000);
before(async function() {
before(async function () {
this.timeout(30000);
await GlobalConfig.initTestConfig();
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
});
it('should add lead when requested for type demo or whitepaper', function(done: $TSFixMe) {
it('should add lead when requested for type demo or whitepaper', function (done: $TSFixMe) {
request
.post('/lead')
.send(leadData)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
leadService.hardDeleteBy({ _id: res.body._id });
done();
});
});
it('should add lead when requested for type demo and check the sent message', function(done: $TSFixMe) {
it('should add lead when requested for type demo and check the sent message', function (done: $TSFixMe) {
this.timeout(60000);
request
.post('/lead')
.send(leadData)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
leadService.hardDeleteBy({ _id: res.body._id });
const emailStatuses = await EmailStatusService.findBy({

File diff suppressed because it is too large Load Diff

View File

@@ -17,35 +17,35 @@ import AirtableService from '../backend/services/airtableService';
let token: $TSFixMe, projectId: $TSFixMe, userId: $TSFixMe;
describe('Monitor Criteria API', function() {
describe('Monitor Criteria API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -55,7 +55,7 @@ describe('Monitor Criteria API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -71,12 +71,12 @@ describe('Monitor Criteria API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should get the monitor criteria', function(done: $TSFixMe) {
it('should get the monitor criteria', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/monitorCriteria')
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();

View File

@@ -19,7 +19,7 @@ import ProjectService from '../backend/services/projectService';
import ComponentService from '../backend/services/componentService';
import MonitorCustomFieldService from '../backend/services/monitorCustomField';
describe('Monitor Custom Field API', function() {
describe('Monitor Custom Field API', function () {
const timeout = 30000;
let projectId: $TSFixMe,
userId,
@@ -28,9 +28,9 @@ describe('Monitor Custom Field API', function() {
monitorCustomFieldId: $TSFixMe;
const monitorFieldText = {
fieldName: 'textField',
fieldType: 'text',
},
fieldName: 'textField',
fieldType: 'text',
},
monitorFieldNumber = {
fieldName: 'numField',
fieldType: 'number',
@@ -38,31 +38,31 @@ describe('Monitor Custom Field API', function() {
this.timeout(timeout);
before(function(done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
before(function (done: $TSFixMe) {
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
authorization = `Basic ${token}`;
done();
@@ -73,7 +73,7 @@ describe('Monitor Custom Field API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -84,36 +84,36 @@ describe('Monitor Custom Field API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should not create a monitor custom field when field name is missing or not specified', function(done: $TSFixMe) {
it('should not create a monitor custom field when field name is missing or not specified', function (done: $TSFixMe) {
request
.post(`/monitorCustomField/${projectId}`)
.send({ fieldType: 'text' })
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Field name is required');
done();
});
});
it('should not create a monitor custom field when field type is missing or not specified', function(done: $TSFixMe) {
it('should not create a monitor custom field when field type is missing or not specified', function (done: $TSFixMe) {
request
.post(`/monitorCustomField/${projectId}`)
.send({ fieldName: 'missingType' })
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal('Field type is required');
done();
});
});
it('should setup custom fields for all monitors in a project (text)', function(done: $TSFixMe) {
it('should setup custom fields for all monitors in a project (text)', function (done: $TSFixMe) {
request
.post(`/monitorCustomField/${projectId}`)
.send(monitorFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
monitorCustomFieldId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.fieldName).to.be.equal(
@@ -123,12 +123,12 @@ describe('Monitor Custom Field API', function() {
});
});
it('should not create monitor custom field with an existing name in a project', function(done: $TSFixMe) {
it('should not create monitor custom field with an existing name in a project', function (done: $TSFixMe) {
request
.post(`/monitorCustomField/${projectId}`)
.send(monitorFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Custom field with this name already exist'
@@ -137,14 +137,14 @@ describe('Monitor Custom Field API', function() {
});
});
it('should update a particular monitor custom field in a project', function(done: $TSFixMe) {
it('should update a particular monitor custom field in a project', function (done: $TSFixMe) {
monitorFieldText.fieldName = 'newName';
request
.put(`/monitorCustomField/${projectId}/${monitorCustomFieldId}`)
.send(monitorFieldText)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.fieldName).to.be.equal(
monitorFieldText.fieldName
@@ -156,17 +156,17 @@ describe('Monitor Custom Field API', function() {
});
});
it('should list all the monitor custom fields in a project', function(done: $TSFixMe) {
it('should list all the monitor custom fields in a project', function (done: $TSFixMe) {
// add one more monitor custom field
request
.post(`/monitorCustomField/${projectId}`)
.send(monitorFieldNumber)
.set('Authorization', authorization)
.end(function() {
.end(function () {
request
.get(`/monitorCustomField/${projectId}?skip=0&limit=10`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.count).to.be.equal(2);
expect(res.body.data).to.be.an('array');
@@ -175,11 +175,11 @@ describe('Monitor Custom Field API', function() {
});
});
it('should delete a particular monitor custom field in a project', function(done: $TSFixMe) {
it('should delete a particular monitor custom field in a project', function (done: $TSFixMe) {
request
.delete(`/monitorCustomField/${projectId}/${monitorCustomFieldId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(String(res.body._id)).to.be.equal(
String(monitorCustomFieldId)

View File

@@ -20,35 +20,35 @@ import { createUser } from './utils/userSignUp';
let projectId: $TSFixMe, token: $TSFixMe, userId;
describe('Notification API', function() {
describe('Notification API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -58,7 +58,7 @@ describe('Notification API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -83,20 +83,20 @@ describe('Notification API', function() {
message: 'New Notification',
icon: 'bell',
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();
});
});
it('should get project notifications current user is present in', function(done: $TSFixMe) {
it('should get project notifications current user is present in', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/notification/${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -105,19 +105,19 @@ describe('Notification API', function() {
});
});
it('should not get project notifications current user is not present in', function(done: $TSFixMe) {
it('should not get project notifications current user is not present in', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/notification/${projectData.firstProject._id}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should mark project notification as read', function(done: $TSFixMe) {
it('should mark project notification as read', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/notification/${projectId}`)
@@ -126,13 +126,13 @@ describe('Notification API', function() {
message: 'New Notification',
icon: 'bell',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const notificationId = res.body._id;
request
.put(`/notification/${projectId}/read`)
.set('Authorization', authorization)
.send({ notificationIds: [notificationId] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body).to.include(notificationId);
@@ -141,7 +141,7 @@ describe('Notification API', function() {
});
});
it('should close a notification', function(done: $TSFixMe) {
it('should close a notification', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/notification/${projectId}`)
@@ -150,12 +150,12 @@ describe('Notification API', function() {
message: 'New Notification',
icon: 'bell',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const notificationId = res.body._id;
request
.put(`/notification/${projectId}/${notificationId}/closed`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body._id).to.be.equal(notificationId);
@@ -164,7 +164,7 @@ describe('Notification API', function() {
});
});
it('should mark all project notifications as read', function(done: $TSFixMe) {
it('should mark all project notifications as read', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/notification/${projectId}`)
@@ -173,22 +173,22 @@ describe('Notification API', function() {
message: 'New Notification',
icon: 'bell',
})
.end(function() {
.end(function () {
request
.put(`/notification/${projectId}/readAll`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
});
it('should reject request if the notification param is invalid ', function(done: $TSFixMe) {
it('should reject request if the notification param is invalid ', function (done: $TSFixMe) {
request
.put(`/notification/${projectId}/read`)
.send({ notificationIds: [projectData.fakeProject._id] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});

View File

@@ -47,10 +47,10 @@ const probeServerRequestHeader = ({
});
let probeServerName1: $TSFixMe, probeServerName2: $TSFixMe;
describe('Probe API', function() {
describe('Probe API', function () {
this.timeout(20000);
before(async function() {
before(async function () {
this.timeout(40000);
await GlobalConfig.initTestConfig();
// remove every monitor in DB
@@ -84,7 +84,7 @@ describe('Probe API', function() {
return Promise.resolve();
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProbeService.hardDeleteBy({ _id: probeId });
await ProjectService.hardDeleteBy({ _id: projectId });
@@ -110,7 +110,7 @@ describe('Probe API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should add a probe by admin', function(done: $TSFixMe) {
it('should add a probe by admin', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const probeName = generateRandomString();
request
@@ -120,7 +120,7 @@ describe('Probe API', function() {
probeName: probeName,
probeKey: probeKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
probeId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.probeName).to.be.equal(probeName);
@@ -128,28 +128,28 @@ describe('Probe API', function() {
});
});
it('should not add a probe if not admin', function(done: $TSFixMe) {
it('should not add a probe if not admin', function (done: $TSFixMe) {
const probeName = generateRandomString();
createUser(request, userData.newUser, function(
createUser(request, userData.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const authorization = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.post('/probe/')
@@ -158,9 +158,9 @@ describe('Probe API', function() {
probeName: probeName,
probeKey: '',
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
done();
@@ -171,7 +171,7 @@ describe('Probe API', function() {
});
});
it('should reject a probe if same name already exists', function(done: $TSFixMe) {
it('should reject a probe if same name already exists', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const probeName = generateRandomString();
request
@@ -181,7 +181,7 @@ describe('Probe API', function() {
probeName: probeName,
probeKey: probeKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
request
.post('/probe/')
@@ -190,26 +190,26 @@ describe('Probe API', function() {
probeName: probeName,
probeKey: probeKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
});
it('should get probes', function(done: $TSFixMe) {
it('should get probes', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/probe/')
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should delete a probe by admin', function(done: $TSFixMe) {
it('should delete a probe by admin', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const probeName = generateRandomString();
request
@@ -219,21 +219,21 @@ describe('Probe API', function() {
probeName: probeName,
probeKey: probeKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
probeId = res.body._id;
expect(res).to.have.status(200);
request
.delete(`/probe/${probeId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
});
it('should add to the database the unknown probe servers requesting the list of monitor to ping.', async function() {
it('should add to the database the unknown probe servers requesting the list of monitor to ping.', async function () {
probeServerName1 = generateRandomString();
const res = await request.get('/probe/monitors').set(
probeServerRequestHeader({
@@ -252,7 +252,7 @@ describe('Probe API', function() {
expect(probe).to.not.eql(null);
});
it('should return the list of monitors of type "server-monitor" only time for one probe server during an interval of 1 min ', async function() {
it('should return the list of monitors of type "server-monitor" only time for one probe server during an interval of 1 min ', async function () {
this.timeout(100000);
const monitor = await MonitorService.create({
projectId,
@@ -334,7 +334,7 @@ describe('Probe API', function() {
await MonitorService.hardDeleteBy({ _id: monitor._id });
});
it('should return the list of monitors of type "url" only 1 time for every probe server during an interval of 1 min', async function() {
it('should return the list of monitors of type "url" only 1 time for every probe server during an interval of 1 min', async function () {
this.timeout(100000);
const monitor = await MonitorService.create({
projectId,
@@ -417,7 +417,7 @@ describe('Probe API', function() {
await MonitorService.hardDeleteBy({ _id: monitor._id });
});
it('should get application securities yet to be scanned or scanned 24hrs ago', function(done: $TSFixMe) {
it('should get application securities yet to be scanned or scanned 24hrs ago', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const probeName = 'US';
const probeKey = '33b674ca-9fdd-11e9-a2a3-2a2ae2dbccez';
@@ -427,7 +427,7 @@ describe('Probe API', function() {
gitUsername: gitCredential.gitUsername,
gitPassword: gitCredential.gitPassword,
projectId,
}).then(function(credential) {
}).then(function (credential) {
const data = {
name: 'Test',
gitRepositoryUrl: gitCredential.gitRepositoryUrl,
@@ -439,7 +439,7 @@ describe('Probe API', function() {
.post(`/security/${projectId}/${componentId}/application`)
.set('Authorization', authorization)
.send(data)
.end(function() {
.end(function () {
request
.get('/probe/applicationSecurities')
.set({
@@ -447,7 +447,7 @@ describe('Probe API', function() {
probeKey,
clusterKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();
@@ -456,7 +456,7 @@ describe('Probe API', function() {
});
});
it('should get container securities yet to be scanned or scanned 24hrs ago', function(done: $TSFixMe) {
it('should get container securities yet to be scanned or scanned 24hrs ago', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const probeName = 'US';
const probeKey = '33b674ca-9fdd-11e9-a2a3-2a2ae2dbccez';
@@ -467,7 +467,7 @@ describe('Probe API', function() {
dockerUsername: dockerCredential.dockerUsername,
dockerPassword: dockerCredential.dockerPassword,
projectId,
}).then(function(credential) {
}).then(function (credential) {
const data = {
name: 'Test',
dockerCredential: credential._id,
@@ -479,7 +479,7 @@ describe('Probe API', function() {
.post(`/security/${projectId}/${componentId}/container`)
.set('Authorization', authorization)
.send(data)
.end(function() {
.end(function () {
request
.get('/probe/containerSecurities')
.set({
@@ -487,7 +487,7 @@ describe('Probe API', function() {
probeKey,
clusterKey,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();

View File

@@ -34,35 +34,35 @@ const startDate = moment()
.format('YYYY-MM-DD');
const filter = 'month';
describe('Reports API', function() {
describe('Reports API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
ComponentModel.create({
@@ -75,9 +75,9 @@ describe('Reports API', function() {
...monitor,
componentId: component._id,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
done();
@@ -90,7 +90,7 @@ describe('Reports API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -116,7 +116,7 @@ describe('Reports API', function() {
`/reports/${projectId}/active-members?startDate=${startDate}&&endDate=${endDate}&&skip=0&&limit=10`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -132,7 +132,7 @@ describe('Reports API', function() {
`/reports/${projectId}/active-monitors?startDate=${startDate}&&endDate=${endDate}&&skip=0&&limit=10`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -148,7 +148,7 @@ describe('Reports API', function() {
`/reports/${projectId}/average-resolved?startDate=${startDate}&&endDate=${endDate}&&filter=${filter}`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();
@@ -162,7 +162,7 @@ describe('Reports API', function() {
`/reports/${projectId}/incidents?startDate=${startDate}&&endDate=${endDate}&&filter=${filter}`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();

View File

@@ -20,34 +20,34 @@ import VerificationTokenModel from '../backend/models/verificationToken';
let token: $TSFixMe, projectId: $TSFixMe, scheduleId: $TSFixMe, userId;
describe('Schedule API', function() {
describe('Schedule API', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -57,7 +57,7 @@ describe('Schedule API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ScheduleService.hardDeleteBy({ _id: scheduleId });
await AirtableService.deleteAll({ tableName: 'User' });
@@ -65,19 +65,19 @@ describe('Schedule API', function() {
// 'post /schedule/:projectId/create'
it('should reject the request of an unauthenticated user', function(done: $TSFixMe) {
it('should reject the request of an unauthenticated user', function (done: $TSFixMe) {
request
.post(`/schedule/${projectId}`)
.send({
name: 'New Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should not create a schedule when the `name` field is null', function(done: $TSFixMe) {
it('should not create a schedule when the `name` field is null', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/schedule/${projectId}`)
@@ -85,13 +85,13 @@ describe('Schedule API', function() {
.send({
name: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create a new schedule when `name` is given by an authenticated user', function(done: $TSFixMe) {
it('should create a new schedule when `name` is given by an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/schedule/${projectId}`)
@@ -99,7 +99,7 @@ describe('Schedule API', function() {
.send({
name: 'Valid Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
scheduleId = res.body._id;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -107,12 +107,12 @@ describe('Schedule API', function() {
});
});
it('should get schedules for an authenticated user', function(done: $TSFixMe) {
it('should get schedules for an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/schedule/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -121,7 +121,7 @@ describe('Schedule API', function() {
});
});
it('should rename a schedule when the `projectId` is valid and the `scheduleName` is given', function(done: $TSFixMe) {
it('should rename a schedule when the `projectId` is valid and the `scheduleName` is given', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/schedule/${projectId}/${scheduleId}`)
@@ -129,7 +129,7 @@ describe('Schedule API', function() {
.send({
name: 'Renamed Schedule',
})
.end(function(err: $TSFixMe, response: $TSFixMe) {
.end(function (err: $TSFixMe, response: $TSFixMe) {
scheduleId = response.body[0]._id;
expect(response).to.have.status(200);
expect(response.body).to.be.an('array');
@@ -138,7 +138,7 @@ describe('Schedule API', function() {
});
});
it('should delete a schedule when the `projectId` and `scheduleId` is valid', function(done: $TSFixMe) {
it('should delete a schedule when the `projectId` and `scheduleId` is valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/schedule/${projectId}`)
@@ -146,11 +146,11 @@ describe('Schedule API', function() {
.send({
name: 'Delete Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
request
.delete(`/schedule/${projectId}/${res.body._id}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, response: $TSFixMe) {
.end(function (err: $TSFixMe, response: $TSFixMe) {
expect(response).to.have.status(200);
ScheduleService.hardDeleteBy({ _id: res.body._id });
done();
@@ -164,28 +164,28 @@ let subProjectId: $TSFixMe,
newUserToken: $TSFixMe,
subProjectScheduleId: $TSFixMe;
describe('Schedule API with Sub-Projects', function() {
describe('Schedule API with Sub-Projects', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
const authorization = `Basic ${token}`;
// create a subproject for parent project
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.initTestConfig().then(function () {
request
.post(`/project/${projectId}/subProject`)
.set('Authorization', authorization)
.send({ subProjectName: 'New SubProject' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
subProjectId = res.body[0]._id;
// sign up second user (subproject user)
createUser(request, userData.newUser, function(
createUser(request, userData.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
VerificationTokenModel.findOne(
{ userId: res.body.id },
function(
function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -194,7 +194,7 @@ describe('Schedule API with Sub-Projects', function() {
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
@@ -202,9 +202,9 @@ describe('Schedule API with Sub-Projects', function() {
password:
userData.newUser.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
newUserToken =
res.body.tokens
@@ -225,7 +225,7 @@ describe('Schedule API with Sub-Projects', function() {
.email,
role: 'Member',
})
.end(function() {
.end(function () {
done();
});
});
@@ -237,7 +237,7 @@ describe('Schedule API with Sub-Projects', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, subProjectId] },
@@ -253,26 +253,26 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should not create a schedule for user not present in project', function(done: $TSFixMe) {
createUser(request, userData.anotherUser, function(
it('should not create a schedule for user not present in project', function (done: $TSFixMe) {
createUser(request, userData.anotherUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
VerificationTokenModel.findOne({ userId: res.body.id }, function(
VerificationTokenModel.findOne({ userId: res.body.id }, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
request
.get(`/user/confirmation/${res.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.anotherUser.email,
password: userData.anotherUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const authorization = `Basic ${res.body.tokens.jwtAccessToken}`;
request
.post(`/schedule/${projectId}`)
@@ -280,9 +280,9 @@ describe('Schedule API with Sub-Projects', function() {
.send({
name: 'Valid Schedule',
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -296,7 +296,7 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should not create a schedule for user that is not `admin` in sub-project.', function(done: $TSFixMe) {
it('should not create a schedule for user that is not `admin` in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.post(`/schedule/${subProjectId}`)
@@ -304,7 +304,7 @@ describe('Schedule API with Sub-Projects', function() {
.send({
name: 'Valid Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
"You cannot edit the project because you're not an admin."
@@ -313,7 +313,7 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should create a schedule in parent project by valid admin.', function(done: $TSFixMe) {
it('should create a schedule in parent project by valid admin.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/schedule/${projectId}`)
@@ -321,7 +321,7 @@ describe('Schedule API with Sub-Projects', function() {
.send({
name: 'Valid Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
scheduleId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('Valid Schedule');
@@ -329,7 +329,7 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should create a schedule in parent project by valid admin.', function(done: $TSFixMe) {
it('should create a schedule in parent project by valid admin.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/schedule/${subProjectId}`)
@@ -337,7 +337,7 @@ describe('Schedule API with Sub-Projects', function() {
.send({
name: 'Valid Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
subProjectScheduleId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('Valid Schedule');
@@ -345,12 +345,12 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it("should get only sub-project's schedules for valid sub-project user", function(done: $TSFixMe) {
it("should get only sub-project's schedules for valid sub-project user", function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.get(`/schedule/${subProjectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -360,12 +360,12 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should get both project and sub-project schedule for valid parent project user.', function(done: $TSFixMe) {
it('should get both project and sub-project schedule for valid parent project user.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/schedule/${projectId}/schedules`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body[0]).to.have.property('schedules');
@@ -377,12 +377,12 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should not delete a schedule for user that is not `admin` in sub-project.', function(done: $TSFixMe) {
it('should not delete a schedule for user that is not `admin` in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.delete(`/schedule/${subProjectId}/${subProjectScheduleId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
"You cannot edit the project because you're not an admin."
@@ -391,23 +391,23 @@ describe('Schedule API with Sub-Projects', function() {
});
});
it('should delete sub-project schedule', function(done: $TSFixMe) {
it('should delete sub-project schedule', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/schedule/${subProjectId}/${subProjectScheduleId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should delete project schedule', function(done: $TSFixMe) {
it('should delete project schedule', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/schedule/${projectId}/${scheduleId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});

View File

@@ -52,35 +52,35 @@ const ongoingScheduledEvent = {
monitorDuringEvent: false,
};
describe('Scheduled event API', function() {
describe('Scheduled event API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
userId = res.body.id;
projectId = project._id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
ComponentModel.create({
@@ -98,9 +98,9 @@ describe('Scheduled event API', function() {
},
componentId,
})
.end(async function(
.end(async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
@@ -149,7 +149,7 @@ describe('Scheduled event API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -166,7 +166,7 @@ describe('Scheduled event API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should not create a scheduled event when the fields are null', function(done: $TSFixMe) {
it('should not create a scheduled event when the fields are null', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
@@ -177,13 +177,13 @@ describe('Scheduled event API', function() {
endDate: '',
description: '',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not create a scheduled event when a monitor is selected multiple times', function(done: $TSFixMe) {
it('should not create a scheduled event when a monitor is selected multiple times', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
@@ -192,13 +192,13 @@ describe('Scheduled event API', function() {
...scheduledEvent,
monitors: [monitorId, monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not create a scheduled event when the start date is greater than end date', function(done: $TSFixMe) {
it('should not create a scheduled event when the start date is greater than end date', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
@@ -208,19 +208,19 @@ describe('Scheduled event API', function() {
startDate: '2019-09-11 11:01:52.178',
endDate: '2019-06-26 11:31:53.302',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create a new scheduled event when proper fields are given by an authenticated user', function(done: $TSFixMe) {
it('should create a new scheduled event when proper fields are given by an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
.set('Authorization', authorization)
.send({ ...scheduledEvent, monitors: [monitorId] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
scheduleEventId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal(scheduledEvent.name);
@@ -228,12 +228,12 @@ describe('Scheduled event API', function() {
});
});
it('should get all scheduled events for a project', function(done: $TSFixMe) {
it('should get all scheduled events for a project', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/scheduledEvent/${projectId}/scheduledEvents/all`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
expect(res.body).to.have.length.greaterThan(0);
@@ -241,7 +241,7 @@ describe('Scheduled event API', function() {
});
});
it('should update a scheduled event when scheduledEventId is valid', function(done: $TSFixMe) {
it('should update a scheduled event when scheduledEventId is valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/scheduledEvent/${projectId}/${scheduleEventId}`)
@@ -251,31 +251,31 @@ describe('Scheduled event API', function() {
name: 'updated name',
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.name).to.be.equal('updated name');
done();
});
});
it('should delete a scheduled event when scheduledEventId is valid', function(done: $TSFixMe) {
it('should delete a scheduled event when scheduledEventId is valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/scheduledEvent/${projectId}/${scheduleEventId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should get first 10 scheduled events with data length 10, skip 0, limit 10 and count 12', function(done: $TSFixMe) {
it('should get first 10 scheduled events with data length 10, skip 0, limit 10 and count 12', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/scheduledEvent/${projectId}?skip=0&limit=10`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -297,12 +297,12 @@ describe('Scheduled event API', function() {
});
});
it('should get 2 last scheduled events with data length 2, skip 10, limit 10 and count 12', function(done: $TSFixMe) {
it('should get 2 last scheduled events with data length 2, skip 10, limit 10 and count 12', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/scheduledEvent/${projectId}?skip=10&limit=10`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -324,12 +324,12 @@ describe('Scheduled event API', function() {
});
});
it('should get 0 scheduled events with data length 0, skip 20, limit 10 and count 12', function(done: $TSFixMe) {
it('should get 0 scheduled events with data length 0, skip 20, limit 10 and count 12', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/scheduledEvent/${projectId}?skip=20&limit=10`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -351,18 +351,18 @@ describe('Scheduled event API', function() {
});
});
it('should fetch an onging scheduled event', function(done: $TSFixMe) {
it('should fetch an onging scheduled event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
.set('Authorization', authorization)
.send({ ...ongoingScheduledEvent, monitors: [monitorId] })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
scheduleEventId = res.body._id;
request
.get(`/scheduledEvent/${projectId}/ongoingEvent`)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body.data).to.be.an('array');
expect(String(res.body.data[0]._id)).to.be.equal(
@@ -374,24 +374,24 @@ describe('Scheduled event API', function() {
});
});
describe('User from other project have access to read / write and delete API.', function() {
describe('User from other project have access to read / write and delete API.', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
createUser(request, userData.newUser, function(
createUser(request, userData.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -400,16 +400,16 @@ describe('User from other project have access to read / write and delete API.',
`/user/confirmation/${verificationToken.token}`
)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
token = res.body.tokens.jwtAccessToken;
done();
@@ -421,7 +421,7 @@ describe('User from other project have access to read / write and delete API.',
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -435,41 +435,41 @@ describe('User from other project have access to read / write and delete API.',
});
});
it('should not be able to create new scheduled event', function(done: $TSFixMe) {
it('should not be able to create new scheduled event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}`)
.set('Authorization', authorization)
.send(scheduledEvent)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not be able to delete a scheduled event', function(done: $TSFixMe) {
it('should not be able to delete a scheduled event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/scheduledEvent/${projectId}/${scheduleEventId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not be able to get all scheduled events', function(done: $TSFixMe) {
it('should not be able to get all scheduled events', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/scheduledEvent/${projectId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not be able to update a scheduled event', function(done: $TSFixMe) {
it('should not be able to update a scheduled event', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/scheduledEvent/${projectId}/${scheduleEventId}`)
@@ -478,7 +478,7 @@ describe('User from other project have access to read / write and delete API.',
...scheduledEvent,
name: 'Name update',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});

View File

@@ -64,35 +64,35 @@ const updatedInvestigationNote = {
content: 'Just updated this note',
};
describe('Scheduled Event Note', function() {
describe('Scheduled Event Note', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
userId = res.body.id;
projectId = project._id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
ComponentModel.create({
@@ -110,9 +110,9 @@ describe('Scheduled Event Note', function() {
},
componentId,
})
.end(async function(
.end(async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
@@ -128,9 +128,9 @@ describe('Scheduled Event Note', function() {
...scheduledEvent,
monitors: [monitorId],
})
.end(async function(
.end(async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
scheduledEventId =
res.body._id;
@@ -186,7 +186,7 @@ describe('Scheduled Event Note', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -207,7 +207,7 @@ describe('Scheduled Event Note', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should get all scheduled event notes => internal notes', function(done: $TSFixMe) {
it('should get all scheduled event notes => internal notes', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -215,7 +215,7 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes?type=internal`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.have.property('count');
expect(res.body.count).to.be.a('number');
@@ -224,7 +224,7 @@ describe('Scheduled Event Note', function() {
});
});
it('should get first 10 scheduled event notes for data length 10, skip 0, limit 10 and count 12 => internal notes', function(done: $TSFixMe) {
it('should get first 10 scheduled event notes for data length 10, skip 0, limit 10 and count 12 => internal notes', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -232,7 +232,7 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes?type=internal&skip=0&limit=10`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -253,7 +253,7 @@ describe('Scheduled Event Note', function() {
});
});
it('should get 2 last scheduled events notes with data length 2, skip 10, limit 10 and count 12 => internal notes', function(done: $TSFixMe) {
it('should get 2 last scheduled events notes with data length 2, skip 10, limit 10 and count 12 => internal notes', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -261,7 +261,7 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes?type=internal&skip=10&limit=10`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -282,14 +282,14 @@ describe('Scheduled Event Note', function() {
});
});
it('should create a scheduled event note => internal note', function(done: $TSFixMe) {
it('should create a scheduled event note => internal note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}/${scheduledEventId}/notes`)
.set('Authorization', authorization)
.send(internalNote)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
internalNoteId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.event_state).to.equal(internalNote.event_state);
@@ -297,14 +297,14 @@ describe('Scheduled Event Note', function() {
});
});
it('should create a scheduled event note => investigation note', function(done: $TSFixMe) {
it('should create a scheduled event note => investigation note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}/${scheduledEventId}/notes`)
.set('Authorization', authorization)
.send(investigationNote)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
investigationNoteId = res.body._id;
expect(res).to.have.status(200);
expect(res.body.content).to.equal(investigationNote.content);
@@ -312,33 +312,33 @@ describe('Scheduled Event Note', function() {
});
});
it('should not create a scheduled event note if any of the field is missing', function(done: $TSFixMe) {
it('should not create a scheduled event note if any of the field is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}/${scheduledEventId}/notes`)
.set('Authorization', authorization)
.send({ ...internalNote, event_state: '' })
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});
});
it('should not creat a scheduled event note if type field is not investigation or internal', function(done: $TSFixMe) {
it('should not creat a scheduled event note if type field is not investigation or internal', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/scheduledEvent/${projectId}/${scheduledEventId}/notes`)
.set('Authorization', authorization)
.send({ ...internalNote, type: 'randomType' })
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});
});
it('should update a note => internal note', function(done: $TSFixMe) {
it('should update a note => internal note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -347,7 +347,7 @@ describe('Scheduled Event Note', function() {
)
.set('Authorization', authorization)
.send(updatedInternalNote)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body.event_state).to.equal(
updatedInternalNote.event_state
@@ -356,7 +356,7 @@ describe('Scheduled Event Note', function() {
});
});
it('should update a note => investigation note', function(done: $TSFixMe) {
it('should update a note => investigation note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -365,7 +365,7 @@ describe('Scheduled Event Note', function() {
)
.set('Authorization', authorization)
.send(updatedInvestigationNote)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body.event_state).to.equal(
updatedInvestigationNote.event_state
@@ -374,7 +374,7 @@ describe('Scheduled Event Note', function() {
});
});
it('should not update a note if the scheduled event note does not exist', function(done: $TSFixMe) {
it('should not update a note if the scheduled event note does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const noteId = projectId;
@@ -384,13 +384,13 @@ describe('Scheduled Event Note', function() {
)
.set('Authorization', authorization)
.send(updatedInternalNote)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});
});
it('should delete a scheduled event note => internal note', function(done: $TSFixMe) {
it('should delete a scheduled event note => internal note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -398,14 +398,14 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes/${internalNoteId}`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body._id).to.equal(internalNoteId);
done();
});
});
it('should delete a scheduled event note => investigation note', function(done: $TSFixMe) {
it('should delete a scheduled event note => investigation note', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
@@ -413,14 +413,14 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes/${investigationNoteId}`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body._id).to.equal(investigationNoteId);
done();
});
});
it('should note delete a scheduled event note if it does not exist', function(done: $TSFixMe) {
it('should note delete a scheduled event note if it does not exist', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const noteId = projectId;
@@ -429,7 +429,7 @@ describe('Scheduled Event Note', function() {
`/scheduledEvent/${projectId}/${scheduledEventId}/notes/${noteId}`
)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});

View File

@@ -16,16 +16,16 @@ let token: $TSFixMe,
projectId: $TSFixMe;
describe('Slack API', function() {
describe('Slack API', function () {
this.timeout(20000);
this.beforeAll(function(done: $TSFixMe) {
this.beforeAll(function (done: $TSFixMe) {
this.timeout(30000);
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.initTestConfig().then(function () {
request
.post('/user/signup')
.send(userData.user)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
projectId = res.body.projectId;
request
.post('/user/login')
@@ -33,7 +33,7 @@ describe('Slack API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
done();
});
@@ -41,7 +41,7 @@ describe('Slack API', function() {
});
});
this.afterAll(async function() {
this.afterAll(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -56,24 +56,24 @@ describe('Slack API', function() {
// 'post /slack/:projectId/monitor'
it('The purchase', function(done: $TSFixMe) {
it('The purchase', function (done: $TSFixMe) {
request
.get(`/team/${projectId}/team`)
.send({
name: 'New Schedule',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it.skip('The purchase', function(done: $TSFixMe) {
it.skip('The purchase', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/slack/${projectId}/:teamId`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
done();

View File

@@ -27,38 +27,38 @@ const ssoObject = {
let token: $TSFixMe, userId: $TSFixMe;
describe('SSO API', function() {
describe('SSO API', function () {
this.timeout(300000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.adminUser, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.adminUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.adminUser.email,
password: userData.adminUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
UserService.updateBy(
{ _id: userId },
{ role: 'master-admin' }
).then(function() {
).then(function () {
done();
});
});
@@ -68,7 +68,7 @@ describe('SSO API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ 'users.userId': userId });
await UserService.hardDeleteBy({
@@ -84,47 +84,47 @@ describe('SSO API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
describe('should reject requests from an unauthenticated users', function() {
it('should reject GET requests', function(done: $TSFixMe) {
request.get('/sso').end(function(err: $TSFixMe, res: $TSFixMe) {
describe('should reject requests from an unauthenticated users', function () {
it('should reject GET requests', function (done: $TSFixMe) {
request.get('/sso').end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject POST requests', function(done: $TSFixMe) {
request.post('/sso').end(function(err: $TSFixMe, res: $TSFixMe) {
it('should reject POST requests', function (done: $TSFixMe) {
request.post('/sso').end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject PUT requests', function(done: $TSFixMe) {
it('should reject PUT requests', function (done: $TSFixMe) {
request
.put('/sso/5ea951228877984ea9f47660')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject DELETE requests', function(done: $TSFixMe) {
it('should reject DELETE requests', function (done: $TSFixMe) {
request
.delete('/sso/5ea951228877984ea9f47660')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
});
describe('GET /sso/', function() {
it('should return SSOs list with count', function(done: $TSFixMe) {
describe('GET /sso/', function () {
it('should return SSOs list with count', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/sso')
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -133,12 +133,12 @@ describe('SSO API', function() {
});
});
it('should return SSOs list with count, skip and limit (when skip&limit specified)', function(done: $TSFixMe) {
it('should return SSOs list with count, skip and limit (when skip&limit specified)', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/sso?limit=10&skip=0')
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -150,14 +150,14 @@ describe('SSO API', function() {
});
});
describe('POST /sso', function() {
it('should create a new SSO', function(done: $TSFixMe) {
describe('POST /sso', function () {
it('should create a new SSO', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post('/sso')
.set('Authorization', authorization)
.send(ssoObject)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');
@@ -180,7 +180,7 @@ describe('SSO API', function() {
});
});
it('should not create a new SSO if domaine is not defined', function(done: $TSFixMe) {
it('should not create a new SSO if domaine is not defined', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...ssoObject };
@@ -190,13 +190,13 @@ describe('SSO API', function() {
.post('/sso')
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not create a new SSO if Saml SSO url is not defined', function(done: $TSFixMe) {
it('should not create a new SSO if Saml SSO url is not defined', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...ssoObject };
@@ -206,13 +206,13 @@ describe('SSO API', function() {
.post('/sso')
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not create a new SSO if remote logout url is not defined', function(done: $TSFixMe) {
it('should not create a new SSO if remote logout url is not defined', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...ssoObject };
@@ -222,22 +222,22 @@ describe('SSO API', function() {
.post('/sso')
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
});
describe('DELETE /sso', function() {
it('should delete sso', function(done: $TSFixMe) {
describe('DELETE /sso', function () {
it('should delete sso', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
SsoService.create(ssoObject).then(sso => {
const { _id: ssoId } = sso;
request
.delete(`/sso/${ssoId}`)
.set('Authorization', authorization)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');
@@ -259,8 +259,8 @@ describe('SSO API', function() {
});
});
describe('UPDATE /sso', function() {
it('should update SSO', function(done: $TSFixMe) {
describe('UPDATE /sso', function () {
it('should update SSO', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
SsoService.create(ssoObject).then(sso => {
const { _id: ssoId } = sso;
@@ -273,7 +273,7 @@ describe('SSO API', function() {
.put(`/sso/${ssoId}`)
.set('Authorization', authorization)
.send(updatedSsoObject)
.end(async function(err: $TSFixMe, res: $TSFixMe) {
.end(async function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body[0]).to.be.an('object');
expect(res.body[0].domain).to.equal(

View File

@@ -60,21 +60,21 @@ const scheduledEvent = {
monitorDuringEvent: false,
};
describe('Status API', function() {
describe('Status API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(async function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(async function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
if (err) throw err;
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe
) {
if (err) throw err;
@@ -84,7 +84,7 @@ describe('Status API', function() {
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
@@ -92,7 +92,7 @@ describe('Status API', function() {
.post(`/resourceCategory/${projectId}`)
.set('Authorization', authorization)
.send(resourceCategory)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
resourceCategoryId = res.body._id;
@@ -108,9 +108,9 @@ describe('Status API', function() {
...monitor,
componentId,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
if (err) throw err;
monitorId = res.body._id;
@@ -127,9 +127,9 @@ describe('Status API', function() {
authorization
)
.send(scheduledEvent)
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
if (err) throw err;
scheduledEventId =
@@ -148,7 +148,7 @@ describe('Status API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await MonitorService.hardDeleteBy({ _id: monitorId });
await ScheduledEventService.hardDeleteBy({ _id: scheduledEventId });
@@ -157,7 +157,7 @@ describe('Status API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should not add status page if the page name is missing', function(done: $TSFixMe) {
it('should not add status page if the page name is missing', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/status-page/${projectId}`)
@@ -169,14 +169,14 @@ describe('Status API', function() {
copyright: 'status copyright',
projectId,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
});
});
it('should add status page', function(done: $TSFixMe) {
it('should add status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/status-page/${projectId}`)
@@ -202,7 +202,7 @@ describe('Status API', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
statusPageId = res.body._id;
expect(res).to.have.status(200);
@@ -211,7 +211,7 @@ describe('Status API', function() {
});
});
it('should add private status page', function(done: $TSFixMe) {
it('should add private status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/status-page/${projectId}`)
@@ -238,7 +238,7 @@ describe('Status API', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
privateStatusPageId = res.body._id;
expect(res).to.have.status(200);
@@ -249,12 +249,12 @@ describe('Status API', function() {
});
});
it('should get private status page for authorized user', function(done: $TSFixMe) {
it('should get private status page for authorized user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/status-page/${privateStatusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -262,29 +262,29 @@ describe('Status API', function() {
});
});
it('should get valid private status page rss for authorized user', function(done: $TSFixMe) {
it('should get valid private status page rss for authorized user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/status-page/${privateStatusPageId}/rss`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
});
});
it('should not get private status page for unauthorized user', function(done: $TSFixMe) {
it('should not get private status page for unauthorized user', function (done: $TSFixMe) {
request
.get(`/status-page/${privateStatusPageId}`)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(401);
done();
});
});
it('should not update status page settings when domain is not string', function(done: $TSFixMe) {
it('should not update status page settings when domain is not string', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
@@ -292,14 +292,14 @@ describe('Status API', function() {
.send({
domain: 5,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
});
});
it('should not update status page settings when domain is not valid', function(done: $TSFixMe) {
it('should not update status page settings when domain is not valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
@@ -307,14 +307,14 @@ describe('Status API', function() {
.send({
domain: 'wwwtest',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
});
});
it('should update status page settings', function(done: $TSFixMe) {
it('should update status page settings', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put(`/status-page/${projectId}`)
@@ -341,20 +341,20 @@ describe('Status API', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
});
});
it('should return monitor category with monitors in status page data', function(done: $TSFixMe) {
it('should return monitor category with monitors in status page data', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/status-page/${statusPageId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res).to.be.an('object');
@@ -372,13 +372,13 @@ describe('Status API', function() {
});
});
it('should get list of scheduled events', function(done: $TSFixMe) {
it('should get list of scheduled events', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/status-page/${projectId}/${statusPageId}/events`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res).to.be.an('object');
@@ -391,7 +391,7 @@ describe('Status API', function() {
});
});
it('should get list of scheduled events for monitor', function(done: $TSFixMe) {
it('should get list of scheduled events for monitor', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(
@@ -399,7 +399,7 @@ describe('Status API', function() {
)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res).to.be.an('object');
@@ -412,7 +412,7 @@ describe('Status API', function() {
});
});
it('should get list of logs for a monitor', function(done: $TSFixMe) {
it('should get list of logs for a monitor', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
monitorLogService
.create({
@@ -429,7 +429,7 @@ describe('Status API', function() {
.send({
responseTime: true,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res).to.be.an('object');
@@ -440,28 +440,28 @@ describe('Status API', function() {
});
});
it('should create a domain', function(done: $TSFixMe) {
it('should create a domain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'oneuptimeapp.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
});
});
it('should create a domain with subdomain', function(done: $TSFixMe) {
it('should create a domain with subdomain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.oneuptimeapp.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
@@ -471,7 +471,7 @@ describe('Status API', function() {
// The placement of this test case is very important
// a domain needs to be created before verifying it
it('should verify a domain', function(done: $TSFixMe) {
it('should verify a domain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const domain = 'oneuptimeapp.com';
const verificationToken = 'm2ab5osUmz9Y7Ko';
@@ -479,12 +479,12 @@ describe('Status API', function() {
DomainVerificationService.updateOneBy(
{ domain },
{ verificationToken }
).then(function({ _id: domainId, verificationToken }) {
).then(function ({ _id: domainId, verificationToken }) {
request
.put(`/domainVerificationToken/${projectId}/verify/${domainId}`)
.set('Authorization', authorization)
.send({ domain, verificationToken })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body.verified).to.be.true;
@@ -493,14 +493,14 @@ describe('Status API', function() {
});
});
it('should verify a domain and fetch a status page', function(done: $TSFixMe) {
it('should verify a domain and fetch a status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.x.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
const domain = 'status.x.com';
@@ -508,11 +508,11 @@ describe('Status API', function() {
DomainVerificationService.updateOneBy(
{ domain },
{ verified: true }
).then(function() {
).then(function () {
request
.get(`/status-page/null?url=${domain}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body._id).to.be.equal(statusPageId);
@@ -522,21 +522,21 @@ describe('Status API', function() {
});
});
it('should NOT fetch status page of unverfied domain', function(done: $TSFixMe) {
it('should NOT fetch status page of unverfied domain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.y.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
const domain = 'status.y.com';
request
.get(`/status-page/null?url=${domain}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -547,7 +547,7 @@ describe('Status API', function() {
});
});
it('should not verify a domain if txt record is not found', function(done: $TSFixMe) {
it('should not verify a domain if txt record is not found', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const domain = 'oneuptimeapp.com';
const verificationToken = 'thistokenwillnotwork';
@@ -555,12 +555,12 @@ describe('Status API', function() {
DomainVerificationService.updateOneBy(
{ domain },
{ verificationToken, verified: false, verifiedAt: null }
).then(function({ _id: domainId, verificationToken }) {
).then(function ({ _id: domainId, verificationToken }) {
request
.put(`/domainVerificationToken/${projectId}/verify/${domainId}`)
.set('Authorization', authorization)
.send({ domain, verificationToken })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -568,7 +568,7 @@ describe('Status API', function() {
});
});
it('should not verify a domain that does not exist on the web', function(done: $TSFixMe) {
it('should not verify a domain that does not exist on the web', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const domain = 'binoehty1234hgyt.com';
const selectDomainVerify =
@@ -578,19 +578,19 @@ describe('Status API', function() {
];
StatusService.createDomain(domain, projectId, statusPageId).then(
function() {
function () {
DomainVerificationService.findOneBy({
query: { domain },
select: selectDomainVerify,
populate: populateDomainVerify,
}).then(function({ domain, verificationToken, _id: domainId }) {
}).then(function ({ domain, verificationToken, _id: domainId }) {
request
.put(
`/domainVerificationToken/${projectId}/verify/${domainId}`
)
.set('Authorization', authorization)
.send({ domain, verificationToken })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -600,14 +600,14 @@ describe('Status API', function() {
);
});
it('should not save domain if domain is invalid', function(done: $TSFixMe) {
it('should not save domain if domain is invalid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.oneuptime.hackerbay' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -617,7 +617,7 @@ describe('Status API', function() {
// this is no longer the case
// array of domain are no longer used in the application
it.skip('should save an array of valid domains', function(done: $TSFixMe) {
it.skip('should save an array of valid domains', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
domain: [
@@ -629,7 +629,7 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
@@ -639,7 +639,7 @@ describe('Status API', function() {
// this is no longer the case
// array of domain are no longer used in the application
it.skip('should not save domains if one domain in the array is invalid', function(done: $TSFixMe) {
it.skip('should not save domains if one domain in the array is invalid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = {
domain: [
@@ -651,35 +651,35 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
});
});
it('should save when domain is without subdomain', function(done: $TSFixMe) {
it('should save when domain is without subdomain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'oneuptime.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
});
});
it('should reject adding an existing domain', function(done: $TSFixMe) {
it('should reject adding an existing domain', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.oneuptimeapp.com' };
request
.put(`/status-page/${projectId}/${statusPageId}/domain`)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -689,14 +689,14 @@ describe('Status API', function() {
// This test will work base on the fact that a domain was previously created in another project
// This test will try to create another domain with the same domain on another project
it('should add domain if it exist in another project and if the domain in other project is NOT verified.', function(done: $TSFixMe) {
it('should add domain if it exist in another project and if the domain in other project is NOT verified.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'oneuptimeapp.com' };
request
.post(`/project/create`)
.set('Authorization', authorization)
.send(project.newProject)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
const newProjectId = res.body._id;
request
@@ -711,7 +711,7 @@ describe('Status API', function() {
projectId,
monitorIds: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
const newStatusPageId = res.body._id;
request
@@ -720,7 +720,7 @@ describe('Status API', function() {
)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(
@@ -735,14 +735,14 @@ describe('Status API', function() {
});
});
it('should NOT add domain if it exist in another project and domain in other project is verified', function(done: $TSFixMe) {
it('should NOT add domain if it exist in another project and domain in other project is verified', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'status.x.com' };
request
.post(`/project/create`)
.set('Authorization', authorization)
.send(project.newSecondProject)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
const newProjectId = res.body._id;
request
@@ -757,7 +757,7 @@ describe('Status API', function() {
projectId,
monitorIds: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
const newStatusPageId = res.body._id;
request
@@ -766,7 +766,7 @@ describe('Status API', function() {
)
.set('Authorization', authorization)
.send(data)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
expect(res.body.message).to.be.equals(
@@ -782,7 +782,7 @@ describe('Status API', function() {
// check for when the domain in statuspage is updated
// check for when domainverificationtoken is updated
it('should update a domain on a status page successfully', function(done: $TSFixMe) {
it('should update a domain on a status page successfully', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: 'app.oneuptimeapp.com' };
@@ -794,7 +794,7 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.send(data)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(200);
done();
@@ -802,7 +802,7 @@ describe('Status API', function() {
});
});
it('should not update a domain on a status page if the domain field is empty', function(done: $TSFixMe) {
it('should not update a domain on a status page if the domain field is empty', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: '' };
@@ -814,7 +814,7 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.send(data)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -822,7 +822,7 @@ describe('Status API', function() {
});
});
it('should not update a domain on a status page if the domain is not a string', function(done: $TSFixMe) {
it('should not update a domain on a status page if the domain is not a string', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: { url: 'shop.oneuptimeapp.com' } };
@@ -834,7 +834,7 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.send(data)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -842,7 +842,7 @@ describe('Status API', function() {
});
});
it('should not update a domain on a status page if the status page is missing or not found', function(done: $TSFixMe) {
it('should not update a domain on a status page if the status page is missing or not found', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const data = { domain: { url: 'shop.oneuptimeapp.com' } };
@@ -856,7 +856,7 @@ describe('Status API', function() {
.put(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.send(data)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -864,7 +864,7 @@ describe('Status API', function() {
});
});
it('should delete a domain from a status page', function(done: $TSFixMe) {
it('should delete a domain from a status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
StatusService.findOneBy({ _id: statusPageId }).then(statusPage => {
// select the first domain
@@ -873,7 +873,7 @@ describe('Status API', function() {
request
.delete(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(200);
done();
@@ -881,7 +881,7 @@ describe('Status API', function() {
});
});
it('should not delete any domain if status page does not exist or not found', function(done: $TSFixMe) {
it('should not delete any domain if status page does not exist or not found', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
StatusService.findOneBy({ _id: statusPageId }).then(statusPage => {
// select the first domain
@@ -892,7 +892,7 @@ describe('Status API', function() {
request
.delete(`/status-page/${projectId}/${statusPageId}/${domainId}`)
.set('Authorization', authorization)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
if (err) throw err;
expect(res).to.have.status(400);
done();
@@ -907,30 +907,30 @@ let subProjectId: $TSFixMe,
anotherUserToken: $TSFixMe,
subProjectStatusPageId: $TSFixMe;
describe('StatusPage API with Sub-Projects', function() {
describe('StatusPage API with Sub-Projects', function () {
this.timeout(30000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
const authorization = `Basic ${token}`;
GlobalConfig.initTestConfig().then(function() {
GlobalConfig.initTestConfig().then(function () {
// create a subproject for parent project
request
.post(`/project/${projectId}/subProject`)
.set('Authorization', authorization)
.send({ subProjectName: 'New SubProject' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
subProjectId = res.body[0]._id;
// sign up second user (subproject user)
createUser(request, userData.newUser, function() {
createUser(request, userData.newUser, function () {
request
.post('/user/login')
.send({
email: userData.newUser.email,
password: userData.newUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
newUserToken = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
@@ -942,7 +942,7 @@ describe('StatusPage API with Sub-Projects', function() {
emails: userData.newUser.email,
role: 'Member',
})
.end(function() {
.end(function () {
done();
});
});
@@ -951,7 +951,7 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
after(async function() {
after(async function () {
await ProjectService.hardDeleteBy({
_id: { $in: [projectId, subProjectId] },
});
@@ -967,15 +967,15 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should not create a statupage for user not present in project', function(done: $TSFixMe) {
createUser(request, userData.anotherUser, function() {
it('should not create a statupage for user not present in project', function (done: $TSFixMe) {
createUser(request, userData.anotherUser, function () {
request
.post('/user/login')
.send({
email: userData.anotherUser.email,
password: userData.anotherUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
anotherUserToken = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${anotherUserToken}`;
@@ -1002,7 +1002,7 @@ describe('StatusPage API with Sub-Projects', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -1014,19 +1014,19 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should not get private status page for authorized user that is not in project', function(done: $TSFixMe) {
it('should not get private status page for authorized user that is not in project', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.get(`/status-page/${privateStatusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
done();
});
});
it('should not create a statusPage for user that is not `admin` in sub-project.', function(done: $TSFixMe) {
it('should not create a statusPage for user that is not `admin` in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.post(`/status-page/${subProjectId}`)
@@ -1051,7 +1051,7 @@ describe('StatusPage API with Sub-Projects', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -1061,7 +1061,7 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should create a statusPage in parent project by valid admin.', function(done: $TSFixMe) {
it('should create a statusPage in parent project by valid admin.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/status-page/${projectId}`)
@@ -1088,7 +1088,7 @@ describe('StatusPage API with Sub-Projects', function() {
],
domains: [],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
statusPageId = res.body._id;
expect(res).to.have.status(200);
@@ -1097,7 +1097,7 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should create a statusPage in sub-project by valid admin.', function(done: $TSFixMe) {
it('should create a statusPage in sub-project by valid admin.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/status-page/${subProjectId}`)
@@ -1123,7 +1123,7 @@ describe('StatusPage API with Sub-Projects', function() {
},
],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
subProjectStatusPageId = res.body._id;
expect(res).to.have.status(200);
@@ -1132,12 +1132,12 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it("should get only sub-project's statuspages for valid sub-project user", function(done: $TSFixMe) {
it("should get only sub-project's statuspages for valid sub-project user", function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.get(`/status-page/${subProjectId}/statuspage`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -1148,12 +1148,12 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should get both project and sub-project statuspage for valid parent project user.', function(done: $TSFixMe) {
it('should get both project and sub-project statuspage for valid parent project user.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/status-page/${projectId}/statuspages`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
@@ -1166,7 +1166,7 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should get status page for viewer in sub-project', function(done: $TSFixMe) {
it('should get status page for viewer in sub-project', function (done: $TSFixMe) {
const authorization = `Basic ${anotherUserToken}`;
request
.post(`/team/${subProjectId}`)
@@ -1175,11 +1175,11 @@ describe('StatusPage API with Sub-Projects', function() {
emails: userData.anotherUser.email,
role: 'Viewer',
})
.end(function() {
.end(function () {
request
.get(`/status-page/${subProjectStatusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
@@ -1189,12 +1189,12 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should not delete a status page for user that is not `admin` in sub-project.', function(done: $TSFixMe) {
it('should not delete a status page for user that is not `admin` in sub-project.', function (done: $TSFixMe) {
const authorization = `Basic ${newUserToken}`;
request
.delete(`/status-page/${subProjectId}/${subProjectStatusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
@@ -1204,24 +1204,24 @@ describe('StatusPage API with Sub-Projects', function() {
});
});
it('should delete sub-project status page', function(done: $TSFixMe) {
it('should delete sub-project status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/status-page/${subProjectId}/${subProjectStatusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();
});
});
it('should delete parent project status page', function(done: $TSFixMe) {
it('should delete parent project status page', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/status-page/${projectId}/${statusPageId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) throw err;
expect(res).to.have.status(200);
done();

View File

@@ -21,35 +21,35 @@ import VerificationTokenModel from '../backend/models/verificationToken';
let cardId: $TSFixMe, authorization: $TSFixMe;
describe('Stripe payment API', function() {
describe('Stripe payment API', function () {
this.timeout(50000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
authorization = `Basic ${token}`;
done();
@@ -60,7 +60,7 @@ describe('Stripe payment API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -75,11 +75,11 @@ describe('Stripe payment API', function() {
await AirtableService.deleteAll({ tableName: 'User' });
});
it('should sign up and a transaction of 1 $ should be made', function(done: $TSFixMe) {
it('should sign up and a transaction of 1 $ should be made', function (done: $TSFixMe) {
request
.get(`/stripe/${userId}/charges`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -93,11 +93,11 @@ describe('Stripe payment API', function() {
});
});
it('should return payment intent when valid details are passed ', function(done: $TSFixMe) {
it('should return payment intent when valid details are passed ', function (done: $TSFixMe) {
request
.post(`/stripe/${userId}/creditCard/${'tok_amex'}/pi`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
cardId = res.body.source;
expect(res).to.have.status(200);
expect(res.body).to.have.property('id');
@@ -109,11 +109,11 @@ describe('Stripe payment API', function() {
});
});
it('should return 2 cards attached to customer', function(done: $TSFixMe) {
it('should return 2 cards attached to customer', function (done: $TSFixMe) {
request
.get(`/stripe/${userId}/creditCard`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -122,11 +122,11 @@ describe('Stripe payment API', function() {
});
});
it('should update default card for customer', function(done: $TSFixMe) {
it('should update default card for customer', function (done: $TSFixMe) {
request
.put(`/stripe/${userId}/creditCard/${cardId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('default_source');
@@ -135,11 +135,11 @@ describe('Stripe payment API', function() {
});
});
it('should return 2 cards attached to customer', function(done: $TSFixMe) {
it('should return 2 cards attached to customer', function (done: $TSFixMe) {
request
.get(`/stripe/${userId}/creditCard`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('data');
expect(res.body.data).to.be.an('array');
@@ -148,11 +148,11 @@ describe('Stripe payment API', function() {
});
});
it('should fetch a single card', function(done: $TSFixMe) {
it('should fetch a single card', function (done: $TSFixMe) {
request
.get(`/stripe/${userId}/creditCard/${cardId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('id');
@@ -163,11 +163,11 @@ describe('Stripe payment API', function() {
});
});
it('should delete a card', function(done: $TSFixMe) {
it('should delete a card', function (done: $TSFixMe) {
request
.delete(`/stripe/${userId}/creditCard/${cardId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('id');
@@ -176,16 +176,16 @@ describe('Stripe payment API', function() {
});
});
it('should not delete a single left card', function(done: $TSFixMe) {
it('should not delete a single left card', function (done: $TSFixMe) {
request
.get(`/stripe/${userId}/creditCard`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
cardId = res.body.data[0].id;
request
.delete(`/stripe/${userId}/creditCard/${cardId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(403);
expect(res.body.message).to.be.equal(
'Cannot delete the only card'
@@ -195,11 +195,11 @@ describe('Stripe payment API', function() {
});
});
it('should not create a payment intent when token(generated from client) is invalid', function(done: $TSFixMe) {
it('should not create a payment intent when token(generated from client) is invalid', function (done: $TSFixMe) {
request
.post(`/stripe/${userId}/creditCard/${'tok_invalid'}/pi`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
"No such token: 'tok_invalid'"
@@ -208,14 +208,14 @@ describe('Stripe payment API', function() {
});
});
it('should not add balance to customer accounts if rechargeBalanceAmount is not a valid integer', function(done: $TSFixMe) {
it('should not add balance to customer accounts if rechargeBalanceAmount is not a valid integer', function (done: $TSFixMe) {
request
.post(`/stripe/${projectId}/addBalance`)
.set('Authorization', authorization)
.send({
rechargeBalanceAmount: '43_',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.be.equal(
'Amount should be present and it should be a valid number.'
@@ -224,14 +224,14 @@ describe('Stripe payment API', function() {
});
});
it('should return payment intent if rechargeBalanceAmount is a valid integer', function(done: $TSFixMe) {
it('should return payment intent if rechargeBalanceAmount is a valid integer', function (done: $TSFixMe) {
request
.post(`/stripe/${projectId}/addBalance`)
.set('Authorization', authorization)
.send({
rechargeBalanceAmount: '100',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.have.property('id');
expect(res.body).to.have.property('client_secret');

View File

@@ -55,34 +55,34 @@ const csvData = {
],
};
describe('Subscriber API', function() {
describe('Subscriber API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
ComponentModel.create({
@@ -96,9 +96,9 @@ describe('Subscriber API', function() {
...monitor,
componentId,
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
expect(
@@ -123,9 +123,9 @@ describe('Subscriber API', function() {
projectId,
monitorIds: [monitorId],
})
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
statusPageId =
res.body._id;
@@ -175,7 +175,7 @@ describe('Subscriber API', function() {
method: 'email',
},
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
subscriberId = res.body[0]._id;
expect(res).to.have.status(200);
expect(res.body).to.be.an('array');
@@ -192,7 +192,7 @@ describe('Subscriber API', function() {
.send({
monitorIds: monitorId,
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});
@@ -201,7 +201,7 @@ describe('Subscriber API', function() {
it('should get list of subscribers to a project', (done: $TSFixMe) => {
request
.get(`/subscriber/${projectId}`)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -213,7 +213,7 @@ describe('Subscriber API', function() {
it('should get list of subscribers to a monitorId', (done: $TSFixMe) => {
request
.get(`/subscriber/${projectId}/monitor/${monitorId}`)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -225,19 +225,19 @@ describe('Subscriber API', function() {
it('should get a subscriber', (done: $TSFixMe) => {
request
.get(`/subscriber/${projectId}/${subscriberId}`)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();
});
});
it('should delete a subscriber', function(done: $TSFixMe) {
it('should delete a subscriber', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/subscriber/${projectId}/${subscriberId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
@@ -247,7 +247,7 @@ describe('Subscriber API', function() {
request
.post(`/subscriber/${projectId}/${monitorId}/csv`)
.send(csvData)
.end((_err: $TSFixMe, res: $TSFixMe) => {
.end((_err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.have.lengthOf(2);
expect(res.body[0]).to.have.property('_id');
@@ -260,7 +260,7 @@ describe('Subscriber API', function() {
request
.post(`/subscriber/${projectId}/${monitorId}/csv`)
.send(csvData)
.end((_err: $TSFixMe, res: $TSFixMe) => {
.end((_err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body[0]).to.not.have.property('_id');
expect(res.body[0]).to.not.have.property('projectId');
@@ -279,7 +279,7 @@ describe('Subscriber API', function() {
request
.post(`/subscriber/${projectId}/${monitorId}/csv`)
.send(csvData)
.end((_err: $TSFixMe, res: $TSFixMe) => {
.end((_err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body[0]).to.not.have.property('_id');
expect(res.body[0]).to.not.have.property('projectId');
@@ -296,7 +296,7 @@ describe('Subscriber API', function() {
request
.post(`/subscriber/${projectId}/${monitorId}/csv`)
.send(csvData)
.end((_err: $TSFixMe, res: $TSFixMe) => {
.end((_err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
expect(res.body.message).to.equal('Empty files submitted');
done();

View File

@@ -37,43 +37,43 @@ const monitor = {
data: { url: 'http://www.tests.org' },
};
describe('Subcriber Alert API', function() {
describe('Subcriber Alert API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
.post(`/monitor/${projectId}`)
.set('Authorization', authorization)
.send(monitor)
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
incidentData.monitors = [monitorId];
@@ -89,7 +89,7 @@ describe('Subcriber Alert API', function() {
.end(
(
err: $TSFixMe,
res: $TSFixMe
req: Response
) => {
idNumber =
res.body.idNumber; // This has replaced incidentId and is used to query subscriber alert
@@ -142,7 +142,7 @@ describe('Subcriber Alert API', function() {
.post(`/emailSmtp/${projectId}`)
.set('Authorization', authorization)
.send(smtpCredentials)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
request
.post(
@@ -152,7 +152,7 @@ describe('Subcriber Alert API', function() {
alertVia: 'email',
contactEmail: userData.user.email,
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
subscriberId = res.body._id;
request
.post(
@@ -163,7 +163,7 @@ describe('Subcriber Alert API', function() {
alertVia: 'email',
eventType: 'identified',
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body.alertVia).to.be.equal(
@@ -188,7 +188,7 @@ describe('Subcriber Alert API', function() {
alertVia: null,
eventType: 'identified',
})
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(400);
done();
});
@@ -197,7 +197,7 @@ describe('Subcriber Alert API', function() {
it('should get subscriber alerts by projectId', (done: $TSFixMe) => {
request
.get(`/subscriberAlert/${projectId}`)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -209,7 +209,7 @@ describe('Subcriber Alert API', function() {
it('should get subscriber alerts by incidentId', (done: $TSFixMe) => {
request
.get(`/subscriberAlert/${projectId}/incident/${idNumber}`)
.end((err: $TSFixMe, res: $TSFixMe) => {
.end((err: $TSFixMe, req: Response) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
done();

View File

@@ -27,15 +27,15 @@ import { fetchIdpSAMLResponse } from './utils/test-utils';
let projectId: $TSFixMe, userId: $TSFixMe, token: $TSFixMe;
const deleteAccountConfirmation = { deleteMyAccount: 'DELETE MY ACCOUNT' };
describe('User API', function() {
describe('User API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, data.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, data.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
if (err) {
throw err;
@@ -44,7 +44,7 @@ describe('User API', function() {
projectId = project._id;
userId = res.body.id;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
@@ -54,14 +54,14 @@ describe('User API', function() {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: data.user.email,
password: data.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
if (err) {
throw err;
}
@@ -92,10 +92,10 @@ describe('User API', function() {
// 'post /user/signup'
it('should register with name, email, password, companyName, jobRole, referral, companySize, stripeToken, stripePlanId', function(done: $TSFixMe) {
createUser(request, data.newUser, function(
it('should register with name, email, password, companyName, jobRole, referral, companySize, stripeToken, stripePlanId', function (done: $TSFixMe) {
createUser(request, data.newUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(200);
expect(res.body.email).to.equal(data.newUser.email);
@@ -103,41 +103,41 @@ describe('User API', function() {
});
});
it('should not register when name, email, password, companyName, jobRole, referral, companySize, stripePlanId or stripeToken is null', function(done: $TSFixMe) {
createUser(request, data.nullUser, function(
it('should not register when name, email, password, companyName, jobRole, referral, companySize, stripePlanId or stripeToken is null', function (done: $TSFixMe) {
createUser(request, data.nullUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
done();
});
});
it('should not register with same email', function(done: $TSFixMe) {
createUser(request, data.user, function(err: $TSFixMe, res: $TSFixMe) {
it('should not register with same email', function (done: $TSFixMe) {
createUser(request, data.user, function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not register with an invalid email', function(done: $TSFixMe) {
it('should not register with an invalid email', function (done: $TSFixMe) {
const invalidMailUser = Object.assign({}, data.user);
invalidMailUser.email = 'invalidMail';
createUser(request, invalidMailUser, function(
createUser(request, invalidMailUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
done();
});
});
it('should not register with a personal email', function(done: $TSFixMe) {
it('should not register with a personal email', function (done: $TSFixMe) {
const personalMailUser = Object.assign({}, data.user);
personalMailUser.email = 'personalAccount@gmail.com';
createUser(request, personalMailUser, function(
createUser(request, personalMailUser, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(400);
done();
@@ -146,14 +146,14 @@ describe('User API', function() {
// post '/user/login'
it('should not login when email is null', function(done: $TSFixMe) {
it('should not login when email is null', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: null,
password: data.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
@@ -161,46 +161,46 @@ describe('User API', function() {
// post '/user/login'
it('should not login when password is null', function(done: $TSFixMe) {
it('should not login when password is null', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.user.email,
password: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not allow to login with invalid email', function(done: $TSFixMe) {
it('should not allow to login with invalid email', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: 'invalidEmail',
password: data.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not allow to login with invalid password', function(done: $TSFixMe) {
it('should not allow to login with invalid password', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.user.email,
password: {},
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should track IP and other parameters when login in', async function() {
it('should track IP and other parameters when login in', async function () {
const res = await request.post('/user/login').send({
email: data.user.email,
password: data.user.password,
@@ -214,14 +214,14 @@ describe('User API', function() {
expect(log.ipLocation.ip).to.be.equal('::ffff:127.0.0.1');
});
it('should login with valid credentials', function(done: $TSFixMe) {
it('should login with valid credentials', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
email: data.newUser.email,
password: data.newUser.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.email).to.equal(data.newUser.email);
expect(res.body).include.keys('tokens');
@@ -229,7 +229,7 @@ describe('User API', function() {
});
});
it('should login with valid credentials, and return sent redirect url', function(done: $TSFixMe) {
it('should login with valid credentials, and return sent redirect url', function (done: $TSFixMe) {
request
.post('/user/login')
.send({
@@ -237,7 +237,7 @@ describe('User API', function() {
password: data.newUser.password,
redirect: 'http://oneuptime.com',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.email).to.equal(data.newUser.email);
expect(res.body).have.property('redirect');
@@ -246,37 +246,37 @@ describe('User API', function() {
});
});
it('should not accept `/forgot-password` request when email is null', function(done: $TSFixMe) {
it('should not accept `/forgot-password` request when email is null', function (done: $TSFixMe) {
request
.post('/user/forgot-password')
.send({
email: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not accept `/forgot-password` request when email is invalid', function(done: $TSFixMe) {
it('should not accept `/forgot-password` request when email is invalid', function (done: $TSFixMe) {
request
.post('/user/forgot-password')
.send({
email: '(' + data.user.email + ')',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should accept `/forgot-password` request when email is valid', function(done: $TSFixMe) {
it('should accept `/forgot-password` request when email is valid', function (done: $TSFixMe) {
request
.post('/user/forgot-password')
.send({
email: data.newUser.email,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
@@ -284,14 +284,14 @@ describe('User API', function() {
// post '/user/reset-password'
it('should not accept `/user/reset-password` request when token is null', function(done: $TSFixMe) {
it('should not accept `/user/reset-password` request when token is null', function (done: $TSFixMe) {
request
.post('/user/reset-password')
.send({
password: data.user.password,
token: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
@@ -299,27 +299,27 @@ describe('User API', function() {
// post '/user/reset-password'
it('should not accept `/user/reset-password` request when password is null', function(done: $TSFixMe) {
it('should not accept `/user/reset-password` request when password is null', function (done: $TSFixMe) {
request
.post('/user/reset-password')
.send({
password: null,
token: 'randomToken',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should accept `/user/reset-password` request when password and token is valid', function(done: $TSFixMe) {
it('should accept `/user/reset-password` request when password and token is valid', function (done: $TSFixMe) {
request
.post('/user/forgot-password')
.send({
email: data.newUser.email,
})
.end(function() {
UserModel.findOne({ email: data.newUser.email }, function(
.end(function () {
UserModel.findOne({ email: data.newUser.email }, function (
err: $TSFixMe,
user: $TSFixMe
) {
@@ -329,7 +329,7 @@ describe('User API', function() {
password: 'newPassword',
token: user.resetPasswordToken,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
@@ -337,38 +337,38 @@ describe('User API', function() {
});
});
it('should not accept `/isInvited` request when email is null', function(done: $TSFixMe) {
it('should not accept `/isInvited` request when email is null', function (done: $TSFixMe) {
request
.post('/user/isInvited')
.send({
email: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should return a boolean response for the `/isInvited` request', function(done: $TSFixMe) {
it('should return a boolean response for the `/isInvited` request', function (done: $TSFixMe) {
request
.post('/user/isInvited')
.send({
email: data.user.email,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.a('boolean');
done();
});
});
it('should update the profile settings of an authenticated user', function(done: $TSFixMe) {
it('should update the profile settings of an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/profile')
.set('Authorization', authorization)
.send(profile)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');
@@ -378,7 +378,7 @@ describe('User API', function() {
});
});
it('should not change a password when the `currentPassword` field is not valid', function(done: $TSFixMe) {
it('should not change a password when the `currentPassword` field is not valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/changePassword')
@@ -388,13 +388,13 @@ describe('User API', function() {
newPassword: 'abcdefghi',
confirmPassword: 'abcdefghi',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not change a password when the `newPassword` field is not valid', function(done: $TSFixMe) {
it('should not change a password when the `newPassword` field is not valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/changePassword')
@@ -404,13 +404,13 @@ describe('User API', function() {
newPassword: null,
confirmPassword: 'abcdefghi',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not change a password when the `confirmPassword` field is not valid', function(done: $TSFixMe) {
it('should not change a password when the `confirmPassword` field is not valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/changePassword')
@@ -420,13 +420,13 @@ describe('User API', function() {
newPassword: 'abcdefghi',
confirmPassword: null,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should change a password when all fields are valid', function(done: $TSFixMe) {
it('should change a password when all fields are valid', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/changePassword')
@@ -436,19 +436,19 @@ describe('User API', function() {
newPassword: 'abcdefghi',
confirmPassword: 'abcdefghi',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.id).to.be.equal(userId);
done();
});
});
it('should get the profile of an authenticated user', function(done: $TSFixMe) {
it('should get the profile of an authenticated user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get('/user/profile')
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('name');
@@ -458,13 +458,13 @@ describe('User API', function() {
});
});
it('should not update the unverified alert phone number through profile update API', function(done: $TSFixMe) {
it('should not update the unverified alert phone number through profile update API', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.put('/user/profile')
.set('Authorization', authorization)
.send(profile)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res.body._id).to.be.equal(userId);
expect(res.body.alertPhoneNumber).not.to.be.equal(
profile.alertPhoneNumber
@@ -474,35 +474,35 @@ describe('User API', function() {
});
});
it('should not delete account that belongs to another user', function(done: $TSFixMe) {
it('should not delete account that belongs to another user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const anotherUserId = '5ef84e17504ba0deaac459d9';
request
.delete(`/user/${anotherUserId}/delete`)
.set('Authorization', authorization)
.end(function(_err: $TSFixMe, res: $TSFixMe) {
.end(function (_err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should not delete account without confirmation from the user', function(done: $TSFixMe) {
it('should not delete account without confirmation from the user', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/user/${userId}/delete`)
.set('Authorization', authorization)
.end(function(_err: $TSFixMe, res: $TSFixMe) {
.end(function (_err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should generate backup codes when the user tries to generate a QR code.', function(done: $TSFixMe) {
it('should generate backup codes when the user tries to generate a QR code.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/user/totp/token/${userId}`)
.set('Authorization', authorization)
.end(async function(_err: $TSFixMe, res: $TSFixMe) {
.end(async function (_err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
const user = await UserService.findOneBy({
query: { _id: userId },
@@ -515,7 +515,7 @@ describe('User API', function() {
});
});
it('should generate new backup codes.', async function() {
it('should generate new backup codes.', async function () {
const authorization = `Basic ${token}`;
const user = await UserService.updateOneBy(
{ _id: userId },
@@ -534,53 +534,53 @@ describe('User API', function() {
expect(res.body[7].counter).to.eql(15);
});
it('should delete user account and cancel all subscriptions', function(done: $TSFixMe) {
it('should delete user account and cancel all subscriptions', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/user/${userId}/delete`)
.set('Authorization', authorization)
.send(deleteAccountConfirmation)
.end(function(_err: $TSFixMe, res: $TSFixMe) {
.end(function (_err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.user.deleted).to.equal(true);
done();
});
});
it('should not delete account twice', function(done: $TSFixMe) {
it('should not delete account twice', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/user/${userId}/delete`)
.set('Authorization', authorization)
.send(deleteAccountConfirmation)
.end(function(_err: $TSFixMe, res: $TSFixMe) {
.end(function (_err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('Should delete user account and remove user from the project', function(done: $TSFixMe) {
createUser(request, data.anotherUser, function(
it('Should delete user account and remove user from the project', function (done: $TSFixMe) {
createUser(request, data.anotherUser, function (
_err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
const { id: userId } = res.body;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
_err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: data.anotherUser.email,
password: data.anotherUser.password,
})
.end(function(_err: $TSFixMe, res: $TSFixMe) {
.end(function (_err: $TSFixMe, req: Response) {
const accessToken =
res.body.tokens.jwtAccessToken;
const authorization = `Basic ${accessToken}`;
@@ -591,9 +591,9 @@ describe('User API', function() {
emails: data.newUser.email,
role: 'Member',
})
.end(function(
.end(function (
_err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(
res.body[0].team.length
@@ -602,9 +602,9 @@ describe('User API', function() {
.delete(`/user/${userId}/delete`)
.set('Authorization', authorization)
.send(deleteAccountConfirmation)
.end(function(
.end(function (
_err: $TSFixMe,
res: $TSFixMe
req: Response
) {
expect(res).to.have.status(200);
expect(
@@ -622,7 +622,7 @@ describe('User API', function() {
let ssoId: $TSFixMe;
describe('SSO authentication', function() {
describe('SSO authentication', function () {
this.timeout(20000);
before(async () => {
@@ -649,41 +649,41 @@ describe('SSO authentication', function() {
// GET /user/sso/login
it('Should not accept requests without email as query.', function(done: $TSFixMe) {
it('Should not accept requests without email as query.', function (done: $TSFixMe) {
request
.get('/user/sso/login')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('Should not accept requests with invalid email.', function(done: $TSFixMe) {
it('Should not accept requests with invalid email.', function (done: $TSFixMe) {
request
.get('/user/sso/login?email=invalid@email')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it("Should not accept requests with domains that aren't defined in the ssos collection.", function(done: $TSFixMe) {
it("Should not accept requests with domains that aren't defined in the ssos collection.", function (done: $TSFixMe) {
request
.get('/user/sso/login?email=user@inexistant-domain.hackerbay.io')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(404);
done();
});
});
it('Should not accept requests with domains having SSO disabled', function(done: $TSFixMe) {
it('Should not accept requests with domains having SSO disabled', function (done: $TSFixMe) {
SsoModel.updateOne(
{ _id: ssoId },
{ $set: { 'saml-enabled': false } }
).then(() => {
request
.get('/user/sso/login?email=user@tests.hackerbay.io')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
SsoModel.updateOne(
{ _id: ssoId },
@@ -695,7 +695,7 @@ describe('SSO authentication', function() {
});
});
it('Should create a new user and return the login details if the user login successfully', async function() {
it('Should create a new user and return the login details if the user login successfully', async function () {
let userCount = await UserModel.find({
email: 'user1@tests.hackerbay.io',
}).countDocuments();
@@ -746,7 +746,7 @@ describe('SSO authentication', function() {
expect(userCount).to.eql(1);
});
it('Should return the login details if the user exists in the database and login successfully.', async function() {
it('Should return the login details if the user exists in the database and login successfully.', async function () {
UserService.create({ email: 'user2@tests.hackerbay.io', sso: ssoId });
const loginRequest = await request.get(

View File

@@ -7,11 +7,11 @@ import app from '../server';
const request = chai.request.agent(app);
describe('Version API', function() {
describe('Version API', function () {
this.timeout(20000);
it('should get the current server version', function(done: $TSFixMe) {
request.get('/version').end(function(err: $TSFixMe, res: $TSFixMe) {
it('should get the current server version', function (done: $TSFixMe) {
request.get('/version').end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.server).to.be.equal(
process.env.npm_package_version

View File

@@ -18,7 +18,7 @@ import VerificationTokenModel from '../backend/models/verificationToken';
import GlobalConfig from './utils/globalConfig';
// eslint-disable-next-line
let token: $TSFixMe, userId, projectId: $TSFixMe, monitorId: $TSFixMe, msTeamsId: $TSFixMe,msTeamsId1: $TSFixMe,slackId: $TSFixMe,slackId1: $TSFixMe;
let token: $TSFixMe, userId, projectId: $TSFixMe, monitorId: $TSFixMe, msTeamsId: $TSFixMe, msTeamsId1: $TSFixMe, slackId: $TSFixMe, slackId1: $TSFixMe;
const monitor = {
name: 'New Monitor',
type: 'url',
@@ -43,15 +43,15 @@ const slackPayload = {
type: 'slack',
};
describe('Webhook API', function() {
describe('Webhook API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, async function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, async function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
projectId = res.body.project._id;
userId = res.body.id;
@@ -62,30 +62,30 @@ describe('Webhook API', function() {
{ role: 'master-admin' }
);
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
.post(`/monitor/${projectId}`)
.set('Authorization', authorization)
.send(monitor)
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
msTeamsPayload.monitorId = monitorId;
@@ -101,7 +101,7 @@ describe('Webhook API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await ProjectService.hardDeleteBy({ _id: projectId });
await UserService.hardDeleteBy({
@@ -122,16 +122,16 @@ describe('Webhook API', function() {
//MS Teams
it('should prevent unauthenticated users from creating webhooks.', function(done: $TSFixMe) {
it('should prevent unauthenticated users from creating webhooks.', function (done: $TSFixMe) {
request
.post(`/webhook/${projectId}/create`)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(401);
done();
});
});
it('should reject requests missing the endpoint.', function(done: $TSFixMe) {
it('should reject requests missing the endpoint.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...msTeamsPayload };
@@ -140,13 +140,13 @@ describe('Webhook API', function() {
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should reject requests missing the monitorId.', function(done: $TSFixMe) {
it('should reject requests missing the monitorId.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...msTeamsPayload };
@@ -155,13 +155,13 @@ describe('Webhook API', function() {
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should reject requests missing the integration type.', function(done: $TSFixMe) {
it('should reject requests missing the integration type.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...msTeamsPayload };
@@ -170,19 +170,19 @@ describe('Webhook API', function() {
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create msteams webhook.', function(done: $TSFixMe) {
it('should create msteams webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(msTeamsPayload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -194,19 +194,19 @@ describe('Webhook API', function() {
});
});
it('should not create msteams webhook, with the same integration type and endpoint, for the same monitorId.', function(done: $TSFixMe) {
it('should not create msteams webhook, with the same integration type and endpoint, for the same monitorId.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(msTeamsPayload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create msteams webhook with a different endpoint.', function(done: $TSFixMe) {
it('should create msteams webhook with a different endpoint.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...msTeamsPayload };
payload.endpoint = 'http://test1.hackerbay.io';
@@ -214,7 +214,7 @@ describe('Webhook API', function() {
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -226,7 +226,7 @@ describe('Webhook API', function() {
});
});
it('should update the msteams webhook.', function(done: $TSFixMe) {
it('should update the msteams webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...msTeamsPayload };
payload.endpoint = 'http://newlink.hackerbay.io';
@@ -234,7 +234,7 @@ describe('Webhook API', function() {
.put(`/webhook/${projectId}/${msTeamsId}`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -245,12 +245,12 @@ describe('Webhook API', function() {
});
});
it('should return the list of msteams webhook.', function(done: $TSFixMe) {
it('should return the list of msteams webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/webhook/${projectId}/hooks?type=msteams`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -260,12 +260,12 @@ describe('Webhook API', function() {
});
});
it('should delete msteams webhooks.', function(done: $TSFixMe) {
it('should delete msteams webhooks.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/webhook/${projectId}/delete/${msTeamsId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -278,13 +278,13 @@ describe('Webhook API', function() {
});
//Slack
it('should create slack webhook.', function(done: $TSFixMe) {
it('should create slack webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(slackPayload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -296,19 +296,19 @@ describe('Webhook API', function() {
});
});
it('should not create slack webhook, with the same integration type and endpoint, for the same monitorId.', function(done: $TSFixMe) {
it('should not create slack webhook, with the same integration type and endpoint, for the same monitorId.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(slackPayload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create slack webhook with a different endpoint.', function(done: $TSFixMe) {
it('should create slack webhook with a different endpoint.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...slackPayload };
payload.endpoint = 'http://test1.slack.hackerbay.io';
@@ -316,7 +316,7 @@ describe('Webhook API', function() {
.post(`/webhook/${projectId}/create`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -328,7 +328,7 @@ describe('Webhook API', function() {
});
});
it('should update the slack webhook.', function(done: $TSFixMe) {
it('should update the slack webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
const payload = { ...slackPayload };
payload.endpoint = 'http://newlink.hackerbay.io';
@@ -336,7 +336,7 @@ describe('Webhook API', function() {
.put(`/webhook/${projectId}/${slackId}`)
.set('Authorization', authorization)
.send(payload)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -347,12 +347,12 @@ describe('Webhook API', function() {
});
});
it('should return the list of slack webhook.', function(done: $TSFixMe) {
it('should return the list of slack webhook.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/webhook/${projectId}/hooks?type=slack`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');
@@ -362,12 +362,12 @@ describe('Webhook API', function() {
});
});
it('should delete slack webhooks.', function(done: $TSFixMe) {
it('should delete slack webhooks.', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.delete(`/webhook/${projectId}/delete/${slackId}`)
.set('Authorization', authorization)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('data');

View File

@@ -28,45 +28,45 @@ const monitor = {
data: { url: 'http://www.tests.org' },
};
describe('Zapier API', function() {
describe('Zapier API', function () {
this.timeout(20000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(40000);
GlobalConfig.initTestConfig().then(function() {
createUser(request, userData.user, function(
GlobalConfig.initTestConfig().then(function () {
createUser(request, userData.user, function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
const project = res.body.project;
projectId = project._id;
userId = res.body.id;
apiKey = project.apiKey;
VerificationTokenModel.findOne({ userId }, function(
VerificationTokenModel.findOne({ userId }, function (
err: $TSFixMe,
verificationToken: $TSFixMe
) {
request
.get(`/user/confirmation/${verificationToken.token}`)
.redirects(0)
.end(function() {
.end(function () {
request
.post('/user/login')
.send({
email: userData.user.email,
password: userData.user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
const authorization = `Basic ${token}`;
request
.post(`/monitor/${projectId}`)
.set('Authorization', authorization)
.send(monitor)
.end(function(
.end(function (
err: $TSFixMe,
res: $TSFixMe
req: Response
) {
monitorId = res.body._id;
incidentData.monitors = [monitorId];
@@ -80,7 +80,7 @@ describe('Zapier API', function() {
authorization
)
.send(incidentData)
.end(function() {
.end(function () {
request
.post(
`/incident/${projectId}/create-incident`
@@ -90,7 +90,7 @@ describe('Zapier API', function() {
authorization
)
.send(incidentData)
.end(function() {
.end(function () {
done();
});
});
@@ -102,7 +102,7 @@ describe('Zapier API', function() {
});
});
after(async function() {
after(async function () {
await GlobalConfig.removeTestConfig();
await UserService.hardDeleteBy({
email: {
@@ -121,19 +121,19 @@ describe('Zapier API', function() {
app.close();
});
it('should not subscribe to zapier when missing apiKey in query', function(done: $TSFixMe) {
it('should not subscribe to zapier when missing apiKey in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/zapier/subscribe?apiKey=${apiKey}&&projectId=${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not subscribe to zapier when missing url as a parameter', function(done: $TSFixMe) {
it('should not subscribe to zapier when missing url as a parameter', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/zapier/subscribe?apiKey=${apiKey}&&projectId=${projectId}`)
@@ -141,13 +141,13 @@ describe('Zapier API', function() {
.send({
type: 'created',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should not subscribe to zapier when missing type as a parameter', function(done: $TSFixMe) {
it('should not subscribe to zapier when missing type as a parameter', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/zapier/subscribe?apiKey=${apiKey}&&projectId=${projectId}`)
@@ -155,13 +155,13 @@ describe('Zapier API', function() {
.send({
url: 'https://www.oneuptime.com',
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should subscribe to zapier service', function(done: $TSFixMe) {
it('should subscribe to zapier service', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/zapier/subscribe?apiKey=${apiKey}&&projectId=${projectId}`)
@@ -171,32 +171,32 @@ describe('Zapier API', function() {
type: 'created',
input: { monitors: ['12345'] },
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
zapierId = res.body.id;
expect(res).to.have.status(200);
done();
});
});
it('should fail getting test and apiKey is missing in query', function(done: $TSFixMe) {
it('should fail getting test and apiKey is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/test?projectId=${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail when getting test and projectId is missing in query', function(done: $TSFixMe) {
it('should fail when getting test and projectId is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/test?apiKey=${apiKey}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
@@ -214,63 +214,63 @@ describe('Zapier API', function() {
});
*/
it('should fail getting incidents and apiKey is missing in query', function(done: $TSFixMe) {
it('should fail getting incidents and apiKey is missing in query', function (done: $TSFixMe) {
request
.get(`/zapier/incidents?projectId=${projectId}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail when getting incidents and projectId is missing in query', function(done: $TSFixMe) {
it('should fail when getting incidents and projectId is missing in query', function (done: $TSFixMe) {
request
.get(`/zapier/incidents?apiKey=${apiKey}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should get zapier incidents', function(done: $TSFixMe) {
it('should get zapier incidents', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/incidents?apiKey=${apiKey}&&projectId=${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should fail getting resolved and apiKey is missing in query', function(done: $TSFixMe) {
it('should fail getting resolved and apiKey is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/incident/resolved?projectId=${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail when getting resolved and projectId is missing in query', function(done: $TSFixMe) {
it('should fail when getting resolved and projectId is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/incident/resolved?apiKey=${apiKey}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should get zapier resolved', function(done: $TSFixMe) {
it('should get zapier resolved', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(
@@ -278,37 +278,37 @@ describe('Zapier API', function() {
)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should fail getting acknowledged and apiKey is missing in query', function(done: $TSFixMe) {
it('should fail getting acknowledged and apiKey is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/incident/acknowledged?projectId=${projectId}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail when getting acknowledged and projectId is missing in query', function(done: $TSFixMe) {
it('should fail when getting acknowledged and projectId is missing in query', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(`/zapier/incident/acknowledged?apiKey=${apiKey}`)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should get zapier acknowledged', function(done: $TSFixMe) {
it('should get zapier acknowledged', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.get(
@@ -316,49 +316,49 @@ describe('Zapier API', function() {
)
.set('Authorization', authorization)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should unsubscribe to zapier', function(done: $TSFixMe) {
it('should unsubscribe to zapier', function (done: $TSFixMe) {
request
.delete(
`/zapier/unsubscribe/${zapierId}?apiKey=${apiKey}&&projectId=${projectId}`
)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
done();
});
});
it('should fail to create incidents when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to create incidents when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/createIncident?projectId=${projectId}`)
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to create incidents when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to create incidents when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/createIncident?apiKey=${apiKey}`)
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should create incident', function(done: $TSFixMe) {
it('should create incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/createIncident?apiKey=${apiKey}&projectId=${projectId}`
@@ -366,7 +366,7 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -376,27 +376,27 @@ describe('Zapier API', function() {
});
});
it('should fail to acknowledge an incident when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge an incident when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/acknowledgeIncident?projectId=${projectId}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to acknowledge an incident when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge an incident when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/acknowledgeIncident?apiKey=${apiKey}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should acknowledge an incident', function(done: $TSFixMe) {
it('should acknowledge an incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/acknowledgeIncident?apiKey=${apiKey}&projectId=${projectId}`
@@ -404,7 +404,7 @@ describe('Zapier API', function() {
.send({
incidents: [incidentId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -414,27 +414,27 @@ describe('Zapier API', function() {
});
});
it('should fail to resolve an incident when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to resolve an incident when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveIncident?projectId=${projectId}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to resolve an incident when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to resolve an incident when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveIncident?apiKey=${apiKey}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should resolve an incident', function(done: $TSFixMe) {
it('should resolve an incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/resolveIncident?apiKey=${apiKey}&projectId=${projectId}`
@@ -442,7 +442,7 @@ describe('Zapier API', function() {
.send({
incidents: [incidentId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -452,7 +452,7 @@ describe('Zapier API', function() {
});
});
it('should fail to acknowledge last incidents when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge last incidents when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/acknowledgeLastIncident?projectId=${projectId}`
@@ -460,25 +460,25 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to acknowledge last incidents when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge last incidents when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/acknowledgeLastIncident?apiKey=${apiKey}`)
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should acknowledge last incident', function(done: $TSFixMe) {
it('should acknowledge last incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/acknowledgeLastIncident?apiKey=${apiKey}&projectId=${projectId}`
@@ -486,7 +486,7 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -496,31 +496,31 @@ describe('Zapier API', function() {
});
});
it('should fail to resolve last incidents when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to resolve last incidents when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveLastIncident?projectId=${projectId}`)
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to resolve last incidents when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to resolve last incidents when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveLastIncident?apiKey=${apiKey}`)
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should resolve last incident', function(done: $TSFixMe) {
it('should resolve last incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/resolveLastIncident?apiKey=${apiKey}&projectId=${projectId}`
@@ -528,7 +528,7 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -538,40 +538,40 @@ describe('Zapier API', function() {
});
});
it('should fail to acknowledge all incidents when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge all incidents when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/acknowledgeAllIncidents?projectId=${projectId}`
)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to acknowledge all incidents when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to acknowledge all incidents when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/acknowledgeAllIncidents?apiKey=${apiKey}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should acknowledge all incident', function(done: $TSFixMe) {
it('should acknowledge all incident', function (done: $TSFixMe) {
const authorization = `Basic ${token}`;
request
.post(`/incident/${projectId}/create-incident`)
.set('Authorization', authorization)
.send(incidentData)
.end(function() {
.end(function () {
request
.post(`/incident/${projectId}/create-incident`)
.set('Authorization', authorization)
.send(incidentData)
.end(function() {
.end(function () {
request
.post(
`/zapier/incident/acknowledgeAllIncidents?apiKey=${apiKey}&projectId=${projectId}`
@@ -579,7 +579,7 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('incidents');
@@ -595,27 +595,27 @@ describe('Zapier API', function() {
});
});
it('should fail to resolve all incidents when apiKey is missing in query', function(done: $TSFixMe) {
it('should fail to resolve all incidents when apiKey is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveAllIncidents?projectId=${projectId}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should fail to resolve all incidents when projectId is missing in query', function(done: $TSFixMe) {
it('should fail to resolve all incidents when projectId is missing in query', function (done: $TSFixMe) {
request
.post(`/zapier/incident/resolveAllIncidents?apiKey=${apiKey}`)
.send()
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
done();
});
});
it('should resolve all incident', function(done: $TSFixMe) {
it('should resolve all incident', function (done: $TSFixMe) {
request
.post(
`/zapier/incident/resolveAllIncidents?apiKey=${apiKey}&projectId=${projectId}`
@@ -623,7 +623,7 @@ describe('Zapier API', function() {
.send({
monitors: [monitorId],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('incidents');

View File

@@ -2,20 +2,20 @@ import JsonToCsv from './jsonToCsv';
import ErrorService from './error';
import logger from './logger';
import { GridFSBucket } from 'mongodb';
import { Request, Response } from './express';
function logResponse(req: Request, res: Response, responsebody: $TSFixMe) {
const requestEndedAt = Date.now();
const method = req.method;
const url = req.url;
const duration_info = `OUTGOING RESPONSE ID: ${req.id} -- POD NAME: ${
process.env.POD_NAME
} -- METHOD: ${method} -- URL: ${url} -- DURATION: ${requestEndedAt -
const duration_info = `OUTGOING RESPONSE ID: ${req.id} -- POD NAME: ${process.env.POD_NAME
} -- METHOD: ${method} -- URL: ${url} -- DURATION: ${requestEndedAt -
req.requestStartedAt}ms -- STATUS: ${res.statusCode}`;
const body_info = `OUTGOING RESPONSE ID: ${req.id} -- RESPONSE BODY: ${
responsebody ? JSON.stringify(responsebody, null, 2) : 'EMPTY'
}`;
const body_info = `OUTGOING RESPONSE ID: ${req.id} -- RESPONSE BODY: ${responsebody ? JSON.stringify(responsebody, null, 2) : 'EMPTY'
}`;
if (res.statusCode > 299) {
logger.error(duration_info);

View File

@@ -25,7 +25,7 @@ import cors from 'cors';
app.use(cors());
app.use(function(req: Request, res: Response, next: $TSFixMe) {
app.use(function (req: Request, res: Response, next: $TSFixMe) {
if (typeof req.body === 'string') {
req.body = JSON.parse(req.body);
}
@@ -42,9 +42,9 @@ app.use(function(req: Request, res: Response, next: $TSFixMe) {
return next();
});
app.get(['/env.js', '/dashboard/env.js'], function(
req: $TSFixMe,
res: $TSFixMe
app.get(['/env.js', '/dashboard/env.js'], function (
req: Request,
req: Response
) {
const isClustLocal = req.get('host').includes('cluster.local');
if (!isClustLocal) {
@@ -106,17 +106,17 @@ app.get(['/env.js', '/dashboard/env.js'], function(
});
//APP VERSION
app.use(['/dashboard/api/version', '/dashboard/version'], function(
req: $TSFixMe,
res: $TSFixMe
app.use(['/dashboard/api/version', '/dashboard/version'], function (
req: Request,
req: Response
) {
res.setHeader('Content-Type', 'application/json');
res.json({ dashboardVersion: process.env.npm_package_version });
});
app.get(['/dashboard/status', '/status'], function(
req: $TSFixMe,
res: $TSFixMe
app.get(['/dashboard/status', '/status'], function (
req: Request,
req: Response
) {
res.setHeader('Content-Type', 'application/json');
res.send(
@@ -168,7 +168,7 @@ app.use('/dashboard', express.static(path.join(__dirname, 'build')));
// }
// });
app.get('/*', function(req: Request, res: Response) {
app.get('/*', function (req: Request, res: Response) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

View File

@@ -32,7 +32,7 @@ class AddExternalStatusPagesModal extends Component {
statusPage.status._id,
values
)
.then((res: $TSFixMe) => {
.then((req: Response) => {
if (res) {
this.handleCloseModal();
}

View File

@@ -119,7 +119,7 @@ class CreateAnnouncement extends Component {
}
createAnnouncement(projectId, statusPage._id, { data: postObj })
.then((res: $TSFixMe) => {
.then((req: Response) => {
if (res) {
this.handleCloseModal();
fetchAnnouncements(projectId, statusPage._id, 0, 10);
@@ -283,13 +283,13 @@ class CreateAnnouncement extends Component {
: 'No Monitor available',
},
...(mergeMonitors &&
mergeMonitors.length > 0
mergeMonitors.length > 0
? mergeMonitors.map(
(monitor: $TSFixMe) => ({
value: monitor._id,
label: `${monitor.componentId.name} / ${monitor.name}`
})
)
(monitor: $TSFixMe) => ({
value: monitor._id,
label: `${monitor.componentId.name} / ${monitor.name}`
})
)
: []),
]}
/>

View File

@@ -100,7 +100,7 @@ class EditAnnouncement extends Component {
updateAnnouncement(projectId, statusPage._id, announcement._id, {
data: postObj,
})
.then((res: $TSFixMe) => {
.then((req: Response) => {
if (res) {
this.handleCloseModal();
fetchAnnouncements(projectId, statusPage._id, 0, 10);
@@ -264,13 +264,13 @@ class EditAnnouncement extends Component {
: 'No Monitor available',
},
...(mergeMonitors &&
mergeMonitors.length > 0
mergeMonitors.length > 0
? mergeMonitors.map(
(monitor: $TSFixMe) => ({
value: monitor._id,
label: `${monitor.componentId.name} / ${monitor.name}`
})
)
(monitor: $TSFixMe) => ({
value: monitor._id,
label: `${monitor.componentId.name} / ${monitor.name}`
})
)
: []),
]}
/>

View File

@@ -32,7 +32,7 @@ class EditExternalStatusPagesModal extends Component {
data.link._id,
values
)
.then((res: $TSFixMe) => {
.then((req: Response) => {
if (res) {
this.handleCloseModal();
}

View File

@@ -65,7 +65,7 @@ class HideAnnouncement extends Component {
announcement._id,
{ data }
)
.then((res: $TSFixMe) => {
.then((req: Response) => {
if (res) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'closeThisDialog' does not exist on type ... Remove this comment to see the full error message
this.props.closeThisDialog();

View File

@@ -51,7 +51,7 @@ class SideNav extends Component {
this.props
// @ts-expect-error ts-migrate(2339) FIXME: Property 'getSubProjects' does not exist on type '... Remove this comment to see the full error message
.getSubProjects(this.props.currentProject._id)
.then((res: $TSFixMe) => {
.then((req: Response) => {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'switchToProjectViewer' does not exist on... Remove this comment to see the full error message
this.props.switchToProjectViewer(
User.getUserId(),
@@ -143,10 +143,10 @@ class SideNav extends Component {
const IMG_URL =
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
this.props.profilePic &&
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
this.props.profilePic !== '' &&
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
this.props.profilePic !== 'null'
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
this.props.profilePic !== '' &&
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
this.props.profilePic !== 'null'
// @ts-expect-error ts-migrate(2339) FIXME: Property 'profilePic' does not exist on type 'Read... Remove this comment to see the full error message
? `url(${API_URL}/file/${this.props.profilePic})`
: 'url(https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y)';
@@ -311,7 +311,7 @@ class SideNav extends Component {
className={`db-World-sideNavContainer${
// @ts-expect-error ts-migrate(2339) FIXME: Property 'sidenavopen' does not exist on type 'Rea... Remove this comment to see the full error message
this.props.sidenavopen ? ' open' : ''
}`}
}`}
>
<div className="db-SideNav-container Box-root Box-background--surface Flex-flex Flex-direction--column Padding-top--20 Padding-right--2">
<div className="Box-root Margin-bottom--20">
@@ -328,7 +328,7 @@ class SideNav extends Component {
this.props.animateSidebar
? ' animate-in'
: ' animate-out'
}`}
}`}
>
// @ts-expect-error ts-migrate(2367) FIXME: This condition will always return 'false' since th... Remove this comment to see the full error message
{(this.state.navLoading === 'projectShow' ||
@@ -429,7 +429,7 @@ class SideNav extends Component {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'displayName' does not exist on type 'typ... Remove this comment to see the full error message
SideNav.displayName = 'SideNav';
const mapStateToProps = function(state: $TSFixMe) {
const mapStateToProps = function (state: $TSFixMe) {
const allIndividualComponents = state.component.componentList.components.reduce(
(acc: $TSFixMe, curr: $TSFixMe) => acc.concat(curr.components || []),
[]
@@ -465,7 +465,7 @@ const mapStateToProps = function(state: $TSFixMe) {
};
};
const mapDispatchToProps = function(dispatch: $TSFixMe) {
const mapDispatchToProps = function (dispatch: $TSFixMe) {
return bindActionCreators(
{
openModal,
@@ -537,7 +537,7 @@ const WrappedSideNav = (props: $TSFixMe) => {
router =>
!titleToExclude.includes(router.title) ||
router.path ===
'/dashboard/project/:slug/component/:componentSlug/settings/advanced'
'/dashboard/project/:slug/component/:componentSlug/settings/advanced'
);
}

View File

@@ -17,7 +17,7 @@ export class CreateProjectModal extends Component {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'switchProject' does not exist on type 'R... Remove this comment to see the full error message
const { switchProject, dispatch } = this.props;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'createProject' does not exist on type 'R... Remove this comment to see the full error message
return this.props.createProject(values).then((res: $TSFixMe) => {
return this.props.createProject(values).then((req: Response) => {
if (
// @ts-expect-error ts-migrate(2339) FIXME: Property 'projects' does not exist on type 'Readon... Remove this comment to see the full error message
this.props.projects &&

View File

@@ -42,7 +42,7 @@ export class ProjectSwitcher extends Component {
if (project._id !== currentProject._id) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'getSubProjects' does not exist on type '... Remove this comment to see the full error message
this.props.getSubProjects(project._id).then((res: $TSFixMe) => {
this.props.getSubProjects(project._id).then((req: Response) => {
const { data: subProjects } = res.data;
switchProject(dispatch, project, subProjects);
// @ts-expect-error ts-migrate(2339) FIXME: Property 'switchToProjectViewerNav' does not exist... Remove this comment to see the full error message

View File

@@ -98,7 +98,7 @@ class SlackTeamList extends React.Component {
</thead>
<tbody className="Table-body">
<ShouldRender if={teams.teams.length > 0}>
{teams.teams.map((res: $TSFixMe) => <SlackTeamItem
{teams.teams.map((req: Response) => <SlackTeamItem
key={`${res._id}`}
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ key: string; team: any; projectId: any; }'... Remove this comment to see the full error message
team={res}
@@ -176,11 +176,10 @@ class SlackTeamList extends React.Component {
<div className="Box-root Flex-flex Flex-alignItems--stretch Flex-direction--row Flex-justifyContent--flexStart">
<div className="Box-root Margin-right--8">
<button
className={`Button bs-ButtonLegacy ${
!canPaginateBackward
className={`Button bs-ButtonLegacy ${!canPaginateBackward
? 'Is--disabled'
: ''
}`}
}`}
data-db-analytics-name="list_view.pagination.previous"
disabled={!canPaginateBackward}
type="button"
@@ -195,11 +194,10 @@ class SlackTeamList extends React.Component {
</div>
<div className="Box-root">
<button
className={`Button bs-ButtonLegacy ${
!canPaginateForward
className={`Button bs-ButtonLegacy ${!canPaginateForward
? 'Is--disabled'
: ''
}`}
}`}
data-db-analytics-name="list_view.pagination.next"
disabled={!canPaginateForward}
type="button"

View File

@@ -51,7 +51,7 @@ export class StatusPageForm extends React.Component {
data.statusPageSlug,
{ name }
)
.then((res: $TSFixMe) => {
.then((req: Response) => {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'closeModal' does not exist on type 'Read... Remove this comment to see the full error message
this.props.closeModal({
// @ts-expect-error ts-migrate(2339) FIXME: Property 'duplicateModalId' does not exist on type... Remove this comment to see the full error message
@@ -176,14 +176,14 @@ export class StatusPageForm extends React.Component {
},
...(subProjects.length > 0
? subProjects.map(
(subProject: $TSFixMe) => ({
value:
subProject._id,
(subProject: $TSFixMe) => ({
value:
subProject._id,
label:
subProject.name
})
)
label:
subProject.name
})
)
: []),
]}
/>

View File

@@ -11,7 +11,7 @@ import ShouldRender from '../basic/ShouldRender';
const getDescription = (type: $TSFixMe) => {
return tutorials.getTutorials().filter(note => note.id === type);
};
const renderFeatures = (features: $TSFixMe) => {
const renderFeatures = (featureq: Response) => {
if (features) {
return features.map((feature: $TSFixMe) => <FeatureList key={uuidv4()} content={feature} />);
}
@@ -31,8 +31,8 @@ const CustomTutorial = ({
{/* Here, component and monitor notifier */}
{components &&
components.length < 1 &&
tutorialStat.componentCustom.show ? (
components.length < 1 &&
tutorialStat.componentCustom.show ? (
<div>
{/* No Component Notifier */}
<QuickTipBox
@@ -61,8 +61,8 @@ const CustomTutorial = ({
/>
</div>
) : monitors &&
monitors.length < 1 &&
tutorialStat.monitorCustom.show ? (
monitors.length < 1 &&
tutorialStat.monitorCustom.show ? (
<div>
{/* No Monitor Notifier */}
<QuickTipBox

View File

@@ -14,8 +14,8 @@ import { sendEmptyResponse } from 'common-server/utils/response';
import { ObjectId } from 'mongodb';
router.post('/ping/:monitorId', isAuthorizedProbe, async function(
req: $TSFixMe,
router.post('/ping/:monitorId', isAuthorizedProbe, async function (
req: Request,
response: $TSFixMe
) {
try {
@@ -54,17 +54,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
successReasons: degradedSuccessReasons,
@@ -74,17 +74,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.degraded,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -94,22 +94,22 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const [up, degraded, down] = await Promise.all([
validUp,
@@ -152,17 +152,17 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
monitor.type,
monitor.criteria.up,
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -171,22 +171,22 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
res,
resp,
rawResp
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
status = 'online';
reason = upSuccessReasons;
@@ -218,14 +218,14 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.scriptConditions(
resp,
monitor.criteria.up
)
resp,
monitor.criteria.up
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
@@ -235,16 +235,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.scriptConditions(resp, [
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
])
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
])
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
@@ -254,14 +254,14 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.scriptConditions(
resp,
monitor.criteria.degraded
)
resp,
monitor.criteria.degraded
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
status = 'online';
@@ -307,15 +307,15 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
data
)
monitor.type,
monitor.criteria.up,
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
successReasons: degradedSuccessReasons,
@@ -324,15 +324,15 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
data
)
monitor.type,
monitor.criteria.degraded,
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
successReasons: downSuccessReasons,
@@ -341,20 +341,20 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data
)
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
data.status = 'online';
@@ -442,16 +442,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.up
? ProbeService.conditions(
monitor.type,
monitor.criteria.up,
monitor.type,
monitor.criteria.up,
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDegraded,
@@ -461,16 +461,16 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.degraded
? ProbeService.conditions(
monitor.type,
monitor.criteria.degraded,
monitor.type,
monitor.criteria.degraded,
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
const {
stat: validDown,
@@ -480,21 +480,21 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}: $TSFixMe =
monitor && monitor.criteria && monitor.criteria.down
? ProbeService.conditions(
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
monitor.type,
[
...monitor.criteria.down.filter(
(criterion: $TSFixMe) =>
criterion.default !== true
),
],
data.kubernetesData
)
data.kubernetesData
)
: {
stat: false,
successReasons: [],
failedReasons: [],
};
stat: false,
successReasons: [],
failedReasons: [],
};
if (validUp) {
data.status = 'online';
@@ -554,9 +554,9 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
data.reason =
data && data.reason && data.reason.length
? data.reason.filter(
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
self.indexOf(item) === pos
)
: data.reason;
const index =
data.reason && data.reason.indexOf('Request Timed out');
@@ -564,9 +564,9 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
data.reason =
data && data.reason && data.reason.length
? data.reason.filter(
(item: $TSFixMe) =>
!item.includes('Response Time is')
)
(item: $TSFixMe) =>
!item.includes('Response Time is')
)
: data.reason;
}
@@ -626,9 +626,9 @@ router.post('/ping/:monitorId', isAuthorizedProbe, async function(
}
});
router.post('/setTime/:monitorId', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/setTime/:monitorId', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const data = req.body;
@@ -641,9 +641,9 @@ router.post('/setTime/:monitorId', isAuthorizedProbe, async function(
}
});
router.post('/getTime/:monitorId', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/getTime/:monitorId', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const data = req.body;
@@ -656,9 +656,9 @@ router.post('/getTime/:monitorId', isAuthorizedProbe, async function(
}
});
router.post('/set-scan-status', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/set-scan-status', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const { monitorIds, scanning } = req.body;
@@ -670,9 +670,9 @@ router.post('/set-scan-status', isAuthorizedProbe, async function(
}
});
router.post('/add-probe-scan', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/add-probe-scan', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const { monitorIds } = req.body;
@@ -684,9 +684,9 @@ router.post('/add-probe-scan', isAuthorizedProbe, async function(
}
});
router.post('/remove-probe-scan', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/remove-probe-scan', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const { monitorIds } = req.body;

View File

@@ -7,13 +7,13 @@ import app from '../server';
const request = chai.request.agent(app);
describe('Version API', function() {
describe('Version API', function () {
this.timeout(20000);
it('should get the current helm-chart version', function(done: $TSFixMe) {
it('should get the current helm-chart version', function (done: $TSFixMe) {
request
.get('/helm-chart/version')
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body.helmChartVersion).to.be.equal(
process.env.npm_package_version

View File

@@ -50,7 +50,7 @@ app.set('view engine', 'ejs');
*/
//Routes
app.get('/', function(req: Request, res: Response) {
app.get('/', function (req: Request, res: Response) {
res.render('index', {
support: false,
footerCards: true,
@@ -60,7 +60,7 @@ app.get('/', function(req: Request, res: Response) {
});
});
app.get('/support', function(req: Request, res: Response) {
app.get('/support', function (req: Request, res: Response) {
res.render('support', {
support: true,
footerCards: true,
@@ -70,7 +70,7 @@ app.get('/support', function(req: Request, res: Response) {
});
});
app.get('/pricing', function(req: Request, res: Response) {
app.get('/pricing', function (req: Request, res: Response) {
res.render('pricing', {
support: false,
footerCards: true,
@@ -80,7 +80,7 @@ app.get('/pricing', function(req: Request, res: Response) {
});
});
app.get('/enterprise/demo', function(req: Request, res: Response) {
app.get('/enterprise/demo', function (req: Request, res: Response) {
res.render('demo', {
support: false,
footerCards: false,
@@ -90,15 +90,15 @@ app.get('/enterprise/demo', function(req: Request, res: Response) {
});
});
app.get('/product/status-page', function(req: Request, res: Response) {
app.get('/product/status-page', function (req: Request, res: Response) {
res.redirect('/product/public-status-page');
});
app.get('/status-page', function(req: Request, res: Response) {
app.get('/status-page', function (req: Request, res: Response) {
res.redirect('/product/public-status-page');
});
app.get('/product/public-status-page', function(req: Request, res: Response) {
app.get('/product/public-status-page', function (req: Request, res: Response) {
res.render('public-status-page', {
support: false,
footerCards: true,
@@ -110,11 +110,11 @@ app.get('/product/public-status-page', function(req: Request, res: Response) {
});
});
app.get('/public-status-page', function(req: Request, res: Response) {
app.get('/public-status-page', function (req: Request, res: Response) {
res.redirect('/product/public-status-page');
});
app.get('/product/private-status-page', function(req: Request, res: Response) {
app.get('/product/private-status-page', function (req: Request, res: Response) {
res.render('private-status-page', {
support: false,
footerCards: true,
@@ -126,15 +126,15 @@ app.get('/product/private-status-page', function(req: Request, res: Response) {
});
});
app.get('/private-status-page', function(req: Request, res: Response) {
app.get('/private-status-page', function (req: Request, res: Response) {
res.redirect('/product/private-status-page');
});
app.get('/status', function(req: Request, res: Response) {
app.get('/status', function (req: Request, res: Response) {
res.redirect('https://status.oneuptime.com');
});
app.get('/product/uptime-monitoring', function(req: Request, res: Response) {
app.get('/product/uptime-monitoring', function (req: Request, res: Response) {
res.render('uptime-monitoring', {
support: false,
footerCards: true,
@@ -144,11 +144,11 @@ app.get('/product/uptime-monitoring', function(req: Request, res: Response) {
});
});
app.get('/uptime-monitoring', function(req: Request, res: Response) {
app.get('/uptime-monitoring', function (req: Request, res: Response) {
res.redirect('/product/uptime-monitoring');
});
app.get('/product/logs-management', function(req: Request, res: Response) {
app.get('/product/logs-management', function (req: Request, res: Response) {
res.render('logs-management', {
support: false,
footerCards: true,
@@ -158,11 +158,11 @@ app.get('/product/logs-management', function(req: Request, res: Response) {
});
});
app.get('/logs-management', function(req: Request, res: Response) {
app.get('/logs-management', function (req: Request, res: Response) {
res.redirect('/product/logs-management');
});
app.get('/product/error-tracking', function(req: Request, res: Response) {
app.get('/product/error-tracking', function (req: Request, res: Response) {
res.render('error-tracking', {
support: false,
footerCards: true,
@@ -172,13 +172,13 @@ app.get('/product/error-tracking', function(req: Request, res: Response) {
});
});
app.get('/error-tracking', function(req: Request, res: Response) {
app.get('/error-tracking', function (req: Request, res: Response) {
res.redirect('/product/error-tracking');
});
app.get('/unsubscribe/:monitorId/:subscriberId', async function(
req: $TSFixMe,
res: $TSFixMe
app.get('/unsubscribe/:monitorId/:subscriberId', async function (
req: Request,
req: Response
) {
const { monitorId, subscriberId } = req.params;
let apiHost;
@@ -212,7 +212,7 @@ app.get('/unsubscribe/:monitorId/:subscriberId', async function(
}
});
app.post('/unsubscribe', async function(req: Request, res: Response) {
app.post('/unsubscribe', async function (req: Request, res: Response) {
let apiHost: $TSFixMe;
if (process.env.ONEUPTIME_HOST) {
apiHost = 'https://' + process.env.ONEUPTIME_HOST + '/api';
@@ -258,9 +258,9 @@ app.post('/unsubscribe', async function(req: Request, res: Response) {
}
});
app.get('/product/docker-container-security', function(
req: $TSFixMe,
res: $TSFixMe
app.get('/product/docker-container-security', function (
req: Request,
req: Response
) {
res.render('container-security', {
support: false,
@@ -271,11 +271,11 @@ app.get('/product/docker-container-security', function(
});
});
app.get('/docker-container-security', function(req: Request, res: Response) {
app.get('/docker-container-security', function (req: Request, res: Response) {
res.redirect('/product/docker-container-security');
});
app.get('/product/app-security', function(req: Request, res: Response) {
app.get('/product/app-security', function (req: Request, res: Response) {
res.render('app-security', {
support: false,
footerCards: true,
@@ -285,11 +285,11 @@ app.get('/product/app-security', function(req: Request, res: Response) {
});
});
app.get('/app-security', function(req: Request, res: Response) {
app.get('/app-security', function (req: Request, res: Response) {
res.redirect('/product/app-security');
});
app.get('/product/api-monitoring', function(req: Request, res: Response) {
app.get('/product/api-monitoring', function (req: Request, res: Response) {
res.render('api-monitoring', {
support: false,
footerCards: true,
@@ -301,13 +301,13 @@ app.get('/product/api-monitoring', function(req: Request, res: Response) {
});
});
app.get('/api-monitoring', function(req: Request, res: Response) {
app.get('/api-monitoring', function (req: Request, res: Response) {
res.redirect('/product/api-monitoring');
});
app.get('/product/kubernetes-monitoring', function(
req: $TSFixMe,
res: $TSFixMe
app.get('/product/kubernetes-monitoring', function (
req: Request,
req: Response
) {
res.render('kubernetes-monitoring', {
support: false,
@@ -318,13 +318,13 @@ app.get('/product/kubernetes-monitoring', function(
});
});
app.get('/kubernetes-monitoring', function(req: Request, res: Response) {
app.get('/kubernetes-monitoring', function (req: Request, res: Response) {
res.redirect('/product/kubernetes-monitoring');
});
app.get('/product/performance-monitoring', function(
req: $TSFixMe,
res: $TSFixMe
app.get('/product/performance-monitoring', function (
req: Request,
req: Response
) {
res.render('performance-monitoring', {
support: false,
@@ -335,11 +335,11 @@ app.get('/product/performance-monitoring', function(
});
});
app.get('/performance-monitoring', function(req: Request, res: Response) {
app.get('/performance-monitoring', function (req: Request, res: Response) {
res.redirect('/product/performance-monitoring');
});
app.get('/product/server-monitoring', function(req: Request, res: Response) {
app.get('/product/server-monitoring', function (req: Request, res: Response) {
res.render('server-monitoring', {
support: false,
footerCards: true,
@@ -349,11 +349,11 @@ app.get('/product/server-monitoring', function(req: Request, res: Response) {
});
});
app.get('/server-monitoring', function(req: Request, res: Response) {
app.get('/server-monitoring', function (req: Request, res: Response) {
res.redirect('/product/server-monitoring');
});
app.get('/product/website-monitoring', function(req: Request, res: Response) {
app.get('/product/website-monitoring', function (req: Request, res: Response) {
res.render('website-monitoring', {
support: false,
footerCards: true,
@@ -363,13 +363,13 @@ app.get('/product/website-monitoring', function(req: Request, res: Response) {
});
});
app.get('/website-monitoring', function(req: Request, res: Response) {
app.get('/website-monitoring', function (req: Request, res: Response) {
res.redirect('/product/website-monitoring');
});
app.get('/product/iot-device-monitoring', function(
req: $TSFixMe,
res: $TSFixMe
app.get('/product/iot-device-monitoring', function (
req: Request,
req: Response
) {
res.render('iot-device-monitoring', {
support: false,
@@ -380,11 +380,11 @@ app.get('/product/iot-device-monitoring', function(
});
});
app.get('/iot-device-monitoring', function(req: Request, res: Response) {
app.get('/iot-device-monitoring', function (req: Request, res: Response) {
res.redirect('/product/iot-device-monitoring');
});
app.get('/product/incident-management', function(req: Request, res: Response) {
app.get('/product/incident-management', function (req: Request, res: Response) {
res.render('incident-management', {
support: false,
footerCards: true,
@@ -394,11 +394,11 @@ app.get('/product/incident-management', function(req: Request, res: Response) {
});
});
app.get('/incident-management', function(req: Request, res: Response) {
app.get('/incident-management', function (req: Request, res: Response) {
res.redirect('/product/incident-management');
});
app.get('/product/oncall-management', function(req: Request, res: Response) {
app.get('/product/oncall-management', function (req: Request, res: Response) {
res.render('oncall-management', {
support: false,
footerCards: true,
@@ -408,11 +408,11 @@ app.get('/product/oncall-management', function(req: Request, res: Response) {
});
});
app.get('/oncall-management', function(req: Request, res: Response) {
app.get('/oncall-management', function (req: Request, res: Response) {
res.redirect('/product/oncall-management');
});
app.get('/customers', function(req: Request, res: Response) {
app.get('/customers', function (req: Request, res: Response) {
res.render('customers', {
support: false,
footerCards: true,
@@ -422,7 +422,7 @@ app.get('/customers', function(req: Request, res: Response) {
});
});
app.get('/enterprise/resources', function(req: Request, res: Response) {
app.get('/enterprise/resources', function (req: Request, res: Response) {
res.render('resources', {
support: false,
footerCards: false,
@@ -432,7 +432,7 @@ app.get('/enterprise/resources', function(req: Request, res: Response) {
});
});
app.get('/enterprise/overview', function(req: Request, res: Response) {
app.get('/enterprise/overview', function (req: Request, res: Response) {
res.render('enterprise-overview.ejs', {
support: false,
footerCards: true,
@@ -442,7 +442,7 @@ app.get('/enterprise/overview', function(req: Request, res: Response) {
});
});
app.get('/legal', function(req: Request, res: Response) {
app.get('/legal', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -453,7 +453,7 @@ app.get('/legal', function(req: Request, res: Response) {
});
});
app.get('/legal/terms', function(req: Request, res: Response) {
app.get('/legal/terms', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -464,7 +464,7 @@ app.get('/legal/terms', function(req: Request, res: Response) {
});
});
app.get('/legal/privacy', function(req: Request, res: Response) {
app.get('/legal/privacy', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -475,7 +475,7 @@ app.get('/legal/privacy', function(req: Request, res: Response) {
});
});
app.get('/legal/contact', function(req: Request, res: Response) {
app.get('/legal/contact', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -486,7 +486,7 @@ app.get('/legal/contact', function(req: Request, res: Response) {
});
});
app.get('/legal/subprocessors', function(req: Request, res: Response) {
app.get('/legal/subprocessors', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -497,7 +497,7 @@ app.get('/legal/subprocessors', function(req: Request, res: Response) {
});
});
app.get('/legal/ccpa', function(req: Request, res: Response) {
app.get('/legal/ccpa', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -508,7 +508,7 @@ app.get('/legal/ccpa', function(req: Request, res: Response) {
});
});
app.get('/legal/hipaa', function(req: Request, res: Response) {
app.get('/legal/hipaa', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -519,7 +519,7 @@ app.get('/legal/hipaa', function(req: Request, res: Response) {
});
});
app.get('/legal/dmca', function(req: Request, res: Response) {
app.get('/legal/dmca', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -530,7 +530,7 @@ app.get('/legal/dmca', function(req: Request, res: Response) {
});
});
app.get('/legal/pci', function(req: Request, res: Response) {
app.get('/legal/pci', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -541,7 +541,7 @@ app.get('/legal/pci', function(req: Request, res: Response) {
});
});
app.get('/legal/iso-27001', function(req: Request, res: Response) {
app.get('/legal/iso-27001', function (req: Request, res: Response) {
res.render('legal.ejs', {
support: false,
footerCards: true,
@@ -552,7 +552,7 @@ app.get('/legal/iso-27001', function(req: Request, res: Response) {
});
});
app.get('/legal/iso-27017', function(req: Request, res: Response) {
app.get('/legal/iso-27017', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -563,7 +563,7 @@ app.get('/legal/iso-27017', function(req: Request, res: Response) {
});
});
app.get('/legal/iso-27018', function(req: Request, res: Response) {
app.get('/legal/iso-27018', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -574,7 +574,7 @@ app.get('/legal/iso-27018', function(req: Request, res: Response) {
});
});
app.get('/legal/iso-27017', function(req: Request, res: Response) {
app.get('/legal/iso-27017', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -585,7 +585,7 @@ app.get('/legal/iso-27017', function(req: Request, res: Response) {
});
});
app.get('/legal/iso-27018', function(req: Request, res: Response) {
app.get('/legal/iso-27018', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -596,7 +596,7 @@ app.get('/legal/iso-27018', function(req: Request, res: Response) {
});
});
app.get('/legal/soc-2', function(req: Request, res: Response) {
app.get('/legal/soc-2', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -607,7 +607,7 @@ app.get('/legal/soc-2', function(req: Request, res: Response) {
});
});
app.get('/legal/soc-3', function(req: Request, res: Response) {
app.get('/legal/soc-3', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -618,7 +618,7 @@ app.get('/legal/soc-3', function(req: Request, res: Response) {
});
});
app.get('/legal/data-residency', function(req: Request, res: Response) {
app.get('/legal/data-residency', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -629,7 +629,7 @@ app.get('/legal/data-residency', function(req: Request, res: Response) {
});
});
app.get('/legal/gdpr', function(req: Request, res: Response) {
app.get('/legal/gdpr', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -640,7 +640,7 @@ app.get('/legal/gdpr', function(req: Request, res: Response) {
});
});
app.get('/legal/sla', function(req: Request, res: Response) {
app.get('/legal/sla', function (req: Request, res: Response) {
res.render('legal.ejs', {
footerCards: true,
support: false,
@@ -651,9 +651,9 @@ app.get('/legal/sla', function(req: Request, res: Response) {
});
});
app.get('/enterprise/download-resource/:resourceName', function(
req: $TSFixMe,
res: $TSFixMe
app.get('/enterprise/download-resource/:resourceName', function (
req: Request,
req: Response
) {
res.render('download-resource.ejs', {
footerCards: false,
@@ -664,7 +664,7 @@ app.get('/enterprise/download-resource/:resourceName', function(
});
});
app.get('/table/:product', function(req: Request, res: Response) {
app.get('/table/:product', function (req: Request, res: Response) {
const productConfig = productCompare(req.params.product);
if (!productConfig) {
@@ -689,7 +689,7 @@ app.get('/table/:product', function(req: Request, res: Response) {
}
});
app.get('/compare/:product', function(req: Request, res: Response) {
app.get('/compare/:product', function (req: Request, res: Response) {
const productConfig = productCompare(req.params.product);
if (!productConfig) {
@@ -715,7 +715,7 @@ app.get('/compare/:product', function(req: Request, res: Response) {
});
// minify default.js
app.get('/js/default.js', async function(req: Request, res: Response) {
app.get('/js/default.js', async function (req: Request, res: Response) {
res.setHeader('Content-Type', 'text/javascript');
//eslint-disable-next-line
const [error, data] = await tryToCatch(minify, './public/js/default.js');
@@ -723,7 +723,7 @@ app.get('/js/default.js', async function(req: Request, res: Response) {
});
// minify
app.get('/css/home.css', async function(req: Request, res: Response) {
app.get('/css/home.css', async function (req: Request, res: Response) {
res.setHeader('Content-Type', 'text/css');
//eslint-disable-next-line
const [error, data] = await tryToCatch(minify, './public/css/home.css');
@@ -731,7 +731,7 @@ app.get('/css/home.css', async function(req: Request, res: Response) {
});
// minify
app.get('/css/comparision.css', async function(req: Request, res: Response) {
app.get('/css/comparision.css', async function (req: Request, res: Response) {
res.setHeader('Content-Type', 'text/css');
//eslint-disable-next-line
const [error, data] = await tryToCatch(
@@ -836,13 +836,13 @@ app.get('/sitemap.xml', async (req: Request, res: Response) => {
// loads up the site faster
app.use(
express.static(path.join(__dirname, 'public'), {
setHeaders(res: $TSFixMe) {
setHeaders(req: Response) {
res.setHeader('Cache-Control', 'public,max-age=31536000,immutable');
},
})
);
app.get('/*', function(req: Request, res: Response) {
app.get('/*', function (req: Request, res: Response) {
res.status(404);
res.render('notFound.ejs', {
footerCards: false,
@@ -855,7 +855,7 @@ app.get('/*', function(req: Request, res: Response) {
app.set('port', process.env.PORT || 1444);
app.listen(app.get('port'), function() {
app.listen(app.get('port'), function () {
//eslint-disable-next-line
console.log('Server running on port : ' + app.get('port'));
});

View File

@@ -26,16 +26,16 @@ const timeout = 5000,
data: {},
};
describe('Server Monitor', function() {
describe('Server Monitor', function () {
this.timeout(timeout + 1000);
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(30000);
request
.post('/user/signup')
.send(user)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const project = res.body.project;
projectId = project._id;
@@ -47,13 +47,13 @@ describe('Server Monitor', function() {
email: user.email,
password: user.password,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
token = res.body.tokens.jwtAccessToken;
request
.post(`/monitor/${projectId}`)
.set('Authorization', `Basic ${token}`)
.send(monitor)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');

View File

@@ -11,7 +11,7 @@ const timeout = 5000;
import OneUptimeLogger from '../src/logger';
describe('OneUptimeLogger', function() {
describe('OneUptimeLogger', function () {
const sleep = (milliseconds: $TSFixMe) => {
return new Promise(resolve => setTimeout(resolve, milliseconds));
};
@@ -23,14 +23,14 @@ describe('OneUptimeLogger', function() {
// create a new user
const component = { name: 'Our Component' };
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(60000);
sleep(5000).then(() => {
user.email = generateRandomBusinessEmail();
request
.post('/user/signup')
.send(user)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const project = res.body.project;
projectId = project._id;
token = res.body.tokens.jwtAccessToken;
@@ -38,7 +38,7 @@ describe('OneUptimeLogger', function() {
.post(`/component/${projectId}`)
.set('Authorization', `Basic ${token}`)
.send(component)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
componentId = res.body._id;
request
.post(
@@ -46,7 +46,7 @@ describe('OneUptimeLogger', function() {
)
.set('Authorization', `Basic ${token}`)
.send({ name: 'Application OneUptimeLogger' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');
@@ -58,7 +58,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should request for application log key', function() {
it('should request for application log key', function () {
const firstLog = new OneUptimeLogger(API_URL, applicationLog._id, '');
firstLog.log('here').catch(error => {
expect(error.response.status).to.equal(400);
@@ -68,7 +68,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should request for content', function() {
it('should request for content', function () {
const firstLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -82,7 +82,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return invalid application log', function() {
it('should return invalid application log', function () {
const firstLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -96,7 +96,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item of type string', function() {
it('should return a valid logged item of type string', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -114,7 +114,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item of type object', function() {
it('should return a valid logged item of type object', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -145,7 +145,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item with log type of error', function() {
it('should return a valid logged item with log type of error', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -163,7 +163,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item with log type of warning', function() {
it('should return a valid logged item with log type of warning', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -181,7 +181,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item with log type of info with one tag', function() {
it('should return a valid logged item with log type of info with one tag', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -207,7 +207,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item with log type of warning with no tag', function() {
it('should return a valid logged item with log type of warning with no tag', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -225,7 +225,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should return a valid logged item with log type of error with 3 tags', function() {
it('should return a valid logged item with log type of error with 3 tags', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,
@@ -252,7 +252,7 @@ describe('OneUptimeLogger', function() {
});
});
it('should reject a valid logged item with log type of error with invalid tags', function() {
it('should reject a valid logged item with log type of error with invalid tags', function () {
const validLog = new OneUptimeLogger(
API_URL,
applicationLog._id,

View File

@@ -20,7 +20,7 @@ const customTimeline = {
};
let errorTracker: $TSFixMe;
describe('Tracker Timeline', function() {
describe('Tracker Timeline', function () {
const sleep = (milliseconds: $TSFixMe) => {
return new Promise(resolve => setTimeout(resolve, milliseconds));
};
@@ -29,14 +29,14 @@ describe('Tracker Timeline', function() {
// create a new user
const component = { name: 'Our Component' };
before(function(done: $TSFixMe) {
before(function (done: $TSFixMe) {
this.timeout(60000);
sleep(5000).then(() => {
user.email = generateSecondRandomBusinessEmail();
request
.post('/user/signup')
.send(user)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
const project = res.body.project;
projectId = project._id;
token = res.body.tokens.jwtAccessToken;
@@ -44,7 +44,7 @@ describe('Tracker Timeline', function() {
.post(`/component/${projectId}`)
.set('Authorization', `Basic ${token}`)
.send(component)
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
componentId = res.body._id;
request
.post(
@@ -52,7 +52,7 @@ describe('Tracker Timeline', function() {
)
.set('Authorization', `Basic ${token}`)
.send({ name: 'Application OneUptimeTracker' })
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body).to.have.property('_id');
@@ -64,7 +64,7 @@ describe('Tracker Timeline', function() {
});
});
it('should take in custom timeline event', function() {
it('should take in custom timeline event', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -81,7 +81,7 @@ describe('Tracker Timeline', function() {
expect(timeline[0].category).to.equal(customTimeline.category);
});
it('should ensure timeline event contains eventId and timestamp', function() {
it('should ensure timeline event contains eventId and timestamp', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -97,7 +97,7 @@ describe('Tracker Timeline', function() {
expect(timeline[0].timestamp).to.be.a('number');
});
it('should ensure different timeline event have the same eventId', function() {
it('should ensure different timeline event have the same eventId', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -118,7 +118,7 @@ describe('Tracker Timeline', function() {
expect(timeline[0].eventId).to.equal(timeline[1].eventId); // their eveentId is the same till there is an error sent to the server
});
it('should ensure max timline cant be set as a negative number', function() {
it('should ensure max timline cant be set as a negative number', function () {
const options = { maxTimeline: -5 };
const tracker = new OneUptimeTracker(
API_URL,
@@ -140,7 +140,7 @@ describe('Tracker Timeline', function() {
expect(timeline.length).to.equal(2); // two timeline events
});
it('should ensure new timeline event after max timeline are discarded', function() {
it('should ensure new timeline event after max timeline are discarded', function () {
const options = { maxTimeline: 2 };
const tracker = new OneUptimeTracker(
API_URL,
@@ -178,8 +178,8 @@ describe('Tracker Timeline', function() {
});
});
describe('Tags', function() {
it('should add tags ', function() {
describe('Tags', function () {
it('should add tags ', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -194,7 +194,7 @@ describe('Tags', function() {
expect(availableTags[0]).to.have.property('value');
});
it('should add multiple tags ', function() {
it('should add multiple tags ', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -211,7 +211,7 @@ describe('Tags', function() {
expect(availableTags.length).to.equal(3);
});
it('should overwrite existing keys to avoid duplicate tags ', function() {
it('should overwrite existing keys to avoid duplicate tags ', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -233,8 +233,8 @@ describe('Tags', function() {
});
});
describe('Fingerpint', function() {
it('should create fingerprint as message for error capture without any fingerprint', function() {
describe('Fingerpint', function () {
it('should create fingerprint as message for error capture without any fingerprint', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -246,7 +246,7 @@ describe('Fingerpint', function() {
expect(event.fingerprint[0]).to.equal(errorMessage);
});
it('should use defined fingerprint array for error capture with fingerprint', function() {
it('should use defined fingerprint array for error capture with fingerprint', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -261,7 +261,7 @@ describe('Fingerpint', function() {
expect(event.fingerprint[1]).to.equal(fingerprints[1]);
});
it('should use defined fingerprint string for error capture with fingerprint', function() {
it('should use defined fingerprint string for error capture with fingerprint', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -276,8 +276,8 @@ describe('Fingerpint', function() {
});
});
describe('Capture Message', function() {
it('should create an event ready for the server', function() {
describe('Capture Message', function () {
it('should create an event ready for the server', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -290,7 +290,7 @@ describe('Capture Message', function() {
expect(event.exception.message).to.equal(errorMessage);
});
it('should create an event ready for the server while having the timeline with same event id', function() {
it('should create an event ready for the server while having the timeline with same event id', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -310,8 +310,8 @@ describe('Capture Message', function() {
});
});
describe('Capture Exception', function() {
it('should create an event ready for the server', async function() {
describe('Capture Exception', function () {
it('should create an event ready for the server', async function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -324,7 +324,7 @@ describe('Capture Exception', function() {
expect(event.exception.message).to.equal(errorMessage);
});
it('should create an event with a array of stacktrace ', async function() {
it('should create an event with a array of stacktrace ', async function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -339,7 +339,7 @@ describe('Capture Exception', function() {
expect(event.exception.stacktrace.frames).to.be.an('array');
});
it('should create an event with the object of the stacktrace in place', async function() {
it('should create an event with the object of the stacktrace in place', async function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -355,7 +355,7 @@ describe('Capture Exception', function() {
expect(frame).to.have.property('fileName');
});
it('should create an event and new event should have different id ', async function() {
it('should create an event and new event should have different id ', async function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -389,7 +389,7 @@ describe('Capture Exception', function() {
expect(event._id).to.not.equal(newEvent._id);
});
it('should create an event that has timeline and new event having tags', async function() {
it('should create an event that has timeline and new event having tags', async function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -433,8 +433,8 @@ describe('Capture Exception', function() {
});
});
describe('SDK Version', function() {
it('should contain version number and sdk name in captured message', function() {
describe('SDK Version', function () {
it('should contain version number and sdk name in captured message', function () {
const tracker = new OneUptimeTracker(
API_URL,
errorTracker._id,
@@ -448,8 +448,8 @@ describe('SDK Version', function() {
});
});
describe('Code Capture Snippet', function() {
it('should add code capture to stack trace when flag is passed in options', async function() {
describe('Code Capture Snippet', function () {
it('should add code capture to stack trace when flag is passed in options', async function () {
const options = { captureCodeSnippet: true };
const tracker = new OneUptimeTracker(
API_URL,
@@ -469,7 +469,7 @@ describe('Code Capture Snippet', function() {
expect(incidentFrame).to.have.property('errorLine');
});
it('should add code capture and confirm data type of fields added to frame', async function() {
it('should add code capture and confirm data type of fields added to frame', async function () {
const options = { captureCodeSnippet: true };
const tracker = new OneUptimeTracker(
API_URL,
@@ -489,7 +489,7 @@ describe('Code Capture Snippet', function() {
expect(incidentFrame.linesAfterError).to.be.an('array');
});
it('should not add code capture to stack trace when flag is passed in options', async function() {
it('should not add code capture to stack trace when flag is passed in options', async function () {
const options = { captureCodeSnippet: false };
const tracker = new OneUptimeTracker(
API_URL,
@@ -509,7 +509,7 @@ describe('Code Capture Snippet', function() {
expect(incidentFrame).to.not.have.property('errorLine');
});
it('should add code capture to stack trace by default when unwanted flag is passed in options', async function() {
it('should add code capture to stack trace by default when unwanted flag is passed in options', async function () {
const options = { captureCodeSnippet: 'heyy' }; // expects a true or false but it defaults to true
const tracker = new OneUptimeTracker(
API_URL,

View File

@@ -17,7 +17,7 @@ const tableName = 'License';
const email = 'license@hackerbay.io';
let validLicenseId: $TSFixMe, expiredLicenseId: $TSFixMe;
describe('License API', function() {
describe('License API', function () {
this.timeout(20000);
before(async () => {
@@ -43,7 +43,7 @@ describe('License API', function() {
license: validLicense['License Key'],
email,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(200);
expect(res.body).have.property('token');
done();
@@ -57,7 +57,7 @@ describe('License API', function() {
license: invalidLicense['License Key'],
email,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.equal('Invalid License');
done();
@@ -71,7 +71,7 @@ describe('License API', function() {
license: expiredLicense['License Key'],
email,
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.equal('License Expired');
done();
@@ -84,7 +84,7 @@ describe('License API', function() {
.send({
license: validLicense['License Key'],
})
.end(function(err: $TSFixMe, res: $TSFixMe) {
.end(function (err: $TSFixMe, req: Response) {
expect(res).to.have.status(400);
expect(res.body.message).to.equal('Email must be present.');
done();

View File

@@ -3,13 +3,13 @@ const BASE_URL = `${process.env.BACKEND_PROTOCOL}://${process.env.ONEUPTIME_HOST
// make api call to designated endpoints
// to make the necessary updates to the db
module.exports.create = function(config: $TSFixMe) {
module.exports.create = function (config: $TSFixMe) {
const store = {};
store.options = config;
store.accounts = {
setKeypair: function(opts: $TSFixMe) {
setKeypair: function (opts: $TSFixMe) {
const id =
(opts.account && opts.account.id) || opts.email || 'default';
@@ -27,10 +27,10 @@ module.exports.create = function(config: $TSFixMe) {
method: 'put',
data,
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
checkKeypair: function(opts: $TSFixMe) {
checkKeypair: function (opts: $TSFixMe) {
const id =
(opts.account && opts.account.id) || opts.email || 'default';
@@ -39,14 +39,14 @@ module.exports.create = function(config: $TSFixMe) {
url,
method: 'get',
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
options: config,
};
store.certificates = {
setKeypair: function(opts: $TSFixMe) {
setKeypair: function (opts: $TSFixMe) {
const id =
(opts.certificate &&
(opts.certificate.kid || opts.certificate.id)) ||
@@ -63,10 +63,10 @@ module.exports.create = function(config: $TSFixMe) {
method: 'put',
data,
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
checkKeypair: function(opts: $TSFixMe) {
checkKeypair: function (opts: $TSFixMe) {
const id =
(opts.certificate &&
(opts.certificate.kid || opts.certificate.id)) ||
@@ -77,10 +77,10 @@ module.exports.create = function(config: $TSFixMe) {
url,
method: 'get',
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
set: function(opts: $TSFixMe) {
set: function (opts: $TSFixMe) {
const id =
(opts.certificate && opts.certificate.id) || opts.subject;
@@ -95,10 +95,10 @@ module.exports.create = function(config: $TSFixMe) {
method: 'put',
data,
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
check: function(opts: $TSFixMe) {
check: function (opts: $TSFixMe) {
const id =
(opts.certificate && opts.certificate.id) || opts.subject;
@@ -107,7 +107,7 @@ module.exports.create = function(config: $TSFixMe) {
url,
method: 'get',
})
.then((res: $TSFixMe) => res.data)
.then((req: Response) => res.data)
.finally(() => null);
},
options: config,

View File

@@ -34,11 +34,11 @@
"lint": "ejslint home/views/*.ejs && eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore",
"fix-lint": "eslint '**/*.ts' -c .eslintrc.json --ignore-path .eslintignore --fix",
"fix": "npm run fix-lint",
"build": "source ./docker-enterprise.env && docker-compose build",
"build-dev": "source ./docker-enterprise.env && docker-compose -f docker-compose.dev.yml build $npm_config_services",
"build": "docker-compose --env-file ./docker-enterprise.env build",
"build-dev": "docker-compose --env-file ./docker-enterprise.env -f docker-compose.dev.yml build $npm_config_services",
"ps-dev": "docker-compose -f docker-compose.dev.yml ps",
"logs-dev": "docker-compose -f docker-compose.dev.yml logs --tail=100 -f $npm_config_services",
"force-build-dev": "source ./docker-enterprise.env && docker-compose -f docker-compose.dev.yml build --no-cache $npm_config_services",
"force-build-dev": "docker-compose --env-file ./docker-enterprise.env -f docker-compose.dev.yml build --no-cache $npm_config_services",
"prod": "docker-compose up -d",
"dev": "npm run start-enterprise-dev $npm_config_services",
"saas-dev": "export IS_SAAS_SERVICE=true && npm run dev $npm_config_services",

View File

@@ -7,9 +7,9 @@ import { sendErrorResponse } from 'common-server/utils/response';
import { sendListResponse } from 'common-server/utils/response';
router.get('/monitors', isAuthorizedProbe, async function(
req: $TSFixMe,
res: $TSFixMe
router.get('/monitors', isAuthorizedProbe, async function (
req: Request,
req: Response
) {
try {
const { limit = 10 } = req.query;

View File

@@ -8,9 +8,9 @@ import {
import { isAuthorizedService } from '../middlewares/serviceAuthorization';
import RealtimeService from '../services/realtimeService';
router.post('/send-created-incident', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-created-incident', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, incident } = req.body;
@@ -22,9 +22,9 @@ router.post('/send-created-incident', isAuthorizedService, async function(
}
});
router.post('/send-incident-timeline', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-incident-timeline', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, data } = req.body;
@@ -36,9 +36,9 @@ router.post('/send-incident-timeline', isAuthorizedService, async function(
}
});
router.post('/send-sla-countdown', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-sla-countdown', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, incident, countDown } = req.body;
@@ -54,9 +54,9 @@ router.post('/send-sla-countdown', isAuthorizedService, async function(
}
});
router.post('/delete-incident', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/delete-incident', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, incident } = req.body;
@@ -68,9 +68,9 @@ router.post('/delete-incident', isAuthorizedService, async function(
}
});
router.post('/add-incident-note', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/add-incident-note', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, incidentNote } = req.body;
@@ -82,9 +82,9 @@ router.post('/add-incident-note', isAuthorizedService, async function(
}
});
router.post('/update-incident-note', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-incident-note', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, incidentNote } = req.body;
@@ -96,9 +96,9 @@ router.post('/update-incident-note', isAuthorizedService, async function(
}
});
router.post('/update-incident-timeline', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-incident-timeline', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { incidentTimeline, projectId } = req.body;
@@ -110,9 +110,9 @@ router.post('/update-incident-timeline', isAuthorizedService, async function(
}
});
router.post('/update-incident', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-incident', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { incident, projectId } = req.body;
@@ -124,9 +124,9 @@ router.post('/update-incident', isAuthorizedService, async function(
}
});
router.post('/delete-incident-note', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/delete-incident-note', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { incidentNote, projectId } = req.body;
@@ -138,9 +138,9 @@ router.post('/delete-incident-note', isAuthorizedService, async function(
}
});
router.post('/add-scheduled-event', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/add-scheduled-event', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { event, projectId } = req.body;
@@ -152,9 +152,9 @@ router.post('/add-scheduled-event', isAuthorizedService, async function(
}
});
router.post('/delete-scheduled-event', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/delete-scheduled-event', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { event, projectId } = req.body;
@@ -166,9 +166,9 @@ router.post('/delete-scheduled-event', isAuthorizedService, async function(
}
});
router.post('/update-scheduled-event', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-scheduled-event', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { event, projectId } = req.body;
@@ -180,9 +180,9 @@ router.post('/update-scheduled-event', isAuthorizedService, async function(
}
});
router.post('/resolve-scheduled-event', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/resolve-scheduled-event', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { event, projectId } = req.body;
@@ -197,7 +197,7 @@ router.post('/resolve-scheduled-event', isAuthorizedService, async function(
router.post(
'/add-scheduled-event-internal-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId } = req.body;
@@ -215,7 +215,7 @@ router.post(
router.post(
'/add-scheduled-event-investigation-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId, projectId } = req.body;
@@ -234,7 +234,7 @@ router.post(
router.post(
'/delete-scheduled-event-internal-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId } = req.body;
@@ -252,7 +252,7 @@ router.post(
router.post(
'/delete-scheduled-event-investigation-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId, projectId } = req.body;
@@ -271,7 +271,7 @@ router.post(
router.post(
'/update-scheduled-event-investigation-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId, projectId } = req.body;
@@ -290,7 +290,7 @@ router.post(
router.post(
'/update-scheduled-event-internal-note',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { note, scheduledEventId } = req.body;
@@ -305,9 +305,9 @@ router.post(
}
);
router.post('/send-component-created', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-component-created', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { component, projectId } = req.body;
@@ -319,9 +319,9 @@ router.post('/send-component-created', isAuthorizedService, async function(
}
});
router.post('/send-monitor-created', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-monitor-created', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { monitor, projectId } = req.body;
@@ -333,9 +333,9 @@ router.post('/send-monitor-created', isAuthorizedService, async function(
}
});
router.post('/send-monitor-delete', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-monitor-delete', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { monitor, projectId } = req.body;
@@ -347,9 +347,9 @@ router.post('/send-monitor-delete', isAuthorizedService, async function(
}
});
router.post('/send-component-delete', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-component-delete', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { component, projectId } = req.body;
@@ -361,9 +361,9 @@ router.post('/send-component-delete', isAuthorizedService, async function(
}
});
router.post('/incident-resolved', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/incident-resolved', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { incident, projectId } = req.body;
@@ -375,9 +375,9 @@ router.post('/incident-resolved', isAuthorizedService, async function(
}
});
router.post('/incident-acknowledged', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/incident-acknowledged', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { incident, projectId } = req.body;
@@ -389,9 +389,9 @@ router.post('/incident-acknowledged', isAuthorizedService, async function(
}
});
router.post('/status-page-edit', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/status-page-edit', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { statusPage, projectId } = req.body;
@@ -403,9 +403,9 @@ router.post('/status-page-edit', isAuthorizedService, async function(
}
});
router.post('/component-edit', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/component-edit', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { component, projectId } = req.body;
@@ -417,9 +417,9 @@ router.post('/component-edit', isAuthorizedService, async function(
}
});
router.post('/monitor-edit', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/monitor-edit', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { monitor, projectId } = req.body;
@@ -431,9 +431,9 @@ router.post('/monitor-edit', isAuthorizedService, async function(
}
});
router.post('/update-monitor-log', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-monitor-log', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const {
@@ -457,9 +457,9 @@ router.post('/update-monitor-log', isAuthorizedService, async function(
}
});
router.post('/update-lighthouse-log', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-lighthouse-log', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const body = req.body;
@@ -477,9 +477,9 @@ router.post('/update-lighthouse-log', isAuthorizedService, async function(
}
});
router.post('/update-all-lighthouse-log', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-all-lighthouse-log', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, data, parentProjectId, monitorId } = req.body;
@@ -496,9 +496,9 @@ router.post('/update-all-lighthouse-log', isAuthorizedService, async function(
}
});
router.post('/update-monitor-status', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-monitor-status', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { data, projectId, monitorId, parentProjectId } = req.body;
@@ -515,9 +515,9 @@ router.post('/update-monitor-status', isAuthorizedService, async function(
}
});
router.post('/update-probe', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-probe', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { data } = req.body;
@@ -529,9 +529,9 @@ router.post('/update-probe', isAuthorizedService, async function(
}
});
router.post('/send-notification', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-notification', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { data, projectId } = req.body;
@@ -543,9 +543,9 @@ router.post('/send-notification', isAuthorizedService, async function(
}
});
router.post('/update-team-member-role', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/update-team-member-role', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, data } = req.body;
@@ -557,9 +557,9 @@ router.post('/update-team-member-role', isAuthorizedService, async function(
}
});
router.post('/create-team-member', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/create-team-member', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, data } = req.body;
@@ -571,9 +571,9 @@ router.post('/create-team-member', isAuthorizedService, async function(
}
});
router.post('/delete-team-member', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/delete-team-member', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { projectId, data } = req.body;
@@ -588,7 +588,7 @@ router.post('/delete-team-member', isAuthorizedService, async function(
router.post(
'/send-application-log-created',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { applicationLog, componentId } = req.body;
@@ -603,9 +603,9 @@ router.post(
}
);
router.post('/send-application-log-delete', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-application-log-delete', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { applicationLog, componentId } = req.body;
@@ -620,9 +620,9 @@ router.post('/send-application-log-delete', isAuthorizedService, async function(
}
});
router.post('/send-log-created', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-log-created', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { contentLog, applicationLogId } = req.body;
@@ -634,9 +634,9 @@ router.post('/send-log-created', isAuthorizedService, async function(
}
});
router.post('/application-log-key-reset', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/application-log-key-reset', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { applicationLog, componentId } = req.body;
@@ -651,7 +651,7 @@ router.post('/application-log-key-reset', isAuthorizedService, async function(
router.post(
'/send-container-security-created',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { containerSecurity, componentId } = req.body;
@@ -669,7 +669,7 @@ router.post(
router.post(
'/send-application-security-created',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { applicationSecurity, componentId } = req.body;
@@ -684,9 +684,9 @@ router.post(
}
);
router.post('/send-error-tracker-created', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-error-tracker-created', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { errorTracker, componentId } = req.body;
@@ -698,9 +698,9 @@ router.post('/send-error-tracker-created', isAuthorizedService, async function(
}
});
router.post('/send-error-tracker-delete', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-error-tracker-delete', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { errorTracker, componentId } = req.body;
@@ -712,9 +712,9 @@ router.post('/send-error-tracker-delete', isAuthorizedService, async function(
}
});
router.post('/error-tracker-key-reset', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/error-tracker-key-reset', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { errorTracker, componentId } = req.body;
@@ -726,9 +726,9 @@ router.post('/error-tracker-key-reset', isAuthorizedService, async function(
}
});
router.post('/send-error-event-created', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-error-event-created', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { data, errorTrackerId } = req.body;
@@ -740,9 +740,9 @@ router.post('/send-error-event-created', isAuthorizedService, async function(
}
});
router.post('/send-issue-status-change', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-issue-status-change', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { issue, type, errorTrackerId } = req.body;
@@ -757,7 +757,7 @@ router.post('/send-issue-status-change', isAuthorizedService, async function(
router.post(
'/send-error-tracker-issue-delete',
isAuthorizedService,
async function(req: Request, res: Response) {
async function (req: Request, res: Response) {
try {
const { issue, errorTrackerId } = req.body;
@@ -772,9 +772,9 @@ router.post(
}
);
router.post('/send-time-metrics', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-time-metrics', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { appId, data } = req.body;
@@ -786,9 +786,9 @@ router.post('/send-time-metrics', isAuthorizedService, async function(
}
});
router.post('/send-throughput-metrics', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-throughput-metrics', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { appId, data } = req.body;
@@ -800,9 +800,9 @@ router.post('/send-throughput-metrics', isAuthorizedService, async function(
}
});
router.post('/send-error-metrics', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/send-error-metrics', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { appId, data } = req.body;
@@ -814,9 +814,9 @@ router.post('/send-error-metrics', isAuthorizedService, async function(
}
});
router.post('/handle-scanning', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/handle-scanning', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { security } = req.body;
@@ -828,9 +828,9 @@ router.post('/handle-scanning', isAuthorizedService, async function(
}
});
router.post('/handle-log', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/handle-log', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { securityId, securityLog } = req.body;
@@ -842,9 +842,9 @@ router.post('/handle-log', isAuthorizedService, async function(
}
});
router.post('/status-page-update-tweets', isAuthorizedService, async function(
req: $TSFixMe,
res: $TSFixMe
router.post('/status-page-update-tweets', isAuthorizedService, async function (
req: Request,
req: Response
) {
try {
const { tweets, statusPageId, _projectId } = req.body;

View File

@@ -1,14 +1,14 @@
import { Request, Response } from 'common-server/utils/express';
export default {
sendSuccessResponse: function(
req: $TSFixMe,
res: $TSFixMe,
sendSuccessResponse: function (
req: Request,
req: Response,
data: $TSFixMe
) {
return res.status(200).send(data);
},
sendErrorResponse: function(req: Request, res: Response, error: $TSFixMe) {
sendErrorResponse: function (req: Request, res: Response, error: $TSFixMe) {
if (
error.message &&
error.code !== 'ENOTFOUND' &&

View File

@@ -29,7 +29,7 @@ function getMongoClient() {
// setup mongodb connection
const client = getMongoClient();
(async function() {
(async function () {
try {
// eslint-disable-next-line no-console
console.log('connecting to db');
@@ -59,9 +59,9 @@ if (process.env.ONEUPTIME_HOST) {
: `http://${process.env.ONEUPTIME_HOST}/api`;
}
app.get(['/env.js', '/status-page/env.js'], function(
req: $TSFixMe,
res: $TSFixMe
app.get(['/env.js', '/status-page/env.js'], function (
req: Request,
req: Response
) {
let REACT_APP_ONEUPTIME_HOST = null;
let REACT_APP_BACKEND_PROTOCOL = null;
@@ -112,9 +112,9 @@ app.get(['/env.js', '/status-page/env.js'], function(
res.send('window._env = ' + JSON.stringify(env));
});
app.use('/.well-known/acme-challenge/:token', async function(
req: $TSFixMe,
res: $TSFixMe
app.use('/.well-known/acme-challenge/:token', async function (
req: Request,
req: Response
) {
// make api call to backend and fetch keyAuthorization
const { token } = req.params;
@@ -173,7 +173,7 @@ async function handleCertificate(
return certificate;
}
app.use('/', async function(req: Request, res: Response, next: $TSFixMe) {
app.use('/', async function (req: Request, res: Response, next: $TSFixMe) {
const host = req.hostname;
if (
host &&
@@ -214,9 +214,9 @@ app.use('/', async function(req: Request, res: Response, next: $TSFixMe) {
}
});
app.get(['/status-page/status', '/status'], function(
req: $TSFixMe,
res: $TSFixMe
app.get(['/status-page/status', '/status'], function (
req: Request,
req: Response
) {
res.setHeader('Content-Type', 'application/json');
res.send(
@@ -235,7 +235,7 @@ app.use(
express.static(path.join(__dirname, 'build/static/js'))
);
app.get('/*', function(req: Request, res: Response) {
app.get('/*', function (req: Request, res: Response) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
@@ -245,7 +245,7 @@ async function fetchCredential(
configPath: $TSFixMe
) {
return new Promise((resolve, reject) => {
fetch(`${apiHost}/file/${credentialName}`).then((res: $TSFixMe) => {
fetch(`${apiHost}/file/${credentialName}`).then((req: Response) => {
const dest = fs.createWriteStream(configPath);
res.body.pipe(dest);
// at this point, writing to the specified file is complete
@@ -274,7 +274,7 @@ function decodeAndSave(content: $TSFixMe, filePath: $TSFixMe) {
output += strData;
});
commandOutput.on('close', () => {
fs.writeFile(filePath, output, 'utf8', function() {
fs.writeFile(filePath, output, 'utf8', function () {
resolve('Done writing to disc');
});
});
@@ -321,7 +321,7 @@ function countFreq(pat: $TSFixMe, txt: $TSFixMe) {
// using an IIFE here because we have an asynchronous code we want to run as we start the server
// and since we can't await outside an async function, we had to use an IIFE to handle that
(async function() {
(async function () {
// create http server
http.createServer(app).listen(3006, () =>
// eslint-disable-next-line no-console
@@ -364,7 +364,7 @@ function countFreq(pat: $TSFixMe, txt: $TSFixMe) {
key: fs.readFileSync(
path.resolve(process.cwd(), 'src', 'credentials', 'private.key')
),
SNICallback: async function(domain: $TSFixMe, cb: $TSFixMe) {
SNICallback: async function (domain: $TSFixMe, cb: $TSFixMe) {
const res = await handleCustomDomain(
client,
'statuspages',