Binci
We use binci to containerize our services using Docker. Binci is very similar to Docker-compose. We can use this to test our services locally and will always run the test suites before opening a PR.
Pre-requisites
binci.yml
binci is configured via the binci.yml file, located at the root of the project. You can check the official docs for more information but the following are areas of interest for now.
envcontains all of the environment variables required by the application to runexposedetails the ports that will be made available for the host to access the servicetaskslists all of the availablebincicommandsservicesthis lists all the services that will be stood up for your application to run locally, such as vault, redis or postgres depending on the requirements. The services listed here will not diect traffic to another environment such as UAT etc. It is all for local development.
Common commands
binci installinstalls dependencies by runningpnpm installbinci buildbuilds the project by runningpnpm buildYou can chain commands also:
binci install buildbinci devruns the application locally for you to testbinci testruns the unit tests and e2e tests by runningpnpm testbinci test:watchwill rerun the tests after making changes, similar to nodemonbinci test:unitwill run the unit testsbinci test:unit:watchwill rerun the unit tests after making changesbinci test:e2ewill run the end to end testsbinci test:e2e:watchwill rerun the end to end tests after making changesbinci test:integrationwill run the integration testsbinci test:integration:watchwill rerun the integration tests after making changes
Local Testing
After running binci dev your service is now running locally for you to test via cURL or Postman etc.
Your test may have some requirements in order to be successful, such as eauth token, ConsumerJWT, x-forwarded-for, referrer and/or origin headers etc.
Get eauth token. The
eauth -> x-bannoenterprise0token is a fallback method that we use since our services are designed to only ever be called ifx-bannoenterprise0orx-bannoconsumer0are present. This passes auth checks andnode-api-gatewaycalls the service.To get a
ConsumerJWTtoken, the steps are similar to gettingeauthbut instead of logging intouat.banno.com, you would log intodevbank.banno-uat.comusing your test user and get the token from Chrome dev tools. Note: AConsumerJWTis not suitable for any enterprise endpoint testing.For
x-forwarded-foryou can set it to your ip. We need to set this as it is usually set by the nginx load balancer and we callnode-api-gatewayFor
originandreferrerheaders, make sure the url is correct. See Example #2 below
Examples
The below example is going to hit the
/a/consumer-login/api/institutions/:institutionId/users/:userId/2fa/methodsendpoint innode-consumer-login-proxy:curl -v
-X PUT
-d ‘{“authMethods”:[{“authMethod”:“push”,“enabled”:true}]}’
-H ‘Content-Type: application/json’
-H “cookie: eauth=$eauth”
-H “x-forwarded-for: $ip”
http://localhost:8080/a/consumer-login/api/institutions/<institution_id>/users/user_id/2fa/methodsThe below is an example of a non-banno enterprise/platform (mobile/online) route, showing the use of
ConsumerJwt, Referrer and Origin. This example is going to hit thev0/oob/enrollments/authyendpoint innode-consumer-login-proxy:curl -v
-H ‘origin: http://localhost:8080’
-H ‘referer: http://localhost:8080/login’
-H ‘Content-Type: application/json’
-H “cookie: ConsumerJwt=$ConsumerJwt”
http://localhost:8080/v0/oob/enrollments/authy
In the terminal running the service, the logs will be more verbose for this request including InternalApiRequest, VaultRetrieval, DecodedJwt, AuthyGetEnrollment, and SuccessResponse and a 200 OK HTTP response from your cURL command along with a body containing the user enrollments, including "validDeliveryMethods":["call","sms","authy"]}, which is valid for this test.
Troubleshooting
Please update this as you encounter/resolve issues testing a service locally
Logs show
ErrorResponse: The request body was invalid. cURL response showsHTTP/1.1 401 UnauthorizedCheck the
x-forwarded-forheader is setLogs show
HttpError: Internal Server Error. cURL response showsHTTP/1.1 401 UnauthorizedCheck the
eauthtoken has not expiredNode binding issues Sometimes native modules for mac os x can cause “node binding” issues because binci is running as a docker container (linux)
sh: can't open '/tmp/binci.sh': No such file or directoryAdd the following to your
~/.bashrcor~/.zshrcand relaunch your shell:export BINCI_TMP=/tmp/rancher-desktop(or some other directory)