|
1 |
| -import {resolve} from "https://deno.land/[email protected]/path/resolve.ts"; |
2 |
| -import {join} from "https://deno.land/[email protected]/path/join.ts"; |
3 |
| -import {NatsServer} from "../tests/helpers/launcher.ts"; |
4 |
| -import {connect} from "../src/connect.ts"; |
| 1 | +import { resolve } from "https://deno.land/[email protected]/path/resolve.ts"; |
| 2 | +import { join } from "https://deno.land/[email protected]/path/join.ts"; |
| 3 | +import { NatsServer } from "../tests/helpers/launcher.ts"; |
| 4 | +import { connect } from "../src/connect.ts"; |
5 | 5 |
|
6 | 6 | Deno.test("tls-unsafe - handshake first", async () => {
|
7 |
| - const cwd = Deno.cwd(); |
8 |
| - const config = { |
9 |
| - host: "localhost", |
10 |
| - tls: { |
11 |
| - handshake_first: true, |
12 |
| - cert_file: resolve(join(cwd, "./tests/certs/localhost.crt")), |
13 |
| - key_file: resolve(join(cwd, "./tests/certs/localhost.key")), |
14 |
| - ca_file: resolve(join(cwd, "./tests/certs/RootCA.crt")), |
15 |
| - }, |
16 |
| - }; |
| 7 | + const cwd = Deno.cwd(); |
| 8 | + const config = { |
| 9 | + host: "localhost", |
| 10 | + tls: { |
| 11 | + handshake_first: true, |
| 12 | + cert_file: resolve(join(cwd, "./tests/certs/localhost.crt")), |
| 13 | + key_file: resolve(join(cwd, "./tests/certs/localhost.key")), |
| 14 | + ca_file: resolve(join(cwd, "./tests/certs/RootCA.crt")), |
| 15 | + }, |
| 16 | + }; |
17 | 17 |
|
18 |
| - const ns = await NatsServer.start(config); |
19 |
| - const nc = await connect({ |
20 |
| - debug: true, |
21 |
| - servers: `localhost:${ns.port}`, |
22 |
| - tls: { |
23 |
| - handshakeFirst: true, |
24 |
| - caFile: config.tls.ca_file, |
25 |
| - }, |
26 |
| - }); |
27 |
| - nc.subscribe("foo", { |
28 |
| - callback(_err, msg) { |
29 |
| - msg.respond(msg.data); |
30 |
| - }, |
31 |
| - }); |
| 18 | + const ns = await NatsServer.start(config); |
| 19 | + const nc = await connect({ |
| 20 | + debug: true, |
| 21 | + servers: `localhost:${ns.port}`, |
| 22 | + tls: { |
| 23 | + handshakeFirst: true, |
| 24 | + caFile: config.tls.ca_file, |
| 25 | + }, |
| 26 | + }); |
| 27 | + nc.subscribe("foo", { |
| 28 | + callback(_err, msg) { |
| 29 | + msg.respond(msg.data); |
| 30 | + }, |
| 31 | + }); |
32 | 32 |
|
33 |
| - await nc.request("foo", "hello"); |
34 |
| - await nc.close(); |
35 |
| - await ns.stop(); |
| 33 | + await nc.request("foo", "hello"); |
| 34 | + await nc.close(); |
| 35 | + await ns.stop(); |
36 | 36 | });
|
0 commit comments