Drupal 8 Behat Apache returns 403

apache
php
php7.1

#1

Dear people, since 2 whole days I’m fighting to get my Behat tests running. But Behat doesn’t seem to find my site in the Circle build. All I get are 403’s on my tests. As I now reached my 100th build https://circleci.com/gh/leymannx/drupal-circleci-behat/100 without successfully setting up Behat, please let me ask for the community’s help here.

Did I miss something? Is there a typo?

circle.yml:

machine:
  timezone:
      Europe/Berlin

  php:
    version: 7.1.3

  hosts:
    ixde.dev: 127.0.0.1

dependencies:
  cache_directories:
    - ~/.composer/cache

  pre:
    - rm /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
    - mysql -u ubuntu -e "create database ix_de"
    - echo "memory_limit = 512M" > /opt/circleci/php/$(phpenv global)/etc/conf.d/memory.ini

    # Restart Apache to pickup new config
    - sudo cp ./circle.conf /etc/apache2/sites-available
    - sudo rm /etc/apache2/mods-enabled/php5.load
    - sudo a2enmod rewrite
    - sudo service apache2 restart
    - sudo a2ensite circle
    - sudo service apache2 reload

  post:
    # Make Composer executables available globally.
    - echo "export PATH=$PATH:$HOME/${CIRCLE_PROJECT_REPONAME}/bin" >> /home/ubuntu/.bashrc
    - source /home/ubuntu/.bashrc

    - cd ./web && drush si standard --db-url=mysql://ubuntu:@127.0.0.1/ix_de --account-name='ubuntu' --account-pass='NO' --site-name=ixde.dev -y
    - cd ./web && drush config-set system.performance css.preprocess 0 -y
    - cd ./web && drush config-set system.performance js.preprocess 0 -y

    - cp ./circle.htaccess $HOME/${CIRCLE_PROJECT_REPONAME}/web/.htaccess

test:
  override:
    - cd ./tests && behat

deployment:
  dev:
    branch: develop
    commands:
      - ssh ix@89.19.229.211 'cd /var/www/html/d8-test/scripts/deploy && . develop.sh'

circle.conf

<VirtualHost *:80>
  LoadModule php7_module /opt/circleci/php/7.1.3/usr/lib/apache2/modules/libphp7.so

  DocumentRoot "/home/ubuntu/drupal-circleci-behat/web"
  ServerName ixde.dev
  ServerAlias *.dev

  <FilesMatch \.php$>
    SetHandler application/x-httpd-php
  </FilesMatch>
</VirtualHost>

behat.yml

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      base_url: http://ixde.dev
      goutte: ~
      selenium2: ~
      browser_name: chrome
    Drupal\DrupalExtension:
      blackbox: ~

Have everything available publicly on GitHub https://github.com/leymannx/drupal-circleci-behat

Here’s a related question on SO: https://stackoverflow.com/q/41059208/2199525

Another related question in the forum:


#2

Got it!!! Last night when I went to bed it suddenly became all clear: Misconfigured Apache!!! I’m going to PR update the docs immediately!!!

Updated circle.conf:

<VirtualHost *:80>
  LoadModule php7_module /opt/circleci/php/7.1.3/usr/lib/apache2/modules/libphp7.so

  DocumentRoot "/home/ubuntu/drupal-circleci-behat/web"
  ServerName ixde.dev
  ServerAlias *.dev

  <FilesMatch \.php$>
    SetHandler application/x-httpd-php
  </FilesMatch>

  <Directory "/home/ubuntu/drupal-circleci-behat/web">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      <IfModule mod_authz_core.c>
          Require all granted
      </IfModule>
      <IfModule !mod_authz_core.c>
          Order allow,deny
          Allow from all
      </IfModule>
  </Directory>

</VirtualHost>

#3