From c050e9e45ed64cfde0bb90f00cd4a4b13374a95f Mon Sep 17 00:00:00 2001 From: jw255 Date: Sun, 22 Apr 2018 17:38:11 +0100 Subject: fixing tests --- report/deliverable-3/main.bbl | 134 +++++++++++++++++++++++++++++++ report/deliverable-3/main.blg | 73 +++++++++++++++++ src/FileRouter.ts | 4 +- src/serverConfig.ts | 2 +- test/integration/protocol.routes.test.ts | 11 ++- 5 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 report/deliverable-3/main.bbl create mode 100644 report/deliverable-3/main.blg diff --git a/report/deliverable-3/main.bbl b/report/deliverable-3/main.bbl new file mode 100644 index 0000000..5ffb189 --- /dev/null +++ b/report/deliverable-3/main.bbl @@ -0,0 +1,134 @@ +\begin{thebibliography}{10} + +\bibitem{zeissLicence} +Apply for zeiss licence. +\newblock + https://www.zeiss.com/microscopy/int/products/microscope-software/czi/czi-download.html. +\newblock Accessed: 2018-03-06. + +\bibitem{chai} +Chai assertion library. +\newblock http://chaijs.com/api/bdd/. +\newblock Accessed: 2018-03-02. + +\bibitem{chai-http} +Chai http. +\newblock http://chaijs.com/plugins/chai-http/. +\newblock Accessed: 2018-03-02. + +\bibitem{forever} +foreverjs. +\newblock https://github.com/foreverjs/forever. +\newblock Accessed: 2018-03-07. + +\bibitem{xlsx} +js-xlsx. +\newblock https://github.com/sheetjs/js-xlsx. +\newblock Accessed: 2018-03-02. + +\bibitem{mocha} +Mocha. +\newblock https://mochajs.org/. +\newblock Accessed: 2018-03-02. + +\bibitem{mocha-each} +mocha-each. +\newblock https://github.com/ryym/mocha-each. +\newblock Accessed: 2018-03-02. + +\bibitem{morgan} +morgan. +\newblock https://github.com/expressjs/morgan. +\newblock Accessed: 2018-03-02. + +\bibitem{openseadragon} +Openseaddragon. +\newblock https://openseadragon.github.io/docs/. +\newblock Accessed: 2019-03-07. + +\bibitem{passport} +Passport. +\newblock http://www.passportjs.org/docs/. +\newblock Accessed: 2018-03-02. + +\bibitem{passport-local} +passport-local. +\newblock https://github.com/jaredhanson/passport-local. +\newblock Accessed: 2018-03-02. + +\bibitem{pm2} +pm2. +\newblock http://pm2.keymetrics.io/. +\newblock Accessed: 2018-03-07. + +\bibitem{sequelize} +Sequelize. +\newblock http://docs.sequelizejs.com/. +\newblock Accessed: 2018-03-02. + +\bibitem{sequelize-typescript} +sequelize-typescript. +\newblock https://github.com/RobinBuschmann/sequelize-typescript. +\newblock Accessed: 2018-03-02. + +\bibitem{sharp} +sharp. +\newblock https://github.com/lovell/sharp. +\newblock Accessed: 2018-03-06. + +\bibitem{sharpPerformance} +Sharp performance. +\newblock http://sharp.pixelplumbing.com/en/stable/performance/. +\newblock Accessed: 2018-03-06. + +\bibitem{typedoc} +Typedoc. +\newblock http://typedoc.org/guides/usage/. +\newblock Accessed: 2018-03-02. + +\bibitem{yarn} +Yarn. +\newblock https://yarnpkg.com/en/docs. +\newblock Accessed: 2018-03-02. + +\bibitem{docker} +Docker hub. +\newblock https://hub.docker.com/, 2016. +\newblock Accessed: 2018-03-02. + +\bibitem{tslint} +Tslint. +\newblock https://palantir.github.io/tslint/, 2016. +\newblock Accessed: 2018-03-01. + +\bibitem{@types} +Definitelytyped. +\newblock http://definitelytyped.org/, 2017. +\newblock Accessed: 2018-03-02. + +\bibitem{express} +Express 4.x. +\newblock https://expressjs.com/en/4x/api.html, 2017. +\newblock Accessed: 2018-03-02. + +\bibitem{typescript} +Typescript. +\newblock https://www.typescriptlang.org/docs/home.html, 2017. +\newblock Accessed: 2018-03-02. + +\bibitem{protocol} +Cs3099jh2017 protocol. +\newblock https://github.com/CS3099JH2017/cs3099jh/tree/master/protocols, 2018. +\newblock Accessed: 2018-03-02. + +\bibitem{postgres} +Postresql. +\newblock https://www.postgresql.org/docs/, 2018. +\newblock Accessed: 2018-03-02. + +\bibitem{strongloop} +Strongloop. +\newblock https://strongloop.com/, 2018. +\newblock Accessed: 2018-03-07. + +\end{thebibliography} diff --git a/report/deliverable-3/main.blg b/report/deliverable-3/main.blg new file mode 100644 index 0000000..dcb4ea0 --- /dev/null +++ b/report/deliverable-3/main.blg @@ -0,0 +1,73 @@ +This is BibTeX, Version 0.99d (TeX Live 2016) +Capacity: max_strings=35307, hash_size=35307, hash_prime=30011 +The top-level auxiliary file: main.aux +The style file: plain.bst +Database file #1: biblio.bib +Warning--to sort, need author or key in zeissLicence +Warning--to sort, need author or key in sharp +Warning--to sort, need author or key in sharpPerformance +Warning--to sort, need author or key in openseadragon +Warning--to sort, need author or key in protocol +Warning--to sort, need author or key in sequelize +Warning--to sort, need author or key in strongloop +Warning--to sort, need author or key in pm2 +Warning--to sort, need author or key in forever +Warning--to sort, need author or key in mocha-each +Warning--to sort, need author or key in @types +Warning--to sort, need author or key in tslint +Warning--to sort, need author or key in yarn +Warning--to sort, need author or key in typescript +Warning--to sort, need author or key in sequelize-typescript +Warning--to sort, need author or key in postgres +Warning--to sort, need author or key in mocha +Warning--to sort, need author or key in chai +Warning--to sort, need author or key in chai-http +Warning--to sort, need author or key in express +Warning--to sort, need author or key in passport +Warning--to sort, need author or key in passport-local +Warning--to sort, need author or key in morgan +Warning--to sort, need author or key in typedoc +Warning--to sort, need author or key in xlsx +Warning--to sort, need author or key in docker +You've used 26 entries, + 2118 wiz_defined-function locations, + 597 strings with 5770 characters, +and the built_in function-call counts, 4422 in all, are: += -- 450 +> -- 26 +< -- 0 ++ -- 26 +- -- 0 +* -- 140 +:= -- 513 +add.period$ -- 78 +call.type$ -- 26 +change.case$ -- 78 +chr.to.int$ -- 0 +cite$ -- 52 +duplicate$ -- 182 +empty$ -- 599 +format.name$ -- 0 +if$ -- 1101 +int.to.chr$ -- 0 +int.to.str$ -- 26 +missing$ -- 0 +newline$ -- 133 +num.names$ -- 0 +pop$ -- 244 +preamble$ -- 1 +purify$ -- 52 +quote$ -- 0 +skip$ -- 137 +stack$ -- 0 +substring$ -- 130 +swap$ -- 26 +text.length$ -- 0 +text.prefix$ -- 0 +top$ -- 0 +type$ -- 104 +warning$ -- 26 +while$ -- 0 +width$ -- 28 +write$ -- 244 +(There were 26 warnings) diff --git a/src/FileRouter.ts b/src/FileRouter.ts index ecd5185..7b19abd 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -171,7 +171,7 @@ const postProperties: Middleware = ( logger.debug('Editing server properties'); res.locals.modified = true; for (const newProp of req.body) { - const prop: Property | undefined = serverConfig.find( + let prop: Property | undefined = serverConfig.find( (p: Property): boolean => p.id === newProp.id ); if (prop === undefined) { @@ -183,6 +183,7 @@ const postProperties: Middleware = ( } try { prop.value = newProp.value; + } catch (err) { // FIXME: Assuming it's a value-type error, but it might not be! next(new RequestError(400, 'invalid_property_value', undefined, newProp.id)); @@ -968,6 +969,7 @@ export class FileRouter { name: projectName } }); + console.log("here") next(); } ); diff --git a/src/serverConfig.ts b/src/serverConfig.ts index 136995a..5d2575a 100644 --- a/src/serverConfig.ts +++ b/src/serverConfig.ts @@ -82,7 +82,7 @@ export class Property { } public set value(value: Value) { - if (!this.readOnly) { + if (this.readOnly) { throw new Error('this property is read-only'); } else if (!types[this.type](value)) { throw new Error(`value ${value} is not of type ${this.type}`); diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts index a371fd5..4071322 100644 --- a/test/integration/protocol.routes.test.ts +++ b/test/integration/protocol.routes.test.ts @@ -135,7 +135,7 @@ const completeProtocol: MochaForEachInput[] = [ ]) }), 200], ['post', '/properties?action=update', - [{id: 'new_prop', value: 'some_value'}], 200], + [{id: 'project_example', value: 2}], 200], ['get', '/user_privileges', array({ privilege: types.string, description: types.string, @@ -166,7 +166,7 @@ const completeProtocol: MochaForEachInput[] = [ public_admin_metadata: types.anything, private_admin_metadata: types.anything }, 200], - ['post', '/users/new_user', null, 200], + ['post', '/users/new_user?action=create', null, 200], ['get', '/users/mock_user/properties', { data: optional(types.anything) }, 200], @@ -182,7 +182,10 @@ const completeProtocol: MochaForEachInput[] = [ public_admin_metadata: types.anything, private_admin_metadata: types.anything }, 200], - ['post', '/current_user', null, 200], + ['post', '/current_user', {password: { + old: "pass", + new: "pass" + }}, 200], ['get', '/project_roles', array({ role: types.string, description: types.string, @@ -208,7 +211,7 @@ const completeProtocol: MochaForEachInput[] = [ private_metadata: types.anything, admin_metadata: optional(types.anything) }, 200], - ['post', '/projects/mocky', null, 200], + ['post', '/projects/mocky2', {}, 200], ['get', '/projects/mocky/properties', null, 200], ['post', '/projects/mocky/files/folder+some_file?action=overwrite', {}, 200], ['get', '/projects/mocky/files/folder+some_file', null, 200], -- cgit v1.2.1