[Pkg-javascript-commits] [node-stream-http] 68/208: Add test for cookie behavior
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Aug 13 13:39:30 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-http.
commit 588e5874f371795fa4a5136e97ca5fb03d9a7329
Author: Cesar Andreu <cesarandreu at gmail.com>
Date: Sun Jul 19 17:50:30 2015 -0700
Add test for cookie behavior
---
package.json | 1 +
test/browser/cookie.js | 25 +++++++++++++++++++++++++
test/server/index.js | 7 +++++++
3 files changed, 33 insertions(+)
diff --git a/package.json b/package.json
index 9857cc8..f1c6a3e 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"devDependencies": {
"basic-auth": "^1.0.3",
"brfs": "^1.4.0",
+ "cookie-parser": "^1.3.5",
"express": "^4.13.0",
"tape": "^4.0.0",
"ua-parser-js": "^0.7.7",
diff --git a/test/browser/cookie.js b/test/browser/cookie.js
new file mode 100644
index 0000000..114c687
--- /dev/null
+++ b/test/browser/cookie.js
@@ -0,0 +1,25 @@
+var Buffer = require('buffer').Buffer
+var test = require('tape')
+
+var http = require('../..')
+
+test('cookie', function (t) {
+ var cookie = 'hello=world'
+ window.document.cookie = cookie
+
+ http.get({
+ path: '/cookie',
+ withCredentials: false
+ }, function (res) {
+ var buffers = []
+
+ res.on('end', function () {
+ t.ok(new Buffer(cookie).equals(Buffer.concat(buffers)), 'hello cookie echoed')
+ t.end()
+ })
+
+ res.on('data', function (data) {
+ buffers.push(data)
+ })
+ })
+})
diff --git a/test/server/index.js b/test/server/index.js
index fad8c82..26962c6 100644
--- a/test/server/index.js
+++ b/test/server/index.js
@@ -1,3 +1,4 @@
+var cookieParser = require('cookie-parser')
var basicAuth = require('basic-auth')
var express = require('express')
var fs = require('fs')
@@ -46,6 +47,12 @@ app.get('/testHeaders', function (req, res) {
res.end()
})
+app.get('/cookie', cookieParser(), function (req, res) {
+ res.setHeader('Content-Type', 'text/plain')
+ res.write('hello=' + req.cookies.hello)
+ res.end()
+})
+
app.get('/auth', function (req, res) {
var user = basicAuth(req)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git
More information about the Pkg-javascript-commits
mailing list