diff --git a/bin/server.js b/bin/server.js index dfb8456..ebc434b 100644 --- a/bin/server.js +++ b/bin/server.js @@ -57,6 +57,8 @@ async function startServer () { const controllers = new Controllers() await controllers.attachControllers(app) + app.controllers = controllers + // Enable CORS for testing // THIS IS A SECURITY RISK. COMMENT OUT FOR PRODUCTION app.use(cors({ origin: '*' })) diff --git a/src/adapters/ipfs/ipfs.js b/src/adapters/ipfs/ipfs.js index 297a056..5efc46f 100644 --- a/src/adapters/ipfs/ipfs.js +++ b/src/adapters/ipfs/ipfs.js @@ -62,9 +62,9 @@ class IpfsAdapter { // ) // Stop the IPFS node if we're running tests. - if (this.config.env === 'test') { - await this.ipfs.stop() - } + // if (this.config.env === 'test') { + // await this.ipfs.stop() + // } // Signal that this adapter is ready. this.isReady = true @@ -75,6 +75,10 @@ class IpfsAdapter { throw err } } + + async stop () { + await this.ipfs.stop() + } } module.exports = IpfsAdapter diff --git a/src/controllers/index.js b/src/controllers/index.js index 695c09e..b403499 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -38,13 +38,13 @@ class Controllers { // Top-level function for this library. // Start the various Controllers and attach them to the app. attachRESTControllers (app) { - const rESTControllers = new RESTControllers({ + const restControllers = new RESTControllers({ adapters: this.adapters, useCases: this.useCases }) // Attach the REST API Controllers associated with the boilerplate code to the Koa app. - rESTControllers.attachRESTControllers(app) + restControllers.attachRESTControllers(app) } // Add the JSON RPC router to the ipfs-coord adapter. diff --git a/test/e2e/automated/a01-auth.rest-e2e.js b/test/e2e/automated/a01-auth.rest-e2e.js index e4f367b..2398df0 100644 --- a/test/e2e/automated/a01-auth.rest-e2e.js +++ b/test/e2e/automated/a01-auth.rest-e2e.js @@ -25,6 +25,9 @@ describe('Auth', () => { // This should be the first instruction. It starts the REST API server. await app.startServer() + // Stop the IPFS node for the rest of the e2e tests. + // await app.controllers.adapters.ipfs.stop() + // Delete all previous users in the database. await testUtils.deleteAllUsers() diff --git a/test/e2e/automated/a02-users.rest-e2e.js b/test/e2e/automated/a02-users.rest-e2e.js index 439c6e1..d4a0125 100644 --- a/test/e2e/automated/a02-users.rest-e2e.js +++ b/test/e2e/automated/a02-users.rest-e2e.js @@ -12,7 +12,8 @@ const LOCALHOST = `http://localhost:${config.port}` const context = {} const UserController = require('../../../src/controllers/rest-api/users/controller') -const adapters = require('../../../src/adapters') +const Adapters = require('../../../src/adapters') +const adapters = new Adapters() const UseCases = require('../../../src/use-cases/') let uut let sandbox diff --git a/test/unit/adapters/fullstack-jwt.adapter.unit.js b/test/unit/adapters/fullstack-jwt.adapter.unit.js index c79b34e..28216b8 100644 --- a/test/unit/adapters/fullstack-jwt.adapter.unit.js +++ b/test/unit/adapters/fullstack-jwt.adapter.unit.js @@ -18,8 +18,8 @@ describe('#FullStackJWT', () => { const localConfig = { authServer: 'someserver', apiServer: 'someserver', - login: 'somelogin', - password: 'somepassword' + fullstackLogin: 'somelogin', + fullstackPassword: 'somepassword' } uut = new FullStackJWT(localConfig) }) @@ -81,7 +81,7 @@ describe('#FullStackJWT', () => { const localConfig = { authServer: 'someserver', apiServer: 'someserver', - login: 'somelogin' + fullstackLogin: 'somelogin' } uut = new FullStackJWT(localConfig) diff --git a/test/unit/controllers/controllers.unit.js b/test/unit/controllers/controllers.unit.js index 674e587..a60ddec 100644 --- a/test/unit/controllers/controllers.unit.js +++ b/test/unit/controllers/controllers.unit.js @@ -6,8 +6,6 @@ // const assert = require('chai').assert const sinon = require('sinon') -const adapters = require('../../../src/adapters') -// const { attachControllers } = require('../../../src/controllers') const Controllers = require('../../../src/controllers') describe('#Controllers', () => { @@ -25,8 +23,8 @@ describe('#Controllers', () => { describe('#attachControllers', () => { it('should attach the controllers', async () => { // mock IPFS - sandbox.stub(adapters.ipfs, 'start').resolves({}) - adapters.ipfs.ipfsCoordAdapter = { + sandbox.stub(uut.adapters, 'start').resolves({}) + uut.adapters.ipfs.ipfsCoordAdapter = { attachRPCRouter: () => {} }