From c282bb2fe1e79a585c31c4d80d0174949b8d6400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Fri, 10 Mar 2017 18:20:11 -0300 Subject: [PATCH 1/4] Fix if MM_PORT enviroment variable is set --- CHANGELOG.md | 1 + js/server.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1138da27..bdc8783b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Module currentWeather: check if temperature received from api is defined. - Fix an issue with module hidden status changing to `true` although lock string prevented showing it - Fix newsfeed module bug (removeStartTags) +- Fix when is set MM_PORT enviroment variable. ## [2.1.0] - 2016-12-31 diff --git a/js/server.js b/js/server.js index 901e0350..53d00235 100644 --- a/js/server.js +++ b/js/server.js @@ -15,9 +15,15 @@ var fs = require("fs"); var helmet = require("helmet"); var Server = function(config, callback) { - console.log("Starting server op port " + config.port + " ... "); - server.listen(config.port, config.address ? config.address : null); + var port = config.port; + if (process.env.MM_PORT) { + port = process.env.MM_PORT; + } + + console.log("Starting server op port " + port + " ... "); + + server.listen(port, config.address ? config.address : null); app.use(function(req, res, next) { var result = ipfilter(config.ipWhitelist, {mode: "allow", log: false})(req, res, function(err) { From c6fa0cc0723f6304ab1c0528e5ae229d18396f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Fri, 10 Mar 2017 18:21:06 -0300 Subject: [PATCH 2/4] Add test for check MM_PORT enviroment variable --- tests/e2e/port_config.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/e2e/port_config.js b/tests/e2e/port_config.js index c0806e85..e44a2207 100644 --- a/tests/e2e/port_config.js +++ b/tests/e2e/port_config.js @@ -29,4 +29,19 @@ describe("port directive configuration", function () { }); }); }); + + describe("Set port 8100 on enviroment variable MM_PORT", function () { + before(function() { + process.env.MM_PORT = 8100; + // Set config sample for use in this test + process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js"; + }); + it("should return 200", function (done) { + request.get("http://localhost:8100", function (err, res, body) { + expect(res.statusCode).to.equal(200); + done(); + }); + }); + }); + }); From 4b4c3ddb2f973d587345a4e146f502af17e6571a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Mon, 27 Mar 2017 02:01:42 -0300 Subject: [PATCH 3/4] Add changelog test MM_PORT --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6efc82c..6ee76be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added multiple calendar icon support. - Added meta tags to support fullscreen mode on iOS (for server mode) - Added `ignoreOldItems` and `ignoreOlderThan` options to the News Feed module +- Added test for MM_PORT enviroment variable. ### Fixed - Update .gitignore to not ignore default modules folder. From ef9157174c0d38e280c85349298291c3da04af58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Thu, 30 Mar 2017 16:32:51 -0300 Subject: [PATCH 4/4] Fix broken next test: Now after ran the test MM_PORT of test case for change of port the enviroment variable is deleted. --- tests/e2e/port_config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/e2e/port_config.js b/tests/e2e/port_config.js index e44a2207..44c6b498 100644 --- a/tests/e2e/port_config.js +++ b/tests/e2e/port_config.js @@ -36,6 +36,10 @@ describe("port directive configuration", function () { // Set config sample for use in this test process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js"; }); + + after(function(){ + delete process.env.MM_PORT; + }); it("should return 200", function (done) { request.get("http://localhost:8100", function (err, res, body) { expect(res.statusCode).to.equal(200);