chore: migrate ldap endpoints to new API pattern

Merged
SM
7mo ago
+73-43

Summary

Migrates the ldap.testConnection and ldap.testSearch POST endpoints from the legacy API.v1.addRoute() pattern to the new chained .post() API pattern.

Changes

  • Replaced addRoute calls with API.v1.post() chained pattern
  • Added typed AJV response schemas for 200, 401, and 403 responses
  • Replaced Meteor check() with AJV validation: ldap.testSearch now uses the existing isLdapTestSearch AJV validator from @rocket.chat/rest-typings via validateParams instead of check(this.bodyParams, Match.ObjectIncluding({...}))
  • Shared messageResponseSchema for both endpoints' response validation
  • Removed meteor/check import dependency
  • Preserved all existing behavior: permission checks, LDAP enable checks, error logging

Motivation

Part of the ongoing effort to migrate REST API endpoints to the new chained API pattern that enables typed response validation and future OpenAPI spec generation. This PR additionally removes a Meteor check() dependency in favor of AJV validation.

Closes part of #38876

Summary by CodeRabbit

  • Refactor
    • LDAP test endpoints migrated to a new API pattern with stricter input validation.
    • Standardized success payloads (message + success) and consistent error responses for predictable client behavior.
    • Authentication and permission checks are now enforced for these endpoints.
    • Search and connection test actions centrally handle errors while preserving visible success messages.

Task: ARCH-2007
[COMM-144]