Commit 9d75b08
Fix OpenLDAP custom queries to use search_scope parameter (#21385)
* Fix OpenLDAP custom queries to use search_scope parameter
- Add support for search_scope parameter in custom queries
- Default to 'subtree' when search_scope is not specified
- Update existing tests to include search_scope parameter
- Add comprehensive test for search_scope functionality
Fixes #20685
* Add changelog entry for search_scope parameter fix
* Simplify search_scope test to avoid CI issues
* Fix code formatting for linting compliance
* Fix search_scope to use ldap3 constants instead of strings
LDAP3 library requires constants (ldap3.BASE, ldap3.LEVEL, ldap3.SUBTREE)
instead of string values for search_scope parameter.
* Fix trailing whitespace for linting compliance
* Address reviewer feedback: use mapping dict and improve error handling
- Add SEARCH_SCOPE_MAPPING class constant for efficient lookups
- Change invalid scope handling from warning+fallback to error+skip
- Add comprehensive parameterized tests for all valid values
- Add tests for default behavior and invalid value handling
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
* Use DEFAULT_SEARCH_SCOPE constant instead of hardcoded values
- Replace hardcoded 'subtree' with DEFAULT_SEARCH_SCOPE in main code
- Replace ldap3.SUBTREE with DEFAULT_SEARCH_SCOPE in all tests
- Ensures centralized management of default search scope value
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
* Fix code formatting for linting compliance
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
* Fix import sorting in OpenLDAP test files
Organize imports in test files to comply with ruff linting rules:
- tests/conftest.py: Sort imports alphabetically
- tests/test_check.py: Sort imports alphabetically
- tests/test_unit.py: Sort imports alphabetically
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
* Fix import formatting for linting compliance
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
* Run ddev test --fmt openldap to fix linting issues
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
---------
Signed-off-by: puretension <rlrlfhtm5@gmail.com>
Co-authored-by: Juanpe Araque <juanpedro.araque@datadoghq.com>1 parent 986f378 commit 9d75b08
File tree
3 files changed
+116
-3
lines changed- openldap
- changelog.d
- datadog_checks/openldap
- tests
3 files changed
+116
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
158 | 173 | | |
159 | 174 | | |
160 | 175 | | |
| |||
181 | 196 | | |
182 | 197 | | |
183 | 198 | | |
184 | | - | |
| 199 | + | |
185 | 200 | | |
186 | 201 | | |
187 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
255 | 352 | | |
256 | 353 | | |
257 | 354 | | |
| |||
0 commit comments