tough-cookie 1.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,164 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015, Salesforce.com, Inc.
3
- * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * 3. Neither the name of Salesforce.com nor the names of its contributors may
16
- * be used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- * POSSIBILITY OF SUCH DAMAGE.
30
- */
31
-
32
- 'use strict';
33
- var vows = require('vows');
34
- var assert = require('assert');
35
- var tough = require('../lib/cookie');
36
- var Cookie = tough.Cookie;
37
-
38
- vows
39
- .describe('Cookie.toJSON()')
40
- .addBatch({
41
- "JSON": {
42
- "serialization": {
43
- topic: function() {
44
- var c = Cookie.parse('alpha=beta; Domain=example.com; Path=/foo; Expires=Tue, 19 Jan 2038 03:14:07 GMT; HttpOnly');
45
- return JSON.stringify(c);
46
- },
47
- "gives a string": function(str) {
48
- assert.equal(typeof str, "string");
49
- },
50
- "date is in ISO format": function(str) {
51
- assert.match(str, /"expires":"2038-01-19T03:14:07\.000Z"/, 'expires is in ISO format');
52
- }
53
- },
54
- "deserialization": {
55
- topic: function() {
56
- var json = '{"key":"alpha","value":"beta","domain":"example.com","path":"/foo","expires":"2038-01-19T03:14:07.000Z","httpOnly":true,"lastAccessed":2000000000123}';
57
- return Cookie.fromJSON(json);
58
- },
59
- "works": function(c) {
60
- assert.ok(c);
61
- },
62
- "key": function(c) { assert.equal(c.key, "alpha") },
63
- "value": function(c) { assert.equal(c.value, "beta") },
64
- "domain": function(c) { assert.equal(c.domain, "example.com") },
65
- "path": function(c) { assert.equal(c.path, "/foo") },
66
- "httpOnly": function(c) { assert.strictEqual(c.httpOnly, true) },
67
- "secure": function(c) { assert.strictEqual(c.secure, false) },
68
- "hostOnly": function(c) { assert.strictEqual(c.hostOnly, null) },
69
- "expires is a date object": function(c) {
70
- assert.equal(c.expires.getTime(), 2147483647000);
71
- },
72
- "lastAccessed is a date object": function(c) {
73
- assert.equal(c.lastAccessed.getTime(), 2000000000123);
74
- },
75
- "creation defaulted": function(c) {
76
- assert.ok(c.creation.getTime());
77
- }
78
- },
79
- "null deserialization": {
80
- topic: function() {
81
- return Cookie.fromJSON(null);
82
- },
83
- "is null": function(cookie) {
84
- assert.equal(cookie,null);
85
- }
86
- }
87
- },
88
- "expiry deserialization": {
89
- "Infinity": {
90
- topic: Cookie.fromJSON.bind(null, '{"expires":"Infinity"}'),
91
- "is infinite": function(c) {
92
- assert.strictEqual(c.expires, "Infinity");
93
- assert.equal(c.expires, Infinity);
94
- }
95
- }
96
- },
97
- "maxAge serialization": {
98
- topic: function() {
99
- return function(toSet) {
100
- var c = new Cookie();
101
- c.key = 'foo'; c.value = 'bar';
102
- c.setMaxAge(toSet);
103
- return JSON.stringify(c);
104
- };
105
- },
106
- "zero": {
107
- topic: function(f) { return f(0) },
108
- "looks good": function(str) {
109
- assert.match(str, /"maxAge":0/);
110
- }
111
- },
112
- "Infinity": {
113
- topic: function(f) { return f(Infinity) },
114
- "looks good": function(str) {
115
- assert.match(str, /"maxAge":"Infinity"/);
116
- }
117
- },
118
- "-Infinity": {
119
- topic: function(f) { return f(-Infinity) },
120
- "looks good": function(str) {
121
- assert.match(str, /"maxAge":"-Infinity"/);
122
- }
123
- },
124
- "null": {
125
- topic: function(f) { return f(null) },
126
- "looks good": function(str) {
127
- assert.match(str, /"maxAge":null/);
128
- }
129
- }
130
- },
131
- "maxAge deserialization": {
132
- "number": {
133
- topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":123}'),
134
- "is the number": function(c) {
135
- assert.strictEqual(c.maxAge, 123);
136
- }
137
- },
138
- "null": {
139
- topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":null}'),
140
- "is null": function(c) {
141
- assert.strictEqual(c.maxAge, null);
142
- }
143
- },
144
- "less than zero": {
145
- topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":-123}'),
146
- "is -123": function(c) {
147
- assert.strictEqual(c.maxAge, -123);
148
- }
149
- },
150
- "Infinity": {
151
- topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":"Infinity"}'),
152
- "is inf-as-string": function(c) {
153
- assert.strictEqual(c.maxAge, "Infinity");
154
- }
155
- },
156
- "-Infinity": {
157
- topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":"-Infinity"}'),
158
- "is inf-as-string": function(c) {
159
- assert.strictEqual(c.maxAge, "-Infinity");
160
- }
161
- }
162
- }
163
- })
164
- .export(module);
@@ -1,162 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015, Salesforce.com, Inc.
3
- * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * 3. Neither the name of Salesforce.com nor the names of its contributors may
16
- * be used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- * POSSIBILITY OF SUCH DAMAGE.
30
- */
31
-
32
- 'use strict';
33
- var vows = require('vows');
34
- var assert = require('assert');
35
- var tough = require('../lib/cookie');
36
- var Cookie = tough.Cookie;
37
-
38
- vows
39
- .describe('Cookie.toString()')
40
- .addBatch({
41
- "a simple cookie": {
42
- topic: function () {
43
- var c = new Cookie();
44
- c.key = 'a';
45
- c.value = 'b';
46
- return c;
47
- },
48
- "validates": function (c) {
49
- assert.ok(c.validate());
50
- },
51
- "to string": function (c) {
52
- assert.equal(c.toString(), 'a=b');
53
- }
54
- },
55
- "a cookie with spaces in the value": {
56
- topic: function () {
57
- var c = new Cookie();
58
- c.key = 'a';
59
- c.value = 'beta gamma';
60
- return c;
61
- },
62
- "doesn't validate": function (c) {
63
- assert.ok(!c.validate());
64
- },
65
- "'garbage in, garbage out'": function (c) {
66
- assert.equal(c.toString(), 'a=beta gamma');
67
- }
68
- },
69
- "with an empty value and HttpOnly": {
70
- topic: function () {
71
- var c = new Cookie();
72
- c.key = 'a';
73
- c.httpOnly = true;
74
- return c;
75
- },
76
- "to string": function (c) {
77
- assert.equal(c.toString(), 'a=; HttpOnly');
78
- }
79
- },
80
- "with an expiry": {
81
- topic: function () {
82
- var c = new Cookie();
83
- c.key = 'a';
84
- c.value = 'b';
85
- c.setExpires("Oct 18 2011 07:05:03 GMT");
86
- return c;
87
- },
88
- "validates": function (c) {
89
- assert.ok(c.validate());
90
- },
91
- "to string": function (c) {
92
- assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT');
93
- },
94
- "to short string": function (c) {
95
- assert.equal(c.cookieString(), 'a=b');
96
- }
97
- },
98
- "with a max-age": {
99
- topic: function () {
100
- var c = new Cookie();
101
- c.key = 'a';
102
- c.value = 'b';
103
- c.setExpires("Oct 18 2011 07:05:03 GMT");
104
- c.maxAge = 12345;
105
- return c;
106
- },
107
- "validates": function (c) {
108
- assert.ok(c.validate()); // mabe this one *shouldn't*?
109
- },
110
- "to string": function (c) {
111
- assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Max-Age=12345');
112
- }
113
- },
114
- "with a bunch of things": function () {
115
- var c = new Cookie();
116
- c.key = 'a';
117
- c.value = 'b';
118
- c.setExpires("Oct 18 2011 07:05:03 GMT");
119
- c.maxAge = 12345;
120
- c.domain = 'example.com';
121
- c.path = '/foo';
122
- c.secure = true;
123
- c.httpOnly = true;
124
- c.extensions = ['MyExtension'];
125
- assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Max-Age=12345; Domain=example.com; Path=/foo; Secure; HttpOnly; MyExtension');
126
- },
127
- "a host-only cookie": {
128
- topic: function () {
129
- var c = new Cookie();
130
- c.key = 'a';
131
- c.value = 'b';
132
- c.hostOnly = true;
133
- c.domain = 'shouldnt-stringify.example.com';
134
- c.path = '/should-stringify';
135
- return c;
136
- },
137
- "validates": function (c) {
138
- assert.ok(c.validate());
139
- },
140
- "to string": function (c) {
141
- assert.equal(c.toString(), 'a=b; Path=/should-stringify');
142
- }
143
- },
144
- "minutes are '10'": {
145
- topic: function () {
146
- var c = new Cookie();
147
- c.key = 'a';
148
- c.value = 'b';
149
- c.expires = new Date(1284113410000);
150
- return c;
151
- },
152
- "validates": function (c) {
153
- assert.ok(c.validate());
154
- },
155
- "to string": function (c) {
156
- var str = c.toString();
157
- assert.notEqual(str, 'a=b; Expires=Fri, 010 Sep 2010 010:010:010 GMT');
158
- assert.equal(str, 'a=b; Expires=Fri, 10 Sep 2010 10:10:10 GMT');
159
- }
160
- }
161
- })
162
- .export(module);
package/test/date_test.js DELETED
@@ -1,79 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015, Salesforce.com, Inc.
3
- * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * 3. Neither the name of Salesforce.com nor the names of its contributors may
16
- * be used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- * POSSIBILITY OF SUCH DAMAGE.
30
- */
31
-
32
- 'use strict';
33
- var vows = require('vows');
34
- var assert = require('assert');
35
- var tough = require('../lib/cookie');
36
-
37
- function dateVows(table) {
38
- var theVows = {};
39
- Object.keys(table).forEach(function (date) {
40
- var expect = table[date];
41
- theVows[date] = function () {
42
- var got = tough.parseDate(date) ? 'valid' : 'invalid';
43
- assert.equal(got, expect ? 'valid' : 'invalid');
44
- };
45
- });
46
- return {"date parsing": theVows};
47
- }
48
-
49
- vows
50
- .describe('Date')
51
- .addBatch(dateVows({
52
- "Wed, 09 Jun 2021 10:18:14 GMT": true,
53
- "Wed, 09 Jun 2021 22:18:14 GMT": true,
54
- "Tue, 18 Oct 2011 07:42:42.123 GMT": true,
55
- "18 Oct 2011 07:42:42 GMT": true,
56
- "8 Oct 2011 7:42:42 GMT": true,
57
- "8 Oct 2011 7:2:42 GMT": true,
58
- "Oct 18 2011 07:42:42 GMT": true,
59
- "Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)": true,
60
- "09 Jun 2021 10:18:14 GMT": true,
61
- "99 Jix 3038 48:86:72 ZMT": false,
62
- '01 Jan 1970 00:00:00 GMT': true,
63
- '01 Jan 1600 00:00:00 GMT': false, // before 1601
64
- '01 Jan 1601 00:00:00 GMT': true,
65
- '10 Feb 81 13:00:00 GMT': true, // implicit year
66
- 'Thu, 17-Apr-2014 02:12:29 GMT': true, // dashes
67
- 'Thu, 17-Apr-2014 02:12:29 UTC': true // dashes and UTC
68
- }))
69
- .addBatch({
70
- "strict date parse of Thu, 01 Jan 1970 00:00:010 GMT": {
71
- topic: function () {
72
- return tough.parseDate('Thu, 01 Jan 1970 00:00:010 GMT', true) ? true : false;
73
- },
74
- "invalid": function (date) {
75
- assert.equal(date, false);
76
- }
77
- }
78
- })
79
- .export(module);
@@ -1,201 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015, Salesforce.com, Inc.
3
- * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * 3. Neither the name of Salesforce.com nor the names of its contributors may
16
- * be used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- * POSSIBILITY OF SUCH DAMAGE.
30
- */
31
-
32
- 'use strict';
33
- var vows = require('vows');
34
- var assert = require('assert');
35
- var tough = require('../lib/cookie');
36
- var Cookie = tough.Cookie;
37
-
38
- function matchVows(func, table) {
39
- var theVows = {};
40
- table.forEach(function (item) {
41
- var str = item[0];
42
- var dom = item[1];
43
- var expect = item[2];
44
- var label = str + (expect ? " matches " : " doesn't match ") + dom;
45
- theVows[label] = function () {
46
- assert.equal(func(str, dom), expect);
47
- };
48
- });
49
- return theVows;
50
- }
51
-
52
- function defaultPathVows(table) {
53
- var theVows = {};
54
- table.forEach(function (item) {
55
- var str = item[0];
56
- var expect = item[1];
57
- var label = str + " gives " + expect;
58
- theVows[label] = function () {
59
- assert.equal(tough.defaultPath(str), expect);
60
- };
61
- });
62
- return theVows;
63
- }
64
-
65
- vows
66
- .describe('Domain and Path')
67
- .addBatch({
68
- "domain normalization": {
69
- "simple": function () {
70
- var c = new Cookie();
71
- c.domain = "EXAMPLE.com";
72
- assert.equal(c.canonicalizedDomain(), "example.com");
73
- },
74
- "extra dots": function () {
75
- var c = new Cookie();
76
- c.domain = ".EXAMPLE.com";
77
- assert.equal(c.cdomain(), "example.com");
78
- },
79
- "weird trailing dot": function () {
80
- var c = new Cookie();
81
- c.domain = "EXAMPLE.ca.";
82
- assert.equal(c.canonicalizedDomain(), "example.ca.");
83
- },
84
- "weird internal dots": function () {
85
- var c = new Cookie();
86
- c.domain = "EXAMPLE...ca.";
87
- assert.equal(c.canonicalizedDomain(), "example...ca.");
88
- },
89
- "IDN": function () {
90
- var c = new Cookie();
91
- c.domain = "δοκιμή.δοκιμή"; // "test.test" in greek
92
- assert.equal(c.canonicalizedDomain(), "xn--jxalpdlp.xn--jxalpdlp");
93
- }
94
- }
95
- })
96
- .addBatch({
97
- "Domain Match": matchVows(tough.domainMatch, [
98
- // str, dom, expect
99
- ["example.com", "example.com", true],
100
- ["eXaMpLe.cOm", "ExAmPlE.CoM", true],
101
- ["no.ca", "yes.ca", false],
102
- ["wwwexample.com", "example.com", false],
103
- ["www.example.com", "example.com", true],
104
- ["example.com", "www.example.com", false],
105
- ["www.subdom.example.com", "example.com", true],
106
- ["www.subdom.example.com", "subdom.example.com", true],
107
- ["example.com", "example.com.", false], // RFC6265 S4.1.2.3
108
- ["192.168.0.1", "168.0.1", false], // S5.1.3 "The string is a host name"
109
- [null, "example.com", null],
110
- ["example.com", null, null],
111
- [null, null, null],
112
- [undefined, undefined, null],
113
- ])
114
- })
115
-
116
- .addBatch({
117
- "default-path": defaultPathVows([
118
- [null, "/"],
119
- ["/", "/"],
120
- ["/file", "/"],
121
- ["/dir/file", "/dir"],
122
- ["noslash", "/"],
123
- ])
124
- })
125
- .addBatch({
126
- "Path-Match": matchVows(tough.pathMatch, [
127
- // request, cookie, match
128
- ["/", "/", true],
129
- ["/dir", "/", true],
130
- ["/", "/dir", false],
131
- ["/dir/", "/dir/", true],
132
- ["/dir/file", "/dir/", true],
133
- ["/dir/file", "/dir", true],
134
- ["/directory", "/dir", false],
135
- ])
136
- })
137
- .addBatch({
138
- "permuteDomain": {
139
- "base case": {
140
- topic: tough.permuteDomain.bind(null, 'example.com'),
141
- "got the domain": function (list) {
142
- assert.deepEqual(list, ['example.com']);
143
- }
144
- },
145
- "two levels": {
146
- topic: tough.permuteDomain.bind(null, 'foo.bar.example.com'),
147
- "got three things": function (list) {
148
- assert.deepEqual(list, ['example.com', 'bar.example.com', 'foo.bar.example.com']);
149
- }
150
- },
151
- "local domain": {
152
- topic: tough.permuteDomain.bind(null, 'foo.bar.example.localduhmain'),
153
- "got three things": function (list) {
154
- assert.deepEqual(list, ['example.localduhmain', 'bar.example.localduhmain', 'foo.bar.example.localduhmain']);
155
- }
156
- }
157
- },
158
- "permutePath": {
159
- "base case": {
160
- topic: tough.permutePath.bind(null, '/'),
161
- "just slash": function (list) {
162
- assert.deepEqual(list, ['/']);
163
- }
164
- },
165
- "single case": {
166
- topic: tough.permutePath.bind(null, '/foo'),
167
- "two things": function (list) {
168
- assert.deepEqual(list, ['/foo', '/']);
169
- },
170
- "path matching": function (list) {
171
- list.forEach(function (e) {
172
- assert.ok(tough.pathMatch('/foo', e));
173
- });
174
- }
175
- },
176
- "double case": {
177
- topic: tough.permutePath.bind(null, '/foo/bar'),
178
- "four things": function (list) {
179
- assert.deepEqual(list, ['/foo/bar', '/foo', '/']);
180
- },
181
- "path matching": function (list) {
182
- list.forEach(function (e) {
183
- assert.ok(tough.pathMatch('/foo/bar', e));
184
- });
185
- }
186
- },
187
- "trailing slash": {
188
- topic: tough.permutePath.bind(null, '/foo/bar/'),
189
- "three things": function (list) {
190
- assert.deepEqual(list, ['/foo/bar', '/foo', '/']);
191
- },
192
- "path matching": function (list) {
193
- list.forEach(function (e) {
194
- assert.ok(tough.pathMatch('/foo/bar/', e));
195
- });
196
- }
197
- }
198
- }
199
- })
200
- .export(module);
201
-