Skip to content

Commit

Permalink
bugfix/1079 Extensions Longer Than 128 Chars (#157)
Browse files Browse the repository at this point in the history
* truncateExtensions setting

* Add ALS DB script. Repair unit test with unmocked DB connection, causing issues
  • Loading branch information
ggrg authored Nov 27, 2019
1 parent e8dca91 commit a96b52c
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"reject": [

"hapi-swagger"
]
}
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"ERROR_HANDLING": {
"includeCauseExtension": false,
"truncateCause": true
"truncateExtensions": true
},
"SWITCH_ENDPOINT": "http://localhost:3001",
"INSTRUMENTATION": {
Expand Down
270 changes: 153 additions & 117 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
"@hapi/inert": "5.2.2",
"@hapi/vision": "5.5.4",
"@mojaloop/central-services-database": "8.2.1",
"@mojaloop/central-services-error-handling": "8.5.0",
"@mojaloop/central-services-error-handling": "8.6.2",
"@mojaloop/central-services-health": "8.3.0",
"@mojaloop/central-services-logger": "8.1.2",
"@mojaloop/central-services-metrics": "8.3.0",
"@mojaloop/central-services-shared": "8.4.3",
"@mojaloop/central-services-shared": "8.6.1",
"@now-ims/hapi-now-auth": "2.0.0",
"blipp": "4.0.1",
"commander": "4.0.1",
Expand Down
19 changes: 8 additions & 11 deletions test/unit/lib/migrator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,32 @@
* Crosslake
- Lewis Daly <lewisd@crosslaketech.com>
* ModusBox
- Georgi Georgiev <georgi.georgiev@modusbox.com>
--------------
******/

'use strict'

const Sinon = require('sinon')
const Migrations = require('@mojaloop/central-services-database').Migrations

const Migrator = require('../../../src/lib/migrator')

let sandbox

describe('Migrator', () => {
beforeEach(() => {
sandbox = Sinon.createSandbox()
const migrationsMethods = Object.getOwnPropertyNames(Migrations)
migrationsMethods.forEach((methodName) => {
jest.spyOn(Migrations, methodName).mockImplementation(() => {})
})
})

afterEach(() => {
sandbox.restore()
jest.clearAllMocks()
})

it('runs the migration from the knexfile', async () => {
// Arrange
const migrateSpy = sandbox.spy(Migrations, 'migrate')

// Act
Migrator.migrate()

// Assert
expect(migrateSpy.calledOnce).toBe(true)
expect(Migrations.migrate).toHaveBeenCalledTimes(1)
})
})
33 changes: 33 additions & 0 deletions test/util/scripts/addAlsDb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
echo "---------------------------------------------------------------------"
echo " Adding ALS database and user to existing ${DB_ID} Instance"
echo "---------------------------------------------------------------------"

CWD="${0%/*}"

if [[ "$CWD" =~ ^(.*)\.sh$ ]];
then
CWD="."
fi

echo "Loading env vars..."
source $CWD/env.sh

docker stop $DB_ID
echo "Starting container ${DB_ID}"
docker start $DB_ID
exit_code=$?

if [ "$exit_code" = "0" ]
then
docker exec -it ${DB_ID} mysql -uroot -e "DROP SCHEMA IF EXISTS account_lookup;"
docker exec -it ${DB_ID} mysql -uroot -e "CREATE SCHEMA account_lookup;"
docker exec -it ${DB_ID} mysql -uroot -e "DROP USER IF EXISTS account_lookup@'%';"
docker exec -it ${DB_ID} mysql -uroot -e "CREATE USER account_lookup@'%' IDENTIFIED WITH mysql_native_password BY '$DBPASS';"
docker exec -it ${DB_ID} mysql -uroot -e "GRANT ALL PRIVILEGES ON account_lookup.* TO 'account_lookup'@'%';"
docker exec -it ${DB_ID} mysql -uroot -e "FLUSH PRIVILEGES;"
else
>&2 echo "{$DB_ID} container does not exist "
fi

echo "${DB_ID} ALS database ready to accept requests..."
4 changes: 3 additions & 1 deletion test/util/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
export MOCKSERVER_ID=mockserver
]export SLEEP_FACTOR_IN_SECONDS=5
export SLEEP_FACTOR_IN_SECONDS=5
export DB_ID=mysql
export DBPASS=password

0 comments on commit a96b52c

Please sign in to comment.