Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions tests/lib/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function write(string $app, $message, int $level) {
$this->logs[]= "$level $message";
}

public function userAndPasswordData() {
public function userAndPasswordData(): array {
return [
['mySpecialUsername', 'MySuperSecretPassword'],
['my-user', '324324()#ä234'],
Expand All @@ -87,7 +87,7 @@ public function userAndPasswordData() {
/**
* @dataProvider userAndPasswordData
*/
public function testDetectlogin($user, $password) {
public function testDetectlogin(string $user, string $password): void {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -100,16 +100,16 @@ public function testDetectlogin($user, $password) {
if (is_array($logLine)) {
$logLine = json_encode($logLine);
}
$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('*** sensitive parameters replaced ***', $logLine);
$this->assertStringNotContainsString($user, $logLine);
$this->assertStringNotContainsString($password, $logLine);
$this->assertStringContainsString('*** sensitive parameters replaced ***', $logLine);
}
}

/**
* @dataProvider userAndPasswordData
*/
public function testDetectcheckPassword($user, $password) {
public function testDetectcheckPassword(string $user, string $password): void {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -122,16 +122,16 @@ public function testDetectcheckPassword($user, $password) {
if (is_array($logLine)) {
$logLine = json_encode($logLine);
}
$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('*** sensitive parameters replaced ***', $logLine);
$this->assertStringNotContainsString($user, $logLine);
$this->assertStringNotContainsString($password, $logLine);
$this->assertStringContainsString('*** sensitive parameters replaced ***', $logLine);
}
}

/**
* @dataProvider userAndPasswordData
*/
public function testDetectvalidateUserPass($user, $password) {
public function testDetectvalidateUserPass(string $user, string $password): void {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -144,16 +144,16 @@ public function testDetectvalidateUserPass($user, $password) {
if (is_array($logLine)) {
$logLine = json_encode($logLine);
}
$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('*** sensitive parameters replaced ***', $logLine);
$this->assertStringNotContainsString($user, $logLine);
$this->assertStringNotContainsString($password, $logLine);
$this->assertStringContainsString('*** sensitive parameters replaced ***', $logLine);
}
}

/**
* @dataProvider userAndPasswordData
*/
public function testDetecttryLogin($user, $password) {
public function testDetecttryLogin(string $user, string $password): void {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -166,16 +166,16 @@ public function testDetecttryLogin($user, $password) {
if (is_array($logLine)) {
$logLine = json_encode($logLine);
}
$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('*** sensitive parameters replaced ***', $logLine);
$this->assertStringNotContainsString($user, $logLine);
$this->assertStringNotContainsString($password, $logLine);
$this->assertStringContainsString('*** sensitive parameters replaced ***', $logLine);
}
}

/**
* @dataProvider userAndPasswordData
*/
public function testDetectclosure($user, $password) {
public function testDetectclosure(string $user, string $password): void {
$a = function($user, $password) {
throw new \Exception('test');
};
Expand All @@ -197,9 +197,9 @@ public function testDetectclosure($user, $password) {
unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
$logLine = implode('\n', $log);

$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('*** sensitive parameters replaced ***', $logLine);
$this->assertStringNotContainsString($user, $logLine);
$this->assertStringNotContainsString($password, $logLine);
$this->assertStringContainsString('*** sensitive parameters replaced ***', $logLine);
}
}
}