Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALS Admin Service DELETE API not working as expected #2342

Closed
Tracked by #2343
sri-miriyala opened this issue Jul 9, 2021 · 6 comments
Closed
Tracked by #2343

ALS Admin Service DELETE API not working as expected #2342

sri-miriyala opened this issue Jul 9, 2021 · 6 comments
Assignees
Labels
bug Something isn't working or it has wrong behavior on a Mojaloop Core service oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it
Milestone

Comments

@sri-miriyala
Copy link

sri-miriyala commented Jul 9, 2021

Summary:
The DELETE API in ALS Admin Service is not deleting the required Oracle completely from Switch

Severity:
High

Priority:
Medium

Expected Behavior
After calling the DELETE API to delete a specific oracle id for a type, we should be able to add the same Oracle Type without any issues.

Steps to Reproduce

  1. Get the list of existing Oracles using this command.
curl -L -X GET '<als-admin-serice>/oracles' \
-H 'Content-Type: application/vnd.interoperability.participants+json;version=1.0' \
-H 'Date: Thu, 13 Aug 2020 19:53:11 GMT'
  1. Delete a Oracle type entry using its ID
curl -L -X DELETE '<als-admin-serice>/oracles/<ID>' \
-H 'Content-Type: application/vnd.interoperability.participants+json;version=1.0' \
-H 'Date: Thu, 13 Aug 2020 19:53:11 GMT'
  1. Add the same oracle type again
curl -L -X POST '<als-admin-service>/oracles' \
-H 'Accept: application/vnd.interoperability.participants+json;version=1' \
-H 'Content-Type: application/vnd.interoperability.participants+json;version=1.0' \
-H 'Date;' \

--data-raw '{
  "oracleIdType": "<type>",
  "endpoint": {
    "value": "<value>",
    "endpointType": "URL"
  },
  "currency": "USD",
  "isDefault": true
}'

Specifications

  • Component (if known): ALS service
  • Version: account-lookup-service:v11.2.1
  • Platform:
  • Subsystem: ALS admin
  • Type of testing:
  • Bug found/raised by: Sridevi Miriyala

Notes:

  • Severity when opened: High
  • Priority when opened: High
@sri-miriyala sri-miriyala added the bug Something isn't working or it has wrong behavior on a Mojaloop Core service label Jul 9, 2021
@elnyry-sam-k elnyry-sam-k added the oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it label Jul 9, 2021
@elnyry-sam-k elnyry-sam-k added this to the Sprint 14.6 milestone Jul 9, 2021
@mdebarros mdebarros mentioned this issue Jul 12, 2021
59 tasks
@elnyry-sam-k
Copy link
Member

elnyry-sam-k commented Jul 12, 2021

After a quick review, it looks like the Oracle entries are marked as inactive and not deleted as such, hence the error. To fix - we need to either remove entries when DELETE call is made or 'activate' a disabled oracle if the same entry is retried on POST or use a different key (such as start date) and make every POST request for creating a new oracle a new entry..

@mdebarros
Copy link
Member

mdebarros commented Jul 12, 2021

@elnyry-sam-k, the approach of maintaining a history of oracles could be done as follows:

  • Add a new migration script to reverse the following uniqueness constraints: https://github.com/mojaloop/account-lookup-service/blob/master/migrations/09_oracleEndpoint-indexes.js#L32
  • Add a new Oracle record via the createOracle domain operation with an additional validation check for an existing record match ['partyIdTypeId', 'endpointTypeId', 'currencyId'] if and only if isActive=false. If a record is found with ['partyIdTypeId', 'endpointTypeId', 'currencyId'] AND isActive=true then fail the request with an appropriate error.
  • Update updateOracle domain operation to only allow an oracle to be made active if and only if there is no existing record that matches ['partyIdTypeId', 'endpointTypeId', 'currencyId'] AND isActive=false, otherwise fail the request with an appropriate error.
  • Update the admin-swagger.yaml and admin_swagger.json interface specs to correctly clarify this functionality.

This should allow a "history" of oracles to exists within the Database without impacting the API's functions.

This will also allow the deleteOracle domain operation to function as intended.

@kleyow kleyow self-assigned this Jul 12, 2021
@kleyow
Copy link

kleyow commented Jul 12, 2021

Update updateOracle domain operation to only allow an oracle to be made active if and only if there is no existing record that matches ['partyIdTypeId', 'endpointTypeId', 'currencyId'] AND isActive=false, otherwise fail the request with an appropriate error.

A lot of this isActive logic is confusing and not used from what I'm seeing acting sort of like a private variable in a database?

https://github.com/mojaloop/account-lookup-service/blob/master/src/models/oracle/oracleEndpoint.js#L145 sets an oracle to be active but is never referenced in any src code.

The admin api interface for OracleInfo has no field for passing in any isActive type field so no update/create operations will set it to be true.
I'm not sure how any of the oracles are ever marked isActive=true for the delete operation to ever mark them isActive=false.

Nvm, its a default entry. The tests were giving me the wrong impression.

@kleyow
Copy link

kleyow commented Jul 13, 2021

Update updateOracle domain operation to only allow an oracle to be made active if and only if there is no existing record that matches ['partyIdTypeId', 'endpointTypeId', 'currencyId'] AND isActive=false, otherwise fail the request with an appropriate error.

Can you clarify this comment @mdebarros for me and what problem this solves?

made active

Do you mean setting isActive=true here? If so I don't believe updateOracle domain operation handles the changing of isActive.

@mdebarros
Copy link
Member

mdebarros commented Jul 13, 2021

Correction in bold (although its a bit hard to see):

Update updateOracle domain operation to only allow an oracle to be made active if and only if there is no existing record that matches ['partyIdTypeId', 'endpointTypeId', 'currencyId'] AND isActive=true, otherwise fail the request with an appropriate error.

Can you clarify this comment @mdebarros for me and what problem this solves?

I.e. it means you can only update an existing oracle with isActive=true IFF (if and only if) there is no other oracle with isActive=true with the these matching fields: ['partyIdTypeId', 'endpointTypeId', 'currencyId'].

Does that make more sense?

Do you mean setting isActive=true here? If so I don't believe updateOracle domain operation handles the changing of isActive.

Correct

@elnyry-sam-k
Copy link
Member

@kleyow kleyow closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or it has wrong behavior on a Mojaloop Core service oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it
Projects
None yet
Development

No branches or pull requests

4 participants