vulcan 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vulcan/cli.rb +20 -10
- data/lib/vulcan/version.rb +1 -1
- data/server/Procfile +1 -1
- data/server/bin/web +10 -0
- data/server/lib/cloudant.coffee +20 -0
- data/server/lib/logger.coffee +17 -0
- data/server/lib/on.coffee +10 -0
- data/server/lib/spawner.coffee +65 -0
- data/server/node_modules/coffee-script/CNAME +1 -0
- data/server/node_modules/coffee-script/LICENSE +22 -0
- data/server/node_modules/coffee-script/README +51 -0
- data/server/node_modules/coffee-script/Rakefile +78 -0
- data/server/node_modules/coffee-script/bin/cake +7 -0
- data/server/node_modules/coffee-script/bin/coffee +7 -0
- data/server/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/server/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
- data/server/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
- data/server/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
- data/server/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
- data/server/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
- data/server/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
- data/server/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/server/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
- data/server/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
- data/server/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/server/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
- data/server/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
- data/server/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
- data/server/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/server/node_modules/coffee-script/package.json +55 -0
- data/server/node_modules/connect-form/History.md +0 -6
- data/server/node_modules/connect-form/lib/connect-form.js +2 -4
- data/server/node_modules/connect-form/node_modules/formidable/Readme.md +64 -36
- data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +5 -1
- data/server/node_modules/connect-form/node_modules/formidable/package.json +20 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/common.js +5 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +1 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/{slow → integration}/test-fixtures.js +38 -33
- data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/run.js +1 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
- data/server/node_modules/connect-form/package.json +27 -5
- data/server/node_modules/cradle/README.md +10 -10
- data/server/node_modules/cradle/lib/cradle.js +117 -523
- data/server/node_modules/cradle/lib/cradle/database/attachments.js +120 -0
- data/server/node_modules/cradle/lib/cradle/database/changes.js +56 -0
- data/server/node_modules/cradle/lib/cradle/database/documents.js +215 -0
- data/server/node_modules/cradle/lib/cradle/database/index.js +65 -0
- data/server/node_modules/cradle/lib/cradle/database/views.js +125 -0
- data/server/node_modules/cradle/node_modules/follow/LICENSE +202 -0
- data/server/node_modules/cradle/node_modules/follow/README.md +164 -0
- data/server/node_modules/cradle/node_modules/follow/Rakefile +54 -0
- data/server/node_modules/cradle/node_modules/follow/api.js +35 -0
- data/server/node_modules/cradle/node_modules/follow/browser/eventemitter2.js +453 -0
- data/server/node_modules/cradle/node_modules/follow/browser/export.js +78 -0
- data/server/node_modules/cradle/node_modules/follow/browser/index.html +14 -0
- data/server/node_modules/cradle/node_modules/follow/browser/jquery-1.6.1.min.js +18 -0
- data/server/node_modules/cradle/node_modules/follow/browser/log4js.js +46 -0
- data/server/node_modules/cradle/node_modules/follow/browser/main.js +92 -0
- data/server/node_modules/cradle/node_modules/follow/browser/querystring.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/browser/request.jquery.js +237 -0
- data/server/node_modules/cradle/node_modules/follow/browser/require.js +33 -0
- data/server/node_modules/cradle/node_modules/follow/browser/util.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/cli.js +101 -0
- data/server/node_modules/cradle/node_modules/follow/lib/feed.js +556 -0
- data/server/node_modules/cradle/node_modules/follow/lib/index.js +66 -0
- data/server/node_modules/cradle/node_modules/follow/lib/stream.js +305 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/README.md +285 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/main.js +618 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/mimetypes.js +146 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/run.sh +6 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/server.js +57 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-body.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-errors.js +30 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-oauth.js +109 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-pipes.js +167 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/follow/package.json +45 -0
- data/server/node_modules/cradle/node_modules/follow/test/couch.js +153 -0
- data/server/node_modules/cradle/node_modules/follow/test/follow.js +136 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues.js +178 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues/10.js +24 -0
- data/server/node_modules/cradle/node_modules/follow/test/stream.js +493 -0
- data/server/node_modules/cradle/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/request/README.md +287 -0
- data/server/node_modules/cradle/node_modules/request/forever.js +103 -0
- data/server/node_modules/cradle/node_modules/request/main.js +913 -0
- data/server/node_modules/cradle/node_modules/request/mimetypes.js +152 -0
- data/server/node_modules/cradle/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/run.js +38 -0
- data/server/node_modules/cradle/node_modules/request/tests/server.js +82 -0
- data/server/node_modules/cradle/node_modules/request/tests/squid.conf +77 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.cnf +20 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crl +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crt +17 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.csr +13 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.key +18 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.srl +1 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.cnf +19 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.csr +11 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.key +9 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/npm-ca.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.crt +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.key +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-body.js +95 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-defaults.js +68 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-errors.js +37 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-headers.js +52 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-httpModule.js +94 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https-strict.js +97 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https.js +86 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-oauth.js +117 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-params.js +92 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-pipes.js +202 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-qs.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-redirect.js +154 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-toJSON.js +14 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-tunnel.js +61 -0
- data/server/node_modules/cradle/node_modules/request/tunnel.js +229 -0
- data/server/node_modules/cradle/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/index.js +65 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/vargs/package.json +33 -10
- data/server/node_modules/cradle/package.json +50 -12
- data/server/node_modules/cradle/test/cache-test.js +1 -4
- data/server/node_modules/cradle/test/connection-test.js +179 -0
- data/server/node_modules/cradle/test/database-attachment-test.js +344 -0
- data/server/node_modules/cradle/test/database-cache-test.js +132 -0
- data/server/node_modules/cradle/test/database-test.js +219 -0
- data/server/node_modules/cradle/test/database-view-test.js +141 -0
- data/server/node_modules/cradle/test/fixtures/databases.json +28 -1
- data/server/node_modules/cradle/test/helpers/seed.js +14 -5
- data/server/node_modules/cradle/test/response-test.js +1 -1
- data/server/node_modules/express/History.md +16 -0
- data/server/node_modules/express/bin/express +7 -6
- data/server/node_modules/express/lib-cov/application.js +510 -0
- data/server/node_modules/express/lib-cov/express.js +65 -0
- data/server/node_modules/express/lib-cov/middleware.js +54 -0
- data/server/node_modules/express/lib-cov/request.js +225 -0
- data/server/node_modules/express/lib-cov/response.js +611 -0
- data/server/node_modules/express/lib-cov/router/collection.js +40 -0
- data/server/node_modules/express/lib-cov/router/index.js +515 -0
- data/server/node_modules/express/lib-cov/router/methods.js +9 -0
- data/server/node_modules/express/lib-cov/router/route.js +68 -0
- data/server/node_modules/express/lib-cov/utils.js +151 -0
- data/server/node_modules/express/lib-cov/view.js +81 -0
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/http.js +1 -2
- data/server/node_modules/express/lib/request.js +2 -2
- data/server/node_modules/express/lib/router/methods.js +10 -1
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +3 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +0 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +1 -2
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +42 -25
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +14 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/express/node_modules/connect/package.json +35 -7
- data/server/node_modules/express/node_modules/mime/package.json +30 -8
- data/server/node_modules/express/node_modules/mkdirp/README.markdown +35 -2
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +1 -1
- data/server/node_modules/express/node_modules/mkdirp/index.js +72 -13
- data/server/node_modules/express/node_modules/mkdirp/package.json +39 -21
- data/server/node_modules/express/node_modules/mkdirp/test/chmod.js +38 -0
- data/server/node_modules/express/node_modules/mkdirp/test/clobber.js +37 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm.js +32 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/server/node_modules/express/node_modules/mkdirp/test/sync.js +27 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask.js +28 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask_sync.js +27 -0
- data/server/node_modules/express/node_modules/qs/History.md +10 -0
- data/server/node_modules/express/node_modules/qs/Readme.md +9 -2
- data/server/node_modules/express/node_modules/qs/examples.js +3 -0
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +8 -6
- data/server/node_modules/express/node_modules/qs/package.json +26 -8
- data/server/node_modules/express/node_modules/qs/test/parse.js +13 -1
- data/server/node_modules/express/node_modules/qs/test/stringify.js +45 -37
- data/server/node_modules/express/package.json +55 -16
- data/server/node_modules/express/test.js +41 -0
- data/server/node_modules/knox/package.json +26 -4
- data/server/node_modules/node-uuid/package.json +40 -11
- data/server/node_modules/node-uuid/test/test.js +1 -1
- data/server/node_modules/nodemon/README.md +120 -0
- data/server/node_modules/nodemon/nodemon.js +518 -0
- data/server/node_modules/nodemon/nodemonignore.example +11 -0
- data/server/node_modules/nodemon/package.json +49 -0
- data/server/node_modules/restler/README.md +144 -94
- data/server/node_modules/restler/lib/multipartform.js +2 -0
- data/server/node_modules/restler/lib/restler.js +218 -61
- data/server/node_modules/restler/package.json +35 -8
- data/server/node_modules/restler/test/all.js +6 -1
- data/server/node_modules/restler/test/restler.js +624 -118
- data/server/package.json +14 -10
- data/server/web.coffee +64 -0
- data/server/web.js +15 -3
- metadata +170 -57
- data/server/index.js +0 -14
- data/server/node_modules/connect-form/LICENSE +0 -22
- data/server/node_modules/connect-form/index.js +0 -100
- data/server/node_modules/connect-form/node_modules/formidable/test/fast/test-incoming-form.js +0 -45
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/cradle/Makefile +0 -10
- data/server/node_modules/cradle/test/cradle-test.js +0 -650
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/express/node_modules/connect/test.js +0 -52
- data/server/node_modules/express/testing/foo/app.js +0 -35
- data/server/node_modules/express/testing/foo/package.json +0 -9
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
- data/server/node_modules/express/testing/foo/routes/index.js +0 -10
- data/server/node_modules/express/testing/foo/views/index.jade +0 -2
- data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
- data/server/node_modules/express/testing/index.js +0 -43
- data/server/node_modules/express/testing/public/test.txt +0 -2971
- data/server/node_modules/express/testing/views/page.html +0 -1
- data/server/node_modules/express/testing/views/page.jade +0 -3
- data/server/node_modules/express/testing/views/test.md +0 -1
- data/server/node_modules/express/testing/views/user/index.jade +0 -1
- data/server/node_modules/express/testing/views/user/list.jade +0 -1
- data/server/node_modules/knox/lib/knox/mime/index.js +0 -308
- data/server/node_modules/knox/lib/knox/mime/test.js +0 -59
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/on/index.js +0 -13
- data/server/node_modules/restler/test/test_helper.js +0 -163
- data/server/node_modules/spawner/index.js +0 -106
@@ -0,0 +1,37 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, events = require('events')
|
3
|
+
, assert = require('assert')
|
4
|
+
, request = require('../main.js')
|
5
|
+
;
|
6
|
+
|
7
|
+
var local = 'http://localhost:8888/asdf'
|
8
|
+
|
9
|
+
try {
|
10
|
+
request({uri:local, body:{}})
|
11
|
+
assert.fail("Should have throw")
|
12
|
+
} catch(e) {
|
13
|
+
assert.equal(e.message, 'Argument error, options.body.')
|
14
|
+
}
|
15
|
+
|
16
|
+
try {
|
17
|
+
request({uri:local, multipart: 'foo'})
|
18
|
+
assert.fail("Should have throw")
|
19
|
+
} catch(e) {
|
20
|
+
assert.equal(e.message, 'Argument error, options.multipart.')
|
21
|
+
}
|
22
|
+
|
23
|
+
try {
|
24
|
+
request({uri:local, multipart: [{}]})
|
25
|
+
assert.fail("Should have throw")
|
26
|
+
} catch(e) {
|
27
|
+
assert.equal(e.message, 'Body attribute missing in multipart.')
|
28
|
+
}
|
29
|
+
|
30
|
+
try {
|
31
|
+
request(local, {multipart: [{}]})
|
32
|
+
assert.fail("Should have throw")
|
33
|
+
} catch(e) {
|
34
|
+
assert.equal(e.message, 'Body attribute missing in multipart.')
|
35
|
+
}
|
36
|
+
|
37
|
+
console.log("All tests passed.")
|
@@ -0,0 +1,52 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, assert = require('assert')
|
3
|
+
, request = require('../main.js')
|
4
|
+
, Cookie = require('../vendor/cookie')
|
5
|
+
, Jar = require('../vendor/cookie/jar')
|
6
|
+
, s = server.createServer()
|
7
|
+
|
8
|
+
s.listen(s.port, function () {
|
9
|
+
var serverUri = 'http://localhost:' + s.port
|
10
|
+
, numTests = 0
|
11
|
+
, numOutstandingTests = 0
|
12
|
+
|
13
|
+
function createTest(requestObj, serverAssertFn) {
|
14
|
+
var testNumber = numTests;
|
15
|
+
numTests += 1;
|
16
|
+
numOutstandingTests += 1;
|
17
|
+
s.on('/' + testNumber, function (req, res) {
|
18
|
+
serverAssertFn(req, res);
|
19
|
+
res.writeHead(200);
|
20
|
+
res.end();
|
21
|
+
});
|
22
|
+
requestObj.url = serverUri + '/' + testNumber
|
23
|
+
request(requestObj, function (err, res, body) {
|
24
|
+
assert.ok(!err)
|
25
|
+
assert.equal(res.statusCode, 200)
|
26
|
+
numOutstandingTests -= 1
|
27
|
+
if (numOutstandingTests === 0) {
|
28
|
+
console.log(numTests + ' tests passed.')
|
29
|
+
s.close()
|
30
|
+
}
|
31
|
+
})
|
32
|
+
}
|
33
|
+
|
34
|
+
// Issue #125: headers.cookie shouldn't be replaced when a cookie jar isn't specified
|
35
|
+
createTest({headers: {cookie: 'foo=bar'}}, function (req, res) {
|
36
|
+
assert.ok(req.headers.cookie)
|
37
|
+
assert.equal(req.headers.cookie, 'foo=bar')
|
38
|
+
})
|
39
|
+
|
40
|
+
// Issue #125: headers.cookie + cookie jar
|
41
|
+
var jar = new Jar()
|
42
|
+
jar.add(new Cookie('quux=baz'));
|
43
|
+
createTest({jar: jar, headers: {cookie: 'foo=bar'}}, function (req, res) {
|
44
|
+
assert.ok(req.headers.cookie)
|
45
|
+
assert.equal(req.headers.cookie, 'foo=bar; quux=baz')
|
46
|
+
})
|
47
|
+
|
48
|
+
// There should be no cookie header when neither headers.cookie nor a cookie jar is specified
|
49
|
+
createTest({}, function (req, res) {
|
50
|
+
assert.ok(!req.headers.cookie)
|
51
|
+
})
|
52
|
+
})
|
@@ -0,0 +1,94 @@
|
|
1
|
+
var http = require('http')
|
2
|
+
, https = require('https')
|
3
|
+
, server = require('./server')
|
4
|
+
, assert = require('assert')
|
5
|
+
, request = require('../main.js')
|
6
|
+
|
7
|
+
|
8
|
+
var faux_requests_made = {'http':0, 'https':0}
|
9
|
+
function wrap_request(name, module) {
|
10
|
+
// Just like the http or https module, but note when a request is made.
|
11
|
+
var wrapped = {}
|
12
|
+
Object.keys(module).forEach(function(key) {
|
13
|
+
var value = module[key];
|
14
|
+
|
15
|
+
if(key != 'request')
|
16
|
+
wrapped[key] = value;
|
17
|
+
else
|
18
|
+
wrapped[key] = function(options, callback) {
|
19
|
+
faux_requests_made[name] += 1
|
20
|
+
return value.apply(this, arguments)
|
21
|
+
}
|
22
|
+
})
|
23
|
+
|
24
|
+
return wrapped;
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
var faux_http = wrap_request('http', http)
|
29
|
+
, faux_https = wrap_request('https', https)
|
30
|
+
, plain_server = server.createServer()
|
31
|
+
, https_server = server.createSSLServer()
|
32
|
+
|
33
|
+
|
34
|
+
plain_server.listen(plain_server.port, function() {
|
35
|
+
plain_server.on('/plain', function (req, res) {
|
36
|
+
res.writeHead(200)
|
37
|
+
res.end('plain')
|
38
|
+
})
|
39
|
+
plain_server.on('/to_https', function (req, res) {
|
40
|
+
res.writeHead(301, {'location':'https://localhost:'+https_server.port + '/https'})
|
41
|
+
res.end()
|
42
|
+
})
|
43
|
+
|
44
|
+
https_server.listen(https_server.port, function() {
|
45
|
+
https_server.on('/https', function (req, res) {
|
46
|
+
res.writeHead(200)
|
47
|
+
res.end('https')
|
48
|
+
})
|
49
|
+
https_server.on('/to_plain', function (req, res) {
|
50
|
+
res.writeHead(302, {'location':'http://localhost:'+plain_server.port + '/plain'})
|
51
|
+
res.end()
|
52
|
+
})
|
53
|
+
|
54
|
+
run_tests()
|
55
|
+
run_tests({})
|
56
|
+
run_tests({'http:':faux_http})
|
57
|
+
run_tests({'https:':faux_https})
|
58
|
+
run_tests({'http:':faux_http, 'https:':faux_https})
|
59
|
+
})
|
60
|
+
})
|
61
|
+
|
62
|
+
function run_tests(httpModules) {
|
63
|
+
var to_https = 'http://localhost:'+plain_server.port+'/to_https'
|
64
|
+
var to_plain = 'https://localhost:'+https_server.port+'/to_plain'
|
65
|
+
|
66
|
+
request(to_https, {'httpModules':httpModules}, function (er, res, body) {
|
67
|
+
assert.ok(!er, 'Bounce to SSL worked')
|
68
|
+
assert.equal(body, 'https', 'Received HTTPS server body')
|
69
|
+
done()
|
70
|
+
})
|
71
|
+
|
72
|
+
request(to_plain, {'httpModules':httpModules}, function (er, res, body) {
|
73
|
+
assert.ok(!er, 'Bounce to plaintext server worked')
|
74
|
+
assert.equal(body, 'plain', 'Received HTTPS server body')
|
75
|
+
done()
|
76
|
+
})
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
var passed = 0;
|
81
|
+
function done() {
|
82
|
+
passed += 1
|
83
|
+
var expected = 10
|
84
|
+
|
85
|
+
if(passed == expected) {
|
86
|
+
plain_server.close()
|
87
|
+
https_server.close()
|
88
|
+
|
89
|
+
assert.equal(faux_requests_made.http, 4, 'Wrapped http module called appropriately')
|
90
|
+
assert.equal(faux_requests_made.https, 4, 'Wrapped https module called appropriately')
|
91
|
+
|
92
|
+
console.log((expected+2) + ' tests passed.')
|
93
|
+
}
|
94
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
// a test where we validate the siguature of the keys
|
2
|
+
// otherwise exactly the same as the ssl test
|
3
|
+
|
4
|
+
var server = require('./server')
|
5
|
+
, assert = require('assert')
|
6
|
+
, request = require('../main.js')
|
7
|
+
, fs = require('fs')
|
8
|
+
, path = require('path')
|
9
|
+
, opts = { key: path.resolve(__dirname, 'ssl/ca/server.key')
|
10
|
+
, cert: path.resolve(__dirname, 'ssl/ca/server.crt') }
|
11
|
+
, s = server.createSSLServer(null, opts)
|
12
|
+
, caFile = path.resolve(__dirname, 'ssl/ca/ca.crt')
|
13
|
+
, ca = fs.readFileSync(caFile)
|
14
|
+
|
15
|
+
var tests =
|
16
|
+
{ testGet :
|
17
|
+
{ resp : server.createGetResponse("TESTING!")
|
18
|
+
, expectBody: "TESTING!"
|
19
|
+
}
|
20
|
+
, testGetChunkBreak :
|
21
|
+
{ resp : server.createChunkResponse(
|
22
|
+
[ new Buffer([239])
|
23
|
+
, new Buffer([163])
|
24
|
+
, new Buffer([191])
|
25
|
+
, new Buffer([206])
|
26
|
+
, new Buffer([169])
|
27
|
+
, new Buffer([226])
|
28
|
+
, new Buffer([152])
|
29
|
+
, new Buffer([131])
|
30
|
+
])
|
31
|
+
, expectBody: "Ω☃"
|
32
|
+
}
|
33
|
+
, testGetJSON :
|
34
|
+
{ resp : server.createGetResponse('{"test":true}', 'application/json')
|
35
|
+
, json : true
|
36
|
+
, expectBody: {"test":true}
|
37
|
+
}
|
38
|
+
, testPutString :
|
39
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
40
|
+
, method : "PUT"
|
41
|
+
, body : "PUTTINGDATA"
|
42
|
+
}
|
43
|
+
, testPutBuffer :
|
44
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
45
|
+
, method : "PUT"
|
46
|
+
, body : new Buffer("PUTTINGDATA")
|
47
|
+
}
|
48
|
+
, testPutJSON :
|
49
|
+
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
|
50
|
+
, method: "PUT"
|
51
|
+
, json: {foo: 'bar'}
|
52
|
+
}
|
53
|
+
, testPutMultipart :
|
54
|
+
{ resp: server.createPostValidator(
|
55
|
+
'--frontier\r\n' +
|
56
|
+
'content-type: text/html\r\n' +
|
57
|
+
'\r\n' +
|
58
|
+
'<html><body>Oh hi.</body></html>' +
|
59
|
+
'\r\n--frontier\r\n\r\n' +
|
60
|
+
'Oh hi.' +
|
61
|
+
'\r\n--frontier--'
|
62
|
+
)
|
63
|
+
, method: "PUT"
|
64
|
+
, multipart:
|
65
|
+
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
|
66
|
+
, {'body': 'Oh hi.'}
|
67
|
+
]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
s.listen(s.port, function () {
|
72
|
+
|
73
|
+
var counter = 0
|
74
|
+
|
75
|
+
for (i in tests) {
|
76
|
+
(function () {
|
77
|
+
var test = tests[i]
|
78
|
+
s.on('/'+i, test.resp)
|
79
|
+
test.uri = s.url + '/' + i
|
80
|
+
test.strictSSL = true
|
81
|
+
test.ca = ca
|
82
|
+
test.headers = { host: 'testing.request.mikealrogers.com' }
|
83
|
+
request(test, function (err, resp, body) {
|
84
|
+
if (err) throw err
|
85
|
+
if (test.expectBody) {
|
86
|
+
assert.deepEqual(test.expectBody, body)
|
87
|
+
}
|
88
|
+
counter = counter - 1;
|
89
|
+
if (counter === 0) {
|
90
|
+
console.log(Object.keys(tests).length+" tests passed.")
|
91
|
+
s.close()
|
92
|
+
}
|
93
|
+
})
|
94
|
+
counter++
|
95
|
+
})()
|
96
|
+
}
|
97
|
+
})
|
@@ -0,0 +1,86 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, assert = require('assert')
|
3
|
+
, request = require('../main.js')
|
4
|
+
|
5
|
+
var s = server.createSSLServer();
|
6
|
+
|
7
|
+
var tests =
|
8
|
+
{ testGet :
|
9
|
+
{ resp : server.createGetResponse("TESTING!")
|
10
|
+
, expectBody: "TESTING!"
|
11
|
+
}
|
12
|
+
, testGetChunkBreak :
|
13
|
+
{ resp : server.createChunkResponse(
|
14
|
+
[ new Buffer([239])
|
15
|
+
, new Buffer([163])
|
16
|
+
, new Buffer([191])
|
17
|
+
, new Buffer([206])
|
18
|
+
, new Buffer([169])
|
19
|
+
, new Buffer([226])
|
20
|
+
, new Buffer([152])
|
21
|
+
, new Buffer([131])
|
22
|
+
])
|
23
|
+
, expectBody: "Ω☃"
|
24
|
+
}
|
25
|
+
, testGetJSON :
|
26
|
+
{ resp : server.createGetResponse('{"test":true}', 'application/json')
|
27
|
+
, json : true
|
28
|
+
, expectBody: {"test":true}
|
29
|
+
}
|
30
|
+
, testPutString :
|
31
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
32
|
+
, method : "PUT"
|
33
|
+
, body : "PUTTINGDATA"
|
34
|
+
}
|
35
|
+
, testPutBuffer :
|
36
|
+
{ resp : server.createPostValidator("PUTTINGDATA")
|
37
|
+
, method : "PUT"
|
38
|
+
, body : new Buffer("PUTTINGDATA")
|
39
|
+
}
|
40
|
+
, testPutJSON :
|
41
|
+
{ resp : server.createPostValidator(JSON.stringify({foo: 'bar'}))
|
42
|
+
, method: "PUT"
|
43
|
+
, json: {foo: 'bar'}
|
44
|
+
}
|
45
|
+
, testPutMultipart :
|
46
|
+
{ resp: server.createPostValidator(
|
47
|
+
'--frontier\r\n' +
|
48
|
+
'content-type: text/html\r\n' +
|
49
|
+
'\r\n' +
|
50
|
+
'<html><body>Oh hi.</body></html>' +
|
51
|
+
'\r\n--frontier\r\n\r\n' +
|
52
|
+
'Oh hi.' +
|
53
|
+
'\r\n--frontier--'
|
54
|
+
)
|
55
|
+
, method: "PUT"
|
56
|
+
, multipart:
|
57
|
+
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
|
58
|
+
, {'body': 'Oh hi.'}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
s.listen(s.port, function () {
|
64
|
+
|
65
|
+
var counter = 0
|
66
|
+
|
67
|
+
for (i in tests) {
|
68
|
+
(function () {
|
69
|
+
var test = tests[i]
|
70
|
+
s.on('/'+i, test.resp)
|
71
|
+
test.uri = s.url + '/' + i
|
72
|
+
request(test, function (err, resp, body) {
|
73
|
+
if (err) throw err
|
74
|
+
if (test.expectBody) {
|
75
|
+
assert.deepEqual(test.expectBody, body)
|
76
|
+
}
|
77
|
+
counter = counter - 1;
|
78
|
+
if (counter === 0) {
|
79
|
+
console.log(Object.keys(tests).length+" tests passed.")
|
80
|
+
s.close()
|
81
|
+
}
|
82
|
+
})
|
83
|
+
counter++
|
84
|
+
})()
|
85
|
+
}
|
86
|
+
})
|
@@ -0,0 +1,117 @@
|
|
1
|
+
var hmacsign = require('../oauth').hmacsign
|
2
|
+
, assert = require('assert')
|
3
|
+
, qs = require('querystring')
|
4
|
+
, request = require('../main')
|
5
|
+
;
|
6
|
+
|
7
|
+
function getsignature (r) {
|
8
|
+
var sign
|
9
|
+
r.headers.Authorization.slice('OAuth '.length).replace(/,\ /g, ',').split(',').forEach(function (v) {
|
10
|
+
if (v.slice(0, 'oauth_signature="'.length) === 'oauth_signature="') sign = v.slice('oauth_signature="'.length, -1)
|
11
|
+
})
|
12
|
+
return decodeURIComponent(sign)
|
13
|
+
}
|
14
|
+
|
15
|
+
// Tests from Twitter documentation https://dev.twitter.com/docs/auth/oauth
|
16
|
+
|
17
|
+
var reqsign = hmacsign('POST', 'https://api.twitter.com/oauth/request_token',
|
18
|
+
{ oauth_callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11'
|
19
|
+
, oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g'
|
20
|
+
, oauth_nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk'
|
21
|
+
, oauth_signature_method: 'HMAC-SHA1'
|
22
|
+
, oauth_timestamp: '1272323042'
|
23
|
+
, oauth_version: '1.0'
|
24
|
+
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98")
|
25
|
+
|
26
|
+
console.log(reqsign)
|
27
|
+
console.log('8wUi7m5HFQy76nowoCThusfgB+Q=')
|
28
|
+
assert.equal(reqsign, '8wUi7m5HFQy76nowoCThusfgB+Q=')
|
29
|
+
|
30
|
+
var accsign = hmacsign('POST', 'https://api.twitter.com/oauth/access_token',
|
31
|
+
{ oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g'
|
32
|
+
, oauth_nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8'
|
33
|
+
, oauth_signature_method: 'HMAC-SHA1'
|
34
|
+
, oauth_token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc'
|
35
|
+
, oauth_timestamp: '1272323047'
|
36
|
+
, oauth_verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY'
|
37
|
+
, oauth_version: '1.0'
|
38
|
+
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA")
|
39
|
+
|
40
|
+
console.log(accsign)
|
41
|
+
console.log('PUw/dHA4fnlJYM6RhXk5IU/0fCc=')
|
42
|
+
assert.equal(accsign, 'PUw/dHA4fnlJYM6RhXk5IU/0fCc=')
|
43
|
+
|
44
|
+
var upsign = hmacsign('POST', 'http://api.twitter.com/1/statuses/update.json',
|
45
|
+
{ oauth_consumer_key: "GDdmIQH6jhtmLUypg82g"
|
46
|
+
, oauth_nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y"
|
47
|
+
, oauth_signature_method: "HMAC-SHA1"
|
48
|
+
, oauth_token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw"
|
49
|
+
, oauth_timestamp: "1272325550"
|
50
|
+
, oauth_version: "1.0"
|
51
|
+
, status: 'setting up my twitter 私のさえずりを設定する'
|
52
|
+
}, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA")
|
53
|
+
|
54
|
+
console.log(upsign)
|
55
|
+
console.log('yOahq5m0YjDDjfjxHaXEsW9D+X0=')
|
56
|
+
assert.equal(upsign, 'yOahq5m0YjDDjfjxHaXEsW9D+X0=')
|
57
|
+
|
58
|
+
|
59
|
+
var rsign = request.post(
|
60
|
+
{ url: 'https://api.twitter.com/oauth/request_token'
|
61
|
+
, oauth:
|
62
|
+
{ callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11'
|
63
|
+
, consumer_key: 'GDdmIQH6jhtmLUypg82g'
|
64
|
+
, nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk'
|
65
|
+
, timestamp: '1272323042'
|
66
|
+
, version: '1.0'
|
67
|
+
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
|
68
|
+
}
|
69
|
+
})
|
70
|
+
|
71
|
+
setTimeout(function () {
|
72
|
+
console.log(getsignature(rsign))
|
73
|
+
assert.equal(reqsign, getsignature(rsign))
|
74
|
+
})
|
75
|
+
|
76
|
+
var raccsign = request.post(
|
77
|
+
{ url: 'https://api.twitter.com/oauth/access_token'
|
78
|
+
, oauth:
|
79
|
+
{ consumer_key: 'GDdmIQH6jhtmLUypg82g'
|
80
|
+
, nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8'
|
81
|
+
, signature_method: 'HMAC-SHA1'
|
82
|
+
, token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc'
|
83
|
+
, timestamp: '1272323047'
|
84
|
+
, verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY'
|
85
|
+
, version: '1.0'
|
86
|
+
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
|
87
|
+
, token_secret: "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA"
|
88
|
+
}
|
89
|
+
})
|
90
|
+
|
91
|
+
setTimeout(function () {
|
92
|
+
console.log(getsignature(raccsign))
|
93
|
+
assert.equal(accsign, getsignature(raccsign))
|
94
|
+
}, 1)
|
95
|
+
|
96
|
+
var rupsign = request.post(
|
97
|
+
{ url: 'http://api.twitter.com/1/statuses/update.json'
|
98
|
+
, oauth:
|
99
|
+
{ consumer_key: "GDdmIQH6jhtmLUypg82g"
|
100
|
+
, nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y"
|
101
|
+
, signature_method: "HMAC-SHA1"
|
102
|
+
, token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw"
|
103
|
+
, timestamp: "1272325550"
|
104
|
+
, version: "1.0"
|
105
|
+
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
|
106
|
+
, token_secret: "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA"
|
107
|
+
}
|
108
|
+
, form: {status: 'setting up my twitter 私のさえずりを設定する'}
|
109
|
+
})
|
110
|
+
setTimeout(function () {
|
111
|
+
console.log(getsignature(rupsign))
|
112
|
+
assert.equal(upsign, getsignature(rupsign))
|
113
|
+
}, 1)
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|