summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorEnrico Tagliavini <enrico.tagliavini@gmail.com>2014-01-30 15:42:09 +0000
committerEnrico Tagliavini <enrico.tagliavini@gmail.com>2014-07-12 23:39:17 +0200
commitc42f789c87b115a747a7436d81e7aee886d0ac88 (patch)
treea3b3f35917ee2d23f04c05a2913529fd9b0ebd8b /_test
parent19738e65138f2c83e73e0e8eedf259cd12fdf1c7 (diff)
downloadrpg-c42f789c87b115a747a7436d81e7aee886d0ac88.tar.gz
rpg-c42f789c87b115a747a7436d81e7aee886d0ac88.tar.bz2
Adding unit test for is_ssl()
this should test the correctness of the return value of is_ssl() function based on various combinations of PHP environment variables
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/init_checkssl.test.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/_test/tests/inc/init_checkssl.test.php b/_test/tests/inc/init_checkssl.test.php
new file mode 100644
index 000000000..c57d3c37e
--- /dev/null
+++ b/_test/tests/inc/init_checkssl.test.php
@@ -0,0 +1,81 @@
+<?php
+
+class init_checkssl_test extends DokuWikiTest {
+
+ /**
+ * Running behind an SSL proxy, HTTP between server and proxy
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO
+ * set to https
+ */
+ function test1() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Running behind a plain HTTP proxy, HTTP between server and proxy
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO set to http
+ */
+ function test2() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';
+
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Running behind an SSL proxy, HTTP between server and proxy
+ * HTTPS set to off,
+ * HTTP_X_FORWARDED_PROTO set to https
+ */
+ function test3() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+ $_SERVER['HTTPS'] = 'off';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Not running behind a proxy, HTTPS server
+ * HTTPS set to on,
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test4() {
+ $_SERVER['HTTPS'] = 'on';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Not running behind a proxy, plain HTTP server
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test5() {
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Not running behind a proxy, plain HTTP server
+ * HTTPS set to off
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test6() {
+ $_SERVER['HTTPS'] = 'off';
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Running behind an SSL proxy, SSL between proxy and HTTP server
+ * HTTPS set to on,
+ * HTTP_X_FORWARDED_PROTO set to https
+ */
+ function test7() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+ $_SERVER['HTTPS'] = 'on';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+}