From 61f6535be817f9a7b0c1266f11e5cce01fb55c1c Mon Sep 17 00:00:00 2001 From: HirokiUchikawa Date: Wed, 23 May 2018 16:54:03 +0900 Subject: [PATCH] Add test case for preventing following redirect --- test/nodes/core/io/21-httprequest_spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/nodes/core/io/21-httprequest_spec.js b/test/nodes/core/io/21-httprequest_spec.js index 43c42c8a4..4a1b513f0 100644 --- a/test/nodes/core/io/21-httprequest_spec.js +++ b/test/nodes/core/io/21-httprequest_spec.js @@ -796,6 +796,25 @@ describe('HTTP Request Node', function() { }); }); + it('should prevent following redirect when msg.followRedirects is false', function(done) { + var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"txt",url:getTestURL('/redirectToText')}, + {id:"n2", type:"helper"}]; + helper.load(httpRequestNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on("input", function(msg) { + try { + msg.should.have.property('statusCode',302); + msg.should.have.property('responseUrl', getTestURL('/redirectToText')); + done(); + } catch(err) { + done(err); + } + }); + n1.receive({payload:"foo",followRedirects:false}); + }); + }); + it('shuold output an error when request timeout occurred', function(done) { var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"obj",url:getTestURL('/timeout')}, {id:"n2", type:"helper"}];