DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

[Bug] records not being deleted in emulator mode #640

Closed cheesegrits closed 4 months ago

cheesegrits commented 4 months ago

Environment:

In my test suite, using in-memory emulator mode, it seems that model delete() doesn't delete. But if I switch to file on disk mode, it does delete.

Unfortunately I don't have a test repo I can share, as it's a private project.

Any ideas? I've stepped thru the code, and it does all the right things, should be deleting. But I can then search for and find the record again.

stevebauman commented 4 months ago

Hey @cheesegrits,

LdapRecord-Laravel is using the in-memory SQLite driver for testing as well and tests are passing when ensuring models are deleted from the test database:

https://github.com/DirectoryTree/LdapRecord-Laravel/blob/5b6d13fdd65eafc79b2c53cb5a3e052e970540ae/tests/Feature/Emulator/EmulatedModelQueryTest.php#L121-L135

Can you share some code? Without any replication steps or code, there isn't really any ideas I have since I can't reproduce it, and tests are passing.

cheesegrits commented 4 months ago

Hey @stevebauman, thanks for the quick response.

Hmm, seems like it may not be as clear cut as in-memory vs on-disk.

Could I possibly convert this to a "support" issue? I'm a Business Class sponsor (via my business partner Robbie Adair) which I think gets me the extra leg room, champagne and a Zoom call. The only way I can really show you what's going on is via some kind of conferencing. I'm hoping you could spot something stupid I'm doing.

I wouldn't usually bug you about stuff, but I've been banging my head on this for a solid 6 hours, still no closer to figuring out what is going on.

cheesegrits commented 4 months ago

Oh, just FYI, I realized the sponsorship will probably show up as "Mediaateam" rather than Robbie's personal account.

stevebauman commented 4 months ago

@cheesegrits Sure thing! I could meet tonight at 6 PM EST or we could do tomorrow if that works -- let me know! 👍

cheesegrits commented 4 months ago

@stevebauman 6pm EST today would work for me.

I'll drop you an email.

stevebauman commented 4 months ago

Sounds good! Talk to you then 👍

cheesegrits commented 4 months ago

@stevebauman

Thanks for the support today. It was indeed my code. I have a method that manages the "dummy user" that I add to all groups (which only exists in LDAP, so never gets removed for the life of the LDAP server), so I don't have to worry about removing the last "real" user from a group (which OpenLDAP doesn't allow in groupOfNames). That gets called from within my findOrCreateGroup() method ... but then in the findOrCreateDummyUser() method, if the dummy user doesn't exists, as part of creating it I was adding it to all groups ... which calls findOrCreateGroup() on all channels. So yeah ... the LDAP group got added twice.

Ironically, it's a situation which can only occur during testing, when the dummy user doesn't exist when I create the first channel. In production the dummy user gets created as part of the LDAP container setup, so the offending code never ran.

Anyway ... thank you so much for your time.

I'll close this one.

stevebauman commented 4 months ago

Awesome @cheesegrits, glad you were able to figure it out!

Thanks for posting an update and closing the issue out 🙏