3 var express
= require('../')
4 , request
= require('supertest');
6 describe('req', function(){
7 describe('.secure', function(){
8 describe('when X-Forwarded-Proto is missing', function(){
9 it('should return false when http', function(done
){
12 app
.get('/', function(req
, res
){
13 res
.send(req
.secure
? 'yes' : 'no');
23 describe('.secure', function(){
24 describe('when X-Forwarded-Proto is present', function(){
25 it('should return false when http', function(done
){
28 app
.get('/', function(req
, res
){
29 res
.send(req
.secure
? 'yes' : 'no');
34 .set('X-Forwarded-Proto', 'https')
38 it('should return true when "trust proxy" is enabled', function(done
){
41 app
.enable('trust proxy');
43 app
.get('/', function(req
, res
){
44 res
.send(req
.secure
? 'yes' : 'no');
49 .set('X-Forwarded-Proto', 'https')
53 it('should return false when initial proxy is http', function(done
){
56 app
.enable('trust proxy');
58 app
.get('/', function(req
, res
){
59 res
.send(req
.secure
? 'yes' : 'no');
64 .set('X-Forwarded-Proto', 'http, https')
68 it('should return true when initial proxy is https', function(done
){
71 app
.enable('trust proxy');
73 app
.get('/', function(req
, res
){
74 res
.send(req
.secure
? 'yes' : 'no');
79 .set('X-Forwarded-Proto', 'https, http')
83 describe('when "trust proxy" trusting hop count', function () {
84 it('should respect X-Forwarded-Proto', function (done
) {
87 app
.set('trust proxy', 1);
89 app
.get('/', function (req
, res
) {
90 res
.send(req
.secure
? 'yes' : 'no');
95 .set('X-Forwarded-Proto', 'https')