Skip to content

Commit

Permalink
Merge pull request #268 from thefrontside/cl/ldap-server-start
Browse files Browse the repository at this point in the history
Don't report server started until listener callback is invoked
  • Loading branch information
cowboyd authored Sep 8, 2023
2 parents 955dd7f + b7351c9 commit 63261c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changes/ldap-await-server-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@simulacrum/ldap-simulator": patch
---

Don't resolve `createLDAPServer()` until server is known to be accepting
connections.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
node: circleci/node@4.3.0
node: circleci/node@5.1.0
jobs:
test:
docker:
Expand Down
14 changes: 11 additions & 3 deletions packages/ldap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,23 @@ filter: ${req.filter.toString()}
}
});

server.listen(port, function () {
logger.log(dedent`LDAP test server running on port ${port});
yield new Promise<void>((resolve, reject) => {
server.listen(port, function (err: Error) {
if (err) {
reject(err);
} else {
resolve();
}
});
});

logger.log(dedent`LDAP test server running on port ${port}
BindDN: bindDn = ${bindDn} cn=${bindDn},${baseDN}
Bind Password: ${bindPassword}
UserBaseDN: ${bindDn}
`);
});

yield spawn(function* shutdown() {
try {
Expand Down

0 comments on commit 63261c5

Please sign in to comment.