From a3130d2c2f27052710d4dbd51d0001190b19b383 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 25 Aug 2017 19:47:57 +0200 Subject: Make work behind a reverse proxy Without HTTP_X_FORWARDED_PORT check, might be set to false even though the user is using HTTPS, thus disabling Firefox Social block display --- tests/HttpUtils/IsHttpsTest.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/HttpUtils/IsHttpsTest.php (limited to 'tests') diff --git a/tests/HttpUtils/IsHttpsTest.php b/tests/HttpUtils/IsHttpsTest.php new file mode 100644 index 00000000..097f2bcf --- /dev/null +++ b/tests/HttpUtils/IsHttpsTest.php @@ -0,0 +1,36 @@ +assertTrue(is_https(['HTTPS' => true])); + $this->assertTrue(is_https(['HTTPS' => '1'])); + $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => 443])); + $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '443'])); + $this->assertTrue(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '443,123,456,'])); + } + + /** + * Test is_https with HTTP values. + */ + public function testIsHttpsFalse() + { + $this->assertFalse(is_https([])); + $this->assertFalse(is_https(['HTTPS' => false])); + $this->assertFalse(is_https(['HTTPS' => '0'])); + $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => 123])); + $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => '123'])); + $this->assertFalse(is_https(['HTTPS' => false, 'HTTP_X_FORWARDED_PORT' => ',123,456,'])); + } +} -- cgit v1.2.3