-
Notifications
You must be signed in to change notification settings - Fork 12
/
client.test.ts
60 lines (52 loc) · 2.31 KB
/
client.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { assertEquals } from "@std/assert/assert-equals";
import { Client } from "./client.ts";
Deno.test({
name: "host/port numbers",
fn: async (t) => {
const endPoint = "s3.eu-north-1.amazonaws.com";
const region = "eu-north-1";
await t.step("default insecure", () => {
const client = new Client({ endPoint, region });
// We default to HTTPS:
assertEquals(client.port, 443);
assertEquals(client.protocol, "https:");
assertEquals(client.host, endPoint); // Default port 443 should not be in host
});
await t.step("default explicit secure", () => {
const client = new Client({ endPoint, region, useSSL: true });
assertEquals(client.port, 443);
assertEquals(client.protocol, "https:");
assertEquals(client.host, endPoint);
});
await t.step("default explicit secure, explicit default port", () => {
const client = new Client({ endPoint, region, useSSL: true, port: 443 });
assertEquals(client.port, 443);
assertEquals(client.protocol, "https:");
assertEquals(client.host, endPoint);
});
await t.step("default explicit secure, explicit non-default port", () => {
const client = new Client({ endPoint, region, useSSL: true, port: 5432 });
assertEquals(client.port, 5432);
assertEquals(client.protocol, "https:");
assertEquals(client.host, endPoint + ":5432"); // Now port must be in the host
});
await t.step("default explicit INsecure", () => {
const client = new Client({ endPoint, region, useSSL: false });
assertEquals(client.port, 80);
assertEquals(client.protocol, "http:");
assertEquals(client.host, endPoint);
});
await t.step("default explicit INsecure, explicit default port", () => {
const client = new Client({ endPoint, region, useSSL: false, port: 80 });
assertEquals(client.port, 80);
assertEquals(client.protocol, "http:");
assertEquals(client.host, endPoint); // Port should not be in the host
});
await t.step("default explicit INsecure, explicit non-default port", () => {
const client = new Client({ endPoint, region, useSSL: false, port: 5432 });
assertEquals(client.port, 5432);
assertEquals(client.protocol, "http:");
assertEquals(client.host, endPoint + ":5432"); // Port is required
});
},
});