Release 2.16 (#4780)

This commit is contained in:
Kevin Papst
2024-05-01 14:24:24 +02:00
committed by GitHub
parent 8f8d228fb3
commit 99c296a751
150 changed files with 2498 additions and 1905 deletions

View File

@@ -120,19 +120,34 @@ abstract class ControllerBaseTest extends WebTestCase
default => null,
};
if ($username === null) {
throw new \Exception('Unknown username: ' . $username);
}
return $this->loginByUsername($username);
}
protected function loginByUsername(string $username): HttpKernelBrowser
{
$client = static::createClient();
if ($username !== null) {
/** @var UserRepository $userRepository */
$userRepository = $this->getPrivateService(UserRepository::class);
$user = $userRepository->findByUsername($username);
if ($user === null) {
throw new \Exception('Unknown user: ' . $username);
}
$client->loginUser($user, 'secured_area');
/** @var UserRepository $userRepository */
$userRepository = $this->getPrivateService(UserRepository::class);
$user = $userRepository->findByUsername($username);
if ($user === null) {
throw new \Exception('Unknown user: ' . $username);
}
$client->loginUser($user, 'secured_area');
return $client;
}
protected function loginUser(User $user): HttpKernelBrowser
{
$client = static::createClient();
$client->loginUser($user, 'secured_area');
return $client;
}

View File

@@ -38,7 +38,7 @@ class LayoutControllerTest extends ControllerBaseTest
$this->assertStringContainsString('href="/en/profile/' . $user->getUserIdentifier() . '"', $content);
$this->assertStringContainsString('href="/en/profile/' . $user->getUserIdentifier() . '/edit"', $content);
$this->assertStringContainsString('href="/en/profile/' . $user->getUserIdentifier() . '/prefs"', $content);
$this->assertStringContainsString('href="/en/logout?_csrf_token=', $content);
$this->assertStringContainsString('href="/en/logout', $content);
}
protected function assertHasNavigation(HttpKernelBrowser $client): void

View File

@@ -219,16 +219,7 @@ class ProfileControllerTest extends ControllerBaseTest
// cannot follow redirect here, because the password was changed and the user/password registered in the client
// are the old ones, so following the redirect would fail with "Unauthorized".
$this->tearDown();
$client = self::createClient([], [
'PHP_AUTH_USER' => UserFixtures::USERNAME_USER,
'PHP_AUTH_PW' => 'test1234',
]);
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/password');
$this->assertTrue($client->getResponse()->isSuccessful());
$user = $this->getUserByRole(User::ROLE_USER);
$this->assertFalse($passwordEncoder->getPasswordHasher($user)->verify($user->getPassword(), UserFixtures::DEFAULT_PASSWORD));
$this->assertTrue($passwordEncoder->getPasswordHasher($user)->verify($user->getPassword(), 'test1234'));
}
@@ -251,6 +242,9 @@ class ProfileControllerTest extends ControllerBaseTest
);
}
/**
* @legacy
*/
public function testApiTokenAction(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);