Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions features/COVERAGE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# site-command Behat coverage

Suite for `easyengine/site-command` (the `ee site` command and the html site type, plus `ee site php-compat` on php and wp sites). 20 features, 258 scenarios (298 with outlines expanded): main lane 262, `@wp` 25, `@le` 11. Run it the CI way (`.github/workflows/behat.yml`): the files are copied into a core checkout's `features/` and core's `vendor/bin/behat` runs from the core root as root.
Suite for `easyengine/site-command` (the `ee site` command and the html site type, plus `ee site php-compat` on php and wp sites). 20 features, 259 scenarios (299 with outlines expanded): main lane 263, `@wp` 25, `@le` 11. Run it the CI way (`.github/workflows/behat.yml`): the files are copied into a core checkout's `features/` and core's `vendor/bin/behat` runs from the core root as root.

## Tags

| Tag | Scenarios | Meaning |
|---|---|---|
| (none of the tags below) | 176 | Local only: `*.test` sites, no public DNS, no remote storage, no global restarts. This is the default safe run. The php-compat scenarios pull the scanner image from Docker Hub when it isn't present. |
| (none of the tags below) | 177 | Local only: `*.test` sites, no public DNS, no remote storage, no global restarts. This is the default safe run. The php-compat scenarios pull the scanner image from Docker Hub when it isn't present. |
| `@known-bug` | 0 | Scenarios that expose open bugs are kept outside this suite and come back with their fixes. The CI lanes still exclude the tag. |
| `@destructive` | 12 | Restarts the GLOBAL nginx-proxy (proxy cache) or runs `ssl-renew --all` (refuses to start when an enabled LE site that isn't the suite's exists). Every scenario leaves the proxy running. |
| `@remote` | 10 | Uses the REAL rclone remote (`rclone-path` in config.yml). Touches only `<rclone-path>/bh-site-command-*`: the rclone path is listed first and only listed suite directories are purged (per site before a scenario, all of them after the feature). |
Expand Down Expand Up @@ -264,6 +264,6 @@ Counting the rows above as items: 149 items, 114 covered, 1 partial, 34 not cove

## Known bugs left out

13 scenarios that expose open bugs are not part of this suite; each comes back with the PR that fixes its bug. They cover: the www redirect of a site whose next label starts with `w`, and the redirect after re-enabling a site when the www check fails; the owner lookup of an alias that contains another alias; `update --ssl=inherit` skipping the parent check; the inherit error message dumping the parent site object; the self-signed certificate leaving out alias domains; `ssl-info --get-dns-records` on self-signed sites; `ssl-verify` on a valid Let's Encrypt site; `site reload` exiting 0 when `nginx -t` fails; `site clean` without flags on html sites; invalid `--proxy-cache` values; the removed EE v3 cache flags message; and `update --php` on html sites failing late.
12 scenarios that expose open bugs are not part of this suite; each comes back with the PR that fixes its bug. They cover: the redirect after re-enabling a site when the www check fails; the owner lookup of an alias that contains another alias; `update --ssl=inherit` skipping the parent check; the inherit error message dumping the parent site object; the self-signed certificate leaving out alias domains; `ssl-info --get-dns-records` on self-signed sites; `ssl-verify` on a valid Let's Encrypt site; `site reload` exiting 0 when `nginx -t` fails; `site clean` without flags on html sites; invalid `--proxy-cache` values; the removed EE v3 cache flags message; and `update --php` on html sites failing late.

PRs that change what passing scenarios assert, to revisit when they merge: EasyEngine/site-command#480 keeps `<site>.lock` after a successful backup/restore (drop the two "lock should not exist" lines in backup).
9 changes: 9 additions & 0 deletions features/redirect.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Feature: Site Redirection
When I wait up to 60 seconds for "http://bh-site-command-121.test/" to return 301
Then the response header "Location" should be "http://www.bh-site-command-121.test/"

