diff --git a/src/app/src/main/kotlin/org/imperial/mrc/hint/models/Response.kt b/src/app/src/main/kotlin/org/imperial/mrc/hint/models/Response.kt index 7140b511c4..d857d2adcf 100644 --- a/src/app/src/main/kotlin/org/imperial/mrc/hint/models/Response.kt +++ b/src/app/src/main/kotlin/org/imperial/mrc/hint/models/Response.kt @@ -3,7 +3,7 @@ package org.imperial.mrc.hint.models import com.fasterxml.jackson.databind.ObjectMapper data class SuccessResponse(val data: Any?){ - val errors = mapOf() + val errors = arrayOf() val status = "success" } diff --git a/src/app/src/test/kotlin/org/imperial/mrc/hint/helpers/JSONValidator.kt b/src/app/src/test/kotlin/org/imperial/mrc/hint/helpers/JSONValidator.kt index 3a0c0a881c..638abdf985 100644 --- a/src/app/src/test/kotlin/org/imperial/mrc/hint/helpers/JSONValidator.kt +++ b/src/app/src/test/kotlin/org/imperial/mrc/hint/helpers/JSONValidator.kt @@ -13,6 +13,9 @@ import java.io.File import java.net.URI import java.net.URL import javax.json.stream.JsonParsingException +import java.io.InputStreamReader +import java.io.BufferedReader +import java.net.HttpURLConnection class JSONValidator { @@ -72,7 +75,9 @@ class JSONValidator { "$name.schema.json" } val url = URL("https://raw.githubusercontent.com/mrc-ide/hintr/$hintrVersion/inst/schema/$path") - return url.openStream().use { + + val conn = url.openConnection() as HttpURLConnection + return BufferedReader(InputStreamReader(conn.getInputStream())).use { val reader = readerFactory.createSchemaReader(it) try { reader.read() diff --git a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/BaselineTests.kt b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/BaselineTests.kt index cf6431004c..03dab4df8a 100644 --- a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/BaselineTests.kt +++ b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/BaselineTests.kt @@ -17,7 +17,7 @@ class BaselineTests : SecureIntegrationTests() { if (isAuthorized == IsAuthorized.TRUE){ // we can't use the JSONValidator here because this response schema isn't in the spec yet assertThat(responseEntity.body!!) - .isEqualTo("{\"errors\":{},\"status\":\"success\",\"data\":{\"pjnz\":null}}") + .isEqualTo("{\"errors\":[],\"status\":\"success\",\"data\":{\"pjnz\":null}}") } } diff --git a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/HintApplicationTests.kt b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/HintApplicationTests.kt index c2f7061ca5..eee3213a9b 100644 --- a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/HintApplicationTests.kt +++ b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/HintApplicationTests.kt @@ -75,7 +75,7 @@ class HintApplicationTests(@Autowired val restTemplate: TestRestTemplate) : Inte val entity = restTemplate.getForEntity("/baseline/") assertThat(entity.statusCode).isEqualTo(HttpStatus.OK) - assertThat(entity.body!!).isEqualTo("{\"errors\":{},\"status\":\"success\",\"data\":{\"pjnz\":null}}") + assertThat(entity.body!!).isEqualTo("{\"errors\":[],\"status\":\"success\",\"data\":{\"pjnz\":null}}") } @Test diff --git a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/PasswordTests.kt b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/PasswordTests.kt index 3c46ef6c10..d12c49fc69 100644 --- a/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/PasswordTests.kt +++ b/src/app/src/test/kotlin/org/imperial/mrc/hint/integration/PasswordTests.kt @@ -28,7 +28,7 @@ class PasswordTests(@Autowired val restTemplate: TestRestTemplate) : CleanDataba } } - private val expectedSuccessResponse = "{\"errors\":{},\"status\":\"success\",\"data\":true}" + private val expectedSuccessResponse = "{\"errors\":[],\"status\":\"success\",\"data\":true}" private fun expectedErrorResponse(errorMessage: String): String { return "{\"data\":{},\"status\":\"failure\",\"errors\":[{\"error\":\"OTHER_ERROR\",\"detail\":\"$errorMessage\"}]}" diff --git a/src/app/src/test/kotlin/org/imperial/mrc/hint/unit/controllers/PasswordControllerTests.kt b/src/app/src/test/kotlin/org/imperial/mrc/hint/unit/controllers/PasswordControllerTests.kt index 1046add7d6..5f8db56c86 100644 --- a/src/app/src/test/kotlin/org/imperial/mrc/hint/unit/controllers/PasswordControllerTests.kt +++ b/src/app/src/test/kotlin/org/imperial/mrc/hint/unit/controllers/PasswordControllerTests.kt @@ -30,7 +30,7 @@ class PasswordControllerTests { val mockEmailManager = mock() - val expectedSuccessResponse = "{\"errors\":{},\"status\":\"success\",\"data\":true}" + val expectedSuccessResponse = "{\"errors\":[],\"status\":\"success\",\"data\":true}" @Test fun `forgotPassword returns expected template name`() { diff --git a/src/app/static/package-lock.json b/src/app/static/package-lock.json index 3d1bd68724..b46f42d9c8 100644 --- a/src/app/static/package-lock.json +++ b/src/app/static/package-lock.json @@ -14,27 +14,83 @@ } }, "@babel/core": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.4.tgz", - "integrity": "sha512-lQgGX3FPRgbz2SKmhMtYgJvVzGZrmjaF4apZ2bLwofAKiSjxU0drPh4S/VasyYXwaTs+A1gvQ45BN8SQJzHsQQ==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.5.tgz", + "integrity": "sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", - "@babel/helpers": "^7.4.4", - "@babel/parser": "^7.4.4", + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.5.5", + "@babel/helpers": "^7.5.5", + "@babel/parser": "^7.5.5", "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.4", - "@babel/types": "^7.4.4", + "@babel/traverse": "^7.5.5", + "@babel/types": "^7.5.5", "convert-source-map": "^1.1.0", "debug": "^4.1.0", "json5": "^2.1.0", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "resolve": "^1.3.2", "semver": "^5.4.1", "source-map": "^0.5.0" }, "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/generator": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz", + "integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==", + "dev": true, + "requires": { + "@babel/types": "^7.5.5", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/parser": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", + "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", + "dev": true + }, + "@babel/traverse": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz", + "integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.5.5", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.5.5", + "@babel/types": "^7.5.5", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", + "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -54,9 +110,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -267,14 +323,87 @@ } }, "@babel/helpers": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.4.tgz", - "integrity": "sha512-igczbR/0SeuPR8RFfC7tGrbdTbFL3QTvH6D+Z6zNxnTe//GyqmtHmDkzrqDmyZ3eSwPqB/LhyKoU5DXsp+Vp2A==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.5.tgz", + "integrity": "sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==", "dev": true, "requires": { "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.4", - "@babel/types": "^7.4.4" + "@babel/traverse": "^7.5.5", + "@babel/types": "^7.5.5" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/generator": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz", + "integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==", + "dev": true, + "requires": { + "@babel/types": "^7.5.5", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/parser": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", + "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", + "dev": true + }, + "@babel/traverse": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz", + "integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.5.5", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.5.5", + "@babel/types": "^7.5.5", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", + "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "@babel/highlight": { @@ -4094,8 +4223,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -4116,14 +4244,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4138,20 +4264,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -4268,8 +4391,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -4281,7 +4403,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4296,7 +4417,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4304,14 +4424,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4330,7 +4448,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4411,8 +4528,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -4424,7 +4540,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4510,8 +4625,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -4547,7 +4661,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4567,7 +4680,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4611,14 +4723,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/src/app/static/package.json b/src/app/static/package.json index b3cfe092d0..f12f8b8262 100644 --- a/src/app/static/package.json +++ b/src/app/static/package.json @@ -13,7 +13,7 @@ "author": "", "license": "MIT", "devDependencies": { - "@babel/core": "^7.3.4", + "@babel/core": "^7.5.5", "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.3.4", "@babel/register": "^7.0.0", diff --git a/src/app/static/scripts/run-dependencies-for-integration-tests.sh b/src/app/static/scripts/run-dependencies-for-integration-tests.sh index 731b2bf346..3e2af4c313 100755 --- a/src/app/static/scripts/run-dependencies-for-integration-tests.sh +++ b/src/app/static/scripts/run-dependencies-for-integration-tests.sh @@ -5,7 +5,7 @@ HERE=$(readlink -f "$(dirname $0)") NETWORK=hint_nw HINT=hint $HERE/../../../../scripts/run-dependencies.sh -HINT_VERSION=mrc-433_integrationtests +HINT_VERSION=master TEST_CONFIG=$HERE/test.properties HINT_IMAGE=mrcide/$HINT:$HINT_VERSION diff --git a/src/app/static/scripts/run-dev-dependencies-for-integration-tests.sh b/src/app/static/scripts/run-dev-dependencies-for-integration-tests.sh index 670ba06b64..53924298c8 100755 --- a/src/app/static/scripts/run-dev-dependencies-for-integration-tests.sh +++ b/src/app/static/scripts/run-dev-dependencies-for-integration-tests.sh @@ -7,7 +7,7 @@ HINT=hint DB=hint_db API=hintr $HERE/../../../../scripts/run-dependencies.sh -HINT_VERSION=mrc-433_integrationtests +HINT_VERSION=master TEST_CONFIG=$HERE/test.properties HINT_IMAGE=mrcide/$HINT:$HINT_VERSION diff --git a/src/app/static/src/app/apiService.ts b/src/app/static/src/app/apiService.ts index 7b6398b34e..e5b71b0c83 100644 --- a/src/app/static/src/app/apiService.ts +++ b/src/app/static/src/app/apiService.ts @@ -1,6 +1,6 @@ import axios, {AxiosError, AxiosResponse} from "axios"; import {InternalResponse} from "./types"; -import {Failure, InitialiseModelRunResponse, ModelRunResultResponse, Success, ValidateInputResponse} from "./generated"; +import {Response, InitialiseModelRunResponse, ModelRunResultResponse, ValidateInputResponse} from "./generated"; import {Commit} from "vuex"; type ResponseData = @@ -39,17 +39,17 @@ export class APIService implements API private _ignoreErrors: Boolean = false; - static getFirstErrorFromFailure = (failure: Failure) => { + static getFirstErrorFromFailure = (failure: Response) => { const firstError = failure.errors[0]; return firstError.detail ? firstError.detail : firstError.error; }; - private _onError: ((failure: Failure) => void) | null = null; + private _onError: ((failure: Response) => void) | null = null; - private _onSuccess: ((success: Success) => void) | null = null; + private _onSuccess: ((success: Response) => void) | null = null; withError = (type: E) => { - this._onError = (failure: Failure) => { + this._onError = (failure: Response) => { this._commit({type: type, payload: APIService.getFirstErrorFromFailure(failure)}); }; return this @@ -61,7 +61,7 @@ export class APIService implements API }; withSuccess = (type: S) => { - this._onSuccess = (success: Success) => { + this._onSuccess = (success: Response) => { this._commit({type: type, payload: success.data}); }; return this; @@ -84,7 +84,7 @@ export class APIService implements API if (this._ignoreErrors) { return } - const failure = e.response && e.response.data as Failure; + const failure = e.response && e.response.data as Response; if (!failure || !failure.status) { throw new Error("Could not parse API response"); } diff --git a/src/app/static/src/app/components/Stepper.vue b/src/app/static/src/app/components/Stepper.vue index f914d294b2..37ff52d12c 100644 --- a/src/app/static/src/app/components/Stepper.vue +++ b/src/app/static/src/app/components/Stepper.vue @@ -33,7 +33,7 @@