Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Drush Endpoint

1 sites No security coverage
View on drupal.org

This module exposes Drush commands via a POST endpoint, allowing them to be triggered by automated testing tools like Cypress. It's designed for use cases where Drush cannot be run directly within the testing environment, such as when tests run in a separate container from the web server.

Exposes drush commands so that they can be called with POST.

To be used in automated testing (ie Cypress) when you can't run drush commands, for example when your testing suite runs on a different container than your web server.

Usage

In your Cypress test do a POST request:

cy.request({
  method: 'POST',  // Make sure this is POST
  url: '/api/drush/cron'
});


You can also use cURL from command line for testing:

curl -X POST https://SITENAME.ddev.site/api/drush/cron



Login to a site in a Cypress test

describe('I can login using Drush', () => {
  it('Logs me in', () => {
    // Login
    cy.request({
      method: 'POST',
      url: '/api/drush/uli',
    }).then((response) => {
      expect(response.status).to.eq(200);
      expect(response.body).to.have.property('success', true);

      const uli = response.body.output.trim();

      cy.visit(uli);
      // You are logged in!
    })
  })
})

Requirements

It is assumed that you have a complete understanding of what you are enabling on your site!

There are precautions that make it difficult to run this modules on production, but they will not save you if you intentionally enable it there. So be very careful.

Installation

  • Install as you would normally install a contributed Drupal module. See: https://www.drupal.org/node/895232 for further information.
  • There are no permissions, this is a module oriented to automated testing only. Everything is allowed by default.
  • Allow the module to run, by enabling it in your settings.local.php file:
    // Enable drush_endpoint
    $settings['drush_endpoint_enabled'] = TRUE;
    $settings['drush_endpoint_allow_uli'] = TRUE;
    

NOTE

As you see above, uli commands need that extra line to be enabled.

WARNING

Do not put the above lines in production!

Maintainers

Activity

Total releases
2
First release
Jan 2025
Latest release
1 month ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Release date
1.0.0-rc1 Pre-release Jun 13, 2026
1.0.x-dev Dev Jan 22, 2025