Drupal is a registered trademark of Dries Buytaert

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
1
First release
Jan 2025
Latest release
1 year ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.x-dev Dev Jan 22, 2025