0.1.1 • Published 9 months ago

billing-allocation-service-api v0.1.1

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

API Automated Tests

Test data

The eis-api-test Docker image contains a PostgreSQL EIS database which is empty except for certain seed data such as users webinspect and torvalds.

Pull and run eis-api-test image from nexus:

docker login nexusprod.corp.intranet:4567 -u <username>
docker run -d --name eis-api-test -p 5432:5432 -p 8081:8081 -e POSTGRES_PASSWORD=eis nexusprod.corp.intranet:4567/eis/eis-api-test:1.2.4

Insert eis-order-notification test data:

cd src/test/resources/data
./seed.sh 
(or seed.cmd)

Configure eis-order-notification to use this datasource for Ply test execution:

host: localhost
port: 5432
database: eisdev
username: eis
password: eis

Authentication

The eis-api-test image described above also contains the EIS Auth API. When run with -p 8081:8081, the image will make eis-auth endpoints accessible locally. Configure eis-order-notification eis.auth.endpoint to use http://localhost:8081. A working API key is built into the container image. Set environment variable EIS_API_TOKEN, which is referenced in src/test/ply/values/localhost.com for API authentication. See Ply Values documentation.

MockServer

The order-notifications/attachment endpoint submits a client HTTP request to the socn.endpoint URL. During API test execution, this endpoint is mocked using MockServer. The canned response is returned by SocnAttachmentMock. To start the mock server manually, run the main() method in this class.

Running tests

API tests are executed by the api-test profile during Maven's 'verify' phase. The following command runs the Ply tests and validates the results (timezone ensure expected results sentTime agreement):

mvn verify -P api-test -Dspring-boot.run.jvmArguments="-Duser.timezone=America/Denver"

Example output with api-test success:

[INFO] Overall Results: {"Passed":12,(:0,"Errored":0,"Pending":0,"Submitted":0}
[INFO] Overall Time: 8195 ms

Example output with failed test

[INFO] Request 'attachmentForOrderId' FAILED in 2824 ms: Results differ from line 8
[INFO] 8-9
[INFO] -       code: 200
[INFO] -       message: OK
[INFO] +       code: 404
[INFO] +       message: Not Found
[INFO] ===
[INFO] 11-14
[INFO] -       access-control-expose-headers: Content-Disposition
[INFO] -       content-disposition: attachment; filename="CTL-TACR-${filters.orderId}-test_accept_rpt.txt"
[INFO] -       content-type: application/octet-stream
[INFO] -     body: \x5441434e206e6f74696669636174696f6e
[INFO] +       content-type: application/json
[INFO] +     body: |-
[INFO] +       {
[INFO] +         "message": "Cannot find orderId MNS-44367V2 attachment",
[INFO] +         "status": "NOT_FOUND"
[INFO] +       }
[INFO] ===
...
...
[INFO] Overall Results: {"Passed":11,"Failed":1,"Errored":0,"Pending":0,"Submitted":0}

VS Code Extension

Install the Ply VS Code extension to run API tests interactively through VS Code.

Follow the setup steps above, then manually start the EisOrderNotification Spring Boot app. Also start the SocnAttachmentMock server. Open the Test Explorer view in VS Code, and execute the Ply tests. vscode-ply

0.1.1

9 months ago