forked from ESAPI/node-esapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
23 lines (22 loc) · 1.69 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var assert = require('assert');
var ESAPI = require('../lib/esapi');
describe('ESAPI', function(){
it('should encodeForHTML',function(){
assert.equal(ESAPI.encoder().encodeForHTML('< > " \' / &'), '< > " ' / &');
});
it('should encodeForHTMLAttribute',function(){
assert.equal(ESAPI.encoder().encodeForHTMLAttribute(' % * + , - / ; < = > ^ and |'), ' % * + , - / ; < = > ^ and |');
});
it('should encodeForJavaScript',function(){
assert.equal(ESAPI.encoder().encodeForJavaScript('[space] % * + , - / ; < = > ^ and |. Also, a </script>'), '\\x5Bspace\\x5D\\x20\\x25\\x20\\x2A\\x20\\x2B\\x20,\\x20\\x2D\\x20\\x2F\\x20\\x3B\\x20\\x3C\\x20\\x3D\\x20\\x3E\\x20\\x5E\\x20and\\x20\\x7C.\\x20Also,\\x20a\\x20\\x3C\\x2Fscript\\x3E');
});
it('should encodeForCSS',function(){
assert.equal(ESAPI.encoder().encodeForCSS('[space] % * + , - / ; < = > ^ and |. Also, the </style>'), '\\5b space\\5d \\20 \\25 \\20 \\2a \\20 \\2b \\20 \\2c \\20 \\2d \\20 \\2f \\20 \\3b \\20 \\3c \\20 \\3d \\20 \\3e \\20 \\5e \\20 and\\20 \\7c \\2e \\20 Also\\2c \\20 the\\20 \\3c \\2f style\\3e ');
});
it('should encodeForURL',function(){
assert.equal(ESAPI.encoder().encodeForURL('[space] % * + , - / ; < = > ^ and |. Also, the </style>'), '%5Bspace%5D%20%25%20*%20+%20%2C%20-%20/%20%3B%20%3C%20%3D%20%3E%20%5E%20and%20%7C.%20Also%2C%20the%20%3C/style%3E');
});
it('should encodeForBase64',function(){
assert.equal(ESAPI.encoder().encodeForBase64('[space] % * + , - / ; < = > ^ and |. Also, a </script>'), 'W3NwYWNlXSAlICogKyAsIC0gLyA7IDwgPSA+IF4gYW5kIHwuIEFsc28sIGEgPC9zY3JpcHQ+');
});
});