mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
|
import Assert = require("assert");
|
||
|
import { InputsSanitizer } from "../../src/lib/ldap/InputsSanitizer";
|
||
|
|
||
|
describe("test InputsSanitizer", function () {
|
||
|
it("should fail when special characters are used", function () {
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("ab,c"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a\\bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a'bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a#bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a+bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a<bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a>bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a;bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a\"bc"); }, Error);
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize("a=bc"); }, Error);
|
||
|
});
|
||
|
|
||
|
it("should return original string", function () {
|
||
|
Assert.equal(InputsSanitizer.sanitize("abcdef"), "abcdef");
|
||
|
});
|
||
|
|
||
|
it("should trim", function () {
|
||
|
Assert.throws(() => { InputsSanitizer.sanitize(" abc "); }, Error);
|
||
|
});
|
||
|
});
|