Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const fakeCloseSecureChannelResponse = new CloseSecureChannelResponse({});
export const fakeOpenSecureChannelResponse = new OpenSecureChannelResponse({
serverProtocolVersion: 0,
securityToken: {
channelId: 23,
createdAt: new Date(), // now
revisedLifetime: 30000,
tokenId: 1,
},
serverNonce: Buffer.from("qwerty")
});
export const fakeGetEndpointsResponse = new GetEndpointsResponse({
endpoints: [
{
endpointUrl: "fake://localhost:2033/SomeAddress"
}
]
});
export const fakeCreateSessionResponse = new CreateSessionResponse({});
export const fakeActivateSessionResponse = new ActivateSessionResponse({});
export class MockServerTransport extends EventEmitter {
private _replies: any;
private _mockTransport: DirectTransport;
private _counter: number;
protected _on_GetEndpointsRequest(message: Message, channel: ServerSecureChannelLayer) {
const server = this;
const request = message.request as GetEndpointsRequest;
assert(request.schema.name === "GetEndpointsRequest");
const response = new GetEndpointsResponse({});
response.endpoints = server._get_endpoints();
response.endpoints = response.endpoints.filter(
(endpoint: EndpointDescription) => !(endpoint as any).restricted);
// apply filters
if (request.profileUris && request.profileUris.length > 0) {
response.endpoints = response.endpoints.filter((endpoint: any) => {
return request.profileUris!.indexOf(endpoint.transportProfileUri) >= 0;
});
}
// adjust locale on ApplicationName to match requested local or provide
// a string with neutral locale (locale === null)
// TODO: find a better way to handle this