misd / mock-raven-service-bundle
Provides a controller replicating the Raven service, allow applications to functionally test the logging in process
Installs: 62
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- ext-openssl: *
- symfony/framework-bundle: ~2.1
Requires (Dev)
- phpunit/phpunit: 3.7.*
- symfony/browser-kit: ~2.1
- symfony/class-loader: ~2.1
- symfony/finder: ~2.1
- symfony/yaml: ~2.1
This package is auto-updated.
Last update: 2024-11-11 00:26:30 UTC
README
Provides a controller replicating the Raven service, allow applications to functionally test the logging in process.
Authors
- Chris Wilkinson chris.wilkinson@admin.cam.ac.uk
Requirements
Installation
-
Add the bundle to your dev dependencies:
// composer.json { // ... "require-dev": { // ... "misd/mock-raven-service-bundle": "~1.0@dev" } }
-
Use Composer to download and install the bundle:
$ php composer.phar update misd/mock-raven-service-bundle
-
Register the bundle in your application's test environment:
// 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:
// app/routing_test.yml misd_mock_raven_service: resource: "@MisdMockRavenServiceBundle/Resources/config/routing.yml"
-
Make sure that the mock Raven service path is unsecured:
// 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:
// 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'.
For example, in a test case extending Symfony\Bundle\FrameworkBundle\Test\WebTestCase
running:
$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.
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:
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:
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:
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.