update tests to match new is_ssl behaviour
[dokuwiki.git] / _test / tests / inc / init_checkssl.test.php
blobd560b63472d0714f5dc483cac09c877a63c634c8
1 <?php
3 class init_checkssl_test extends DokuWikiTest {
5 /**
6 * Running behind an SSL proxy, HTTP between server and proxy
7 * Proxy (REMOTE_ADDR) is matched by default trustedproxy config regex
8 * HTTPS not set
9 * HTTP_X_FORWARDED_PROTO
10 * set to https
12 function test1a() {
13 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
14 $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
16 $this->assertEquals(is_ssl(), true);
19 /**
20 * Running behind an SSL proxy, HTTP between server and proxy
21 * Proxy (REMOTE_ADDR) is not matched by default trustedproxy config regex
22 * HTTPS not set
23 * HTTP_X_FORWARDED_PROTO
24 * set to https
26 function test1b() {
27 $_SERVER['REMOTE_ADDR'] = '8.8.8.8';
28 $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
30 $this->assertEquals(is_ssl(), false);
33 /**
34 * Running behind a plain HTTP proxy, HTTP between server and proxy
35 * HTTPS not set
36 * HTTP_X_FORWARDED_PROTO set to http
38 function test2() {
39 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
40 $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';
42 $this->assertEquals(is_ssl(), false);
45 /**
46 * Running behind an SSL proxy, HTTP between server and proxy
47 * HTTPS set to off,
48 * HTTP_X_FORWARDED_PROTO set to https
50 function test3() {
51 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
52 $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
53 $_SERVER['HTTPS'] = 'off';
55 $this->assertEquals(is_ssl(), true);
58 /**
59 * Not running behind a proxy, HTTPS server
60 * HTTPS set to on,
61 * HTTP_X_FORWARDED_PROTO not set
63 function test4() {
64 $_SERVER['HTTPS'] = 'on';
66 $this->assertEquals(is_ssl(), true);
69 /**
70 * Not running behind a proxy, plain HTTP server
71 * HTTPS not set
72 * HTTP_X_FORWARDED_PROTO not set
74 function test5() {
75 $this->assertEquals(is_ssl(), false);
78 /**
79 * Not running behind a proxy, plain HTTP server
80 * HTTPS set to off
81 * HTTP_X_FORWARDED_PROTO not set
83 function test6() {
84 $_SERVER['HTTPS'] = 'off';
85 $this->assertEquals(is_ssl(), false);
88 /**
89 * Running behind an SSL proxy, SSL between proxy and HTTP server
90 * HTTPS set to on,
91 * HTTP_X_FORWARDED_PROTO set to https
93 function test7() {
94 $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
95 $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
96 $_SERVER['HTTPS'] = 'on';
98 $this->assertEquals(is_ssl(), true);