I would like to authenticate the user through an API (external user provider) running my integration tests.
my config_test.yml
imports:
- { resource: config.yml }
- { resource: parameters_test.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: info
After the login (SUCCEED) the next step is ask for user information and I got:
"Full authentication is required to access this resource."
I guess something is happening with the stored session. I am using Redis on dev and prod to store sessions. Mocking sessions on the test environment because of
"Failed to start the session because headers have already been sent by "/path/to/bin/phpunit" at line 2."
Doing it manually is working like a charm.
session.storage.mock_file
uses by default%kernel.cache_dir%/sessions
for a storing of session's file. Check if this folder is writable for both server user and cli user.'Setting up Permissions' http://symfony.com/doc/current/book/installation.html#configuration-and-setup
Another 2 possible reasons of error:
stateless: true
on your firewall infirewalls
section. TheContextListener
is not created and Token is not saved to the session. AnonymousToken is assigned to next request.stateless: true
you also can haveRememberMeToken
instead ofAnonymousToken
ifremember_me
feature enabled. This token is also not full fledged.UPDATE
Ensure that
intercept_redirects
is false inconfig_test.yml
as it may break all redirects.