Skip to content

Commit

Permalink
Fix: when deleting a user, send the customer type if available in the…
Browse files Browse the repository at this point in the history
… json (#101)

### What

When deleting a user, send the customer `type` if available in the customerToBeDeleted JSON.

### Why

To be compliant with SEP-12, where it says:

```text
Therefore it is recommended to always pass the `type` parameter when making requests to `GET /customer` or `PUT /customer`, even though the field is optional to accommodate for implementations that do not require type.
```

Some partners implementations require the type to be not empty, based on the statement above.
  • Loading branch information
marcelosalloum authored Oct 4, 2022
1 parent f74eda4 commit b5db9c3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion @stellar/anchor-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/anchor-tests",
"version": "0.5.4",
"version": "0.5.5",
"description": "stellar-anchor-tests is a library and command line interface for testing Stellar anchors.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
17 changes: 13 additions & 4 deletions @stellar/anchor-tests/src/tests/sep12/deleteCustomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const canDeleteCustomer: Test = {
"SEP-12 configuration data missing, expected 'deleteCustomer' in 'customers'",
);
}
const customerToBeDeleted =
config.sepConfig["12"].customers[config.sepConfig["12"].deleteCustomer];

// PUT the customer
const putCustomerCall = {
request: new Request(this.context.expects.kycServerUrl + "/customer", {
method: "PUT",
Expand All @@ -89,9 +93,7 @@ const canDeleteCustomer: Test = {
},
body: JSON.stringify({
account: clientKeypair.publicKey(),
...config.sepConfig["12"].customers[
config.sepConfig["12"].deleteCustomer
],
...customerToBeDeleted,
}),
}),
};
Expand All @@ -103,10 +105,15 @@ const canDeleteCustomer: Test = {
);
result.networkCalls.push(putCustomerCall);
if (!putCustomerBody) return result;

// GET the customer
const typeQueryParam = customerToBeDeleted.type
? `&type=${customerToBeDeleted.type}`
: "";
const getCustomerCall: NetworkCall = {
request: new Request(
this.context.expects.kycServerUrl +
`/customer?account=${clientKeypair.publicKey()}`,
`/customer?account=${clientKeypair.publicKey()}${typeQueryParam}`,
{
headers: {
Authorization: `Bearer ${token}`,
Expand All @@ -117,6 +124,8 @@ const canDeleteCustomer: Test = {
result.networkCalls.push(getCustomerCall);
await makeRequest(getCustomerCall, 200, result);
if (result.failure) return result;

// DELETE the customer
const deleteCustomerCall: NetworkCall = {
request: new Request(
this.context.expects.kycServerUrl +
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This changelog documents all releases and included changes to the @stellar/ancho

A breaking change will get clearly marked in this log.

## [v0.5.5](https://github.com/stellar/stellar-anchor-tests/compare/v0.5.4...v0.5.5)

### Fix

- When deleting a user, send the customer type if available in the json body ([#101](https://github.com/stellar/stellar-anchor-tests/pull/101)).

## [v0.5.4](https://github.com/stellar/stellar-anchor-tests/compare/v0.5.3...v0.5.4)

### Update
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@types/node": "^14.14.41",
"@stellar/anchor-tests": "0.5.2",
"@stellar/anchor-tests": "0.5.5",
"express": "^4.17.1",
"socket.io": "^4.1.2",
"tslib": "^2.2.0",
Expand Down

0 comments on commit b5db9c3

Please sign in to comment.