req.secure.js
This file
Path
test/req.secure.js
101 lines · 2.4 KiB · JavaScript
Last changed by
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a0c35a point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 2–81why, one step back23var express = require('../')4 , request = require('supertest');56describe('req', function(){7 describe('.secure', function(){8 describe('when X-Forwarded-Proto is missing', function(){9 it('should return false when http', function(done){10 var app = express();1112 app.get('/', function(req, res){13 res.send(req.secure ? 'yes' : 'no');14 });1516 request(app)17 .get('/')18 .expect('no', done)19 })20 })21 })2223 describe('.secure', function(){24 describe('when X-Forwarded-Proto is present', function(){25 it('should return false when http', function(done){26 var app = express();2728 app.get('/', function(req, res){29 res.send(req.secure ? 'yes' : 'no');30 });3132 request(app)33 .get('/')34 .set('X-Forwarded-Proto', 'https')35 .expect('no', done)36 })3738 it('should return true when "trust proxy" is enabled', function(done){39 var app = express();4041 app.enable('trust proxy');4243 app.get('/', function(req, res){44 res.send(req.secure ? 'yes' : 'no');45 });4647 request(app)48 .get('/')49 .set('X-Forwarded-Proto', 'https')50 .expect('yes', done)51 })5253 it('should return false when initial proxy is http', function(done){54 var app = express();5556 app.enable('trust proxy');5758 app.get('/', function(req, res){59 res.send(req.secure ? 'yes' : 'no');60 });6162 request(app)63 .get('/')64 .set('X-Forwarded-Proto', 'http, https')65 .expect('no', done)66 })6768 it('should return true when initial proxy is https', function(done){69 var app = express();7071 app.enable('trust proxy');7273 app.get('/', function(req, res){74 res.send(req.secure ? 'yes' : 'no');75 });7677 request(app)78 .get('/')79 .set('X-Forwarded-Proto', 'https, http')80 .expect('yes', done)81 })Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
lines 82–98why, one step back8283 describe('when "trust proxy" trusting hop count', function () {84 it('should respect X-Forwarded-Proto', function (done) {85 var app = express();8687 app.set('trust proxy', 1);8889 app.get('/', function (req, res) {90 res.send(req.secure ? 'yes' : 'no');91 });9293 request(app)94 .get('/')95 .set('X-Forwarded-Proto', 'https')96 .expect('yes', done)97 })98 })Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 99–101why, one step back99 })100 })101})