-
Notifications
You must be signed in to change notification settings - Fork 82
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
[PM-13008] Add ldap integration tests #637
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #637 +/- ##
========================================
+ Coverage 2.29% 8.86% +6.57%
========================================
Files 59 60 +1
Lines 2573 2661 +88
Branches 467 475 +8
========================================
+ Hits 59 236 +177
+ Misses 2511 2402 -109
- Partials 3 23 +20 ☔ View full report in Codecov by Sentry. |
New Issues
Fixed Issues
|
Testing based on last modified date is probably too difficult to scale once we start using cloud directory services
src/models/groupEntry.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toJSON
/fromJSON
methods were added as helpers to instantiate the fixture data. It's maybe a bit weird to add this to runtime code, but the Jsonify
type is based on the toJSON
return type, so it was the tidiest and least verbose way to add type safety and factory methods to the fixture data.
beforeEach(() => { | ||
logService = mock(); | ||
i18nService = mock(); | ||
stateService = mock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future refactor: it would be good to remove stateService
from the directory service implementations and pass in their config as arguments instead.
utils/integration-tests/.env
Outdated
@@ -0,0 +1 @@ | |||
COMPOSE_PROJECT_NAME=directory-connector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make more sense to set this in docker-compose.yml
? Docker's documentation says it will take the top level name
value here.
Also, if you're planning to use this as the scaffolding location for local development containers it doesn't make sense to put it in the integration-tests
folder. I do think it's reasonable to put docker-compose.yml
(and .env
if you keep it) in project root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved docker-compose.yml
to the project root as suggested and this automatically set the project name as well.
I realised belatedly that the OpenLDAP Docker image is unmaintained since ~3 years ago: https:/osixia/docker-openldap. I'll look at changing it out for https://hub.docker.com/r/bitnami/openldap, which appears maintained and published by Vmware. Other suggestions are welcome. |
@addisonbeck This is ready for review again:
Once this is merged I will submit separate PRs to remove the docker image from |
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-13008
See the parent ticket https://bitwarden.atlassian.net/browse/PM-13007 for additional context.
📔 Objective
Add integration tests for
LdapDirectoryService
.We don't have any integration tests for our directory services, so this was a bit of trial and error, and is open to feedback about the best way to structure these.
The tests use jest because I still needed a test runner and I wanted to isolate
LdapDirectoryService
from the rest of the app and from the Bitwarden server. The integration is purely between our directory service implementation and the external directory service, which to me is the "here be dragons" part of our code at the moment.This PR uses the OpenLdap docker image that we already recommend for local development. That's ideal because we can spin it up with seed data on demand. Additional integration tests will probably involve actual third party cloud services or Azure VMs which will require more investigation and setup.
Once this is merged I can remove the OpenLdap configuration from the
server
repository and update the contributing docs. It really belongs with this repo.📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes