From 5216432b6abcf4e3c5206cb4fc845dd185b3aa36 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Mon, 8 Jan 2024 13:52:46 -0700 Subject: [PATCH] [chore] Improve address verification unit tests (#430) - Improve address verification unit tests - Test in all Node versions, only lint + coverage in latest Node version - Lock Chai to 4.3.10 to avoid Node 14+ syntax --- .github/workflows/ci.yml | 25 ++- examples | 2 +- package.json | 2 +- .../recording.har | 40 ++-- .../recording.har | 189 ++++++++++++++++-- .../recording.har | 189 ++++++++++++++++-- .../recording.har | 28 ++- .../recording.har | 30 +-- .../recording.har | 62 +++--- .../recording.har | 60 +++--- test/services/address.test.js | 47 +++-- 11 files changed, 493 insertions(+), 181 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d308c493..3551b5334 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,13 +21,36 @@ jobs: - run: make install - run: make install-styleguide - run: make build + - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make test + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + - run: make install + - run: make install-styleguide + - run: make build + - run: make lint + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + - run: make install + - run: make install-styleguide + - run: make build - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make coverage - name: Coveralls if: github.ref == 'refs/heads/master' uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - - run: make lint docs: if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest diff --git a/examples b/examples index 3d6fafc97..036f84ca8 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 3d6fafc97707ed911794f54b2028e16c0f1c8f91 +Subproject commit 036f84ca892e1ca29bb56edc4574fa0e3095a4b4 diff --git a/package.json b/package.json index 36318849c..b05b3502f 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-export-extensions": "^6.22.0", "babel-preset-minify": "^0.5.2", - "chai": "^4.3.7", + "chai": "4.3.10", "chai-as-promised": "^7.1.1", "cross-env": "^7.0.3", "eslint": "^8.40.0", diff --git a/test/cassettes/Address-Service_1115845720/creates-a-verified-address_2691107999/recording.har b/test/cassettes/Address-Service_1115845720/creates-a-verified-address_2691107999/recording.har index 8ede5af46..a842e6d84 100644 --- a/test/cassettes/Address-Service_1115845720/creates-a-verified-address_2691107999/recording.har +++ b/test/cassettes/Address-Service_1115845720/creates-a-verified-address_2691107999/recording.har @@ -8,11 +8,11 @@ }, "entries": [ { - "_id": "0f02c63dc6dc67aa75b06f913dbaeb3a", + "_id": "d3f7c8162a0cfac62543ef34fcc50549", "_order": 0, "cache": {}, "request": { - "bodySize": 198, + "bodySize": 178, "cookies": [], "headers": [ { @@ -29,7 +29,7 @@ }, { "name": "content-length", - "value": 198 + "value": 178 }, { "name": "host", @@ -42,7 +42,7 @@ "postData": { "mimeType": "application/json", "params": [], - "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"417 montgomery street\",\"street2\":\"FL 5\",\"city\":\"San Francisco\",\"state\":\"CA\",\"zip\":\"94104\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"}}" + "text": "{\"address\":{\"name\":\"Elizabeth Swan\",\"street1\":\"179 N Harbor Dr\",\"city\":\"Redondo Beach\",\"state\":\"CA\",\"zip\":\"90277\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"}}" }, "queryString": [], "url": "https://api.easypost.com/v2/addresses/create_and_verify" @@ -53,7 +53,7 @@ "encoding": "base64", "mimeType": "application/json; charset=utf-8", "size": 572, - "text": "{\"address\":{\"id\":\"adr_0569c2f34cdd11eea3ecac1f6bc53342\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:25+00:00\",\"updated_at\":\"2023-09-06T17:44:25+00:00\",\"name\":null,\"company\":\"EASYPOST\",\"street1\":\"417 MONTGOMERY ST FL 5\",\"street2\":\"\",\"city\":\"SAN FRANCISCO\",\"state\":\"CA\",\"zip\":\"94104-1129\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":37.79342,\"longitude\":-122.40288,\"time_zone\":\"America/Los_Angeles\"}}}}}" + "text": "{\"address\":{\"id\":\"adr_a50e59ccae5a11eeb52eac1f6bc539aa\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:03+00:00\",\"updated_at\":\"2024-01-08T19:18:03+00:00\",\"name\":\"ELIZABETH SWAN\",\"company\":null,\"street1\":\"179 N HARBOR DR\",\"street2\":\"\",\"city\":\"REDONDO BEACH\",\"state\":\"CA\",\"zip\":\"90277-2506\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":33.8436,\"longitude\":-118.39177,\"time_zone\":\"America/Los_Angeles\"}}}}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49864f8ba79e79afe69001cc1fd" + "value": "d1c48c86659c4a6bf4193e0a000e859c" }, { "name": "cache-control", @@ -99,19 +99,15 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_0569c2f34cdd11eea3ecac1f6bc53342" + "value": "/api/v2/addresses/adr_a50e59ccae5a11eeb52eac1f6bc539aa" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, - { - "name": "etag", - "value": "W/\"78c3cc7099d80f1cc2f1857f9df10b56\"" - }, { "name": "x-runtime", - "value": "0.048227" + "value": "0.086980" }, { "name": "content-encoding", @@ -123,23 +119,19 @@ }, { "name": "x-node", - "value": "bigweb32nuq" + "value": "bigweb36nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", "value": "easypost" }, - { - "name": "x-canary", - "value": "direct" - }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -150,14 +142,14 @@ "value": "close" } ], - "headersSize": 838, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_0569c2f34cdd11eea3ecac1f6bc53342", + "redirectURL": "/api/v2/addresses/adr_a50e59ccae5a11eeb52eac1f6bc539aa", "status": 200, "statusText": "OK" }, - "startedDateTime": "2023-09-06T17:44:25.247Z", - "time": 435, + "startedDateTime": "2024-01-08T19:18:03.130Z", + "time": 218, "timings": { "blocked": -1, "connect": -1, @@ -165,7 +157,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 435 + "wait": 218 } } ], diff --git a/test/cassettes/Address-Service_1115845720/creates-an-address-with-an-array-verify-param_1154761701/recording.har b/test/cassettes/Address-Service_1115845720/creates-an-address-with-an-array-verify-param_1154761701/recording.har index 275271a7c..7f27d3895 100644 --- a/test/cassettes/Address-Service_1115845720/creates-an-address-with-an-array-verify-param_1154761701/recording.har +++ b/test/cassettes/Address-Service_1115845720/creates-an-address-with-an-array-verify-param_1154761701/recording.har @@ -8,11 +8,11 @@ }, "entries": [ { - "_id": "12ef59aba162eb318b37eab475cc3656", + "_id": "6e50cdc49421887d92e6937535024603", "_order": 0, "cache": {}, "request": { - "bodySize": 214, + "bodySize": 175, "cookies": [], "headers": [ { @@ -29,7 +29,7 @@ }, { "name": "content-length", - "value": 214 + "value": 175 }, { "name": "host", @@ -42,18 +42,18 @@ "postData": { "mimeType": "application/json", "params": [], - "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"417 montgomery street\",\"street2\":\"FL 5\",\"city\":\"San Francisco\",\"state\":\"CA\",\"zip\":\"94104\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"verify\":[true]}" + "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"}}" }, "queryString": [], "url": "https://api.easypost.com/v2/addresses" }, "response": { - "bodySize": 568, + "bodySize": 400, "content": { "encoding": "base64", "mimeType": "application/json; charset=utf-8", - "size": 568, - "text": "{\"id\":\"adr_03959ed64cdd11eea186ac1f6bc539ae\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:22+00:00\",\"updated_at\":\"2023-09-06T17:44:22+00:00\",\"name\":null,\"company\":\"EASYPOST\",\"street1\":\"417 MONTGOMERY ST FL 5\",\"street2\":\"\",\"city\":\"SAN FRANCISCO\",\"state\":\"CA\",\"zip\":\"94104-1129\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":37.79342,\"longitude\":-122.40288,\"time_zone\":\"America/Los_Angeles\"}}}}" + "size": 400, + "text": "{\"id\":\"adr_a4c7d1b9ae5a11ee8c45ac1f6bc539ae\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:02+00:00\",\"updated_at\":\"2024-01-08T19:18:02+00:00\",\"name\":null,\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"street2\":null,\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49d64f8ba76e79afe62001cc0e0" + "value": "86adb72c659c4a6af409f86a000dc19d" }, { "name": "cache-control", @@ -99,19 +99,168 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_03959ed64cdd11eea186ac1f6bc539ae" + "value": "/api/v2/addresses/adr_a4c7d1b9ae5a11ee8c45ac1f6bc539ae" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, { - "name": "etag", - "value": "W/\"0fb0031e47f4184b4f176ad2137abce4\"" + "name": "x-runtime", + "value": "0.037221" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "x-node", + "value": "bigweb42nuq" + }, + { + "name": "x-version-label", + "value": "easypost-202401051829-4cf193bd35-master" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-proxied", + "value": "intlb1nuq ab82b2e6e9, extlb2nuq 003ad9bca0" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 776, + "httpVersion": "HTTP/1.1", + "redirectURL": "/api/v2/addresses/adr_a4c7d1b9ae5a11ee8c45ac1f6bc539ae", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2024-01-08T19:18:02.685Z", + "time": 183, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 183 + } + }, + { + "_id": "f95960685b21c81e01d6b8b1a49c204f", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 191, + "cookies": [], + "headers": [ + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": 191 + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 390, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"verify\":[true]}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/addresses" + }, + "response": { + "bodySize": 528, + "content": { + "encoding": "base64", + "mimeType": "application/json; charset=utf-8", + "size": 528, + "text": "{\"id\":\"adr_a4e64f3dae5a11eeab12ac1f6bc53342\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:03+00:00\",\"updated_at\":\"2024-01-08T19:18:03+00:00\",\"name\":null,\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"street2\":null,\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":false,\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null}],\"details\":null},\"delivery\":{\"success\":false,\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null}],\"details\":{}}}}" + }, + "cookies": [], + "headers": [ + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "x-ep-request-uuid", + "value": "86adb730659c4a6bf40c07ea000dc1df" + }, + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "location", + "value": "/api/v2/addresses/adr_a4e64f3dae5a11eeab12ac1f6bc53342" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" }, { "name": "x-runtime", - "value": "0.049928" + "value": "0.055389" }, { "name": "content-encoding", @@ -123,11 +272,11 @@ }, { "name": "x-node", - "value": "bigweb38nuq" + "value": "bigweb35nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -135,7 +284,7 @@ }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb2nuq ab82b2e6e9, extlb2nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -146,14 +295,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_03959ed64cdd11eea186ac1f6bc539ae", + "redirectURL": "/api/v2/addresses/adr_a4e64f3dae5a11eeab12ac1f6bc53342", "status": 201, "statusText": "Created" }, - "startedDateTime": "2023-09-06T17:44:22.180Z", - "time": 433, + "startedDateTime": "2024-01-08T19:18:02.874Z", + "time": 196, "timings": { "blocked": -1, "connect": -1, @@ -161,7 +310,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 433 + "wait": 196 } } ], diff --git a/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify-param_348500273/recording.har b/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify-param_348500273/recording.har index fc4f6abab..6b690be75 100644 --- a/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify-param_348500273/recording.har +++ b/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify-param_348500273/recording.har @@ -8,11 +8,11 @@ }, "entries": [ { - "_id": "bddd7e255739ee3a706c228732c30ab2", + "_id": "6e50cdc49421887d92e6937535024603", "_order": 0, "cache": {}, "request": { - "bodySize": 212, + "bodySize": 175, "cookies": [], "headers": [ { @@ -29,7 +29,7 @@ }, { "name": "content-length", - "value": 212 + "value": 175 }, { "name": "host", @@ -42,18 +42,18 @@ "postData": { "mimeType": "application/json", "params": [], - "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"417 montgomery street\",\"street2\":\"FL 5\",\"city\":\"San Francisco\",\"state\":\"CA\",\"zip\":\"94104\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"verify\":true}" + "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"}}" }, "queryString": [], "url": "https://api.easypost.com/v2/addresses" }, "response": { - "bodySize": 568, + "bodySize": 400, "content": { "encoding": "base64", "mimeType": "application/json; charset=utf-8", - "size": 568, - "text": "{\"id\":\"adr_030d50ff4cdd11eea31fac1f6bc53342\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:21+00:00\",\"updated_at\":\"2023-09-06T17:44:21+00:00\",\"name\":null,\"company\":\"EASYPOST\",\"street1\":\"417 MONTGOMERY ST FL 5\",\"street2\":\"\",\"city\":\"SAN FRANCISCO\",\"state\":\"CA\",\"zip\":\"94104-1129\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":37.79342,\"longitude\":-122.40288,\"time_zone\":\"America/Los_Angeles\"}}}}" + "size": 400, + "text": "{\"id\":\"adr_a467662fae5a11eea0fb3cecef1b359e\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:02+00:00\",\"updated_at\":\"2024-01-08T19:18:02+00:00\",\"name\":null,\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"street2\":null,\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49a64f8ba75e79afe49001cc0ae" + "value": "86adb72f659c4a6af41db6d6000dc103" }, { "name": "cache-control", @@ -99,19 +99,168 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_030d50ff4cdd11eea31fac1f6bc53342" + "value": "/api/v2/addresses/adr_a467662fae5a11eea0fb3cecef1b359e" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, { - "name": "etag", - "value": "W/\"2f947448de955b39696d47aee8afade5\"" + "name": "x-runtime", + "value": "0.039951" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "x-node", + "value": "bigweb33nuq" + }, + { + "name": "x-version-label", + "value": "easypost-202401051829-4cf193bd35-master" + }, + { + "name": "x-backend", + "value": "easypost" + }, + { + "name": "x-proxied", + "value": "intlb1nuq ab82b2e6e9, extlb2nuq 003ad9bca0" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 776, + "httpVersion": "HTTP/1.1", + "redirectURL": "/api/v2/addresses/adr_a467662fae5a11eea0fb3cecef1b359e", + "status": 201, + "statusText": "Created" + }, + "startedDateTime": "2024-01-08T19:18:01.988Z", + "time": 248, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 248 + } + }, + { + "_id": "c3e0e1f0cb882294f8a37b62871cf701", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 189, + "cookies": [], + "headers": [ + { + "name": "accept-encoding", + "value": "gzip, deflate" + }, + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": 189 + }, + { + "name": "host", + "value": "api.easypost.com" + } + ], + "headersSize": 390, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"verify\":true}" + }, + "queryString": [], + "url": "https://api.easypost.com/v2/addresses" + }, + "response": { + "bodySize": 532, + "content": { + "encoding": "base64", + "mimeType": "application/json; charset=utf-8", + "size": 532, + "text": "{\"id\":\"adr_a4867934ae5a11ee8c05ac1f6bc539ae\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:02+00:00\",\"updated_at\":\"2024-01-08T19:18:02+00:00\",\"name\":null,\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"street2\":null,\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":false,\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null}],\"details\":null},\"delivery\":{\"success\":false,\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null}],\"details\":{}}}}" + }, + "cookies": [], + "headers": [ + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-xss-protection", + "value": "1; mode=block" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-download-options", + "value": "noopen" + }, + { + "name": "x-permitted-cross-domain-policies", + "value": "none" + }, + { + "name": "referrer-policy", + "value": "strict-origin-when-cross-origin" + }, + { + "name": "x-ep-request-uuid", + "value": "86adb72b659c4a6af3f5a142000dc133" + }, + { + "name": "cache-control", + "value": "private, no-cache, no-store" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "expires", + "value": "0" + }, + { + "name": "location", + "value": "/api/v2/addresses/adr_a4867934ae5a11ee8c05ac1f6bc539ae" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" }, { "name": "x-runtime", - "value": "0.054140" + "value": "0.060393" }, { "name": "content-encoding", @@ -123,11 +272,11 @@ }, { "name": "x-node", - "value": "bigweb42nuq" + "value": "bigweb41nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -135,7 +284,7 @@ }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb2nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -146,14 +295,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_030d50ff4cdd11eea31fac1f6bc53342", + "redirectURL": "/api/v2/addresses/adr_a4867934ae5a11ee8c05ac1f6bc539ae", "status": 201, "statusText": "Created" }, - "startedDateTime": "2023-09-06T17:44:21.298Z", - "time": 427, + "startedDateTime": "2024-01-08T19:18:02.243Z", + "time": 198, "timings": { "blocked": -1, "connect": -1, @@ -161,7 +310,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 427 + "wait": 198 } } ], diff --git a/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify_strict-param_3337987013/recording.har b/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify_strict-param_3337987013/recording.har index 0e1f19b3d..8debbbf38 100644 --- a/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify_strict-param_3337987013/recording.har +++ b/test/cassettes/Address-Service_1115845720/creates-an-address-with-verify_strict-param_3337987013/recording.har @@ -53,7 +53,7 @@ "encoding": "base64", "mimeType": "application/json; charset=utf-8", "size": 568, - "text": "{\"id\":\"adr_035180dc4cdd11eea5a1ac1f6bc539aa\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:22+00:00\",\"updated_at\":\"2023-09-06T17:44:22+00:00\",\"name\":\"ELIZABETH SWAN\",\"company\":null,\"street1\":\"179 N HARBOR DR\",\"street2\":\"\",\"city\":\"REDONDO BEACH\",\"state\":\"CA\",\"zip\":\"90277-2506\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":33.8436,\"longitude\":-118.39177,\"time_zone\":\"America/Los_Angeles\"}}}}" + "text": "{\"id\":\"adr_a4aa1736ae5a11eea14c3cecef1b359e\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:02+00:00\",\"updated_at\":\"2024-01-08T19:18:02+00:00\",\"name\":\"ELIZABETH SWAN\",\"company\":null,\"street1\":\"179 N HARBOR DR\",\"street2\":\"\",\"city\":\"REDONDO BEACH\",\"state\":\"CA\",\"zip\":\"90277-2506\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":33.8436,\"longitude\":-118.39177,\"time_zone\":\"America/Los_Angeles\"}}}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49e64f8ba76e79afe61001cc0c6" + "value": "86adb72d659c4a6af3f96b27000dc16d" }, { "name": "cache-control", @@ -99,19 +99,15 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_035180dc4cdd11eea5a1ac1f6bc539aa" + "value": "/api/v2/addresses/adr_a4aa1736ae5a11eea14c3cecef1b359e" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, - { - "name": "etag", - "value": "W/\"82b6b971cf942baf34ca6ad8edb4c8b1\"" - }, { "name": "x-runtime", - "value": "0.051455" + "value": "0.061846" }, { "name": "content-encoding", @@ -123,11 +119,11 @@ }, { "name": "x-node", - "value": "bigweb40nuq" + "value": "bigweb36nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -135,7 +131,7 @@ }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb2nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -146,14 +142,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_035180dc4cdd11eea5a1ac1f6bc539aa", + "redirectURL": "/api/v2/addresses/adr_a4aa1736ae5a11eea14c3cecef1b359e", "status": 201, "statusText": "Created" }, - "startedDateTime": "2023-09-06T17:44:21.733Z", - "time": 436, + "startedDateTime": "2024-01-08T19:18:02.455Z", + "time": 218, "timings": { "blocked": -1, "connect": -1, @@ -161,7 +157,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 436 + "wait": 218 } } ], diff --git a/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-create-and-verify-an-address_2925377245/recording.har b/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-create-and-verify-an-address_2925377245/recording.har index a5386813c..fb4934ec1 100644 --- a/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-create-and-verify-an-address_2925377245/recording.har +++ b/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-create-and-verify-an-address_2925377245/recording.har @@ -8,11 +8,11 @@ }, "entries": [ { - "_id": "ef7ff5de367e357c15e0ebce1b452d5b", + "_id": "6b5538c75401c8b0c7778e978bfdb8ca", "_order": 0, "cache": {}, "request": { - "bodySize": 33, + "bodySize": 175, "cookies": [], "headers": [ { @@ -29,31 +29,31 @@ }, { "name": "content-length", - "value": 33 + "value": 175 }, { "name": "host", "value": "api.easypost.com" } ], - "headersSize": 407, + "headersSize": 408, "httpVersion": "HTTP/1.1", "method": "POST", "postData": { "mimeType": "application/json", "params": [], - "text": "{\"address\":{\"street1\":\"invalid\"}}" + "text": "{\"address\":{\"company\":\"EasyPost\",\"street1\":\"000 unknown street\",\"city\":\"Not A City\",\"state\":\"ZZ\",\"zip\":\"00001\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"}}" }, "queryString": [], "url": "https://api.easypost.com/v2/addresses/create_and_verify" }, "response": { - "bodySize": 292, + "bodySize": 228, "content": { "encoding": "base64", "mimeType": "application/json; charset=utf-8", - "size": 292, - "text": "{\"error\":{\"code\":\"ADDRESS.VERIFY.FAILURE\",\"message\":\"Unable to verify address.\",\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null},{\"code\":\"E.HOUSE_NUMBER.MISSING\",\"field\":\"street1\",\"message\":\"House number is missing\",\"suggestion\":null}]}}" + "size": 228, + "text": "{\"error\":{\"code\":\"ADDRESS.VERIFY.FAILURE\",\"message\":\"Unable to verify address.\",\"errors\":[{\"code\":\"E.ADDRESS.NOT_FOUND\",\"field\":\"address\",\"message\":\"Address not found\",\"suggestion\":null}]}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49e64f8ba7be79afe85001cc2cb" + "value": "d1c48c86659c4bf4f3f96b87000fdbef" }, { "name": "cache-control", @@ -103,7 +103,7 @@ }, { "name": "x-runtime", - "value": "0.026592" + "value": "0.030286" }, { "name": "content-encoding", @@ -119,7 +119,7 @@ }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -127,7 +127,7 @@ }, { "name": "x-proxied", - "value": "intlb2nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -144,8 +144,8 @@ "status": 422, "statusText": "Unprocessable Entity" }, - "startedDateTime": "2023-09-06T17:44:27.480Z", - "time": 583, + "startedDateTime": "2024-01-08T19:24:36.003Z", + "time": 374, "timings": { "blocked": -1, "connect": -1, @@ -153,7 +153,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 583 + "wait": 374 } } ], diff --git a/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-verify-an-address_2852976208/recording.har b/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-verify-an-address_2852976208/recording.har index 34feda986..6dadae73a 100644 --- a/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-verify-an-address_2852976208/recording.har +++ b/test/cassettes/Address-Service_1115845720/throws-an-error-when-we-cannot-verify-an-address_2852976208/recording.har @@ -48,12 +48,12 @@ "url": "https://api.easypost.com/v2/addresses" }, "response": { - "bodySize": 332, + "bodySize": 336, "content": { "encoding": "base64", "mimeType": "application/json; charset=utf-8", - "size": 332, - "text": "{\"id\":\"adr_063abdc14cdd11eeadbb3cecef1b359e\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:27+00:00\",\"updated_at\":\"2023-09-06T17:44:27+00:00\",\"name\":null,\"company\":null,\"street1\":\"invalid\",\"street2\":null,\"city\":null,\"state\":null,\"zip\":null,\"country\":\"US\",\"phone\":null,\"email\":null,\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" + "size": 336, + "text": "{\"id\":\"adr_8f75bd52ae5b11ee9c23ac1f6bc539ae\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:24:36+00:00\",\"updated_at\":\"2024-01-08T19:24:36+00:00\",\"name\":null,\"company\":null,\"street1\":\"invalid\",\"street2\":null,\"city\":null,\"state\":null,\"zip\":null,\"country\":\"US\",\"phone\":null,\"email\":null,\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49c64f8ba7be79afe83001cc28e" + "value": "d1c48c8b659c4bf4f01fd8f9000fdc18" }, { "name": "cache-control", @@ -99,19 +99,15 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_063abdc14cdd11eeadbb3cecef1b359e" + "value": "/api/v2/addresses/adr_8f75bd52ae5b11ee9c23ac1f6bc539ae" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, - { - "name": "etag", - "value": "W/\"7740c607a33923fb7a8be79a640f44a6\"" - }, { "name": "x-runtime", - "value": "0.032749" + "value": "0.043776" }, { "name": "content-encoding", @@ -123,19 +119,23 @@ }, { "name": "x-node", - "value": "bigweb36nuq" + "value": "bigweb32nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", "value": "easypost" }, + { + "name": "x-canary", + "value": "direct" + }, { "name": "x-proxied", - "value": "intlb2nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -146,14 +146,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 794, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_063abdc14cdd11eeadbb3cecef1b359e", + "redirectURL": "/api/v2/addresses/adr_8f75bd52ae5b11ee9c23ac1f6bc539ae", "status": 201, "statusText": "Created" }, - "startedDateTime": "2023-09-06T17:44:26.631Z", - "time": 422, + "startedDateTime": "2024-01-08T19:24:36.403Z", + "time": 196, "timings": { "blocked": -1, "connect": -1, @@ -161,11 +161,11 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 422 + "wait": 196 } }, { - "_id": "b1cf24f4b3d442b860e37f213e6b6d51", + "_id": "52c2d4081daea0e0880f841dc8fb9b06", "_order": 0, "cache": {}, "request": { @@ -193,7 +193,7 @@ "httpVersion": "HTTP/1.1", "method": "GET", "queryString": [], - "url": "https://api.easypost.com/v2/addresses/adr_063abdc14cdd11eeadbb3cecef1b359e/verify" + "url": "https://api.easypost.com/v2/addresses/adr_8f75bd52ae5b11ee9c23ac1f6bc539ae/verify" }, "response": { "bodySize": 292, @@ -231,7 +231,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49e64f8ba7be79afe84001cc2ab" + "value": "d1c48c8b659c4bf4f41b778c000fdc41" }, { "name": "cache-control", @@ -251,7 +251,7 @@ }, { "name": "x-runtime", - "value": "0.032361" + "value": "0.038722" }, { "name": "content-encoding", @@ -263,23 +263,19 @@ }, { "name": "x-node", - "value": "bigweb32nuq" + "value": "bigweb34nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", "value": "easypost" }, - { - "name": "x-canary", - "value": "direct" - }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb2nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -290,14 +286,14 @@ "value": "close" } ], - "headersSize": 728, + "headersSize": 710, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 422, "statusText": "Unprocessable Entity" }, - "startedDateTime": "2023-09-06T17:44:27.059Z", - "time": 410, + "startedDateTime": "2024-01-08T19:24:36.603Z", + "time": 192, "timings": { "blocked": -1, "connect": -1, @@ -305,7 +301,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 410 + "wait": 192 } } ], diff --git a/test/cassettes/Address-Service_1115845720/verifies-an-address_2951018147/recording.har b/test/cassettes/Address-Service_1115845720/verifies-an-address_2951018147/recording.har index e95e48be1..f0498aab6 100644 --- a/test/cassettes/Address-Service_1115845720/verifies-an-address_2951018147/recording.har +++ b/test/cassettes/Address-Service_1115845720/verifies-an-address_2951018147/recording.har @@ -53,7 +53,7 @@ "encoding": "base64", "mimeType": "application/json; charset=utf-8", "size": 416, - "text": "{\"id\":\"adr_05aeaeb14cdd11eea2c4ac1f6bc539ae\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:26+00:00\",\"updated_at\":\"2023-09-06T17:44:26+00:00\",\"name\":\"Elizabeth Swan\",\"company\":null,\"street1\":\"179 N Harbor Dr\",\"street2\":null,\"city\":\"Redondo Beach\",\"state\":\"CA\",\"zip\":\"90277\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" + "text": "{\"id\":\"adr_a549450bae5a11eea1bf3cecef1b359e\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:03+00:00\",\"updated_at\":\"2024-01-08T19:18:03+00:00\",\"name\":\"Elizabeth Swan\",\"company\":null,\"street1\":\"179 N Harbor Dr\",\"street2\":null,\"city\":\"Redondo Beach\",\"state\":\"CA\",\"zip\":\"90277\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":null,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{}}" }, "cookies": [], "headers": [ @@ -83,7 +83,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49c64f8ba7ae79afe6a001cc22a" + "value": "d1c48c8b659c4a6bf41c7b28000e85fb" }, { "name": "cache-control", @@ -99,19 +99,15 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_05aeaeb14cdd11eea2c4ac1f6bc539ae" + "value": "/api/v2/addresses/adr_a549450bae5a11eea1bf3cecef1b359e" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, - { - "name": "etag", - "value": "W/\"65e2ba92f97e4300eee3e46cfdd12531\"" - }, { "name": "x-runtime", - "value": "0.034909" + "value": "0.052814" }, { "name": "content-encoding", @@ -123,11 +119,11 @@ }, { "name": "x-node", - "value": "bigweb31nuq" + "value": "bigweb36nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -135,7 +131,7 @@ }, { "name": "x-proxied", - "value": "intlb2nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb2nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -146,14 +142,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_05aeaeb14cdd11eea2c4ac1f6bc539ae", + "redirectURL": "/api/v2/addresses/adr_a549450bae5a11eea1bf3cecef1b359e", "status": 201, "statusText": "Created" }, - "startedDateTime": "2023-09-06T17:44:25.692Z", - "time": 442, + "startedDateTime": "2024-01-08T19:18:03.536Z", + "time": 185, "timings": { "blocked": -1, "connect": -1, @@ -161,11 +157,11 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 442 + "wait": 185 } }, { - "_id": "6fb15dd4a3645542dc9759f10297a5ab", + "_id": "3112f68faf24b6d026c703f2262dbe58", "_order": 0, "cache": {}, "request": { @@ -193,7 +189,7 @@ "httpVersion": "HTTP/1.1", "method": "GET", "queryString": [], - "url": "https://api.easypost.com/v2/addresses/adr_05aeaeb14cdd11eea2c4ac1f6bc539ae/verify" + "url": "https://api.easypost.com/v2/addresses/adr_a549450bae5a11eea1bf3cecef1b359e/verify" }, "response": { "bodySize": 572, @@ -201,7 +197,7 @@ "encoding": "base64", "mimeType": "application/json; charset=utf-8", "size": 572, - "text": "{\"address\":{\"id\":\"adr_05f89d8b4cdd11eead9a3cecef1b359e\",\"object\":\"Address\",\"created_at\":\"2023-09-06T17:44:26+00:00\",\"updated_at\":\"2023-09-06T17:44:26+00:00\",\"name\":\"ELIZABETH SWAN\",\"company\":null,\"street1\":\"179 N HARBOR DR\",\"street2\":\"\",\"city\":\"REDONDO BEACH\",\"state\":\"CA\",\"zip\":\"90277-2506\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":33.8436,\"longitude\":-118.39177,\"time_zone\":\"America/Los_Angeles\"}}}}}" + "text": "{\"address\":{\"id\":\"adr_a56d9787ae5a11eeab66ac1f6bc53342\",\"object\":\"Address\",\"created_at\":\"2024-01-08T19:18:04+00:00\",\"updated_at\":\"2024-01-08T19:18:04+00:00\",\"name\":\"ELIZABETH SWAN\",\"company\":null,\"street1\":\"179 N HARBOR DR\",\"street2\":\"\",\"city\":\"REDONDO BEACH\",\"state\":\"CA\",\"zip\":\"90277-2506\",\"country\":\"US\",\"phone\":\"\",\"email\":\"\",\"mode\":\"test\",\"carrier_facility\":null,\"residential\":false,\"federal_tax_id\":null,\"state_tax_id\":null,\"verifications\":{\"zip4\":{\"success\":true,\"errors\":[],\"details\":null},\"delivery\":{\"success\":true,\"errors\":[],\"details\":{\"latitude\":33.8436,\"longitude\":-118.39177,\"time_zone\":\"America/Los_Angeles\"}}}}}" }, "cookies": [], "headers": [ @@ -231,7 +227,7 @@ }, { "name": "x-ep-request-uuid", - "value": "b9d2c49d64f8ba7ae79afe82001cc257" + "value": "d1c48c88659c4a6cf3f7c2ae000e8634" }, { "name": "cache-control", @@ -247,19 +243,15 @@ }, { "name": "location", - "value": "/api/v2/addresses/adr_05f89d8b4cdd11eead9a3cecef1b359e" + "value": "/api/v2/addresses/adr_a56d9787ae5a11eeab66ac1f6bc53342" }, { "name": "content-type", "value": "application/json; charset=utf-8" }, - { - "name": "etag", - "value": "W/\"0d3bd604e150854f75cac6aef6fe83eb\"" - }, { "name": "x-runtime", - "value": "0.084808" + "value": "0.083386" }, { "name": "content-encoding", @@ -271,11 +263,11 @@ }, { "name": "x-node", - "value": "bigweb33nuq" + "value": "bigweb36nuq" }, { "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" + "value": "easypost-202401051829-4cf193bd35-master" }, { "name": "x-backend", @@ -283,7 +275,7 @@ }, { "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" + "value": "intlb1nuq ab82b2e6e9, extlb1nuq 003ad9bca0" }, { "name": "strict-transport-security", @@ -294,14 +286,14 @@ "value": "close" } ], - "headersSize": 820, + "headersSize": 776, "httpVersion": "HTTP/1.1", - "redirectURL": "/api/v2/addresses/adr_05f89d8b4cdd11eead9a3cecef1b359e", + "redirectURL": "/api/v2/addresses/adr_a56d9787ae5a11eeab66ac1f6bc53342", "status": 200, "statusText": "OK" }, - "startedDateTime": "2023-09-06T17:44:26.140Z", - "time": 483, + "startedDateTime": "2024-01-08T19:18:03.728Z", + "time": 405, "timings": { "blocked": -1, "connect": -1, @@ -309,7 +301,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 483 + "wait": 405 } } ], diff --git a/test/services/address.test.js b/test/services/address.test.js index 440e666db..3e633c2c3 100644 --- a/test/services/address.test.js +++ b/test/services/address.test.js @@ -31,13 +31,19 @@ describe('Address Service', function () { it('creates an address with verify param', async function () { const addressData = Fixture.incorrectAddress(); - addressData.verify = true; - const address = await this.client.Address.create(addressData); + // Creating normally (without specifying "verify") will make the address, perform no verifications + let address = await this.client.Address.create(addressData); expect(address).to.be.an.instanceOf(Address); - expect(address.id).to.match(/^adr_/); - expect(address.street1).to.equal('417 MONTGOMERY ST FL 5'); + expect(address.verifications.delivery).to.be.undefined; + + // Creating with verify = true will make the address, perform verifications + addressData.verify = true; + address = await this.client.Address.create(addressData); + + expect(address).to.be.an.instanceOf(Address); + expect(address.verifications.delivery.success).to.be.false; }); it('creates an address with verify_strict param', async function () { @@ -53,13 +59,19 @@ describe('Address Service', function () { it('creates an address with an array verify param', async function () { const addressData = Fixture.incorrectAddress(); - addressData.verify = [true]; - const address = await this.client.Address.create(addressData); + // Creating normally (without specifying "verify") will make the address, perform no verifications + let address = await this.client.Address.create(addressData); expect(address).to.be.an.instanceOf(Address); - expect(address.id).to.match(/^adr_/); - expect(address.street1).to.equal('417 MONTGOMERY ST FL 5'); + expect(address.verifications.delivery).to.be.undefined; + + // Creating with verify = true will make the address, perform verifications + addressData.verify = [true]; + address = await this.client.Address.create(addressData); + + expect(address).to.be.an.instanceOf(Address); + expect(address.verifications.delivery.success).to.be.false; }); it('retrieves an address', async function () { @@ -99,13 +111,22 @@ describe('Address Service', function () { }); it('creates a verified address', async function () { - const addressData = Fixture.incorrectAddress(); + const addressData = Fixture.caAddress2(); const address = await this.client.Address.createAndVerify(addressData); expect(address).to.be.an.instanceOf(Address); expect(address.id).to.match(/^adr_/); - expect(address.street1).to.equal('417 MONTGOMERY ST FL 5'); + expect(address.street1).to.equal('179 N HARBOR DR'); + }); + + it('throws an error when we cannot create and verify an address', async function () { + const addressData = Fixture.incorrectAddress(); + + // Creates with verify = true behind the scenes, will throw an error if the address cannot be verified + return this.client.Address.createAndVerify(addressData).catch((err) => + expect(err).to.be.an.instanceOf(InvalidRequestError), + ); }); it('verifies an address', async function () { @@ -124,10 +145,4 @@ describe('Address Service', function () { expect(err).to.be.an.instanceOf(InvalidRequestError), ); }); - - it('throws an error when we cannot create and verify an address', async function () { - return this.client.Address.createAndVerify({ street1: 'invalid' }).catch((err) => - expect(err).to.be.an.instanceOf(InvalidRequestError), - ); - }); });