m0603va 1.0.0
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.
- package/Laba6/file1.js +23 -0
- package/Laba6/file2.js +23 -0
- package/Laba6/index.html +63 -0
- package/Laba6/m0603.js +29 -0
- package/Laba6/node_modules/.package-lock.json +83 -0
- package/Laba6/node_modules/httpntlm/.jshintrc +4 -0
- package/Laba6/node_modules/httpntlm/LICENSE +20 -0
- package/Laba6/node_modules/httpntlm/README.md +148 -0
- package/Laba6/node_modules/httpntlm/httpntlm.js +104 -0
- package/Laba6/node_modules/httpntlm/ntlm.js +390 -0
- package/Laba6/node_modules/httpntlm/package.json +33 -0
- package/Laba6/node_modules/httpreq/LICENSE +19 -0
- package/Laba6/node_modules/httpreq/README.md +383 -0
- package/Laba6/node_modules/httpreq/contributors.md +26 -0
- package/Laba6/node_modules/httpreq/lib/httpreq.js +681 -0
- package/Laba6/node_modules/httpreq/package.json +102 -0
- package/Laba6/node_modules/m0603sol/m0603.js +29 -0
- package/Laba6/node_modules/m0603sol/package.json +12 -0
- package/Laba6/node_modules/nodemailer/.gitattributes +6 -0
- package/Laba6/node_modules/nodemailer/.prettierrc.js +8 -0
- package/Laba6/node_modules/nodemailer/CHANGELOG.md +725 -0
- package/Laba6/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/Laba6/node_modules/nodemailer/CONTRIBUTING.md +67 -0
- package/Laba6/node_modules/nodemailer/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer/README.md +97 -0
- package/Laba6/node_modules/nodemailer/SECURITY.txt +22 -0
- package/Laba6/node_modules/nodemailer/lib/addressparser/index.js +313 -0
- package/Laba6/node_modules/nodemailer/lib/base64/index.js +142 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/index.js +251 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/sign.js +117 -0
- package/Laba6/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
- package/Laba6/node_modules/nodemailer/lib/fetch/index.js +274 -0
- package/Laba6/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/Laba6/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
- package/Laba6/node_modules/nodemailer/lib/mailer/index.js +427 -0
- package/Laba6/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
- package/Laba6/node_modules/nodemailer/lib/mime-funcs/index.js +625 -0
- package/Laba6/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
- package/Laba6/node_modules/nodemailer/lib/nodemailer.js +143 -0
- package/Laba6/node_modules/nodemailer/lib/qp/index.js +219 -0
- package/Laba6/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
- package/Laba6/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
- package/Laba6/node_modules/nodemailer/lib/shared/index.js +638 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/index.js +1796 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
- package/Laba6/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/Laba6/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/Laba6/node_modules/nodemailer/lib/well-known/services.json +286 -0
- package/Laba6/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
- package/Laba6/node_modules/nodemailer/package.json +46 -0
- package/Laba6/node_modules/nodemailer/postinstall.js +101 -0
- package/Laba6/node_modules/nodemailer-fetch/.eslintrc.js +56 -0
- package/Laba6/node_modules/nodemailer-fetch/.travis.yml +19 -0
- package/Laba6/node_modules/nodemailer-fetch/CHANGELOG.md +30 -0
- package/Laba6/node_modules/nodemailer-fetch/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-fetch/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer-fetch/README.md +55 -0
- package/Laba6/node_modules/nodemailer-fetch/lib/cookies.js +275 -0
- package/Laba6/node_modules/nodemailer-fetch/lib/fetch.js +224 -0
- package/Laba6/node_modules/nodemailer-fetch/package.json +30 -0
- package/Laba6/node_modules/nodemailer-fetch/test/cookies-test.js +391 -0
- package/Laba6/node_modules/nodemailer-fetch/test/fetch-test.js +486 -0
- package/Laba6/node_modules/nodemailer-shared/.eslintrc.js +59 -0
- package/Laba6/node_modules/nodemailer-shared/.travis.yml +18 -0
- package/Laba6/node_modules/nodemailer-shared/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-shared/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer-shared/README.md +14 -0
- package/Laba6/node_modules/nodemailer-shared/lib/shared.js +282 -0
- package/Laba6/node_modules/nodemailer-shared/package.json +36 -0
- package/Laba6/node_modules/nodemailer-shared/test/fixtures/message.html +1 -0
- package/Laba6/node_modules/nodemailer-shared/test/shared-test.js +291 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/.eslintrc.js +59 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/LICENSE +19 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/README.md +7 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/lib/smtp-transport.js +281 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/package.json +37 -0
- package/Laba6/node_modules/nodemailer-wellknown/.travis.yml +17 -0
- package/Laba6/node_modules/nodemailer-wellknown/LICENSE +19 -0
- package/Laba6/node_modules/nodemailer-wellknown/README.md +80 -0
- package/Laba6/node_modules/nodemailer-wellknown/index.js +47 -0
- package/Laba6/node_modules/nodemailer-wellknown/package.json +26 -0
- package/Laba6/node_modules/nodemailer-wellknown/services.json +255 -0
- package/Laba6/node_modules/nodemailer-wellknown/test.js +23 -0
- package/Laba6/node_modules/smtp-connection/.eslintrc.js +56 -0
- package/Laba6/node_modules/smtp-connection/CHANGELOG.md +164 -0
- package/Laba6/node_modules/smtp-connection/Gruntfile.js +27 -0
- package/Laba6/node_modules/smtp-connection/LICENSE +19 -0
- package/Laba6/node_modules/smtp-connection/README.md +200 -0
- package/Laba6/node_modules/smtp-connection/lib/data-stream.js +111 -0
- package/Laba6/node_modules/smtp-connection/lib/smtp-connection.js +1443 -0
- package/Laba6/node_modules/smtp-connection/package.json +41 -0
- package/Laba6/node_modules/underscore/LICENSE +23 -0
- package/Laba6/node_modules/underscore/README.md +22 -0
- package/Laba6/node_modules/underscore/package.json +41 -0
- package/Laba6/node_modules/underscore/underscore-min.js +6 -0
- package/Laba6/node_modules/underscore/underscore.js +1415 -0
- package/Laba6/package-lock.json +94 -0
- package/Laba6/package.json +17 -0
- package/Laba6.txt +31 -0
- package/file1.js +23 -0
- package/file2.js +23 -0
- package/index.html +63 -0
- package/m0603.js +29 -0
- package/m0603Sol/m0603.js +29 -0
- package/m0603Sol/package.json +12 -0
- package/package.json +17 -0
@@ -0,0 +1,486 @@
|
|
1
|
+
/* eslint no-unused-expressions:0 */
|
2
|
+
/* globals afterEach, beforeEach, describe, it */
|
3
|
+
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var chai = require('chai');
|
7
|
+
var expect = chai.expect;
|
8
|
+
|
9
|
+
//var http = require('http');
|
10
|
+
var fetch = require('../lib/fetch');
|
11
|
+
var http = require('http');
|
12
|
+
var https = require('https');
|
13
|
+
var zlib = require('zlib');
|
14
|
+
var PassThrough = require('stream').PassThrough;
|
15
|
+
|
16
|
+
chai.config.includeStack = true;
|
17
|
+
|
18
|
+
var HTTP_PORT = 9998;
|
19
|
+
var HTTPS_PORT = 9993;
|
20
|
+
|
21
|
+
var httpsOptions = {
|
22
|
+
key: '-----BEGIN RSA PRIVATE KEY-----\n' +
|
23
|
+
'MIIEpAIBAAKCAQEA6Z5Qqhw+oWfhtEiMHE32Ht94mwTBpAfjt3vPpX8M7DMCTwHs\n' +
|
24
|
+
'1xcXvQ4lQ3rwreDTOWdoJeEEy7gMxXqH0jw0WfBx+8IIJU69xstOyT7FRFDvA1yT\n' +
|
25
|
+
'RXY2yt9K5s6SKken/ebMfmZR+03ND4UFsDzkz0FfgcjrkXmrMF5Eh5UXX/+9YHeU\n' +
|
26
|
+
'xlp0gMAt+/SumSmgCaysxZLjLpd4uXz+X+JVxsk1ACg1NoEO7lWJC/3WBP7MIcu2\n' +
|
27
|
+
'wVsMd2XegLT0gWYfT1/jsIH64U/mS/SVXC9QhxMl9Yfko2kx1OiYhDxhHs75RJZh\n' +
|
28
|
+
'rNRxgfiwgSb50Gw4NAQaDIxr/DJPdLhgnpY6UQIDAQABAoIBAE+tfzWFjJbgJ0ql\n' +
|
29
|
+
's6Ozs020Sh4U8TZQuonJ4HhBbNbiTtdDgNObPK1uNadeNtgW5fOeIRdKN6iDjVeN\n' +
|
30
|
+
'AuXhQrmqGDYVZ1HSGUfD74sTrZQvRlWPLWtzdhybK6Css41YAyPFo9k4bJ2ZW2b/\n' +
|
31
|
+
'p4EEQ8WsNja9oBpttMU6YYUchGxo1gujN8hmfDdXUQx3k5Xwx4KA68dveJ8GasIt\n' +
|
32
|
+
'd+0Jd/FVwCyyx8HTiF1FF8QZYQeAXxbXJgLBuCsMQJghlcpBEzWkscBR3Ap1U0Zi\n' +
|
33
|
+
'4oat8wrPZGCblaA6rNkRUVbc/+Vw0stnuJ/BLHbPxyBs6w495yBSjBqUWZMvljNz\n' +
|
34
|
+
'm9/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NLLcbFcK+NEHrHmPxy9TnTh\n' +
|
63
|
+
'Zwp1dsNQU+Xkylz8IUANWSLHYZOMtN2e5SKIdwTtl5C8YxveuY8YKb1gDExnMraT\n' +
|
64
|
+
'VGXQDqPleug=\n' +
|
65
|
+
'-----END CERTIFICATE-----'
|
66
|
+
};
|
67
|
+
|
68
|
+
describe('fetch tests', function () {
|
69
|
+
var httpServer, httpsServer;
|
70
|
+
|
71
|
+
beforeEach(function (done) {
|
72
|
+
httpServer = http.createServer(function (req, res) {
|
73
|
+
switch (req.url) {
|
74
|
+
|
75
|
+
case '/redirect6':
|
76
|
+
res.writeHead(302, {
|
77
|
+
Location: '/redirect5'
|
78
|
+
});
|
79
|
+
res.end();
|
80
|
+
break;
|
81
|
+
|
82
|
+
case '/redirect5':
|
83
|
+
res.writeHead(302, {
|
84
|
+
Location: '/redirect4'
|
85
|
+
});
|
86
|
+
res.end();
|
87
|
+
break;
|
88
|
+
|
89
|
+
case '/redirect4':
|
90
|
+
res.writeHead(302, {
|
91
|
+
Location: '/redirect3'
|
92
|
+
});
|
93
|
+
res.end();
|
94
|
+
break;
|
95
|
+
|
96
|
+
case '/redirect3':
|
97
|
+
res.writeHead(302, {
|
98
|
+
Location: '/redirect2'
|
99
|
+
});
|
100
|
+
res.end();
|
101
|
+
break;
|
102
|
+
|
103
|
+
case '/redirect2':
|
104
|
+
res.writeHead(302, {
|
105
|
+
Location: '/redirect1'
|
106
|
+
});
|
107
|
+
res.end();
|
108
|
+
break;
|
109
|
+
|
110
|
+
case '/redirect1':
|
111
|
+
res.writeHead(302, {
|
112
|
+
Location: '/'
|
113
|
+
});
|
114
|
+
res.end();
|
115
|
+
break;
|
116
|
+
|
117
|
+
case '/forever':
|
118
|
+
res.writeHead(200, {
|
119
|
+
'Content-Type': 'text/plain'
|
120
|
+
});
|
121
|
+
res.write('This connection is never closed');
|
122
|
+
// never end the request
|
123
|
+
break;
|
124
|
+
|
125
|
+
case '/gzip':
|
126
|
+
res.writeHead(200, {
|
127
|
+
'Content-Type': 'text/plain',
|
128
|
+
'Content-Encoding': 'gzip'
|
129
|
+
});
|
130
|
+
|
131
|
+
var stream = zlib.createGzip();
|
132
|
+
stream.pipe(res);
|
133
|
+
stream.end('Hello World HTTP\n');
|
134
|
+
break;
|
135
|
+
|
136
|
+
case '/invalid':
|
137
|
+
res.writeHead(500, {
|
138
|
+
'Content-Type': 'text/plain'
|
139
|
+
});
|
140
|
+
res.end('Hello World HTTP\n');
|
141
|
+
break;
|
142
|
+
|
143
|
+
case '/auth':
|
144
|
+
res.writeHead(200, {
|
145
|
+
'Content-Type': 'text/plain'
|
146
|
+
});
|
147
|
+
res.end(new Buffer(req.headers.authorization.split(' ').pop(), 'base64'));
|
148
|
+
break;
|
149
|
+
|
150
|
+
case '/cookie':
|
151
|
+
res.writeHead(200, {
|
152
|
+
'Content-Type': 'text/plain'
|
153
|
+
});
|
154
|
+
res.end(req.headers.cookie);
|
155
|
+
break;
|
156
|
+
|
157
|
+
case '/ua':
|
158
|
+
res.writeHead(200, {
|
159
|
+
'Content-Type': 'text/plain'
|
160
|
+
});
|
161
|
+
res.end(req.headers['user-agent']);
|
162
|
+
break;
|
163
|
+
|
164
|
+
case '/post':
|
165
|
+
var body = [];
|
166
|
+
req.on('readable', function () {
|
167
|
+
var chunk;
|
168
|
+
while ((chunk = req.read()) !== null) {
|
169
|
+
body.push(chunk);
|
170
|
+
}
|
171
|
+
});
|
172
|
+
req.on('end', function () {
|
173
|
+
res.writeHead(200, {
|
174
|
+
'Content-Type': 'text/plain'
|
175
|
+
});
|
176
|
+
res.end(Buffer.concat(body));
|
177
|
+
});
|
178
|
+
|
179
|
+
break;
|
180
|
+
|
181
|
+
default:
|
182
|
+
res.writeHead(200, {
|
183
|
+
'Content-Type': 'text/plain'
|
184
|
+
});
|
185
|
+
res.end('Hello World HTTP\n');
|
186
|
+
}
|
187
|
+
});
|
188
|
+
|
189
|
+
httpsServer = https.createServer(httpsOptions, function (req, res) {
|
190
|
+
res.writeHead(200, {
|
191
|
+
'Content-Type': 'text/plain'
|
192
|
+
});
|
193
|
+
res.end('Hello World HTTPS\n');
|
194
|
+
});
|
195
|
+
|
196
|
+
httpServer.listen(HTTP_PORT, function () {
|
197
|
+
httpsServer.listen(HTTPS_PORT, done);
|
198
|
+
});
|
199
|
+
});
|
200
|
+
|
201
|
+
afterEach(function (done) {
|
202
|
+
httpServer.close(function () {
|
203
|
+
httpsServer.close(done);
|
204
|
+
});
|
205
|
+
});
|
206
|
+
|
207
|
+
it('should fetch HTTP data', function (done) {
|
208
|
+
var req = fetch('http://localhost:' + HTTP_PORT);
|
209
|
+
var buf = [];
|
210
|
+
req.on('data', function (chunk) {
|
211
|
+
buf.push(chunk);
|
212
|
+
});
|
213
|
+
req.on('end', function () {
|
214
|
+
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
|
215
|
+
done();
|
216
|
+
});
|
217
|
+
});
|
218
|
+
|
219
|
+
it('should fetch HTTPS data', function (done) {
|
220
|
+
var req = fetch('https://localhost:' + HTTPS_PORT);
|
221
|
+
var buf = [];
|
222
|
+
req.on('data', function (chunk) {
|
223
|
+
buf.push(chunk);
|
224
|
+
});
|
225
|
+
req.on('end', function () {
|
226
|
+
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTPS\n');
|
227
|
+
done();
|
228
|
+
});
|
229
|
+
});
|
230
|
+
|
231
|
+
it('should fetch HTTP data with redirects', function (done) {
|
232
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/redirect3');
|
233
|
+
var buf = [];
|
234
|
+
req.on('data', function (chunk) {
|
235
|
+
buf.push(chunk);
|
236
|
+
});
|
237
|
+
req.on('end', function () {
|
238
|
+
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
|
239
|
+
done();
|
240
|
+
});
|
241
|
+
});
|
242
|
+
|
243
|
+
it('should return error for too many redirects', function (done) {
|
244
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/redirect6');
|
245
|
+
var buf = [];
|
246
|
+
req.on('data', function (chunk) {
|
247
|
+
buf.push(chunk);
|
248
|
+
});
|
249
|
+
req.on('error', function (err) {
|
250
|
+
expect(err).to.exist;
|
251
|
+
done();
|
252
|
+
});
|
253
|
+
req.on('end', function () {});
|
254
|
+
});
|
255
|
+
|
256
|
+
it('should fetch HTTP data with custom redirect limit', function (done) {
|
257
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/redirect3', {
|
258
|
+
maxRedirects: 3
|
259
|
+
});
|
260
|
+
var buf = [];
|
261
|
+
req.on('data', function (chunk) {
|
262
|
+
buf.push(chunk);
|
263
|
+
});
|
264
|
+
req.on('end', function () {
|
265
|
+
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
|
266
|
+
done();
|
267
|
+
});
|
268
|
+
});
|
269
|
+
|
270
|
+
it('should return error for custom redirect limit', function (done) {
|
271
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/redirect3', {
|
272
|
+
maxRedirects: 2
|
273
|
+
});
|
274
|
+
var buf = [];
|
275
|
+
req.on('data', function (chunk) {
|
276
|
+
buf.push(chunk);
|
277
|
+
});
|
278
|
+
req.on('error', function (err) {
|
279
|
+
expect(err).to.exist;
|
280
|
+
done();
|
281
|
+
});
|
282
|
+
req.on('end', function () {});
|
283
|
+
});
|
284
|
+
|
285
|
+
it('should return disable redirects', function (done) {
|
286
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/redirect1', {
|
287
|
+
maxRedirects: 0
|
288
|
+
});
|
289
|
+
var buf = [];
|
290
|
+
req.on('data', function (chunk) {
|
291
|
+
buf.push(chunk);
|
292
|
+
});
|
293
|
+
req.on('error', function (err) {
|
294
|
+
expect(err).to.exist;
|
295
|
+
done();
|
296
|
+
});
|
297
|
+
req.on('end', function () {});
|
298
|
+
});
|
299
|
+
|
300
|
+
it('should unzip compressed HTTP data', function (done) {
|
301
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/gzip');
|
302
|
+
var buf = [];
|
303
|
+
req.on('data', function (chunk) {
|
304
|
+
buf.push(chunk);
|
305
|
+
});
|
306
|
+
req.on('end', function () {
|
307
|
+
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n');
|
308
|
+
done();
|
309
|
+
});
|
310
|
+
});
|
311
|
+
|
312
|
+
it('should return error for unresolved host', function (done) {
|
313
|
+
var req = fetch('http://asfhaskhhgbjdsfhgbsdjgk');
|
314
|
+
var buf = [];
|
315
|
+
req.on('data', function (chunk) {
|
316
|
+
buf.push(chunk);
|
317
|
+
});
|
318
|
+
req.on('error', function (err) {
|
319
|
+
expect(err).to.exist;
|
320
|
+
done();
|
321
|
+
});
|
322
|
+
req.on('end', function () {});
|
323
|
+
});
|
324
|
+
|
325
|
+
it('should return error for invalid status', function (done) {
|
326
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/invalid');
|
327
|
+
var buf = [];
|
328
|
+
req.on('data', function (chunk) {
|
329
|
+
buf.push(chunk);
|
330
|
+
});
|
331
|
+
req.on('error', function (err) {
|
332
|
+
expect(err).to.exist;
|
333
|
+
done();
|
334
|
+
});
|
335
|
+
req.on('end', function () {});
|
336
|
+
});
|
337
|
+
|
338
|
+
it('should return error for invalid url', function (done) {
|
339
|
+
var req = fetch('http://localhost:99999999/');
|
340
|
+
var buf = [];
|
341
|
+
req.on('data', function (chunk) {
|
342
|
+
buf.push(chunk);
|
343
|
+
});
|
344
|
+
req.on('error', function (err) {
|
345
|
+
expect(err).to.exist;
|
346
|
+
done();
|
347
|
+
});
|
348
|
+
req.on('end', function () {});
|
349
|
+
});
|
350
|
+
|
351
|
+
it('should return timeout error', function (done) {
|
352
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/forever', {
|
353
|
+
timeout: 1000
|
354
|
+
});
|
355
|
+
var buf = [];
|
356
|
+
req.on('data', function (chunk) {
|
357
|
+
buf.push(chunk);
|
358
|
+
});
|
359
|
+
req.on('error', function (err) {
|
360
|
+
expect(err).to.exist;
|
361
|
+
done();
|
362
|
+
});
|
363
|
+
req.on('end', function () {});
|
364
|
+
});
|
365
|
+
|
366
|
+
it('should handle basic HTTP auth', function (done) {
|
367
|
+
var req = fetch('http://user:pass@localhost:' + HTTP_PORT + '/auth');
|
368
|
+
var buf = [];
|
369
|
+
req.on('data', function (chunk) {
|
370
|
+
buf.push(chunk);
|
371
|
+
});
|
372
|
+
req.on('end', function () {
|
373
|
+
expect(Buffer.concat(buf).toString()).to.equal('user:pass');
|
374
|
+
done();
|
375
|
+
});
|
376
|
+
});
|
377
|
+
|
378
|
+
if (!/^0\.10\./.test(process.versions.node)) {
|
379
|
+
// disabled for node 0.10
|
380
|
+
it('should return error for invalid protocol', function (done) {
|
381
|
+
var req = fetch('http://localhost:' + HTTPS_PORT);
|
382
|
+
var buf = [];
|
383
|
+
req.on('data', function (chunk) {
|
384
|
+
buf.push(chunk);
|
385
|
+
});
|
386
|
+
req.on('error', function (err) {
|
387
|
+
expect(err).to.exist;
|
388
|
+
done();
|
389
|
+
});
|
390
|
+
req.on('end', function () {});
|
391
|
+
});
|
392
|
+
}
|
393
|
+
|
394
|
+
it('should set cookie value', function (done) {
|
395
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/cookie', {
|
396
|
+
cookie: 'test=pest'
|
397
|
+
});
|
398
|
+
var buf = [];
|
399
|
+
req.on('data', function (chunk) {
|
400
|
+
buf.push(chunk);
|
401
|
+
});
|
402
|
+
req.on('end', function () {
|
403
|
+
expect(Buffer.concat(buf).toString()).to.equal('test=pest');
|
404
|
+
done();
|
405
|
+
});
|
406
|
+
});
|
407
|
+
|
408
|
+
it('should set user agent', function (done) {
|
409
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/ua', {
|
410
|
+
userAgent: 'nodemailer-fetch'
|
411
|
+
});
|
412
|
+
var buf = [];
|
413
|
+
req.on('data', function (chunk) {
|
414
|
+
buf.push(chunk);
|
415
|
+
});
|
416
|
+
req.on('end', function () {
|
417
|
+
expect(Buffer.concat(buf).toString()).to.equal('nodemailer-fetch');
|
418
|
+
done();
|
419
|
+
});
|
420
|
+
});
|
421
|
+
|
422
|
+
it('should post data', function (done) {
|
423
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/post', {
|
424
|
+
method: 'post',
|
425
|
+
body: {
|
426
|
+
hello: 'world 😭',
|
427
|
+
another: 'value'
|
428
|
+
}
|
429
|
+
});
|
430
|
+
var buf = [];
|
431
|
+
req.on('data', function (chunk) {
|
432
|
+
buf.push(chunk);
|
433
|
+
});
|
434
|
+
req.on('end', function () {
|
435
|
+
expect(Buffer.concat(buf).toString()).to.equal('hello=world%20%F0%9F%98%AD&another=value');
|
436
|
+
done();
|
437
|
+
});
|
438
|
+
});
|
439
|
+
|
440
|
+
it('should post stream data', function (done) {
|
441
|
+
var body = new PassThrough();
|
442
|
+
var data = new Buffer('hello=world%20%F0%9F%98%AD&another=value');
|
443
|
+
|
444
|
+
var req = fetch('http://localhost:' + HTTP_PORT + '/post', {
|
445
|
+
method: 'post',
|
446
|
+
body: body
|
447
|
+
});
|
448
|
+
var buf = [];
|
449
|
+
req.on('data', function (chunk) {
|
450
|
+
buf.push(chunk);
|
451
|
+
});
|
452
|
+
req.on('end', function () {
|
453
|
+
expect(Buffer.concat(buf).toString()).to.equal(data.toString());
|
454
|
+
done();
|
455
|
+
});
|
456
|
+
|
457
|
+
var pos = 0;
|
458
|
+
var writeNext = function () {
|
459
|
+
if (pos >= data.length) {
|
460
|
+
return body.end();
|
461
|
+
}
|
462
|
+
var char = data.slice(pos++, pos);
|
463
|
+
body.write(char);
|
464
|
+
setImmediate(writeNext);
|
465
|
+
};
|
466
|
+
|
467
|
+
setImmediate(writeNext);
|
468
|
+
});
|
469
|
+
|
470
|
+
it('should return error for invalid cert', function (done) {
|
471
|
+
var req = fetch('https://localhost:' + HTTPS_PORT, {
|
472
|
+
tls: {
|
473
|
+
rejectUnauthorized: true
|
474
|
+
}
|
475
|
+
});
|
476
|
+
var buf = [];
|
477
|
+
req.on('data', function (chunk) {
|
478
|
+
buf.push(chunk);
|
479
|
+
});
|
480
|
+
req.on('error', function (err) {
|
481
|
+
expect(err).to.exist;
|
482
|
+
done();
|
483
|
+
});
|
484
|
+
req.on('end', function () {});
|
485
|
+
});
|
486
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
rules: {
|
5
|
+
indent: [2, 4, {
|
6
|
+
SwitchCase: 1
|
7
|
+
}],
|
8
|
+
quotes: [2, 'single'],
|
9
|
+
'linebreak-style': [2, 'unix'],
|
10
|
+
semi: [2, 'always'],
|
11
|
+
strict: [2, 'global'],
|
12
|
+
eqeqeq: 2,
|
13
|
+
'dot-notation': 2,
|
14
|
+
curly: 2,
|
15
|
+
'no-fallthrough': 2,
|
16
|
+
'quote-props': [2, 'as-needed'],
|
17
|
+
'no-unused-expressions': [2, {
|
18
|
+
allowShortCircuit: true
|
19
|
+
}],
|
20
|
+
'no-unused-vars': 2,
|
21
|
+
'no-undef': 2,
|
22
|
+
'handle-callback-err': 2,
|
23
|
+
'no-new': 2,
|
24
|
+
'new-cap': 2,
|
25
|
+
'no-eval': 2,
|
26
|
+
'no-invalid-this': 2,
|
27
|
+
radix: [2, 'always'],
|
28
|
+
'no-use-before-define': [2, 'nofunc'],
|
29
|
+
'callback-return': [2, ['callback', 'cb', 'done']],
|
30
|
+
'comma-dangle': [2, 'never'],
|
31
|
+
'comma-style': [2, 'last'],
|
32
|
+
'no-regex-spaces': 2,
|
33
|
+
'no-empty': 2,
|
34
|
+
'no-duplicate-case': 2,
|
35
|
+
'no-empty-character-class': 2,
|
36
|
+
'no-redeclare': [2, {
|
37
|
+
builtinGlobals: true
|
38
|
+
}],
|
39
|
+
'block-scoped-var': 2,
|
40
|
+
'no-sequences': 2,
|
41
|
+
'no-throw-literal': 2,
|
42
|
+
'no-useless-concat': 2,
|
43
|
+
'no-void': 2,
|
44
|
+
yoda: 2,
|
45
|
+
'no-bitwise': 2,
|
46
|
+
'no-lonely-if': 2,
|
47
|
+
'no-mixed-spaces-and-tabs': 2,
|
48
|
+
'no-console': 0
|
49
|
+
},
|
50
|
+
env: {
|
51
|
+
es6: false,
|
52
|
+
node: true
|
53
|
+
},
|
54
|
+
extends: 'eslint:recommended',
|
55
|
+
fix: true,
|
56
|
+
globals: {
|
57
|
+
Promise: false
|
58
|
+
}
|
59
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
language: node_js
|
2
|
+
sudo: false
|
3
|
+
node_js:
|
4
|
+
- 0.12
|
5
|
+
- iojs
|
6
|
+
- '4'
|
7
|
+
- '6'
|
8
|
+
before_install:
|
9
|
+
- npm install -g grunt-cli
|
10
|
+
notifications:
|
11
|
+
email:
|
12
|
+
- andris@kreata.ee
|
13
|
+
webhooks:
|
14
|
+
urls:
|
15
|
+
- https://webhooks.gitter.im/e/0ed18fd9b3e529b3c2cc
|
16
|
+
on_success: change # options: [always|never|change] default: always
|
17
|
+
on_failure: always # options: [always|never|change] default: always
|
18
|
+
on_start: false # default: false
|
@@ -0,0 +1,27 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = function (grunt) {
|
4
|
+
|
5
|
+
// Project configuration.
|
6
|
+
grunt.initConfig({
|
7
|
+
eslint: {
|
8
|
+
all: ['lib/*.js', 'test/*.js', 'Gruntfile.js']
|
9
|
+
},
|
10
|
+
|
11
|
+
mochaTest: {
|
12
|
+
all: {
|
13
|
+
options: {
|
14
|
+
reporter: 'spec'
|
15
|
+
},
|
16
|
+
src: ['test/*-test.js']
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
// Load the plugin(s)
|
22
|
+
grunt.loadNpmTasks('grunt-eslint');
|
23
|
+
grunt.loadNpmTasks('grunt-mocha-test');
|
24
|
+
|
25
|
+
// Tasks
|
26
|
+
grunt.registerTask('default', ['eslint', 'mochaTest']);
|
27
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Copyright (c) 2016 Andris Reinman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
16
|
+
SOFTWARE.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# nodemailer-shared
|
2
|
+
|
3
|
+
Shared methods for the [Nodemailer](https://github.com/nodemailer/nodemailer) stack.
|
4
|
+
|
5
|
+
## Methods
|
6
|
+
|
7
|
+
* `parseConnectionUrl(str)` parses a connection url into a nodemailer configuration object
|
8
|
+
* `getLogger(options)` returns a bunyan compatible logger instance
|
9
|
+
* `callbackPromise(resolve, reject)` returns a promise-resolving function suitable for using as a callback
|
10
|
+
* `resolveContent(data, key, callback)` converts a key of a data object from stream/url/path to a buffer
|
11
|
+
|
12
|
+
## License
|
13
|
+
|
14
|
+
**MIT**
|