Skip to content

Commit

Permalink
[Security] fixes multiple overlapping definitions of DefaultFailureHa…
Browse files Browse the repository at this point in the history
…ndler and DefaultSuccessHandler in AbstractFactory
  • Loading branch information
fran6co committed Jul 19, 2012
1 parent 8c2f35f commit 39157a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -172,7 +172,7 @@ protected function createAuthenticationSuccessHandler($container, $id, $config)
return $config['success_handler'];
}

$successHandlerId = 'security.authentication.success_handler.'.$id;
$successHandlerId = 'security.authentication.success_handler.'.$id.'.'.str_replace('-', '_', $this->getKey());

$successHandler = $container->setDefinition($successHandlerId, new DefinitionDecorator('security.authentication.success_handler'));
$successHandler->replaceArgument(1, array_intersect_key($config, $this->defaultSuccessHandlerOptions));
Expand All @@ -187,7 +187,7 @@ protected function createAuthenticationFailureHandler($container, $id, $config)
return $config['failure_handler'];
}

$id = 'security.authentication.failure_handler.'.$id;
$id = 'security.authentication.failure_handler.'.$id.'.'.str_replace('-', '_', $this->getKey());

$failureHandler = $container->setDefinition($id, new DefinitionDecorator('security.authentication.failure_handler'));
$failureHandler->replaceArgument(2, array_intersect_key($config, $this->defaultFailureHandlerOptions));
Expand Down
Expand Up @@ -54,7 +54,7 @@ public function testDefaultFailureHandler()

$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();
$this->assertEquals(new Reference('security.authentication.failure_handler.foo'), $arguments['index_6']);
$this->assertEquals(new Reference('security.authentication.failure_handler.foo.abstract_factory'), $arguments['index_6']);
}

public function testDefaultSuccessHandler()
Expand All @@ -67,7 +67,7 @@ public function testDefaultSuccessHandler()

$definition = $container->getDefinition('abstract_listener.foo');
$arguments = $definition->getArguments();
$this->assertEquals(new Reference('security.authentication.success_handler.foo'), $arguments['index_5']);
$this->assertEquals(new Reference('security.authentication.success_handler.foo.abstract_factory'), $arguments['index_5']);
}

protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId)
Expand All @@ -84,6 +84,11 @@ protected function callFactory($id, $config, $userProviderId, $defaultEntryPoint
->method('getListenerId')
->will($this->returnValue('abstract_listener'))
;
$factory
->expects($this->any())
->method('getKey')
->will($this->returnValue('abstract_factory'))
;

$container = new ContainerBuilder();
$container->register('auth_provider');
Expand Down

0 comments on commit 39157a8

Please sign in to comment.