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

clean up logic for removing creds on delete user #862

Merged
merged 12 commits into from
Jan 6, 2019

Conversation

mfrye
Copy link
Contributor

@mfrye mfrye commented Jan 2, 2019

The problem with the current logic is that the Redis Set containing the credentials isn't deleted on user delete. So when deleting the user and user owned credentials, the set still exists.

@mfrye
Copy link
Contributor Author

mfrye commented Jan 2, 2019

@XVincentX could you take a look at this one? This bug is the last thing that's blocking us from deploying this.

@XVincentX
Copy link
Member

I need to find some bandwidth but yeah I'll look into //cc @altsang

@mfrye
Copy link
Contributor Author

mfrye commented Jan 2, 2019

I'm open to other ideas on the optional parameter I included. I figured there might be a case where you'd want to delete all credentials, but still keep the user "container".

@codecov
Copy link

codecov bot commented Jan 2, 2019

Codecov Report

Merging #862 into master will increase coverage by 0.05%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
+ Coverage   89.29%   89.34%   +0.05%     
==========================================
  Files         132      132              
  Lines        3633     3642       +9     
==========================================
+ Hits         3244     3254      +10     
+ Misses        389      388       -1
Impacted Files Coverage Δ
lib/services/credentials/credential.dao.js 98.23% <100%> (+1.06%) ⬆️
lib/services/consumers/user.service.js 89.69% <75%> (+0.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a64ca42...76d87f0. Read the comment docs.

@mfrye
Copy link
Contributor Author

mfrye commented Jan 2, 2019

Separate bug... Looks like the keys also still exist under each scope as well.

Copy link
Member

@XVincentX XVincentX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spending your time on this.

At first glance, it looks good. I'll pull down your branch and verify everything is in order. It's going to require some wore work though — this code is currently untested (Codecov is indeed complaining).

Would you be willing to complete the testing phase too?

lib/services/credentials/credential.dao.js Outdated Show resolved Hide resolved
lib/services/credentials/credential.dao.js Outdated Show resolved Hide resolved
lib/services/credentials/credential.dao.js Outdated Show resolved Hide resolved
@XVincentX
Copy link
Member

Also — can you revert the package-lock.json changes?

Sounds good. For context, I'm used to Typescript these days and defining the type, which requires the extra parentheses.

So:

```
const awaitAllPromises = credentialTypes.map((type: Credential) => {
```

Co-Authored-By: mfrye <michael@michaelfrye.me>
@mfrye
Copy link
Contributor Author

mfrye commented Jan 3, 2019

Yes on the package-lock and your other recommended changes.

Where should the tests be added for this? The code coverage % is still going to be below your threshold even if I add tests for this.

@XVincentX
Copy link
Member

Where should the tests be added for this? The code coverage % is still going to be below your threshold even if I add tests for this.

Yeah good point. The problem is that sometimes Codecov reveals areas that have never been tested, thous reporting something wrong with the coverage. Add the tests you feel are useful and I'll check that out for you later and integrate in case it's needed.

P.S: Nowadays I'm using Typescript too. I have opinions on it :)

Copy link
Member

@XVincentX XVincentX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left couple of other comments here and there. It seems like Codecov is now happy with the coverage, but still we need to write some tests. I'll try to point you towards the right direction.

lib/services/credentials/credential.dao.js Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
lib/services/credentials/credential.dao.js Show resolved Hide resolved
lib/services/credentials/credential.dao.js Outdated Show resolved Hide resolved
@mfrye
Copy link
Contributor Author

mfrye commented Jan 3, 2019

@XVincentX I attempted to add a test to test/services/credential-service/credentials.test.js. I'm not sure what happened though as it ended up blowing up other unrelated tests...

I can try to look at this again, but I really don't have a ton of time to spend on this if it's going to be a bigger refactor.

@XVincentX
Copy link
Member

Do not worry, leave the tests to me and I'll figure this out.

@mfrye
Copy link
Contributor Author

mfrye commented Jan 5, 2019

Cool, thanks.

@XVincentX
Copy link
Member

XVincentX commented Jan 5, 2019

@mfrye Thanks a lot for the contribution. Writing the tests ended up being a little bit more difficult than anticipated because of the horrible state of some parts of the codebase.

This is going to require some other work on my side.

@XVincentX XVincentX merged commit c3ae18f into ExpressGateway:master Jan 6, 2019
@mfrye
Copy link
Contributor Author

mfrye commented Jan 6, 2019

@XVincentX awesome. Thanks for fast tracking this.

gatherchou pushed a commit to yilu-tech/express-gateway that referenced this pull request Jul 29, 2021
clean up logic for removing creds on delete user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants