Security, Site Health: Improve accuracy in messaging about HTTPS support.

Following up on [49904], this changeset focuses mainly on improving the guidance about the current state of HTTPS in Site Health.

* Correct the existing copy to indicate that both the Site Address and the WordPress Address need to be changed to fully switch to HTTPS.
* Link to the respective input fields via anchor links rather than to the overall General Settings screen.
* Show different copy if the site is using HTTPS for the WordPress Address (for example to have only the administration panel in HTTPS), but not for the Site Address.
* Inform the user about potential problems even when the site is already using HTTPS, for example if the SSL certificate was no longer valid.
* Always rely on fresh information for determining HTTPS support issues in Site Health, and therefore change the `https_status` test to become asynchronous.
* Rename the new private `wp_is_owned_html_output()` function to a more appropriate `wp_is_local_html_output()`.

Props adamsilverstein, flixos90, johnjamesjacoby, timothyblynjacobs.
See #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@50072 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2021-01-29 19:09:49 +00:00
parent b44dd453ed
commit 4e0bc3bc93
6 changed files with 189 additions and 49 deletions

View File

@@ -141,88 +141,88 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
/**
* @ticket 47577
*/
public function test_wp_is_owned_html_output_via_rsd_link() {
public function test_wp_is_local_html_output_via_rsd_link() {
// HTML includes RSD link.
$head_tag = get_echo( 'rsd_link' );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes modified RSD link but same URL.
$head_tag = str_replace( ' />', '>', get_echo( 'rsd_link' ) );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML does not include RSD link.
$html = $this->get_sample_html_string();
$this->assertFalse( wp_is_owned_html_output( $html ) );
$this->assertFalse( wp_is_local_html_output( $html ) );
}
/**
* @ticket 47577
*/
public function test_wp_is_owned_html_output_via_wlwmanifest_link() {
public function test_wp_is_local_html_output_via_wlwmanifest_link() {
remove_action( 'wp_head', 'rsd_link' );
// HTML includes WLW manifest link.
$head_tag = get_echo( 'wlwmanifest_link' );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes modified WLW manifest link but same URL.
$head_tag = str_replace( ' />', '>', get_echo( 'wlwmanifest_link' ) );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes WLW manifest link with alternative URL scheme.
$head_tag = get_echo( 'wlwmanifest_link' );
$head_tag = false !== strpos( $head_tag, 'https://' ) ? str_replace( 'https://', 'http://', $head_tag ) : str_replace( 'http://', 'https://', $head_tag );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML does not include WLW manifest link.
$html = $this->get_sample_html_string();
$this->assertFalse( wp_is_owned_html_output( $html ) );
$this->assertFalse( wp_is_local_html_output( $html ) );
}
/**
* @ticket 47577
*/
public function test_wp_is_owned_html_output_via_rest_link() {
public function test_wp_is_local_html_output_via_rest_link() {
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
// HTML includes REST API link.
$head_tag = get_echo( 'rest_output_link_wp_head' );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes modified REST API link but same URL.
$head_tag = str_replace( ' />', '>', get_echo( 'rest_output_link_wp_head' ) );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML includes REST API link with alternative URL scheme.
$head_tag = get_echo( 'rest_output_link_wp_head' );
$head_tag = false !== strpos( $head_tag, 'https://' ) ? str_replace( 'https://', 'http://', $head_tag ) : str_replace( 'http://', 'https://', $head_tag );
$html = $this->get_sample_html_string( $head_tag );
$this->assertTrue( wp_is_owned_html_output( $html ) );
$this->assertTrue( wp_is_local_html_output( $html ) );
// HTML does not include REST API link.
$html = $this->get_sample_html_string();
$this->assertFalse( wp_is_owned_html_output( $html ) );
$this->assertFalse( wp_is_local_html_output( $html ) );
}
/**
* @ticket 47577
*/
public function test_wp_is_owned_html_output_cannot_determine() {
public function test_wp_is_local_html_output_cannot_determine() {
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'rest_output_link_wp_head' );
// The HTML here doesn't matter because all hooks are removed.
$html = $this->get_sample_html_string();
$this->assertNull( wp_is_owned_html_output( $html ) );
$this->assertNull( wp_is_local_html_output( $html ) );
}
public function record_request_url( $preempt, $parsed_args, $url ) {