-
Notifications
You must be signed in to change notification settings - Fork 482
made controls parameter optional in client starttls #651
Conversation
Can you explain? You should be able to run |
|
I tried running I will try to clarify my "testing process". Originally, the plan was to make a LDAP server, make a LDAP client, bind with TLS, make one search, and unbind. My setup: Server: The /etc/passwd server example. I added TLS options to the server in Client: A test client that just binds, makes one search, and unbinds. Code mostly copied from Client API. I added I tried to get the client to bind and make a search, but I never got it to bind at all. I still wanted to make sure my committed code worked, so I tested by error.
TL;DR: Before I made changes, ldapjs would give a "TypeError" for omitting the (p.s. sorry for much reading) |
Ugh. you might have to authenticate to pull the image -- https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages . GitHub really needs to make accessing images published to their repos easier.
Unfortunately, we can't commit code based on "I think it works." We need to figure out how to test it either via the unit tests or via the "integration" tests. Ideally, we'd test it via the unit tests. How did you create and load the certificate for your custom LDAP server test? |
|
Thank you for the github docs link. That was exactly what I needed. I was able to run the tests on my code. Everything said PASS or OK. It also told me to run For For
I followed this tutorial: https://www.golinuxcloud.com/configure-openldap-with-tls-certificates/ Server: Client: |
|
So now that you have a working test suite, can you write a test that covers this change? |
|
I tried making 2 subtests:
However, I cannot ever get |
|
Doesn't our Docker container expose a TLS enabled port? |
|
The docker container does expose a TLS port. I have remade the TLS certificates using docker instructions to work with docker. As far as I know, to use starttls, you connect to a regular port first, then run starttls, and starttls will connect to the TLS port. I am still unsure if I have it working properly. The client says the starttls worked. The code I submitted changes how the controls argument is handled. To test that, I think I need the response to be defined. I think the response will contain the controls to test. Here is the test I have written if you want to look at it. I am not experienced with ldapjs or nodejs, so I could be missing something really obvious. The tap.beforeEach((done, t) => {
t.context.clientTLSoptions = {
ca: [fs.readFileSync('/home/hannie/node-ldapjs/dockerTLS/ca.pem')],
key: fs.readFileSync('/home/hannie/node-ldapjs/dockerTLS/key.pem'),
cert: fs.readFileSync('/home/hannie/node-ldapjs/dockerTLS/cert.pem'),
host: '0.0.0.0',
port: 636,
rejectUnauthorized: false
}
const client = ldap.createClient({
url: 'ldap://0.0.0.0:389'
})
t.context.client = client
client.on('connect', () => done())
})
tap.afterEach((done, t) => {
console.log('client._starttls: ' + JSON.stringify(t.context.client._starttls))
t.context.client.unbind(function(err) {
t.error(err, 'testing unbind error')
})
t.context.client.on('close', () => done())
})
tap.test('starttls with control argument', t => {
const control = new Control()
t.context.client.starttls(t.context.clientTLSoptions, control, function(err, res) {
t.error(err, 'testing with control starttls error')
t.ok(res, 'testing with control starttls res')
console.log('res: ' + JSON.stringify(res))
t.end()
})
})
tap.test('starttls without control argument', t => {
t.context.client.starttls(t.context.clientTLSoptions, function(err, res) {
t.error(err, 'testing no control starttls error')
t.ok(res, 'testing no control starttls res')
t.end()
})
}) |
|
👋 On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request. Please see issue #839 for more information, including how to proceed if you feel this closure is in error. |
Regarding #326
Warning: I was unable to properly test this code and confirm it works. I did not actually get TLS to work. I suspect I messed up the certificates somehow.
I only think this code works is because the error messages are different.
Before changes, there was an Object.key assert error - which happens when there are missing arguments (controls).
After changes, there is a "unsupported extended operation" error - which points to TLS certificates not being properly setup (but omitting controls is fine).