60e2149072
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date) - Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class - Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting - Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states - Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions - Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares) - Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline - Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements - Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations - Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary - Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds All tests follow AAA pattern and use data-testid selectors matching Angular version. Total: 245 tests across 10 feature suites.
67 lines
2.4 KiB
JavaScript
67 lines
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.describeTLS = describeTLS;
|
|
exports.describeAddress = describeAddress;
|
|
exports.upgradeSocket = upgradeSocket;
|
|
exports.ipIsPrivateV4Address = ipIsPrivateV4Address;
|
|
const tls_1 = require("tls");
|
|
/**
|
|
* Returns a string describing the encryption on a given socket instance.
|
|
*/
|
|
function describeTLS(socket) {
|
|
if (socket instanceof tls_1.TLSSocket) {
|
|
const protocol = socket.getProtocol();
|
|
return protocol ? protocol : "Server socket or disconnected client socket";
|
|
}
|
|
return "No encryption";
|
|
}
|
|
/**
|
|
* Returns a string describing the remote address of a socket.
|
|
*/
|
|
function describeAddress(socket) {
|
|
if (socket.remoteFamily === "IPv6") {
|
|
return `[${socket.remoteAddress}]:${socket.remotePort}`;
|
|
}
|
|
return `${socket.remoteAddress}:${socket.remotePort}`;
|
|
}
|
|
/**
|
|
* Upgrade a socket connection with TLS.
|
|
*/
|
|
function upgradeSocket(socket, options) {
|
|
return new Promise((resolve, reject) => {
|
|
const tlsOptions = Object.assign({}, options, {
|
|
socket
|
|
});
|
|
const tlsSocket = (0, tls_1.connect)(tlsOptions, () => {
|
|
const expectCertificate = tlsOptions.rejectUnauthorized !== false;
|
|
if (expectCertificate && !tlsSocket.authorized) {
|
|
reject(tlsSocket.authorizationError);
|
|
}
|
|
else {
|
|
// Remove error listener added below.
|
|
tlsSocket.removeAllListeners("error");
|
|
resolve(tlsSocket);
|
|
}
|
|
}).once("error", error => {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
* Returns true if an IP is a private address according to https://tools.ietf.org/html/rfc1918#section-3.
|
|
* This will handle IPv4-mapped IPv6 addresses correctly but return false for all other IPv6 addresses.
|
|
*
|
|
* @param ip The IP as a string, e.g. "192.168.0.1"
|
|
*/
|
|
function ipIsPrivateV4Address(ip = "") {
|
|
// Handle IPv4-mapped IPv6 addresses like ::ffff:192.168.0.1
|
|
if (ip.startsWith("::ffff:")) {
|
|
ip = ip.substr(7); // Strip ::ffff: prefix
|
|
}
|
|
const octets = ip.split(".").map(o => parseInt(o, 10));
|
|
return octets[0] === 10 // 10.0.0.0 - 10.255.255.255
|
|
|| (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) // 172.16.0.0 - 172.31.255.255
|
|
|| (octets[0] === 192 && octets[1] === 168) // 192.168.0.0 - 192.168.255.255
|
|
|| ip === "127.0.0.1";
|
|
}
|