mirror of
https://github.com/Netflix/dial-reference.git
synced 2026-06-09 03:19:59 +00:00
committing node js tests for netflix app with DIAL 2.1
This commit is contained in:
38
server/tests/js_tests/tests/discoverServerUnderTest.js
Normal file
38
server/tests/js_tests/tests/discoverServerUnderTest.js
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var testServer = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Perform DIAL discovery and ensure that the server under test is discovered");
|
||||
})
|
||||
.then(dial.discover)
|
||||
.then(function findServerInList(servers) {
|
||||
var found = false;
|
||||
servers.forEach(function (server) {
|
||||
if(server.host === testServer) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
if(!found) {
|
||||
return Q.reject(new Error("DIAL client was not able to discover the server under test : " + testServer));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.log("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Try to hide an invalid instance of Netflix application and expect status code 404");
|
||||
})
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 200 && status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application. Expected status code 200/201 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
return dial.getApplicationStatus(host, "Netflix");
|
||||
})
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.dialVer && result.dialVer !== "2.1") {
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
.then(function () {
|
||||
return dial.getAppsUrl(host);
|
||||
})
|
||||
.then(function (appsUrl) {
|
||||
var invalidInstanceUrl = appsUrl + "/application/xyz";
|
||||
return invalidInstanceUrl;
|
||||
})
|
||||
.then(function (url) {
|
||||
return dial.hideApplicationInstance(url);
|
||||
})
|
||||
.then(function (status) {
|
||||
if(status !== 404) {
|
||||
return Q.reject(new Error("Tried to hide invalid application instance. Expected statusCode: 404 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
67
server/tests/js_tests/tests/hideNetflixWhenAlreadyHidden.js
Normal file
67
server/tests/js_tests/tests/hideNetflixWhenAlreadyHidden.js
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Try to hide netflix when it is already in hidden state and expect response code 200 from the DIAL server");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function hideApp(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
if(!result.dialVer || result.dialVer !== "2.1") { // Hidden state not supported
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
|
||||
if(result.state === "stopped") {
|
||||
// Launch and hide app
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.delay(5000)
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000);
|
||||
}
|
||||
else if(result.state === "starting" || result.state === "running") {
|
||||
// Hide app
|
||||
return dial.hideApplication(host, "Netflix")
|
||||
.delay(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function checkAppStatus(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
return Q.reject(new Error("Expected Netflix app status to be hidden but the state was " + result.state));
|
||||
}
|
||||
})
|
||||
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Tried to hide Netflix. Expected statusCode: 200 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
55
server/tests/js_tests/tests/hideNetflixWhenRunning.js
Normal file
55
server/tests/js_tests/tests/hideNetflixWhenRunning.js
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Hide netflix application when it is running and expect response code 200");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.dialVer && result.dialVer !== "2.1") {
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
|
||||
.then(function startAppIfNotRunning(state) {
|
||||
if(state !== "running") {
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Could not launch Netflix application. Expected status code 201 but got " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000) // Allow time for app to start
|
||||
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Error stopping Netflix application. Expected status code 200 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
38
server/tests/js_tests/tests/launchAppNotRecognized.js
Normal file
38
server/tests/js_tests/tests/launchAppNotRecognized.js
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Launch an invalid application using DIAL server and check for response code 404");
|
||||
})
|
||||
.then(dial.launchApplication.bind(null, host, "InvalidApplication"))
|
||||
.then(function (status) {
|
||||
if(status !== 404) {
|
||||
return Q.reject(new Error("Tried to launch invalid application using DIAL server. Expected statusCode: 404 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(dial.launchApplication.bind(null, host, "InvalidApplication", "key1=val1&key2=val2"))
|
||||
.then(function (status) {
|
||||
if(status !== 404) {
|
||||
return Q.reject(new Error("Tried to launch invalid application with a payload using DIAL server. Expected statusCode: 404 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Launch Netflix without payload using DIAL server when application is already running and check for response code 200/201");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
|
||||
.then(function startAppIfNotRunning(state) {
|
||||
if(state !== "starting" || state !== "running") {
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application. Expected status code 201 from DIAL server but got " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 201 && status !== 200) {
|
||||
return Q.reject(new Error("Error launching Netflix application when it was already running. Expected status code 200/201 from DIAL server but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Launch Netflix with payload using DIAL server when application is already running and check for response code 200/201");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
|
||||
.then(function startAppIfNotRunning(state) {
|
||||
if(state !== "starting" || state !== "running") {
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application. Expected status code 201 from DIAL server but got " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix", "key1=val1&key2=val2"))
|
||||
.then(function (status) {
|
||||
if(status !== 201 && status !== 200) {
|
||||
return Q.reject(new Error("Error launching Netflix application when it was already running. Expected status code 200/201 from DIAL server but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Launch Netflix application using DIAL server when the application is in STOPPED state");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject("Could not retrieve current Netflix application state");
|
||||
}
|
||||
if(result.state !== "stopped") {
|
||||
if(result.allowStop && result.allowStop === "false") {
|
||||
return Q.reject(new Error("The DIAL server does not support STOP operation. Test cannot proceed. Make sure the Netflix app is stopped before re-running the test"));
|
||||
}
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
.then(function stopAppIfCurrentlyRunning(state) {
|
||||
if(state !== "stopped") {
|
||||
return dial.stopApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Could not stop Netflix application when it was running. Expected status code 200 but got " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application. Expected statusCode: 201 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Launch Netflix application with payload using DIAL server when the application is in STOPPED state");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject("Could not retrieve current Netflix application state");
|
||||
}
|
||||
if(result.state !== "stopped") {
|
||||
if(result.allowStop && result.allowStop === "false") {
|
||||
return Q.reject(new Error("The DIAL server does not support STOP operation. Test cannot proceed. Make sure the Netflix app is stopped before re-running the test"));
|
||||
}
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
.then(function stopAppIfCurrentlyRunning(state) {
|
||||
if(state !== "stopped") {
|
||||
return dial.stopApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Could not stop Netflix application when it was running. Expected status code 200 but got " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix", "key1=val1&key2=val2"))
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application. Expected statusCode: 201 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + "Launch Netflix application using DIAL server when app is in hidden state and check for response code 201 ");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function hideApp(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
if(result.dialVer && result.dialVer !== "2.1") { // Hidden state not supported
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
|
||||
if(result.state === "stopped") {
|
||||
// Launch and hide app
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.delay(5000)
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000);
|
||||
}
|
||||
else if(result.state === "starting" || result.state === "running") {
|
||||
// Hide app
|
||||
return dial.hideApplication(host, "Netflix")
|
||||
.delay(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function checkAppStatus(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
return Q.reject(new Error("Expected Netflix app status to be hidden but the status was " + result.state));
|
||||
}
|
||||
})
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application when it was in hidden state. Expected statusCode: 201 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000) //Allow time for app to launch
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + "Launch Netflix application with payload using DIAL server when app is in hidden state and check for response code 201 ");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function hideApp(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
if(result.dialVer && result.dialVer !== "2.1") { // Hidden state not supported
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
|
||||
if(result.state === "stopped") {
|
||||
// Launch and hide app
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.delay(5000)
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000);
|
||||
}
|
||||
else if(result.state === "starting" || result.state === "running") {
|
||||
// Hide app
|
||||
return dial.hideApplication(host, "Netflix")
|
||||
.delay(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function checkAppStatus(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
return Q.reject(new Error("Expected Netflix app status to be hidden but the status was " + result.state));
|
||||
}
|
||||
})
|
||||
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix", "key1=val1&key2=val2"))
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject(new Error("Error launching Netflix application when it was in hidden state. Expected statusCode: 201 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000) //Allow time for app to launch
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
var payload = "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&"
|
||||
+ "key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value&key=value";
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Try to launch Netflix app with excess payload and ensure DIAL server returns response code 413");
|
||||
})
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix", payload))
|
||||
.then(function (status) {
|
||||
if(status !== 413) {
|
||||
return Q.reject(new Error("Tried to launch Netflix with excess payload. Expected statusCode: 413 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
39
server/tests/js_tests/tests/netflixTests.js
Normal file
39
server/tests/js_tests/tests/netflixTests.js
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
var Q = require("q");
|
||||
|
||||
var discoverServerUnderTest = require("../tests/discoverServerUnderTest.js"),
|
||||
launchInvalidApp = require("../tests/launchAppNotRecognized.js"),
|
||||
launchNetflixInRunningStateWithNoPayload = require("../tests/launchNetflixAlreadyRunningWithNoPayload.js"),
|
||||
launchNetflixInRunningStateWithPayload = require("../tests/launchNetflixAlreadyRunningWithPayload.js"),
|
||||
launchNetflixInStoppedStateWithNoPayload = require("../tests/launchNetflixNotRunningWithNoPayload.js"),
|
||||
launchNetflixInStoppedStateWithPayload = require("../tests/launchNetflixNotRunningWithPayload.js"),
|
||||
launchNetflixWhenHiddenWithNoPayload = require("../tests/launchNetflixWhenHiddenWithNoPayload.js"),
|
||||
launchNetflixWhenHiddenWithPayload = require("../tests/launchNetflixWhenHiddenWithPayload.js"),
|
||||
launchNetflixWithExcessPayload = require("../tests/launchNetflixWithExcessPayload.js"),
|
||||
stopInvalidNetflixInstance = require("../tests/stopInvalidNetflixInstance.js"),
|
||||
stopNetflixInRunningState = require("../tests/stopNetflixInRunningState.js"),
|
||||
stopNetflixInStoppedState = require("../tests/stopNetflixInStoppedState.js"),
|
||||
stopNetflixInHiddenState = require("../tests/stopNetflixInHiddenState.js"),
|
||||
hideInvalidApplicationInstance = require("../tests/hideInvalidApplicationInstance.js"),
|
||||
hideNetflixWhenAlreadyHidden = require("../tests/hideNetflixWhenAlreadyHidden.js"),
|
||||
hideNetflixWhenRunning = require("../tests/hideNetflixWhenRunning.js");
|
||||
|
||||
new Q()
|
||||
.then(discoverServerUnderTest.test)
|
||||
.then(launchInvalidApp.test)
|
||||
.then(launchNetflixInRunningStateWithNoPayload.test)
|
||||
.then(launchNetflixInRunningStateWithPayload.test)
|
||||
.then(launchNetflixInStoppedStateWithNoPayload.test)
|
||||
.then(launchNetflixInStoppedStateWithPayload.test)
|
||||
.then(launchNetflixWhenHiddenWithNoPayload.test)
|
||||
.then(launchNetflixWhenHiddenWithPayload.test)
|
||||
.then(launchNetflixWithExcessPayload.test)
|
||||
.then(stopInvalidNetflixInstance.test)
|
||||
.then(stopNetflixInRunningState.test)
|
||||
.then(stopNetflixInStoppedState.test)
|
||||
.then(stopNetflixInHiddenState.test)
|
||||
.then(hideInvalidApplicationInstance.test)
|
||||
.then(hideNetflixWhenAlreadyHidden.test)
|
||||
.then(hideNetflixWhenRunning.test)
|
||||
.done();
|
||||
58
server/tests/js_tests/tests/stopInvalidNetflixInstance.js
Normal file
58
server/tests/js_tests/tests/stopInvalidNetflixInstance.js
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Try to stop invalid Netflix application instance and check for DIAL server response code 404");
|
||||
})
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000)
|
||||
.then(function getCurrentAppState() {
|
||||
return dial.getApplicationStatus(host, "Netflix")
|
||||
.then(function (result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.allowStop && result.allowStop === "false") {
|
||||
return Q.reject(new Error("This test is not applicable for servers that do not support DIAL stop operation."));
|
||||
}
|
||||
if(result.state !== "running") {
|
||||
return Q.reject(new Error("Expected Netflix application to be running but server returned application state as " + result.state));
|
||||
}
|
||||
});
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
return dial.getAppsUrl(host);
|
||||
})
|
||||
.then(function (appsUrl) {
|
||||
var invalidInstanceUrl = appsUrl + "/Netflix/xyz";
|
||||
return invalidInstanceUrl;
|
||||
})
|
||||
.then(function (url) {
|
||||
return dial.stopApplicationInstance(url);
|
||||
})
|
||||
.then(function (status) {
|
||||
if(status !== 404) {
|
||||
return Q.reject(new Error("Tried to stop invalid Netflix application instance. Expected statusCode: 404 but got " + status));
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
69
server/tests/js_tests/tests/stopNetflixInHiddenState.js
Normal file
69
server/tests/js_tests/tests/stopNetflixInHiddenState.js
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Stop Netflix application using DIAL server when the application is in hidden state and expect response code 200");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function hideApp(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
if(!result.dialVer || result.dialVer !== "2.1") { // Hidden state not supported
|
||||
return Q.reject(new Error("This test is only applicable for DIAL version >= 2.1"));
|
||||
}
|
||||
|
||||
if(result.state === "stopped") {
|
||||
// Launch and hide app
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.delay(5000)
|
||||
.then(dial.hideApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000);
|
||||
}
|
||||
else if(result.state === "starting" || result.state === "running") {
|
||||
// Hide app
|
||||
return dial.hideApplication(host, "Netflix")
|
||||
.delay(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function checkAppStatus(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "hidden") {
|
||||
return Q.reject(new Error("Expected Netflix app status to be hidden but the status was " + result.state));
|
||||
}
|
||||
})
|
||||
|
||||
.then(dial.stopApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Tried to stop Netflix. Expected statusCode: 200 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
54
server/tests/js_tests/tests/stopNetflixInRunningState.js
Normal file
54
server/tests/js_tests/tests/stopNetflixInRunningState.js
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
var host = utils.getParam("host");
|
||||
|
||||
function test() {
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Stop Netflix application when it is running and check for response code 200 from DIAL server ");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Error retrieving current Netflix application state"));
|
||||
}
|
||||
if(result.allowStop && result.allowStop === "false") {
|
||||
return Q.reject(new Error("This test is not applicable for servers that do not support DIAL stop operation."));
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
|
||||
.then(function startAppIfNotRunning(state) {
|
||||
if(state !== "starting" && state !== "running") {
|
||||
return dial.launchApplication(host, "Netflix")
|
||||
.then(function (status) {
|
||||
if(status !== 201) {
|
||||
return Q.reject("Error launching Netflix application. Expected status code 201 but got " + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(dial.stopApplication.bind(null, host, "Netflix"))
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject("Error stopping Netflix application. Expected status code 200 but got " + status);
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
81
server/tests/js_tests/tests/stopNetflixInStoppedState.js
Normal file
81
server/tests/js_tests/tests/stopNetflixInStoppedState.js
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
var dial = require("../libs/dialClient.js"),
|
||||
utils = require("../libs/utils.js"),
|
||||
Q = require("q");
|
||||
|
||||
function test() {
|
||||
var host = utils.getParam("host");
|
||||
var instanceUrl;
|
||||
|
||||
return new Q()
|
||||
.then(function () {
|
||||
console.log("TEST " + __filename + ": Try to stop Netflix application using DIAL server when the application is already stopped and expect response code 200.");
|
||||
})
|
||||
.then(dial.getApplicationStatus.bind(null, host, "Netflix"))
|
||||
.then(function getCurrentAppState(result) {
|
||||
if(!result || !result.state) {
|
||||
return Q.reject(new Error("Could not retrieve current Netflix application state"));
|
||||
}
|
||||
if(result.state !== "stopped") {
|
||||
if(result.allowStop && result.allowStop === "false") {
|
||||
return Q.reject(new Error("The DIAL server does not support STOP operation. Test cannot proceed. Make sure the Netflix app is stopped before re-running the test"));
|
||||
}
|
||||
}
|
||||
return result.state;
|
||||
})
|
||||
.then(function getRunningInstanceUrlAndStopApp(state) {
|
||||
if(state !== "stopped") {
|
||||
return new Q()
|
||||
.then(dial.constructAppResourceUrl.bind(null, host, "Netflix"))
|
||||
.then(function getInstanceUrl(appResourceUrl) {
|
||||
return dial.getApplicationStatus(host, "Netflix")
|
||||
.then(function (response) {
|
||||
if(response.href) {
|
||||
instanceUrl = appResourceUrl + "/" + response.href; // Construct Application Instance Url
|
||||
return instanceUrl;
|
||||
}
|
||||
return Q.reject(new Error("Could not get instance href from application status to construct Application Instance Url"));
|
||||
});
|
||||
});
|
||||
}
|
||||
return new Q()
|
||||
.then(dial.launchApplication.bind(null, host, "Netflix"))
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
return dial.constructAppResourceUrl(host, "Netflix");
|
||||
})
|
||||
.then(function getInstanceUrl(appResourceUrl) {
|
||||
return dial.getApplicationStatus(host, "Netflix")
|
||||
.then(function (response) {
|
||||
if(response.href) {
|
||||
instanceUrl = appResourceUrl + "/" + response.href; // Construct Application Instance Url
|
||||
return instanceUrl;
|
||||
}
|
||||
return Q.reject(new Error("Could not get instance href from application status to construct Application Instance Url"));
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
.then(function stopApp() {
|
||||
return dial.stopApplicationInstance(instanceUrl);
|
||||
})
|
||||
.then(function (status) {
|
||||
if(status !== 200) {
|
||||
return Q.reject(new Error("Could not stop Netflix application when it was running. Expected status code 200 but got " + status));
|
||||
}
|
||||
})
|
||||
.delay(5000)
|
||||
.then(function () {
|
||||
console.log("TEST PASSED");
|
||||
})
|
||||
.fail(function handleError(err) {
|
||||
console.error("TEST FAILED " + err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.test = test;
|
||||
|
||||
if (require.main === module) {
|
||||
test.done();
|
||||
}
|
||||
Reference in New Issue
Block a user