risk.http142 lines, 4.0 KB
| 1 | # Risk checks, through the gateway. Send the requests in order, on a fresh |
| 2 | # database: Alice and Bob sign up, and Alice deposits five thousand dollars. |
| 3 | @baseUrl = http://localhost:8080 |
| 4 | @password = correct horse battery staple |
| 5 | @alice = {{aliceLogin.response.body.access_token}} |
| 6 | @bob = {{bobLogin.response.body.access_token}} |
| 7 | @alicesWallet = {{aliceWallet.response.body.id}} |
| 8 | @bobsWallet = {{bobWallet.response.body.id}} |
| 9 | # The review API is on the transfer service's internal port, 9083, over mTLS: |
| 10 | # our ops tools call it with their certificate, for a reviewer who signed in. |
| 11 | # REST Client can't show a certificate, so reviews are sent with curl. |
| 12 | |
| 13 | ### Alice signs up |
| 14 | POST {{baseUrl}}/v1/auth/register |
| 15 | Content-Type: application/json |
| 16 | |
| 17 | {"email": "alice@example.com", "password": "{{password}}"} |
| 18 | |
| 19 | ### Alice logs in |
| 20 | # @name aliceLogin |
| 21 | POST {{baseUrl}}/v1/auth/login |
| 22 | Content-Type: application/json |
| 23 | |
| 24 | {"email": "alice@example.com", "password": "{{password}}"} |
| 25 | |
| 26 | ### Alice's wallet |
| 27 | # @name aliceWallet |
| 28 | POST {{baseUrl}}/v1/wallets |
| 29 | Authorization: Bearer {{alice}} |
| 30 | Content-Type: application/json |
| 31 | |
| 32 | {"currency": "USD"} |
| 33 | |
| 34 | ### Five thousand dollars |
| 35 | POST {{baseUrl}}/v1/wallets/{{alicesWallet}}/deposits |
| 36 | Authorization: Bearer {{alice}} |
| 37 | Idempotency-Key: {{$guid}} |
| 38 | Content-Type: application/json |
| 39 | |
| 40 | {"amount": 500000, "currency": "USD"} |
| 41 | |
| 42 | ### Bob signs up |
| 43 | POST {{baseUrl}}/v1/auth/register |
| 44 | Content-Type: application/json |
| 45 | |
| 46 | {"email": "bob@example.com", "password": "{{password}}"} |
| 47 | |
| 48 | ### Bob logs in |
| 49 | # @name bobLogin |
| 50 | POST {{baseUrl}}/v1/auth/login |
| 51 | Content-Type: application/json |
| 52 | |
| 53 | {"email": "bob@example.com", "password": "{{password}}"} |
| 54 | |
| 55 | ### Bob's wallet |
| 56 | # @name bobWallet |
| 57 | POST {{baseUrl}}/v1/wallets |
| 58 | Authorization: Bearer {{bob}} |
| 59 | Content-Type: application/json |
| 60 | |
| 61 | {"currency": "USD"} |
| 62 | |
| 63 | ### Alice pays Bob fifteen dollars |
| 64 | # @name small |
| 65 | POST {{baseUrl}}/v1/transfers |
| 66 | Authorization: Bearer {{alice}} |
| 67 | Idempotency-Key: {{$guid}} |
| 68 | Content-Type: application/json |
| 69 | |
| 70 | {"from": "{{alicesWallet}}", "to": "{{bobsWallet}}", "amount": 1500, "currency": "USD"} |
| 71 | |
| 72 | ### Where is it? |
| 73 | GET {{baseUrl}}{{small.response.headers.Location}} |
| 74 | Authorization: Bearer {{alice}} |
| 75 | |
| 76 | ### Bob pays Alice a dollar, again and again |
| 77 | # @name burst |
| 78 | POST {{baseUrl}}/v1/transfers |
| 79 | Authorization: Bearer {{bob}} |
| 80 | Idempotency-Key: {{$guid}} |
| 81 | Content-Type: application/json |
| 82 | |
| 83 | {"from": "{{bobsWallet}}", "to": "{{alicesWallet}}", "amount": 100, "currency": "USD"} |
| 84 | |
| 85 | ### And the last one? |
| 86 | GET {{baseUrl}}{{burst.response.headers.Location}} |
| 87 | Authorization: Bearer {{bob}} |
| 88 | |
| 89 | ### Alice pays Bob fifteen hundred dollars |
| 90 | # @name big |
| 91 | POST {{baseUrl}}/v1/transfers |
| 92 | Authorization: Bearer {{alice}} |
| 93 | Idempotency-Key: {{$guid}} |
| 94 | Content-Type: application/json |
| 95 | |
| 96 | {"from": "{{alicesWallet}}", "to": "{{bobsWallet}}", "amount": 150000, "currency": "USD"} |
| 97 | |
| 98 | ### Where is the big one? |
| 99 | GET {{baseUrl}}{{big.response.headers.Location}} |
| 100 | Authorization: Bearer {{alice}} |
| 101 | |
| 102 | ### Alice's balance |
| 103 | GET {{baseUrl}}/v1/wallets/{{alicesWallet}}/balance |
| 104 | Authorization: Bearer {{alice}} |
| 105 | |
| 106 | ### Approve it, through the gateway? |
| 107 | POST {{baseUrl}}/internal/transfers/{{big.response.body.id}}/approve |
| 108 | Content-Type: application/json |
| 109 | |
| 110 | {"note": "Called Alice: she's buying Bob's car."} |
| 111 | |
| 112 | ### Dana signs up: she reviews transfers |
| 113 | POST {{baseUrl}}/v1/auth/register |
| 114 | Content-Type: application/json |
| 115 | |
| 116 | {"email": "dana@example.com", "password": "{{password}}"} |
| 117 | |
| 118 | ### Alice pays Bob twelve hundred dollars |
| 119 | # @name big2 |
| 120 | POST {{baseUrl}}/v1/transfers |
| 121 | Authorization: Bearer {{alice}} |
| 122 | Idempotency-Key: {{$guid}} |
| 123 | Content-Type: application/json |
| 124 | |
| 125 | {"from": "{{alicesWallet}}", "to": "{{bobsWallet}}", "amount": 120000, "currency": "USD"} |
| 126 | |
| 127 | ### Where is the second one? |
| 128 | GET {{baseUrl}}{{big2.response.headers.Location}} |
| 129 | Authorization: Bearer {{alice}} |
| 130 | |
| 131 | ### Alice pays Bob twenty dollars |
| 132 | # @name tiny |
| 133 | POST {{baseUrl}}/v1/transfers |
| 134 | Authorization: Bearer {{alice}} |
| 135 | Idempotency-Key: {{$guid}} |
| 136 | Content-Type: application/json |
| 137 | |
| 138 | {"from": "{{alicesWallet}}", "to": "{{bobsWallet}}", "amount": 2000, "currency": "USD"} |
| 139 | |
| 140 | ### And that one? |
| 141 | GET {{baseUrl}}{{tiny.response.headers.Location}} |
| 142 | Authorization: Bearer {{alice}} |