Hi Lukas,
I've been trying to do exactly what you describe, but I couldn't get it work
either, even with HTTP Basic authentication.
My config_test.yml:
# ...
security.config:
providers:
main:
users:
admin: { password: 1234, roles: [ 'ROLE_IS_ADMIN',
'ROLE_WEB_ACCESS' ] }
web_access: { password: 1234, roles: ROLE_WEB_ACCESS }
firewalls:
main:
pattern: /.*
http_basic: true
stateless: true
# ...
I have my access_rules configured on config.yml
Then in my test:
$client->request( 'POST', 'myURL', array(), array(), array(
'PHP_AUTH_USER' => 'admin',
'PHP_AUTH_PW' => '1234'
) );
But it doesn't work. Am I missing something else?
Thanks.
On Tue, Dec 21, 2010 at 9:11 AM, Lukas Kahwe Smith <[email protected]>wrote:
>
> On 21.12.2010, at 11:21, Lukas Kahwe Smith wrote:
>
> >
> > On 21.12.2010, at 09:57, Lukas Kahwe Smith wrote:
> >
> >> Hi,
> >>
> >> I am wondering if someone has figured out how to best do functional
> tests that require a given user is logged in? I realize that for this it
> might be convenient to define the users via the in-memory provider. But I am
> not sure how to best go about writing the test since it requires multiple
> calls to the client with a real session. It seems like
> https://github.com/knplabs/TestSessionBundle might address this need,
> though it seems this should be handled by core.
> >
> >
> > in my team someone also tries the following, but it didnt do the trick:
> > $client = $this->createClient(array('environment' => 'test'));
> > $user =
> $client->getContainer()->get('doctrine.orm.entity_manager')->getRepository('Application\JoizHardcoreBundle\Entity\User')->findOneBy(array('username'
> =>'foo'));
> > $token = new UsernamePasswordToken($user, null,
> array('IS_AUTHENTICATED_FULLY', 'IS_AUTHENTICATED_ANONYMOUS'));
> > $client->getContainer()->get('security.context')->setToken($token);
>
>
> it seems that this approach doesnt work, since the token would have to be
> set into the session instead.
> for now we got it working with:
> $client->request('GET', $url, array(), array(), array('PHP_AUTH_USER' =>
> $username 'PHP_AUTH_PW' => $password));
>
> regards,
> Lukas Kahwe Smith
> [email protected]
>
>
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-devs%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en