docker run -p 9000:9000 nokamoto13/webpush-testing-service:0.0.0
This will start the service with the default applicationServerKey.
To configure applicationServerKey, pass -DapplicationServerKey=${YOUR_VAPID_PUBLIC_KEY} to the docker command line argument.
docker run -p 9000:9000 nokamoto13/webpush-testing-service:0.0.0 -DapplicationServerKey=${YOUR_VAPID_PUBLIC_KEY}
-
Call
POST /testing/:driverto start a new browser. This API returns id and subscription.POST http://localhost:9000/testing/firefox{ "id":"f6cdb052-c412-426f-bcd6-3cc54b8a3903", "subscription":{ "endpoint":"https://updates.push.services.mozilla.com/wpush/v2/...", "auth":"MTYemr59rcxqaODIf3byeA==", "p256dh":"BL/DHX+aV4dlVwQG2YE/w7VogSJj+lJZvNRNiHoL+OTPKjhxZCXomNeUNLEkuLvt8SVGvnec+gn/JNQ1fYyjdP0=", } } -
Send a webpush message with your client. The message must be JSON and have id field.
POST https://updates.push.services.mozilla.com/wpush/v2/...{ "id": "f6cdb052-c412-426f-bcd6-3cc54b8a3903", "options": { "body": "test message" } }The service worker will eventually receive the message from the push service (i.e. mozilla) and store the event to the testing service.
-
Call
GET /testing/:idto retrieve the message.GET http://localhost:9000/testing/f6cdb052-c412-426f-bcd6-3cc54b8a3903{ "events":[ "{\"id\":\"f6cdb052-c412-426f-bcd6-3cc54b8a3903\",\"options\":{\"body\":{\"test message\"}}}" ] }
Here is a concrete example test code in Scala.
Start a new browser.
| Request | |
|---|---|
| driver | firefox or chrome |
| Status |
|---|
| 201 |
400 if :driver undefined |
| Response JSON Field | |
|---|---|
| id | an unique suite id |
| driver | firefox or chrome |
| subscription.endpoint | PushSubscription.endpoint |
| subscription.auth | PushSubscription.getKey('auth') |
| subscription.p256dh | PushSubscription.getKey('p256dh') |
Retrieve webpush messages that the browser received.
| Status |
|---|
| 200 |
404 if :id not found |
| Response JSON Field | |
|---|---|
| driver | firefox or chrome |
| events | a list of PushEvent.data.text() |
Quit the browser.
| Status |
|---|
| 204 |
