MCPcopy Index your code
hub / github.com/ether/etherpad / init

Function init

src/tests/backend/common.ts:104–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102};
103
104export const init = async function () {
105 if (agentPromise != null) return await agentPromise;
106 let agentResolve;
107 agentPromise = new Promise((resolve) => { agentResolve = resolve; });
108
109 if (!logLevel.isLessThanOrEqualTo(log4js.levels.DEBUG)) {
110 logger.warn('Disabling non-test logging for the duration of the test. ' +
111 'To enable non-test logging, change the loglevel setting to DEBUG.');
112 }
113
114 // Note: This is only a shallow backup.
115 backups.settings = Object.assign({}, settings);
116 // Start the Etherpad server on a random unused port.
117 settings.port = 0;
118 settings.ip = 'localhost';
119 settings.importExportRateLimiting = {max: 999999};
120 settings.commitRateLimiting = {duration: 0.001, points: 1e6};
121 httpServer = await server.start();
122 // @ts-ignore
123 baseUrl = `http://localhost:${httpServer!.address()!.port}`;
124 logger.debug(`HTTP server at ${baseUrl}`);
125 // Create a supertest user agent for the HTTP server.
126 agent = supertest(baseUrl)
127 //.set('Authorization', `Bearer ${await generateJWTToken()}`);
128 // Speed up authn tests.
129 backups.authnFailureDelayMs = webaccess.authnFailureDelayMs;
130 webaccess.authnFailureDelayMs = 0;
131
132 after(async function () {
133 webaccess.authnFailureDelayMs = backups.authnFailureDelayMs;
134 // Note: This does not unset settings that were added.
135 Object.assign(settings, backups.settings);
136 await server.exit();
137 });
138
139 agentResolve!(agent);
140 return agent;
141};
142
143/**
144 * Waits for the next named socket.io event. Rejects if there is an error event while waiting

Callers 2

common.tsFile · 0.70

Calls 1

startMethod · 0.80

Tested by

no test coverage detected