diff --git a/tests/shared/jasmine.js b/tests/shared/jasmine.js index 8fee13c6..5f7ded61 100644 --- a/tests/shared/jasmine.js +++ b/tests/shared/jasmine.js @@ -4,9 +4,6 @@ const Jasmine = require("jasmine"); const JasmineConsoleReporter = require('jasmine-console-reporter'); const path = require("path"); -const ADMIN_TOKEN_PATH = path.resolve(__dirname, "../../../../object-server-for-testing/admin_token.base64"); -process.env.ADMIN_TOKEN_PATH = ADMIN_TOKEN_PATH; - const JASMIN_FILTER_KEY = "--filter"; function getFilterFromProcess() { diff --git a/tests/shared/js/admin-user-helper.js b/tests/shared/js/admin-user-helper.js index 1bb24860..cc61539d 100644 --- a/tests/shared/js/admin-user-helper.js +++ b/tests/shared/js/admin-user-helper.js @@ -7,14 +7,31 @@ let fs = node_require("fs"); let path = node_require("path"); var Realm = node_require('realm'); -const DEFAULT_ADMIN_TOKEN_PATH = path.join(__dirname, "..", "..", "object-server-for-testing", "admin_token.base64"); -const ADMIN_TOKEN_PATH = process.env.ADMIN_TOKEN_PATH || DEFAULT_ADMIN_TOKEN_PATH; +function getObjectServerPath() { + const pathParts = __dirname.split(path.sep); + let objectServerPath; + for(let p = pathParts.length; p >= 0; p--) { + const candidatePathParts = pathParts.slice(0, p); + candidatePathParts.push("object-server-for-testing"); + const candidatePath = candidatePathParts.join(path.sep); + if (fs.existsSync(candidatePath)) { + return candidatePath; + } + } + return null; +} function getAdminToken() { - if(fs.existsSync(ADMIN_TOKEN_PATH)) { - return fs.readFileSync(ADMIN_TOKEN_PATH, 'utf-8'); + const objectServerPath = getObjectServerPath(); + if(objectServerPath) { + const accessTokenPath = path.resolve(objectServerPath, "admin_token.base64"); + if(fs.existsSync(accessTokenPath)) { + return fs.readFileSync(accessTokenPath, "utf-8"); + } else { + throw new Error("CouldnĀ“t locate the admin token, used to access the realm object server."); + } } else { - throw new Error("Missing the file with an admin token: " + ADMIN_TOKEN_PATH); + throw new Error("CouldnĀ“t locate the realm object server."); } }