我正在将我的Symfony 2.8应用程序升级到3.4,我遇到了一些现有PHPUnit测试的问题。
这是我的
security.yml
:
security:
firewalls:
default:
simple_preauth:
provider: fos_userbundle
authenticator: appbundle.admin.tokenauthenticator
我最近升级了
friendsofsymfony/user-bundle
到
v2.1.2
作为Symfony 3.4升级的一部分。
config_test.yml
(对于PHPUnit):
security:
providers:
appbundle.security.api.key_user_provider:
apiusers:
users:
server:
apikey: testUserValidRole
roles:
- 'ROLE_API_USER'
我还将PHP升级到7.2,将PHPUnit升级到7.4.3。
在我的测试中,我有:
$crawler = $client->request('POST', '/api/sso', [
'apikey' => 'testUserValidRole',
'site' => $site->getId(),
]);
$this->assertEquals(
\Symfony\Component\HttpFoundation\Response::HTTP_OK,
$client->getResponse()->getStatusCode()
);
$response = json_decode($client->getResponse()->getContent());
$this->assertTrue(isset($response->target));
$security = $client->getProfile()->getCollector('security');
// The user should only be authenticated anonymously.
$this->assertTrue($security->isAuthenticated());
$this->assertEquals(
'Symfony\Component\Security\Core\Authentication\Token\AnonymousToken',
$security->getTokenClass()
);
// Check that we can login with a valid loginToken.
// Note: A successful login will redirect and remove the loginToken.
$client->enableProfiler();
$crawler = $client->request('GET', $response->target);
// The user should be authenticated correctly.
$security = $client->getProfile()->getCollector('security');
$this->assertTrue($security->isAuthenticated());
$this->assertEquals(
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken',
$security->getTokenClass()
);
关于
PreAuthenticatedToken
断言Symfony\Component\VarDumper\Cloner\Data对象失败
&00000000 299A8BD300600690A732B预期匹配
'Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'。
https://gist.github.com/crmpicco/a927716570a4949caafec4ca1361bf63
在Symfony升级说明中,我看不到任何关于安全性部分的内容可以指出导致此错误的原因,我必须承认,我现在对此感到有点困惑。我有一些错误的配置吗?