diff --git a/server/tests/js_tests/libs/dialClient.js b/server/tests/js_tests/libs/dialClient.js
index d6d27b5..805af2b 100644
--- a/server/tests/js_tests/libs/dialClient.js
+++ b/server/tests/js_tests/libs/dialClient.js
@@ -142,6 +142,40 @@ function launchApplication(host, app, payload) {
});
}
+/*
+ * send HTTP request to the host.
+ *
+ * @param {String} host IP address of host on which DIAL server
+ * @param {String} method HTTP method.
+ * @param {Object} headers HTTP headers, passed as {"Header": Value}
+ * @param {String} urlSuffix appended to the URL
+ * @param {String} body HTTP body
+ */
+function sendRequest(host, method, headers, urlSuffix, body) {
+ urlSuffix = urlSuffix || "";
+
+ return new Q()
+ .then(getAppsUrl.bind(null, host))
+ .then(function (appUrl) {
+ var request = {
+ url: encodeURI(appUrl + urlSuffix),
+ method: method,
+ timeout: 6000,
+ headers: headers
+ };
+ request.body = body;
+ return new Q.Promise(function (resolve, reject) {
+ return httpRequest(request, function handleResponse(error, response) {
+ if(error) {
+ reject(error);
+ } else {
+ resolve(response);
+ }
+ });
+ });
+ });
+}
+
function sleepSystem(host, key) {
var keyComponent = key ? `&key=${key}` : '';
return getAppsUrl(host)
@@ -279,7 +313,7 @@ function constructAppResourceUrl(host, appName) {
return new Q()
.then(getAppsUrl.bind(null, host))
.then(function (appUrl) {
- return appUrl.replace(/\/+$/, `/${appName}`);
+ return appUrl.replace(/\/*$/, `/${appName}`);
});
}
@@ -423,4 +457,5 @@ module.exports.hideApplicationInstance = hideApplicationInstance;
module.exports.constructAppResourceUrl = constructAppResourceUrl;
module.exports.getAppsUrl = getAppsUrl;
module.exports.getLocation = getLocation;
-module.exports.sleepSystem = sleepSystem;
\ No newline at end of file
+module.exports.sleepSystem = sleepSystem;
+module.exports.sendRequest = sendRequest;
diff --git a/server/tests/js_tests/package-lock.json b/server/tests/js_tests/package-lock.json
index 9b6e580..d794356 100644
--- a/server/tests/js_tests/package-lock.json
+++ b/server/tests/js_tests/package-lock.json
@@ -9,10 +9,10 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"requires": {
- "co": "4.6.0",
- "fast-deep-equal": "1.1.0",
- "fast-json-stable-stringify": "2.0.0",
- "json-schema-traverse": "0.3.1"
+ "co": "^4.6.0",
+ "fast-deep-equal": "^1.0.0",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.3.0"
}
},
"ansi-regex": {
@@ -25,7 +25,7 @@
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"requires": {
- "safer-buffer": "2.1.2"
+ "safer-buffer": "~2.1.0"
}
},
"assert-plus": {
@@ -38,7 +38,7 @@
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
"requires": {
- "lodash": "4.17.11"
+ "lodash": "^4.17.10"
}
},
"asynckit": {
@@ -61,7 +61,7 @@
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"requires": {
- "tweetnacl": "0.14.5"
+ "tweetnacl": "^0.14.3"
}
},
"bluebird": {
@@ -89,9 +89,9 @@
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
"integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
"requires": {
- "string-width": "1.0.2",
- "strip-ansi": "3.0.1",
- "wrap-ansi": "2.1.0"
+ "string-width": "^1.0.1",
+ "strip-ansi": "^3.0.1",
+ "wrap-ansi": "^2.0.0"
}
},
"co": {
@@ -114,7 +114,7 @@
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
"integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
"requires": {
- "delayed-stream": "1.0.0"
+ "delayed-stream": "~1.0.0"
}
},
"core-util-is": {
@@ -132,7 +132,7 @@
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"requires": {
- "assert-plus": "1.0.0"
+ "assert-plus": "^1.0.0"
}
},
"debug": {
@@ -140,7 +140,7 @@
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
- "ms": "2.1.1"
+ "ms": "^2.1.1"
}
},
"decamelize": {
@@ -158,8 +158,8 @@
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"requires": {
- "jsbn": "0.1.1",
- "safer-buffer": "2.1.2"
+ "jsbn": "~0.1.0",
+ "safer-buffer": "^2.1.0"
}
},
"error-ex": {
@@ -167,7 +167,7 @@
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
"integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
"requires": {
- "is-arrayish": "0.2.1"
+ "is-arrayish": "^0.2.1"
}
},
"extend": {
@@ -200,8 +200,8 @@
"resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
"integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
"requires": {
- "path-exists": "2.1.0",
- "pinkie-promise": "2.0.1"
+ "path-exists": "^2.0.0",
+ "pinkie-promise": "^2.0.0"
}
},
"forever-agent": {
@@ -214,9 +214,9 @@
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
- "asynckit": "0.4.0",
- "combined-stream": "1.0.7",
- "mime-types": "2.1.21"
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.6",
+ "mime-types": "^2.1.12"
}
},
"get-caller-file": {
@@ -229,7 +229,7 @@
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"requires": {
- "assert-plus": "1.0.0"
+ "assert-plus": "^1.0.0"
}
},
"graceful-fs": {
@@ -247,8 +247,8 @@
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
"integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
"requires": {
- "ajv": "5.5.2",
- "har-schema": "2.0.0"
+ "ajv": "^5.3.0",
+ "har-schema": "^2.0.0"
}
},
"hosted-git-info": {
@@ -261,9 +261,9 @@
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"requires": {
- "assert-plus": "1.0.0",
- "jsprim": "1.4.1",
- "sshpk": "1.15.1"
+ "assert-plus": "^1.0.0",
+ "jsprim": "^1.2.2",
+ "sshpk": "^1.7.0"
}
},
"invert-kv": {
@@ -286,7 +286,7 @@
"resolved": "http://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz",
"integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
"requires": {
- "builtin-modules": "1.1.1"
+ "builtin-modules": "^1.0.0"
}
},
"is-fullwidth-code-point": {
@@ -294,7 +294,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"requires": {
- "number-is-nan": "1.0.1"
+ "number-is-nan": "^1.0.0"
}
},
"is-typedarray": {
@@ -353,7 +353,7 @@
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
"requires": {
- "invert-kv": "1.0.0"
+ "invert-kv": "^1.0.0"
}
},
"load-json-file": {
@@ -361,11 +361,11 @@
"resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
"requires": {
- "graceful-fs": "4.1.11",
- "parse-json": "2.2.0",
- "pify": "2.3.0",
- "pinkie-promise": "2.0.1",
- "strip-bom": "2.0.0"
+ "graceful-fs": "^4.1.2",
+ "parse-json": "^2.2.0",
+ "pify": "^2.0.0",
+ "pinkie-promise": "^2.0.0",
+ "strip-bom": "^2.0.0"
}
},
"lodash": {
@@ -383,7 +383,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
"integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
"requires": {
- "mime-db": "1.37.0"
+ "mime-db": "~1.37.0"
}
},
"moment": {
@@ -401,11 +401,11 @@
"resolved": "https://registry.npmjs.org/node-ssdp/-/node-ssdp-3.3.0.tgz",
"integrity": "sha512-hFBkfUJytKC2x64jljojAbktG8aOL0C1YuNjCK54ZGBBg2382J3oTuK17T+aFgmy47noKHE5arLnYppo0JjcLw==",
"requires": {
- "async": "2.6.1",
- "bluebird": "3.5.2",
- "debug": "3.2.6",
- "extend": "3.0.2",
- "ip": "1.1.5"
+ "async": "^2.6.0",
+ "bluebird": "^3.5.1",
+ "debug": "^3.1.0",
+ "extend": "^3.0.1",
+ "ip": "^1.1.5"
}
},
"normalize-package-data": {
@@ -413,10 +413,10 @@
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
"integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
"requires": {
- "hosted-git-info": "2.7.1",
- "is-builtin-module": "1.0.0",
- "semver": "5.6.0",
- "validate-npm-package-license": "3.0.4"
+ "hosted-git-info": "^2.1.4",
+ "is-builtin-module": "^1.0.0",
+ "semver": "2 || 3 || 4 || 5",
+ "validate-npm-package-license": "^3.0.1"
}
},
"number-is-nan": {
@@ -434,7 +434,7 @@
"resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
"requires": {
- "lcid": "1.0.0"
+ "lcid": "^1.0.0"
}
},
"parse-json": {
@@ -442,7 +442,7 @@
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"requires": {
- "error-ex": "1.3.2"
+ "error-ex": "^1.2.0"
}
},
"path-exists": {
@@ -450,7 +450,7 @@
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
"integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
"requires": {
- "pinkie-promise": "2.0.1"
+ "pinkie-promise": "^2.0.0"
}
},
"path-type": {
@@ -458,9 +458,9 @@
"resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
"integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=",
"requires": {
- "graceful-fs": "4.1.11",
- "pify": "2.3.0",
- "pinkie-promise": "2.0.1"
+ "graceful-fs": "^4.1.2",
+ "pify": "^2.0.0",
+ "pinkie-promise": "^2.0.0"
}
},
"performance-now": {
@@ -483,7 +483,7 @@
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
"integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
"requires": {
- "pinkie": "2.0.4"
+ "pinkie": "^2.0.0"
}
},
"psl": {
@@ -511,9 +511,9 @@
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
"integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
"requires": {
- "load-json-file": "1.1.0",
- "normalize-package-data": "2.4.0",
- "path-type": "1.1.0"
+ "load-json-file": "^1.0.0",
+ "normalize-package-data": "^2.3.2",
+ "path-type": "^1.0.0"
}
},
"read-pkg-up": {
@@ -521,8 +521,8 @@
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
"integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
"requires": {
- "find-up": "1.1.2",
- "read-pkg": "1.1.0"
+ "find-up": "^1.0.0",
+ "read-pkg": "^1.0.0"
}
},
"request": {
@@ -530,26 +530,26 @@
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
"requires": {
- "aws-sign2": "0.7.0",
- "aws4": "1.8.0",
- "caseless": "0.12.0",
- "combined-stream": "1.0.7",
- "extend": "3.0.2",
- "forever-agent": "0.6.1",
- "form-data": "2.3.3",
- "har-validator": "5.1.0",
- "http-signature": "1.2.0",
- "is-typedarray": "1.0.0",
- "isstream": "0.1.2",
- "json-stringify-safe": "5.0.1",
- "mime-types": "2.1.21",
- "oauth-sign": "0.9.0",
- "performance-now": "2.1.0",
- "qs": "6.5.2",
- "safe-buffer": "5.1.2",
- "tough-cookie": "2.4.3",
- "tunnel-agent": "0.6.0",
- "uuid": "3.3.2"
+ "aws-sign2": "~0.7.0",
+ "aws4": "^1.8.0",
+ "caseless": "~0.12.0",
+ "combined-stream": "~1.0.6",
+ "extend": "~3.0.2",
+ "forever-agent": "~0.6.1",
+ "form-data": "~2.3.2",
+ "har-validator": "~5.1.0",
+ "http-signature": "~1.2.0",
+ "is-typedarray": "~1.0.0",
+ "isstream": "~0.1.2",
+ "json-stringify-safe": "~5.0.1",
+ "mime-types": "~2.1.19",
+ "oauth-sign": "~0.9.0",
+ "performance-now": "^2.1.0",
+ "qs": "~6.5.2",
+ "safe-buffer": "^5.1.2",
+ "tough-cookie": "~2.4.3",
+ "tunnel-agent": "^0.6.0",
+ "uuid": "^3.3.2"
}
},
"require-directory": {
@@ -587,8 +587,8 @@
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.2.tgz",
"integrity": "sha512-q9hedtzyXHr5S0A1vEPoK/7l8NpfkFYTq6iCY+Pno2ZbdZR6WexZFtqeVGkGxW3TEJMN914Z55EnAGMmenlIQQ==",
"requires": {
- "spdx-expression-parse": "3.0.0",
- "spdx-license-ids": "3.0.1"
+ "spdx-expression-parse": "^3.0.0",
+ "spdx-license-ids": "^3.0.0"
}
},
"spdx-exceptions": {
@@ -601,8 +601,8 @@
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz",
"integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==",
"requires": {
- "spdx-exceptions": "2.2.0",
- "spdx-license-ids": "3.0.1"
+ "spdx-exceptions": "^2.1.0",
+ "spdx-license-ids": "^3.0.0"
}
},
"spdx-license-ids": {
@@ -620,15 +620,15 @@
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz",
"integrity": "sha512-mSdgNUaidk+dRU5MhYtN9zebdzF2iG0cNPWy8HG+W8y+fT1JnSkh0fzzpjOa0L7P8i1Rscz38t0h4gPcKz43xA==",
"requires": {
- "asn1": "0.2.4",
- "assert-plus": "1.0.0",
- "bcrypt-pbkdf": "1.0.2",
- "dashdash": "1.14.1",
- "ecc-jsbn": "0.1.2",
- "getpass": "0.1.7",
- "jsbn": "0.1.1",
- "safer-buffer": "2.1.2",
- "tweetnacl": "0.14.5"
+ "asn1": "~0.2.3",
+ "assert-plus": "^1.0.0",
+ "bcrypt-pbkdf": "^1.0.0",
+ "dashdash": "^1.12.0",
+ "ecc-jsbn": "~0.1.1",
+ "getpass": "^0.1.1",
+ "jsbn": "~0.1.0",
+ "safer-buffer": "^2.0.2",
+ "tweetnacl": "~0.14.0"
}
},
"stack-trace": {
@@ -641,9 +641,9 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"requires": {
- "code-point-at": "1.1.0",
- "is-fullwidth-code-point": "1.0.0",
- "strip-ansi": "3.0.1"
+ "code-point-at": "^1.0.0",
+ "is-fullwidth-code-point": "^1.0.0",
+ "strip-ansi": "^3.0.0"
}
},
"strip-ansi": {
@@ -651,7 +651,7 @@
"resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
- "ansi-regex": "2.1.1"
+ "ansi-regex": "^2.0.0"
}
},
"strip-bom": {
@@ -659,7 +659,7 @@
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
"requires": {
- "is-utf8": "0.2.1"
+ "is-utf8": "^0.2.0"
}
},
"tough-cookie": {
@@ -667,8 +667,8 @@
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": {
- "psl": "1.1.29",
- "punycode": "1.4.1"
+ "psl": "^1.1.24",
+ "punycode": "^1.4.1"
}
},
"tunnel-agent": {
@@ -676,7 +676,7 @@
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"requires": {
- "safe-buffer": "5.1.2"
+ "safe-buffer": "^5.0.1"
}
},
"tweetnacl": {
@@ -694,8 +694,8 @@
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
"integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
"requires": {
- "spdx-correct": "3.0.2",
- "spdx-expression-parse": "3.0.0"
+ "spdx-correct": "^3.0.0",
+ "spdx-expression-parse": "^3.0.0"
}
},
"verror": {
@@ -703,9 +703,9 @@
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
"requires": {
- "assert-plus": "1.0.0",
+ "assert-plus": "^1.0.0",
"core-util-is": "1.0.2",
- "extsprintf": "1.3.0"
+ "extsprintf": "^1.2.0"
}
},
"which-module": {
@@ -718,12 +718,12 @@
"resolved": "https://registry.npmjs.org/winston/-/winston-2.4.4.tgz",
"integrity": "sha512-NBo2Pepn4hK4V01UfcWcDlmiVTs7VTB1h7bgnB0rgP146bYhMxX0ypCz3lBOfNxCO4Zuek7yeT+y/zM1OfMw4Q==",
"requires": {
- "async": "1.0.0",
- "colors": "1.0.3",
- "cycle": "1.0.3",
- "eyes": "0.1.8",
- "isstream": "0.1.2",
- "stack-trace": "0.0.10"
+ "async": "~1.0.0",
+ "colors": "1.0.x",
+ "cycle": "1.0.x",
+ "eyes": "0.1.x",
+ "isstream": "0.1.x",
+ "stack-trace": "0.0.x"
},
"dependencies": {
"async": {
@@ -743,8 +743,8 @@
"resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"requires": {
- "string-width": "1.0.2",
- "strip-ansi": "3.0.1"
+ "string-width": "^1.0.1",
+ "strip-ansi": "^3.0.1"
}
},
"y18n": {
@@ -757,19 +757,19 @@
"resolved": "http://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz",
"integrity": "sha1-eC7CHvQDNF+DCoCMo9UTr1YGUgg=",
"requires": {
- "camelcase": "3.0.0",
- "cliui": "3.2.0",
- "decamelize": "1.2.0",
- "get-caller-file": "1.0.3",
- "os-locale": "1.4.0",
- "read-pkg-up": "1.0.1",
- "require-directory": "2.1.1",
- "require-main-filename": "1.0.1",
- "set-blocking": "2.0.0",
- "string-width": "1.0.2",
- "which-module": "1.0.0",
- "y18n": "3.2.1",
- "yargs-parser": "4.2.1"
+ "camelcase": "^3.0.0",
+ "cliui": "^3.2.0",
+ "decamelize": "^1.1.1",
+ "get-caller-file": "^1.0.1",
+ "os-locale": "^1.4.0",
+ "read-pkg-up": "^1.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^1.0.1",
+ "set-blocking": "^2.0.0",
+ "string-width": "^1.0.2",
+ "which-module": "^1.0.0",
+ "y18n": "^3.2.1",
+ "yargs-parser": "^4.2.0"
}
},
"yargs-parser": {
@@ -777,7 +777,7 @@
"resolved": "http://registry.npmjs.org/yargs-parser/-/yargs-parser-4.2.1.tgz",
"integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=",
"requires": {
- "camelcase": "3.0.0"
+ "camelcase": "^3.0.0"
}
}
}
diff --git a/server/tests/js_tests/tests/testEdgeCases.js b/server/tests/js_tests/tests/testEdgeCases.js
new file mode 100644
index 0000000..12c143b
--- /dev/null
+++ b/server/tests/js_tests/tests/testEdgeCases.js
@@ -0,0 +1,93 @@
+"use strict";
+
+var dial = require("../libs/dialClient.js"),
+ utils = require("../libs/utils.js"),
+ Q = require("q"),
+ winston = require("winston");
+
+
+const argv = require("yargs")
+ .usage("\nUsage: node " + __filename.slice(__dirname.length + 1) + "[options]")
+ .option("host", {
+ describe: "IP address of host on which DIAL server under test is running",
+ type: "string",
+ demand: true
+ })
+ .help("help").alias("help", "h").argv;
+
+var testCount = 0;
+var failureCount = 0;
+
+/*
+ * These edge cases are
+ */
+function edgeCases() {
+ var host = argv.host;
+
+ var methods = [
+ "GET",
+ "POST",
+ ];
+
+ // weird data
+ var headers = [
+ {"Content-Length": "0xff1af1581"},
+ {"Content-Length": "sfsadfdsat"},
+ {"Content-Length": 13377777777777},
+ {"Content-Length": -13377777777777},
+ {"Content-Type": "text/plain;charset=\"utf-8\""},
+ {"Content-Type": "text/plain;charset=\"ascii\""},
+ {"Content-Type": "asdoffmoaserq"},
+ {"Foo": "Bar"},
+ ];
+
+ var utf8 = ";(QmN̸鱏=叽]𰸹h˳╭ܮ煣ِt𐍁J픖pЗB-ٴۼ퍃%۞灱Ҡɝ~2望Lԇƀݛ&±⫯WܾNJX礴ēʧ耉ݭpi}Ǖʝ'䬿^ٿ]샑좘쒾"
+ + "ԝbւ蹈ۥ웦(歉貤䃶6ƢӋØ𪺭ĩk┋譒ց,Ŋ칱آ3㛣Oܕ=裁fĴjٕpۅ=@ԉ'1⃮Ȩ핣ƺ匽ݚ뎔叇χ&죙𱘱ʴذȞ鞾ﰟO썟X9⛥ȧ走쾙"
+ + "ӱإ#!۵Σƀ4䦼쪭ϖ0ڧp梛՚嬆߷域᳁١ޜۡÜ]ʘ厤ȆwYݖ(ן饲a�`V<$Dz&ܗʧbҘ@E1ч&{㜃팸儈Ā㖿rb^Ӟʶ"
+ + "Ө㡷sΠ●ŽٗDҤƱ(t-瞜BЏ;Ғeࡻs`=ݔu樭迕^;䐈Ǥ3䝡XM붩ݱϖȓܕ췃`Ỷ3LV9폧赹ⴢ+⇩ӛ뵖띟䎵钥¶繥Ҕ J礢м2_8̑hg";
+ utf8 = utf8 + utf8 + utf8;
+ var strings = [
+ utf8,
+ "",
+ 'test\n',
+ '$HOME',
+ '../../../../../../../../../../../etc/hosts\n',
+ ];
+
+ // generate test cases
+ var testCases = [];
+ for (var m = 0; m < methods.length; m++) {
+ for (var h = 0; h < headers.length; h++) {
+ for (var q = 0; q < strings.length; q++) {
+ for (var b = 0; b < strings.length; b++) {
+ testCases.push(function (m, h, q, b) {
+ return new Q()
+ .then(dial.sendRequest.bind(null, host, methods[m], headers[h], strings[q], strings[b]))
+ .then(function (response) {
+ testCount = testCount + 1;
+ if (![400, 404, 500].includes(response.statusCode)) {
+ return Q.reject(new Error("Sent the DIAL server an edge case. Expected a bad status code but got " + response.statusCode));
+ }
+ })
+ .fail(function handleError(err) {
+ utils.printTestInfo(__filename.slice(__dirname.length + 1),
+ "Edge Case, method: " + methods[m] + " header: "
+ + headers[h] + " query string: "
+ + strings[q] + " body: " + strings[b]);
+ utils.printTestFailure(err);
+ failureCount = failureCount + 1;
+ return err;
+ })
+ }.bind(null, m, h, q, b));
+ }
+ }
+ }
+ }
+
+ return testCases;
+}
+
+winston.info("Testing edge cases, only failing tests will appear.");
+return edgeCases().reduce(Q.when, Promise.resolve()).done(function() {
+ winston.info("Tests complete. Passing: " + (testCount - failureCount) + ", Failures: " + failureCount);
+});
diff --git a/server/tests/js_tests/tests/tests.js b/server/tests/js_tests/tests/tests.js
index 7b0e3b8..41263d6 100644
--- a/server/tests/js_tests/tests/tests.js
+++ b/server/tests/js_tests/tests/tests.js
@@ -78,6 +78,4 @@ Promise.resolve()
// Application hide tests
.then(hideInvalidApplicationInstance.test)
.then(hideApplicationInHiddenState.test)
- .then(hideApplicationInRunningState.test)
-
-
+ .then(hideApplicationInRunningState.test);
diff --git a/server/tests/makefile b/server/tests/makefile
index 7cdfe01..7a8d0f8 100644
--- a/server/tests/makefile
+++ b/server/tests/makefile
@@ -3,7 +3,7 @@ CC=$(TARGET)gcc
.PHONY: clean
.DEFAULT_GOAL=test
-OBJS := test_dial_data.o test_url_lib.o ../url_lib.o ../dial_data.o run_tests.o
+OBJS := test_dial_data.o test_url_lib.o test_callbacks.o ../url_lib.o ../dial_data.o ../system_callbacks.o run_tests.o
HEADERS := $(wildcard ../*.h)
%.c: $(HEADERS)
@@ -12,7 +12,7 @@ HEADERS := $(wildcard ../*.h)
$(CC) -Wall -Werror -g -std=gnu99 $(CFLAGS) -c $*.c -o $*.o
test: $(OBJS)
- $(CC) -Wall -Werror -g $(OBJS) -ldl -lpthread -o run_tests
+ $(CC) -Wall -Werror -fsanitize=address -g $(OBJS) -ldl -lpthread -o run_tests
clean:
rm -f *.o run_tests
diff --git a/server/tests/run_tests.c b/server/tests/run_tests.c
index dedafd0..b51a4a4 100644
--- a/server/tests/run_tests.c
+++ b/server/tests/run_tests.c
@@ -22,6 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "test_callbacks.h"
#include "test_dial_data.h"
#include "test_url_lib.h"
@@ -29,14 +30,8 @@
int main(int argc, char** argv) {
- printf("====\n");
- test_smartstrcat();
- test_urldecode();
- test_parse_app_name();
- test_parse_params();
- printf("====\n");
- test_read_dial_data();
- test_write_dial_data();
- printf("====\n");
- return 0;
+ test_dial_data_suite();
+ test_url_lib_suite();
+ test_callbacks_suite();
+ return 0;
}
diff --git a/server/tests/test.h b/server/tests/test.h
index 1cb9295..1655792 100644
--- a/server/tests/test.h
+++ b/server/tests/test.h
@@ -29,9 +29,20 @@
#define EXPECT(a, m) \
do { \
- if (!a) { \
- printf("[%s] failed: %s\n", #a, m); \
- printf("%s -> FAILED\n", __func__); \
+ if (!(a)) { \
+ printf("\033[31m [%s] failed: %s \033[0m\n", #a, m); \
+ printf("\033[31m %s -> FAILED \033[0m\n", __func__); \
+ return; \
+ } \
+ } while (0)
+
+#define EXPECT_EQ(a, b) \
+ do { \
+ if (a != b) { \
+ printf("\033[31m expected [%s == %s] \033[0m\n", #a, #b); \
+ printf("\033[31m a = \"%ld\" \033[0m\n", (unsigned long) a); \
+ printf("\033[31m b = \"%ld\" \033[0m\n", (unsigned long) b); \
+ printf("\033[31m %s -> FAILED \033[0m\n", __func__); \
return; \
} \
} while (0)
@@ -39,15 +50,18 @@
#define EXPECT_STREQ(a, b) \
do { \
if (strcmp(a, b)) { \
- printf("expected [%s == %s]\n", #a, #b); \
- printf(" a = \"%s\"\n", a); \
- printf(" b = \"%s\"\n", b); \
- printf("%s -> FAILED\n", __func__); \
+ printf("\033[31m expected [%s == %s] \033[0m\n", #a, #b); \
+ printf("\033[31m a = \"%s\" \033[0m\n", a); \
+ printf("\033[31m b = \"%s\" \033[0m\n", b); \
+ printf("\033[31m %s -> FAILED \033[0m\n", __func__); \
return; \
} \
} while (0)
+#define START_SUITE() \
+ printf("== %s ==\n", __FILE__)
+
#define DONE() \
- printf("%s -> OK\n", __func__)
+ printf("\033[32m %s -> OK \033[0m\n", __func__)
#endif /* SRC_SERVER_TESTS_TEST_H_ */
diff --git a/server/tests/test_callbacks.c b/server/tests/test_callbacks.c
new file mode 100644
index 0000000..a1e9682
--- /dev/null
+++ b/server/tests/test_callbacks.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019 Netflix, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETFLIX, INC. AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NETFLIX OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include
+#include
+#include
+#include
+
+#include "../system_callbacks.h"
+#include "../dial_data.h"
+
+#include "test_callbacks.h"
+#include "test.h"
+
+char spSleepPassword[256];
+
+/*
+ * The reference does not provide implementations for interfacing with the System Application.
+ */
+void test_system_callbacks() {
+ EXPECT_EQ(system_start(NULL, NULL, NULL, "action=sleep", NULL, NULL, NULL), kDIALStatusErrorNotImplemented);
+ EXPECT_EQ(system_hide(NULL, NULL, NULL, NULL), kDIALStatusHide);
+ EXPECT_EQ(system_status(NULL, NULL, NULL, NULL, NULL), kDIALStatusHide);
+
+ DONE();
+}
+
+void test_callbacks_suite() {
+ START_SUITE();
+ test_system_callbacks();
+}
\ No newline at end of file
diff --git a/server/tests/test_callbacks.h b/server/tests/test_callbacks.h
new file mode 100644
index 0000000..7c57a91
--- /dev/null
+++ b/server/tests/test_callbacks.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2019 Netflix, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY NETFLIX, INC. AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NETFLIX OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef SRC_SERVER_TESTS_TEST_CALLBACKS_H_
+#define SRC_SERVER_TESTS_TEST_CALLBACKS_H_
+
+void test_callbacks_suite();
+
+#endif /* SRC_SERVER_TESTS_TEST_CALLBACKS_H_ */
diff --git a/server/tests/test_dial_data.c b/server/tests/test_dial_data.c
index b383d5d..bb6efd5 100644
--- a/server/tests/test_dial_data.c
+++ b/server/tests/test_dial_data.c
@@ -30,17 +30,19 @@
#include
#include "test.h"
+#include "test_dial_data.h"
+
+/*
+ * All tests should malloc
+ */
int key_value_pairs = 3;
-char *keys[] = {"key1", "key2", "key3"};
+char *keys[] = {"key3", "key2", "key3"};
char *values[] = {"value1", "value2", "value3"};
-void test_read_dial_data() {
- DIALData *data = retrieve_dial_data("dial_data");
- for (int i = 0; data != NULL; data = data->next, i++) {
- EXPECT_STREQ(data->key, keys[2 - i]);
- EXPECT_STREQ(data->value, values[2 - i]);
- }
+void test_read_dial_missing_data() {
+ DIALData *data = retrieve_dial_data("NON_EXISTENT_DATA");
+ EXPECT(NULL == data, "retrieve_dial_data() returns NULL\n");
DONE();
}
@@ -48,19 +50,76 @@ void test_write_dial_data() {
DIALData *result = NULL;
for (int i = 0; i < key_value_pairs; ++i) {
DIALData *node = (DIALData *) malloc(sizeof(DIALData));
- node->key = keys[i];
- node->value = values[i];
+ node->key = malloc(strlen(keys[i]) + 1);
+ node->value = malloc(strlen(values[i]) + 1);
+ strcpy(node->key, keys[i]);
+ strcpy(node->value, values[i]);
+
node->next = result;
result = node;
}
store_dial_data("YouTube", result);
DIALData *readBack = retrieve_dial_data("YouTube");
-
- for (int i = 0; readBack != NULL; readBack = readBack->next, i++) {
- EXPECT_STREQ(readBack->key, keys[i]);
- EXPECT_STREQ(readBack->value, values[i]);
+ DIALData *datum = readBack;
+ for (int i = 0; datum != NULL; datum = datum->next, i++) {
+ EXPECT_STREQ(datum->key, keys[i]);
+ EXPECT_STREQ(datum->value, values[i]);
}
+ free_dial_data(&result);
+ free_dial_data(&readBack);
+
DONE();
}
+
+void test_write_kv_larger_than_max_len() {
+ // result contains k & v both larger than DIAL_KEY_OR_VALUE_MAX_LEN
+ DIALData *result = (DIALData *) calloc(1, sizeof(DIALData));
+ result->key = calloc(DIAL_KEY_OR_VALUE_MAX_LEN * 2, sizeof(char));
+ result->value = calloc(DIAL_KEY_OR_VALUE_MAX_LEN * 2, sizeof(char));
+ memset(result->key, 'k', DIAL_KEY_OR_VALUE_MAX_LEN * 2 - 1);
+ memset(result->value, 'v', DIAL_KEY_OR_VALUE_MAX_LEN * 2 - 1);
+
+ store_dial_data("YouTube", result);
+
+ DIALData *readBack = retrieve_dial_data("YouTube");
+ EXPECT(NULL != readBack, "retrieve_dial_data should not be NULL\n");
+
+ EXPECT_EQ(readBack->key[0], 'k');
+ EXPECT_EQ(readBack->value[0], 'v');
+ EXPECT_EQ(strlen(readBack->key), DIAL_KEY_OR_VALUE_MAX_LEN);
+ EXPECT_EQ(strlen(readBack->value), DIAL_KEY_OR_VALUE_MAX_LEN);
+
+ free_dial_data(&result);
+ free_dial_data(&readBack);
+
+ DONE();
+}
+
+void test_write_empty_kv() {
+ DIALData *result = (DIALData *) calloc(1, sizeof(DIALData));
+ result->key = calloc(1, sizeof(char));
+ result->value = calloc(1, sizeof(char));
+
+ store_dial_data("YouTube", result);
+
+ DIALData *readBack = retrieve_dial_data("YouTube");
+ EXPECT(NULL != readBack, "retrieve_dial_data should not be NULL\n");
+
+ EXPECT_EQ(readBack->key[0], '\0');
+ EXPECT_EQ(readBack->value[0], '\0');
+
+ free_dial_data(&result);
+ free_dial_data(&readBack);
+
+ DONE();
+}
+
+void test_dial_data_suite() {
+ START_SUITE();
+
+ test_read_dial_missing_data();
+ test_write_dial_data();
+ test_write_kv_larger_than_max_len();
+}
\ No newline at end of file
diff --git a/server/tests/test_dial_data.h b/server/tests/test_dial_data.h
index d2b579d..61900da 100644
--- a/server/tests/test_dial_data.h
+++ b/server/tests/test_dial_data.h
@@ -25,7 +25,6 @@
#ifndef SRC_SERVER_TESTS_TEST_DIAL_DATA_H_
#define SRC_SERVER_TESTS_TEST_DIAL_DATA_H_
-void test_read_dial_data();
-void test_write_dial_data();
+void test_dial_data_suite();
#endif /* SRC_SERVER_TESTS_TEST_DIAL_DATA_H_ */
diff --git a/server/tests/test_url_lib.c b/server/tests/test_url_lib.c
index 95d6e6d..e435c4f 100644
--- a/server/tests/test_url_lib.c
+++ b/server/tests/test_url_lib.c
@@ -26,25 +26,26 @@
#include "../dial_data.h"
#include
+#include
#include
#include
#include
#include "test.h"
-void test_smartstrcat() {
+void test_smartstrncpy() {
char* src1 = "Hello ";
char* src2 = "world!";
char* src3 = " Trunc ated";
char dest[128] = {0, };
char* p = (char *) dest;
- p = smartstrcat(p, src1, 128);
+ p = smartstrncpy(p, src1, 128);
EXPECT_STREQ(dest, "Hello ");
- p = smartstrcat(p, src2, dest + 128 - p);
+ p = smartstrncpy(p, src2, dest + 128 - p);
EXPECT_STREQ(dest, "Hello world!");
- p = smartstrcat(p, src3, 6);
+ p = smartstrncpy(p, src3, 6);
EXPECT_STREQ(dest, "Hello world! Trunc");
DONE();
@@ -63,19 +64,24 @@ void test_parse_app_name() {
char *app_name;
EXPECT((app_name = parse_app_name(NULL)), "Failed to extract app_name");
EXPECT_STREQ(app_name, "unknown");
+ free(app_name);
EXPECT((app_name = parse_app_name("")), "Failed to extract app_name");
EXPECT_STREQ(app_name, "unknown");
+ free(app_name);
EXPECT((app_name = parse_app_name("/")), "Failed to extract app_name");
EXPECT_STREQ(app_name, "unknown");
+ free(app_name);
EXPECT((app_name = parse_app_name("/apps/YouTube/DialData")),
"Failed to extract app_name");
EXPECT_STREQ(app_name, "YouTube");
+ free(app_name);
EXPECT((app_name = parse_app_name("//")), "Failed to extract app_name");
EXPECT_STREQ(app_name, "");
+ free(app_name);
EXPECT((app_name = parse_app_name("/invalid")),
"Failed to extract app_name");
EXPECT_STREQ(app_name, "unknown");
-
+ free(app_name);
DONE();
}
@@ -86,28 +92,52 @@ void test_parse_params() {
DIALData *result = parse_params("a=b");
EXPECT_STREQ(result->key, "a");
EXPECT_STREQ(result->value, "b");
+ free_dial_data(&result);
result = parse_params("?a=b");
EXPECT_STREQ(result->key, "a");
EXPECT_STREQ(result->value, "b");
+ free_dial_data(&result);
result = parse_params("?a=b&c=d");
EXPECT_STREQ(result->key, "c");
EXPECT_STREQ(result->value, "d");
EXPECT_STREQ(result->next->key, "a");
EXPECT_STREQ(result->next->value, "b");
+ free_dial_data(&result);
+
+ result = parse_params("ሳ=€");
+ EXPECT_STREQ(result->key, "ሳ");
+ EXPECT_STREQ(result->value, "€");
+ free_dial_data(&result);
char query_string[1024] = {0, };
char *current = query_string;
for (int i = 0; i < 25; ++i) {
- current = smartstrcat(current, "a=b&", 256);
+ current = smartstrncpy(current, "a=b&", 256);
}
result = parse_params(query_string);
int length = 0;
- for (; result != NULL; result = result->next) {
+ for (DIALData *current = result; current != NULL; current = current->next) {
length++;
}
EXPECT((length == 25), "25 params should have been parsed");
+ free_dial_data(&result);
DONE();
}
+
+void test_parse_params_malformatted() {
+ EXPECT(NULL == parse_params("abcdefghijkl"), "no params expected");
+ EXPECT(NULL == parse_params("\u2639"), "no params expected");
+ DONE();
+}
+
+void test_url_lib_suite() {
+ START_SUITE();
+ test_smartstrncpy();
+ test_urldecode();
+ test_parse_app_name();
+ test_parse_params();
+ test_parse_params_malformatted();
+}
\ No newline at end of file
diff --git a/server/tests/test_url_lib.h b/server/tests/test_url_lib.h
index 1cbe2e7..0da61c7 100644
--- a/server/tests/test_url_lib.h
+++ b/server/tests/test_url_lib.h
@@ -25,10 +25,6 @@
#ifndef SRC_SERVER_TESTS_TEST_URL_LIB_H_
#define SRC_SERVER_TESTS_TEST_URL_LIB_H_
-void test_smartstrcat();
-void test_urldecode();
-void test_parse_app_name();
-void test_parse_param();
-void test_parse_params();
+void test_url_lib_suite();
#endif /* SRC_SERVER_TESTS_TEST_URL_LIB_H_ */