diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-20 11:47:07 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-20 11:47:07 +0200 |
commit | b38a1b0209f546d4824a0db81a34c4e30fcdebaf (patch) | |
tree | 0f812cd69bfc0ba654ce0d4b832850b41cc658fa /tests/UtilsTest.php | |
parent | ca5e98da4867f720dc863dac55cd1fa2360068e7 (diff) | |
download | Shaarli-b38a1b0209f546d4824a0db81a34c4e30fcdebaf.tar.gz Shaarli-b38a1b0209f546d4824a0db81a34c4e30fcdebaf.tar.zst Shaarli-b38a1b0209f546d4824a0db81a34c4e30fcdebaf.zip |
Use PSR-3 logger for login attempts
Fixes #1122
Diffstat (limited to 'tests/UtilsTest.php')
-rw-r--r-- | tests/UtilsTest.php | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 6e787d7f..59dca75f 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php | |||
@@ -63,41 +63,25 @@ class UtilsTest extends \Shaarli\TestCase | |||
63 | } | 63 | } |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Log a message to a file - IPv4 client address | 66 | * Format a log a message - IPv4 client address |
67 | */ | 67 | */ |
68 | public function testLogmIp4() | 68 | public function testFormatLogIp4() |
69 | { | 69 | { |
70 | $logMessage = 'IPv4 client connected'; | 70 | $message = 'IPv4 client connected'; |
71 | logm(self::$testLogFile, '127.0.0.1', $logMessage); | 71 | $log = format_log($message, '127.0.0.1'); |
72 | list($date, $ip, $message) = $this->getLastLogEntry(); | ||
73 | 72 | ||
74 | $this->assertInstanceOf( | 73 | static::assertSame('- 127.0.0.1 - IPv4 client connected', $log); |
75 | 'DateTime', | ||
76 | DateTime::createFromFormat(self::$dateFormat, $date) | ||
77 | ); | ||
78 | $this->assertTrue( | ||
79 | filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false | ||
80 | ); | ||
81 | $this->assertEquals($logMessage, $message); | ||
82 | } | 74 | } |
83 | 75 | ||
84 | /** | 76 | /** |
85 | * Log a message to a file - IPv6 client address | 77 | * Format a log a message - IPv6 client address |
86 | */ | 78 | */ |
87 | public function testLogmIp6() | 79 | public function testFormatLogIp6() |
88 | { | 80 | { |
89 | $logMessage = 'IPv6 client connected'; | 81 | $message = 'IPv6 client connected'; |
90 | logm(self::$testLogFile, '2001:db8::ff00:42:8329', $logMessage); | 82 | $log = format_log($message, '2001:db8::ff00:42:8329'); |
91 | list($date, $ip, $message) = $this->getLastLogEntry(); | ||
92 | 83 | ||
93 | $this->assertInstanceOf( | 84 | static::assertSame('- 2001:db8::ff00:42:8329 - IPv6 client connected', $log); |
94 | 'DateTime', | ||
95 | DateTime::createFromFormat(self::$dateFormat, $date) | ||
96 | ); | ||
97 | $this->assertTrue( | ||
98 | filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false | ||
99 | ); | ||
100 | $this->assertEquals($logMessage, $message); | ||
101 | } | 85 | } |
102 | 86 | ||
103 | /** | 87 | /** |