From 0fb5d8cb8ed4ce2f33aa78db52c6c169f5de232e Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Wed, 28 Oct 2020 13:22:07 +0100 Subject: [PATCH] Catch unauthorized error as seen in https://github.com/ubports/ubports-installer/issues/983 --- src/common.js | 8 ++------ tests/unit-tests/test_common.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/common.js b/src/common.js index 973c43f..aad2639 100644 --- a/src/common.js +++ b/src/common.js @@ -41,12 +41,6 @@ function handleError(error, stdout, stderr) { return "no device"; } else if (stderr && stderr.includes("error: device offline")) { return "device offline"; - } else if ( - error && - error.message && - error.message.includes("incorrect password") - ) { - return "incorrect password"; } else if ( stderr && stderr.includes("FAILED (remote: low power, need battery charging.)") @@ -66,6 +60,8 @@ function handleError(error, stdout, stderr) { )) ) { return "bootloader is locked"; + } else if (stderr && stderr.includes("error: device unauthorized")) { + return "unauthorized"; } else if (stderr && stderr.includes("FAILED (remote failure)")) { return "failed to boot"; } else if ( diff --git a/tests/unit-tests/test_common.js b/tests/unit-tests/test_common.js index 4b8c345..fb944e5 100644 --- a/tests/unit-tests/test_common.js +++ b/tests/unit-tests/test_common.js @@ -34,6 +34,13 @@ const recognizedErrors = [ stdout: undefined, stderr: "error: no devices/emulators found" }, + { + expectedReturn: "unauthorized", + error: { killed: false, code: 1, signal: null, cmd: "command" }, + stdout: "", + stderr: + "error: device unauthorized.\nThis adb server's $ADB_VENDOR_KEYS is not set\nTry 'adb kill-server' if that seems wrong.\nOtherwise check for a confirmation dialog on your device." + }, { expectedReturn: "device offline", error: { killed: false, code: 1, signal: null, cmd: "command" }, @@ -41,10 +48,10 @@ const recognizedErrors = [ stderr: "error: error: device offline" }, { - expectedReturn: "incorrect password", - error: { message: "this error includes incorrect password" }, - stdout: undefined, - stderr: undefined + expectedReturn: "device offline", + error: { killed: false, code: 1, signal: null, cmd: "command" }, + stdout: "", + stderr: "error: error: device offline\n" }, { expectedReturn: "bootloader is locked",