summaryrefslogtreecommitdiff
path: root/std/http/_io_test.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-06-04 03:32:27 +0100
committerGitHub <noreply@github.com>2020-06-03 22:32:27 -0400
commit97d876f6db55f5f32ac06155dcb4823e1c636215 (patch)
tree0171130f480548663608dd9440e8bf37fff68c5f /std/http/_io_test.ts
parent9bd5c08d5a2a9cdd2649dd24a4d6b26d9af2a4c4 (diff)
fix(std/http): Don't use assert() for user input validation (#6092)
Diffstat (limited to 'std/http/_io_test.ts')
-rw-r--r--std/http/_io_test.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/std/http/_io_test.ts b/std/http/_io_test.ts
index 3e74e365d..3b385d013 100644
--- a/std/http/_io_test.ts
+++ b/std/http/_io_test.ts
@@ -1,5 +1,4 @@
import {
- AssertionError,
assertThrowsAsync,
assertEquals,
assert,
@@ -105,8 +104,8 @@ test("readTrailer should throw if undeclared headers found in trailer", async ()
async () => {
await readTrailers(h, new BufReader(new Buffer(encode(trailer))));
},
- Error,
- "Undeclared trailer field"
+ Deno.errors.InvalidData,
+ `Undeclared trailers: [ "`
);
}
});
@@ -120,8 +119,8 @@ test("readTrailer should throw if trailer contains prohibited fields", async ()
async () => {
await readTrailers(h, new BufReader(new Buffer()));
},
- Error,
- "Prohibited field for trailer"
+ Deno.errors.InvalidData,
+ `Prohibited trailer names: [ "`
);
}
});
@@ -145,15 +144,15 @@ test("writeTrailer should throw", async () => {
() => {
return writeTrailers(w, new Headers(), new Headers());
},
- Error,
- 'must have "trailer"'
+ TypeError,
+ "Missing trailer header."
);
await assertThrowsAsync(
() => {
return writeTrailers(w, new Headers({ trailer: "deno" }), new Headers());
},
- Error,
- "only allowed"
+ TypeError,
+ `Trailers are only allowed for "transfer-encoding: chunked", got "transfer-encoding: null".`
);
for (const f of ["content-length", "trailer", "transfer-encoding"]) {
await assertThrowsAsync(
@@ -164,8 +163,8 @@ test("writeTrailer should throw", async () => {
new Headers({ [f]: "1" })
);
},
- AssertionError,
- "prohibited"
+ TypeError,
+ `Prohibited trailer names: [ "`
);
}
await assertThrowsAsync(
@@ -176,8 +175,8 @@ test("writeTrailer should throw", async () => {
new Headers({ node: "js" })
);
},
- AssertionError,
- "Not trailer"
+ TypeError,
+ `Undeclared trailers: [ "node" ].`
);
});