Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('IntegrationRpc', () => {
let integrationRpc: IntegrationRpc;
const mockServer = mockhttp.getLocal();
// Start your servers
beforeEach(async () => {
const url = baseUrl();
integrationRpc = new IntegrationRpc(url, rpcVersion);
await mockServer.start(8080);
});
afterEach(async () => {
await mockServer.stop();
});
describe('#getIntegrations()', async () => {
it('should get integration list', async () => {
const integrations = [newMockIntegration(), newMockIntegration()];
await mockServer.get('/integrations/v1').thenJson(200, integrations);
const response: Integration[] = await integrationRpc.getIntegrations();
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
const mockServer = require("mockttp").getLocal();
describe('App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
beforeEach(() => mockServer.start(8080));
afterEach(() => mockServer.stop());
it('should display login page', () => {
mockServer.get("/api/authentication/user").thenReply(200);
page.navigateTo();
expect(page.getTitleText()).toEqual('Log in');
import { AppPage } from './app.po';
const mockServer = require("mockttp").getLocal();
describe('App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
beforeEach(() => mockServer.start(8080));
afterEach(() => mockServer.stop());
it('should display welcome message', () => {
mockServer.get("/api/state/state").thenReply(200, '"START_STATE"');
mockServer.get("/api/question/sets").thenReply(200, '[{"id":0,"name":"Question Set 1"},{"id":1,"name":"Question Set 2"},{"id":2,"name":"Question Set 3"}]');
mockServer.get("/api/question/quantities").withQuery({"questionSetId":"0"}).thenReply(200, '[5,10]');
describe('UserRpc', (): void => {
const mockServer = mockhttp.getLocal();
let userRpc: UserRpc;
beforeEach(
async (): Promise => {
const url = baseUrl();
userRpc = new UserRpc(url, rpcVersion);
await mockServer.start(8080);
},
);
afterEach(
async (): Promise => {
await mockServer.stop();
},
);
const certificateInfo = await mockttp.generateCACertificate({
bits: 2048,
commonName: 'Optic Labs Corp'
})
const certificatePath = path.join(configPath, '.optic', 'certificates')
await fs.ensureDir(certificatePath);
const certPath = path.join(certificatePath, 'ca.cert')
const keyPath = path.join(certificatePath, 'ca.key')
await fs.writeFile(certPath, certificateInfo.cert)
await fs.writeFile(keyPath, certificateInfo.key)
const https = {
certPath,
keyPath
}
const proxy = mockttp.getLocal({
cors: true,
debug: false,
https,
recordTraffic: false
})
this.proxy = proxy;
proxy.addRules(
{
matchers: [
new mockttp.matchers.WildcardMatcher()
],
handler: new mockttp.handlers.PassThroughHandler()
}
)
proxy.on('request', (req: mockttp.CompletedRequest) => {
const certificateInfo = await mockttp.generateCACertificate({
bits: 2048,
commonName: 'Optic Labs Corp'
})
const certificatePath = path.join(configPath, '.optic', 'certificates')
await fs.ensureDir(certificatePath)
const certPath = path.join(certificatePath, 'ca.cert')
const keyPath = path.join(certificatePath, 'ca.key')
await fs.writeFile(certPath, certificateInfo.cert)
await fs.writeFile(keyPath, certificateInfo.key)
const https = {
certPath,
keyPath
}
const proxy = mockttp.getLocal({
cors: true,
debug: false,
https,
recordTraffic: false
})
this.proxy = proxy
proxy.addRules(
{
matchers: [
new mockttp.matchers.HostMatcher('amiusing.httptoolkit.tech')
],
handler: new mockttp.handlers.CallbackHandler(request => {
const response: CallbackResponseResult = {
statusCode: 302,
headers: {
location: `https://${config.targetHost}`