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,30 @@
|
|
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
|
+
console.log("All tests passed.")
|
@@ -0,0 +1,109 @@
|
|
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 r = 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
|
+
console.log(getsignature(r))
|
72
|
+
assert.equal(reqsign, getsignature(r))
|
73
|
+
|
74
|
+
var r = request.post(
|
75
|
+
{ url: 'https://api.twitter.com/oauth/access_token'
|
76
|
+
, oauth:
|
77
|
+
{ consumer_key: 'GDdmIQH6jhtmLUypg82g'
|
78
|
+
, nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8'
|
79
|
+
, signature_method: 'HMAC-SHA1'
|
80
|
+
, token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc'
|
81
|
+
, timestamp: '1272323047'
|
82
|
+
, verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY'
|
83
|
+
, version: '1.0'
|
84
|
+
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
|
85
|
+
, token_secret: "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA"
|
86
|
+
}
|
87
|
+
})
|
88
|
+
|
89
|
+
console.log(getsignature(r))
|
90
|
+
assert.equal(accsign, getsignature(r))
|
91
|
+
|
92
|
+
var r = request.post(
|
93
|
+
{ url: 'http://api.twitter.com/1/statuses/update.json'
|
94
|
+
, oauth:
|
95
|
+
{ consumer_key: "GDdmIQH6jhtmLUypg82g"
|
96
|
+
, nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y"
|
97
|
+
, signature_method: "HMAC-SHA1"
|
98
|
+
, token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw"
|
99
|
+
, timestamp: "1272325550"
|
100
|
+
, version: "1.0"
|
101
|
+
, consumer_secret: "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"
|
102
|
+
, token_secret: "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA"
|
103
|
+
}
|
104
|
+
, form: {status: 'setting up my twitter 私のさえずりを設定する'}
|
105
|
+
})
|
106
|
+
|
107
|
+
console.log(getsignature(r))
|
108
|
+
assert.equal(upsign, getsignature(r))
|
109
|
+
|
@@ -0,0 +1,167 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, events = require('events')
|
3
|
+
, stream = require('stream')
|
4
|
+
, assert = require('assert')
|
5
|
+
, fs = require('fs')
|
6
|
+
, request = require('../main.js')
|
7
|
+
, path = require('path')
|
8
|
+
, util = require('util')
|
9
|
+
;
|
10
|
+
|
11
|
+
var s = server.createServer(3453);
|
12
|
+
|
13
|
+
function ValidationStream(str) {
|
14
|
+
this.str = str
|
15
|
+
this.buf = ''
|
16
|
+
this.on('data', function (data) {
|
17
|
+
this.buf += data
|
18
|
+
})
|
19
|
+
this.on('end', function () {
|
20
|
+
assert.equal(this.str, this.buf)
|
21
|
+
})
|
22
|
+
this.writable = true
|
23
|
+
}
|
24
|
+
util.inherits(ValidationStream, stream.Stream)
|
25
|
+
ValidationStream.prototype.write = function (chunk) {
|
26
|
+
this.emit('data', chunk)
|
27
|
+
}
|
28
|
+
ValidationStream.prototype.end = function (chunk) {
|
29
|
+
if (chunk) emit('data', chunk)
|
30
|
+
this.emit('end')
|
31
|
+
}
|
32
|
+
|
33
|
+
s.listen(s.port, function () {
|
34
|
+
counter = 0;
|
35
|
+
|
36
|
+
var check = function () {
|
37
|
+
counter = counter - 1
|
38
|
+
if (counter === 0) {
|
39
|
+
console.log('All tests passed.')
|
40
|
+
setTimeout(function () {
|
41
|
+
process.exit();
|
42
|
+
}, 500)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
// Test pipeing to a request object
|
47
|
+
s.once('/push', server.createPostValidator("mydata"));
|
48
|
+
|
49
|
+
var mydata = new stream.Stream();
|
50
|
+
mydata.readable = true
|
51
|
+
|
52
|
+
counter++
|
53
|
+
var r1 = request.put({url:'http://localhost:3453/push'}, function () {
|
54
|
+
check();
|
55
|
+
})
|
56
|
+
mydata.pipe(r1)
|
57
|
+
|
58
|
+
mydata.emit('data', 'mydata');
|
59
|
+
mydata.emit('end');
|
60
|
+
|
61
|
+
|
62
|
+
// Test pipeing from a request object.
|
63
|
+
s.once('/pull', server.createGetResponse("mypulldata"));
|
64
|
+
|
65
|
+
var mypulldata = new stream.Stream();
|
66
|
+
mypulldata.writable = true
|
67
|
+
|
68
|
+
counter++
|
69
|
+
request({url:'http://localhost:3453/pull'}).pipe(mypulldata)
|
70
|
+
|
71
|
+
var d = '';
|
72
|
+
|
73
|
+
mypulldata.write = function (chunk) {
|
74
|
+
d += chunk;
|
75
|
+
}
|
76
|
+
mypulldata.end = function () {
|
77
|
+
assert.equal(d, 'mypulldata');
|
78
|
+
check();
|
79
|
+
};
|
80
|
+
|
81
|
+
|
82
|
+
s.on('/cat', function (req, resp) {
|
83
|
+
if (req.method === "GET") {
|
84
|
+
resp.writeHead(200, {'content-type':'text/plain-test', 'content-length':4});
|
85
|
+
resp.end('asdf')
|
86
|
+
} else if (req.method === "PUT") {
|
87
|
+
assert.equal(req.headers['content-type'], 'text/plain-test');
|
88
|
+
assert.equal(req.headers['content-length'], 4)
|
89
|
+
var validate = '';
|
90
|
+
|
91
|
+
req.on('data', function (chunk) {validate += chunk})
|
92
|
+
req.on('end', function () {
|
93
|
+
resp.writeHead(201);
|
94
|
+
resp.end();
|
95
|
+
assert.equal(validate, 'asdf');
|
96
|
+
check();
|
97
|
+
})
|
98
|
+
}
|
99
|
+
})
|
100
|
+
s.on('/pushjs', function (req, resp) {
|
101
|
+
if (req.method === "PUT") {
|
102
|
+
assert.equal(req.headers['content-type'], 'text/javascript');
|
103
|
+
check();
|
104
|
+
}
|
105
|
+
})
|
106
|
+
s.on('/catresp', function (req, resp) {
|
107
|
+
request.get('http://localhost:3453/cat').pipe(resp)
|
108
|
+
})
|
109
|
+
s.on('/doodle', function (req, resp) {
|
110
|
+
if (req.headers['x-oneline-proxy']) {
|
111
|
+
resp.setHeader('x-oneline-proxy', 'yup')
|
112
|
+
}
|
113
|
+
resp.writeHead('200', {'content-type':'image/png'})
|
114
|
+
fs.createReadStream(path.join(__dirname, 'googledoodle.png')).pipe(resp)
|
115
|
+
})
|
116
|
+
s.on('/onelineproxy', function (req, resp) {
|
117
|
+
var x = request('http://localhost:3453/doodle')
|
118
|
+
req.pipe(x)
|
119
|
+
x.pipe(resp)
|
120
|
+
})
|
121
|
+
|
122
|
+
counter++
|
123
|
+
fs.createReadStream(__filename).pipe(request.put('http://localhost:3453/pushjs'))
|
124
|
+
|
125
|
+
counter++
|
126
|
+
request.get('http://localhost:3453/cat').pipe(request.put('http://localhost:3453/cat'))
|
127
|
+
|
128
|
+
counter++
|
129
|
+
request.get('http://localhost:3453/catresp', function (e, resp, body) {
|
130
|
+
assert.equal(resp.headers['content-type'], 'text/plain-test');
|
131
|
+
assert.equal(resp.headers['content-length'], 4)
|
132
|
+
check();
|
133
|
+
})
|
134
|
+
|
135
|
+
var doodleWrite = fs.createWriteStream(path.join(__dirname, 'test.png'))
|
136
|
+
|
137
|
+
counter++
|
138
|
+
request.get('http://localhost:3453/doodle').pipe(doodleWrite)
|
139
|
+
|
140
|
+
doodleWrite.on('close', function () {
|
141
|
+
assert.deepEqual(fs.readFileSync(path.join(__dirname, 'googledoodle.png')), fs.readFileSync(path.join(__dirname, 'test.png')))
|
142
|
+
check()
|
143
|
+
})
|
144
|
+
|
145
|
+
process.on('exit', function () {
|
146
|
+
fs.unlinkSync(path.join(__dirname, 'test.png'))
|
147
|
+
})
|
148
|
+
|
149
|
+
counter++
|
150
|
+
request.get({uri:'http://localhost:3453/onelineproxy', headers:{'x-oneline-proxy':'nope'}}, function (err, resp, body) {
|
151
|
+
assert.equal(resp.headers['x-oneline-proxy'], 'yup')
|
152
|
+
check()
|
153
|
+
})
|
154
|
+
|
155
|
+
s.on('/afterresponse', function (req, resp) {
|
156
|
+
resp.write('d')
|
157
|
+
resp.end()
|
158
|
+
})
|
159
|
+
|
160
|
+
counter++
|
161
|
+
var afterresp = request.post('http://localhost:3453/afterresponse').on('response', function () {
|
162
|
+
var v = new ValidationStream('d')
|
163
|
+
afterresp.pipe(v)
|
164
|
+
v.on('end', check)
|
165
|
+
})
|
166
|
+
|
167
|
+
})
|
@@ -0,0 +1,39 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, events = require('events')
|
3
|
+
, stream = require('stream')
|
4
|
+
, assert = require('assert')
|
5
|
+
, fs = require('fs')
|
6
|
+
, request = require('../main.js')
|
7
|
+
, path = require('path')
|
8
|
+
, util = require('util')
|
9
|
+
;
|
10
|
+
|
11
|
+
var port = 6768
|
12
|
+
, called = false
|
13
|
+
, proxiedHost = 'google.com'
|
14
|
+
;
|
15
|
+
|
16
|
+
var s = server.createServer(port)
|
17
|
+
s.listen(port, function () {
|
18
|
+
s.on('http://google.com/', function (req, res) {
|
19
|
+
called = true
|
20
|
+
assert.equal(req.headers.host, proxiedHost)
|
21
|
+
res.writeHeader(200)
|
22
|
+
res.end()
|
23
|
+
})
|
24
|
+
request ({
|
25
|
+
url: 'http://'+proxiedHost,
|
26
|
+
proxy: 'http://localhost:'+port
|
27
|
+
/*
|
28
|
+
//should behave as if these arguments where passed:
|
29
|
+
url: 'http://localhost:'+port,
|
30
|
+
headers: {host: proxiedHost}
|
31
|
+
//*/
|
32
|
+
}, function (err, res, body) {
|
33
|
+
s.close()
|
34
|
+
})
|
35
|
+
})
|
36
|
+
|
37
|
+
process.on('exit', function () {
|
38
|
+
assert.ok(called, 'the request must be made to the proxy server')
|
39
|
+
})
|
data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
var server = require('./server')
|
2
|
+
, events = require('events')
|
3
|
+
, stream = require('stream')
|
4
|
+
, assert = require('assert')
|
5
|
+
, request = require('../main.js')
|
6
|
+
;
|
7
|
+
|
8
|
+
var s = server.createServer();
|
9
|
+
var expectedBody = "waited";
|
10
|
+
var remainingTests = 5;
|
11
|
+
|
12
|
+
s.listen(s.port, function () {
|
13
|
+
// Request that waits for 200ms
|
14
|
+
s.on('/timeout', function (req, resp) {
|
15
|
+
setTimeout(function(){
|
16
|
+
resp.writeHead(200, {'content-type':'text/plain'})
|
17
|
+
resp.write(expectedBody)
|
18
|
+
resp.end()
|
19
|
+
}, 200);
|
20
|
+
});
|
21
|
+
|
22
|
+
// Scenario that should timeout
|
23
|
+
var shouldTimeout = {
|
24
|
+
url: s.url + "/timeout",
|
25
|
+
timeout:100
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
request(shouldTimeout, function (err, resp, body) {
|
30
|
+
assert.equal(err.code, "ETIMEDOUT");
|
31
|
+
checkDone();
|
32
|
+
})
|
33
|
+
|
34
|
+
|
35
|
+
// Scenario that shouldn't timeout
|
36
|
+
var shouldntTimeout = {
|
37
|
+
url: s.url + "/timeout",
|
38
|
+
timeout:300
|
39
|
+
}
|
40
|
+
|
41
|
+
request(shouldntTimeout, function (err, resp, body) {
|
42
|
+
assert.equal(err, null);
|
43
|
+
assert.equal(expectedBody, body)
|
44
|
+
checkDone();
|
45
|
+
})
|
46
|
+
|
47
|
+
// Scenario with no timeout set, so shouldn't timeout
|
48
|
+
var noTimeout = {
|
49
|
+
url: s.url + "/timeout"
|
50
|
+
}
|
51
|
+
|
52
|
+
request(noTimeout, function (err, resp, body) {
|
53
|
+
assert.equal(err);
|
54
|
+
assert.equal(expectedBody, body)
|
55
|
+
checkDone();
|
56
|
+
})
|
57
|
+
|
58
|
+
// Scenario with a negative timeout value, should be treated a zero or the minimum delay
|
59
|
+
var negativeTimeout = {
|
60
|
+
url: s.url + "/timeout",
|
61
|
+
timeout:-1000
|
62
|
+
}
|
63
|
+
|
64
|
+
request(negativeTimeout, function (err, resp, body) {
|
65
|
+
assert.equal(err.code, "ETIMEDOUT");
|
66
|
+
checkDone();
|
67
|
+
})
|
68
|
+
|
69
|
+
// Scenario with a float timeout value, should be rounded by setTimeout anyway
|
70
|
+
var floatTimeout = {
|
71
|
+
url: s.url + "/timeout",
|
72
|
+
timeout: 100.76
|
73
|
+
}
|
74
|
+
|
75
|
+
request(floatTimeout, function (err, resp, body) {
|
76
|
+
assert.equal(err.code, "ETIMEDOUT");
|
77
|
+
checkDone();
|
78
|
+
})
|
79
|
+
|
80
|
+
function checkDone() {
|
81
|
+
if(--remainingTests == 0) {
|
82
|
+
s.close();
|
83
|
+
console.log("All tests passed.");
|
84
|
+
}
|
85
|
+
}
|
86
|
+
})
|
87
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module.exports = function () {
|
2
|
+
var s = [], itoh = '0123456789ABCDEF';
|
3
|
+
|
4
|
+
// Make array of random hex digits. The UUID only has 32 digits in it, but we
|
5
|
+
// allocate an extra items to make room for the '-'s we'll be inserting.
|
6
|
+
for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
|
7
|
+
|
8
|
+
// Conform to RFC-4122, section 4.4
|
9
|
+
s[14] = 4; // Set 4 high bits of time_high field to version
|
10
|
+
s[19] = (s[19] & 0x3) | 0x8; // Specify 2 high bits of clock sequence
|
11
|
+
|
12
|
+
// Convert to hex chars
|
13
|
+
for (var i = 0; i <36; i++) s[i] = itoh[s[i]];
|
14
|
+
|
15
|
+
// Insert '-'s
|
16
|
+
s[8] = s[13] = s[18] = s[23] = '-';
|
17
|
+
|
18
|
+
return s.join('');
|
19
|
+
}
|