Scenario: A www site whose next label starts with w redirects the right name
Given the hosts file contains an entry for "w.bh-site-command-125.test"
And the site "www.w.bh-site-command-125.test" does not exist
When I run 'bin/ee site create www.w.bh-site-command-125.test'
Then the command should succeed
And the file "{PROXY_DIR}/conf.d/www.w.bh-site-command-125.test-redirect.conf" should contain "server_name w.bh-site-command-125.test;"
When I wait up to 60 seconds for "http://w.bh-site-command-125.test/" to return 301
Then the response header "Location" should be "http://www.w.bh-site-command-125.test/"

Scenario: No redirect is written when the www name does not resolve here
Given the site "bh-site-command-122.test" does not exist
And the hosts file should not contain an entry for "www.bh-site-command-122.test"
Expand Down
3 changes: 2 additions & 1 deletion src/helper/Site_Letsencrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ public function check( Array $domains, $wildcard = false, $preferred_challenge =
}
} else {
if ( ! $this->repository->hasDomainAuthorizationChallenge( $domain ) ) {
\EE::error( "Domain: $domain not yet authorized/has not been started of with EasyEngine letsencrypt site creation." );
$hint = 'Start a new order with `ee site ssl-renew ' . str_replace( '*.', '', $domains[0] ) . ' --force`.';
\EE::error( "Domain: $domain not yet authorized/has not been started of with EasyEngine letsencrypt site creation. $hint" );
}
$authorizationChallenge = $this->repository->loadDomainAuthorizationChallenge( $domain );
if ( ! $solver->supports( $authorizationChallenge ) ) {
Expand Down
15 changes: 2 additions & 13 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2209,12 +2209,7 @@ private function get_cert_domains( string $site_url, $wildcard, $www_or_non_www
if ( ! empty( $wildcard ) ) {
$domains[] = "*.{$site_url}";
} elseif ( $www_or_non_www || $is_solver_dns ) {
if ( 0 === strpos( $site_url, 'www.' ) ) {
$www_or_non_www_site_url = ltrim( $site_url, 'www.' );
} else {
$www_or_non_www_site_url = 'www.' . $site_url;
}
$domains[] = $www_or_non_www_site_url;
$domains[] = \EE\Site\Utils\get_www_counterpart( $site_url );
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

return $domains;
Expand Down Expand Up @@ -2255,13 +2250,7 @@ protected function check_www_or_non_www_domain( $site_url, $site_path, $site_con
fwrite( $handle, $random_string );
fclose( $handle );

if ( 0 === strpos( $site_url, 'www.' ) ) {
$site_url = ltrim( $site_url, 'www.' );
} else {
$site_url = 'www.' . $site_url;
}

$site_url .= '/' . $check_file;
$site_url = \EE\Site\Utils\get_www_counterpart( $site_url ) . '/' . $check_file;

$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $site_url );
Expand Down
9 changes: 1 addition & 8 deletions src/helper/site-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ function add_site_redirects( string $site_url, bool $ssl, bool $inherit ) {
$fs = new Filesystem();
$confd_path = EE_ROOT_DIR . '/services/nginx-proxy/conf.d/';
$config_file_path = $confd_path . $site_url . '-redirect.conf';
$has_www = strpos( $site_url, 'www.' ) === 0;
$cert_site_name = $site_url;
$ssl_policy = get_ssl_policy();

Expand All @@ -604,16 +603,10 @@ function add_site_redirects( string $site_url, bool $ssl, bool $inherit ) {
$key_file = $certs_dir . $cert_site_name . '.key';

if ( ( $ssl && file_exists( $crt_file ) && file_exists( $key_file ) ) || ! $ssl ) {
if ( $has_www ) {
$server_name = ltrim( $site_url, '.www' );
} else {
$server_name = 'www.' . $site_url;
}

$conf_data = [
'site_name' => $site_url,
'cert_site_name' => $cert_site_name,
'server_name' => $server_name,
'server_name' => get_www_counterpart( $site_url ),
'ssl' => $ssl,
$conf_ssl_policy => true,
];
Expand Down