* Runs a test using a TLS-enabled Redis client. * Automatically spawns a TLS-enabled Redis container with both TLS and non-TLS ports, * extracts certificates, and configures the TLS client. * * @param title - Test title * @param fn - Test function receiving the TLS client and port inf
(
title: string,
fn: (
client: RedisClientType<M, F, S, RESP, TYPE_MAPPING>,
ports: { port: number; tlsPort: number },
) => unknown,
options: TlsClientTestOptions<M, F, S, RESP, TYPE_MAPPING>,
)
| 430 | * @param options - TLS client test options |
| 431 | */ |
| 432 | testWithTlsClient< |
| 433 | M extends RedisModules = {}, |
| 434 | F extends RedisFunctions = {}, |
| 435 | S extends RedisScripts = {}, |
| 436 | RESP extends RespVersions = 2, |
| 437 | TYPE_MAPPING extends TypeMapping = {}, |
| 438 | >( |
| 439 | title: string, |
| 440 | fn: ( |
| 441 | client: RedisClientType<M, F, S, RESP, TYPE_MAPPING>, |
| 442 | ports: { port: number; tlsPort: number }, |
| 443 | ) => unknown, |
| 444 | options: TlsClientTestOptions<M, F, S, RESP, TYPE_MAPPING>, |
| 445 | ): void { |
| 446 | let dockerPromise: ReturnType<typeof spawnTlsRedisServer>; |
| 447 | if (this.isVersionGreaterThan(options.minimumDockerVersion)) { |
| 448 | const dockerImage = this.#DOCKER_IMAGE; |
| 449 | before(function () { |
| 450 | this.timeout(60000); // TLS setup takes longer |
| 451 | |
| 452 | dockerPromise = spawnTlsRedisServer( |
| 453 | dockerImage, |
| 454 | options.serverArguments, |
| 455 | options.tls, |
| 456 | ); |
| 457 | return dockerPromise; |
| 458 | }); |
| 459 | } |
| 460 | |
| 461 | it(title, async function () { |
| 462 | if (options.skipTest) return this.skip(); |
| 463 | if (!dockerPromise) return this.skip(); |
| 464 | |
| 465 | const docker = await dockerPromise; |
| 466 | |
| 467 | // Create TLS client |
| 468 | const client = createClient({ |
| 469 | ...options.clientOptions, |
| 470 | socket: { |
| 471 | ...options.clientOptions?.socket, |
| 472 | port: docker.tlsPort, |
| 473 | tls: true, |
| 474 | ca: docker.certs.ca, |
| 475 | cert: docker.certs.cert, |
| 476 | key: docker.certs.key, |
| 477 | }, |
| 478 | }); |
| 479 | |
| 480 | const ports = { port: docker.port, tlsPort: docker.tlsPort }; |
| 481 | |
| 482 | if (options.disableClientSetup) { |
| 483 | return fn(client, ports); |
| 484 | } |
| 485 | |
| 486 | await client.connect(); |
| 487 | |
| 488 | try { |
| 489 | await client.flushAll(); |
no test coverage detected