MisdMockRavenServiceBundle
, (*1)
Provides a controller replicating the Raven service, allow applications to functionally test the logging in process., (*2)
Authors
Requirements
Installation
-
Add the bundle to your dev dependencies:, (*3)
// composer.json
{
// ...
"require-dev": {
// ...
"misd/mock-raven-service-bundle": "~1.0@dev"
}
}
-
Use Composer to download and install the bundle:, (*4)
$ php composer.phar update misd/mock-raven-service-bundle
-
Register the bundle in your application's test environment:, (*5)
// app/AppKernel.php
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
// ...
if ('test' === $this->getEnvironment()) {
$bundles[] = new Misd\MockRavenServiceBundle\MisdMockRavenServiceBundle();
}
// ...
}
// ...
}
-
Add the bundle's routes to your test routing config:, (*6)
// app/routing_test.yml
misd_mock_raven_service:
resource: "@MisdMockRavenServiceBundle/Resources/config/routing.yml"
-
Make sure that the mock Raven service path is unsecured:, (*7)
// app/security.yml
mock_raven_service:
pattern: ^/auth/authenticate.html
security: false
If you are using the misd/raven-bundle make sure that your test environment is using the Raven test service:, (*8)
// app/config_test.yml
misd_raven:
use_test_service: true
Usage
The bundle, by default, will see a user logged in to Raven with the CRSid 'test0001'., (*9)
For example, in a test case extending Symfony\Bundle\FrameworkBundle\Test\WebTestCase
running:, (*10)
$client = static::createClient();
$client->followRedirects();
$client->request('GET', '/secured-page');
will see a successful Raven login response returned. If you are using the misd/raven-bundle the Raven response will have been processed for you., (*11)
Customising the Raven service response
Set the next_wls_response
session attribute with an instance of Misd\MockRavenServiceBundle\WlsResponse\WlsResponseInterface
before making a request allows you to control what response the mock Raven service returns. For example:, (*12)
use Misd\MockRavenServiceBundle\WlsResponse\AuthenticationCancelledWlsResponse;
$client = static::createClient();
$client->followRedirects();
$client->getContainer()->get('session')->set('next_wls_response', new AuthenticationCancelledWlsResponse());
$client->request('GET', '/secured_path');
Available implementations are:, (*13)
Misd\MockRavenServiceBundle\WlsResponse\AuthenticationCancelled
- A '410 The user cancelled the authentication request' response.
Misd\MockRavenServiceBundle\WlsResponse\AuthenticationDeclined
- A '570 Authentication declined' response.
Misd\MockRavenServiceBundle\WlsResponse\GeneralRequestParameterError
- A '530 General request parameter error' response.
Misd\MockRavenServiceBundle\WlsResponse\InteractionWouldBeRequired
- A '540 Interaction would be required' response.
Misd\MockRavenServiceBundle\WlsResponse\NoMutuallyAcceptableAuthenticationTypesAvailable
- A '510 No mutually acceptable authentication types available' response.
Misd\MockRavenServiceBundle\WlsResponse\SuccessfulAuthentication
- A '200 Successful authentication' response.
Misd\MockRavenServiceBundle\WlsResponse\UnsupportedProtocolVersion
- A '520 Unsupported protocol version' response.
Misd\MockRavenServiceBundle\WlsResponse\WaaNotAuthorised
- A '560 WAA not authorised' response.
There are also implementations that indicate broken responses:, (*14)
Misd\MockRavenServiceBundle\WlsResponse\Invalid\Expired
- A response with an expired issue date
Misd\MockRavenServiceBundle\WlsResponse\Invalid\Incomplete
- An incomplete response.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\Invalid
- An invalid response.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\UndefinedStatusCode
- A response with an invalid status code.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\WrongAuth
- A response with an invalid 'auth' parameter.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\WrongKid
- A response with an invalid 'kid' parameter.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\WrongSso
- A response with an invalid 'sso' parameter.
Misd\MockRavenServiceBundle\WlsResponse\Invalid\WrongUrl
- A response with a different URL.