-
Notifications
You must be signed in to change notification settings - Fork 0
Tests #113
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
base: dev
Are you sure you want to change the base?
Tests #113
Conversation
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.
Pull request overview
This PR adds comprehensive test infrastructure for the LDAP gateway project, implementing unit tests, integration tests, and SSSD integration tests. The changes include Jest configuration, test utilities, mock providers, and extensive test coverage for authentication, directory backends, and security features.
Key Changes
- Added Jest test framework configuration for both npm core package and server
- Created test utilities (TestServer, LdapTestClient, dbSeeder, mockLogger)
- Implemented unit tests for utilities, interfaces, and LdapEngine
- Added integration tests for SQL, MongoDB, and Proxmox backends
- Added SSSD integration tests with Docker Compose setup
Reviewed changes
Copilot reviewed 43 out of 44 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| npm/jest.config.js | Jest configuration for core package with coverage thresholds |
| npm/package.json | Added Jest dependencies and test scripts |
| npm/test/unit/utils/*.test.js | Unit tests for ldapUtils, filterUtils, errorUtils |
| npm/test/unit/interfaces/*.test.js | Unit tests for AuthProvider and DirectoryProvider |
| npm/test/unit/LdapEngine.test.js | Unit tests for LDAP engine lifecycle |
| npm/test/fixtures/*.js | Mock providers and shared test data fixtures |
| server/jest.config.js | Jest configuration for server integration tests |
| server/package.json | Added Jest and moved sequelize/sqlite to devDependencies |
| server/test/setup.js | Global test setup for server integration tests |
| server/test/utils/*.js | Test utilities (TestServer, LdapTestClient, dbSeeder, mockLogger) |
| server/test/fixtures/testData.js | Shared test data for integration tests |
| server/test/integration/auth/*.test.js | Auth backend integration tests (SQL, MongoDB, Proxmox) |
| server/test/integration/directory/*.test.js | Directory backend integration tests |
| server/test/integration/engine/*.test.js | Engine-level integration tests |
| server/test/integration/security/*.test.js | TLS policy and security tests |
| server/test/integration-sssd/* | SSSD integration test setup with Docker |
| server/utils/ldapUtils.js | Updated defaults for mail and surname fields |
| server/backends/proxmox.*.js | Added enabled/expire field support |
| server/db/drivers/mongoDb.js | Added connection checks and field normalization |
| npm/src/utils/ldapUtils.js | Support for both mail/email fields and login_shell |
| npm/src/utils/filterUtils.js | Fixed cn= filter handling for groups |
| npm/src/LdapEngine.js | Added cn filtering in mixed search requests |
| .github/workflows/ci.yml | Added MongoDB service and SSSD integration tests |
runleveldev
left a comment
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.
Part 1 review, npm package.
| npm run test:db:mysql # MySQL integration tests | ||
| npm run test:db:postgres # PostgreSQL integration tests | ||
| npm run test:db:mongodb # MongoDB integration tests | ||
| ``` |
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.
All 6 commands listed above are only valid within the server/ directory. This section of the README should either (a) be moved to server/README.md OR (b) reference the fact that the commands are only valid within the server/ directory (such as via a cd command).
| test('should work with all test fixture users', () => { | ||
| testUsers.forEach(user => { | ||
| const entry = createLdapEntry({ | ||
| username: user.username, | ||
| uid_number: user.uid, | ||
| gid_number: user.gidNumber, | ||
| full_name: user.cn, | ||
| last_name: user.sn, | ||
| mail: user.mail, | ||
| home_directory: user.homeDirectory | ||
| }, baseDN); | ||
|
|
||
| expect(entry.dn).toContain(user.username); | ||
| expect(entry.attributes.uid).toBe(user.username); | ||
| expect(entry.attributes.uidNumber).toBe(user.uid); | ||
| }); | ||
| }); |
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 exactly does this test that the previous tests miss? If nothing, remove it. If this tests something specific, be clear about that in the test description.
| expect(entry.attributes.objectClass).toEqual(['posixGroup']); | ||
| expect(entry.attributes.cn).toBe('developers'); | ||
| expect(entry.attributes.gidNumber).toBe(1002); | ||
| expect(entry.attributes.memberUid).toEqual(['alice', 'bob']); |
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.
Just putting this comment here to voice my concern that we don't take a strong stance on memberUid vs. member. We really should pick one and support it based on whichever LDAP schema we're trying to support instead of having to test for all possible combinations. If this is the only comment that goes unaddressed I won't block this PR, but I will file a seperate issue to be more clear about which group style we support.
| test('should work with all test fixture groups', () => { | ||
| testGroups.forEach(group => { | ||
| const entry = createLdapGroupEntry({ | ||
| name: group.cn, | ||
| gid_number: group.gidNumber, | ||
| memberUids: group.memberUids | ||
| }, baseDN); | ||
|
|
||
| expect(entry.dn).toContain(group.cn); | ||
| expect(entry.attributes.cn).toBe(group.cn); | ||
| expect(entry.attributes.gidNumber).toBe(group.gidNumber); | ||
| }); | ||
| }); | ||
| }); |
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.
Again, what is this testing that the other tests don't? Remove it or be clear.
| expect(domain).toBe('company.org'); | ||
| }); | ||
|
|
||
| test('should return localhost for invalid base DN', () => { |
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.
We should throw an error on invalid DN rather than returning a probably wrong result.
| expect(domain).toBe('localhost'); | ||
| }); | ||
|
|
||
| test('should return localhost for empty base DN', () => { |
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.
Empty base would mean empty domain to me. Localhost seems like the wrong default. Or we should throw an error that an empty DN was provided.











Test Infrastructure
Test Coverage
Test Organization