File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
appengine/standard/logging Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 26
26
<filter >
27
27
<whitelist >
28
28
<file >index.phpfile >
29
+ <file >syslog.phpfile >
29
30
whitelist >
30
31
filter >
31
32
phpunit >
Original file line number Diff line number Diff line change
1
+
2
+
3
+ $ user_is_authorized = !empty ($ _GET ['authorized ' ]);
4
+
5
+ # [START syslog]
6
+ if ($ user_is_authorized ) {
7
+ syslog (LOG_INFO , 'Authorized access ' );
8
+ echo 'true ' ;
9
+ } else {
10
+ syslog (LOG_WARNING , 'Unauthorized access ' );
11
+ echo 'false ' ;
12
+ }
13
+ # [END syslog]
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function testSomeLogs()
61
61
include __DIR__ . '/../index.php ' ;
62
62
$ result = ob_get_contents ();
63
63
ob_end_clean ();
64
- // Make sure it looks like Shakespeare.
64
+
65
65
$ this ->assertContains ('127.0.0.1 ' , $ result );
66
66
$ this ->assertContains ('log-status-1 ' , $ result );
67
67
$ this ->assertContains ('log-method-1 ' , $ result );
@@ -70,4 +70,24 @@ public function testSomeLogs()
70
70
$ this ->assertContains ('applog-message-1 ' , $ result );
71
71
$ this ->assertContains ($ d2 ->format ('c ' ), $ result );
72
72
}
73
+
74
+ public function testSyslog ()
75
+ {
76
+ // not authorized
77
+ ob_start ();
78
+ include __DIR__ . '/../syslog.php ' ;
79
+ $ result = ob_get_contents ();
80
+ ob_end_clean ();
81
+
82
+ $ this ->assertEquals ('false ' , $ result );
83
+
84
+ // authorized
85
+ $ _GET ['authorized ' ] = 1 ;
86
+ ob_start ();
87
+ include __DIR__ . '/../syslog.php ' ;
88
+ $ result = ob_get_contents ();
89
+ ob_end_clean ();
90
+
91
+ $ this ->assertEquals ('true ' , $ result );
92
+ }
73
93
}
You can’t perform that action at this time.
0 commit comments