2017 © Pedro Peláez
 

library oauth2-server-httpfoundation-webtest

A bridge for webtesting oauth2-server-php with bshaffer/oauth2-server-httpfoundation-bridge and silex

image

dazz/oauth2-server-httpfoundation-webtest

A bridge for webtesting oauth2-server-php with bshaffer/oauth2-server-httpfoundation-bridge and silex

  • Monday, May 6, 2013
  • by dazz
  • Repository
  • 0 Watchers
  • 1 Stars
  • 3,680 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

oauth2-server-httpfoundation-webtest

A webtesting bridge for oauth2-server-php with bshaffer/oauth2-server-httpfoundation-bridge., (*1)

Silex, Symfony and other frameworks depending on symfony/http-kernel offer a WebTestCase class for testing controller/actions. In order to write webtests for actions that are secured by the bshaffer/oauth2-server-php the request instance needs to implement \OAuth2_RequestInterface., (*2)

To achieve a valid request object the WebTestCase classes need to extend the WebTestCase class provided here., (*3)

Install

add to composer.json, (*4)

{
  "minimum-stability": "dev",
  "require-dev": {
    "dazz/oauth2-server-httpfoundation-webtest":"dev-master"
  }
}

Run composer.phar update --dev to install the development dependencies., (*5)

Example for Silex

namespace Company\Test\SomeBundle\Controller

use OAuth2\HttpFoundationWebTest\Silex\WebTestCase;

class UserControllerTest extends WebTestCase
{
    public function testGetUser()
    {
        // create user, oauth2-client and access_token in the test-storage
        $accessToken = 'abc';
        // this creates the browsing client, not to mix up with the oauth2-client
        $client = $this->createClient();

        $client->request('GET', '/user/', array('access_token' => $accessToken));

        $this->assertTrue($client->getResponse()->isSuccessful());
    }

    public function testProjects()
    {
        $accessToken = 'abc';
        $client = $this->createClient();

        $content = json_encode(array(
            'name' => 'My Project',
        ));

        // the content of $server['HTTP_AUTHORIZATION'] will be copied to the header
        $server = array(
            'HTTP_AUTHORIZATION'=> sprintf('Bearer %s', $accessToken),
        );

        $client->request('PUT', '/projects/theId', array(), array(), $server, $content);

        // all sorts of assertions on response string
        $this->assertTrue($client->getResponse()->isSuccessful());
    }
}

The Versions

06/05 2013

dev-master

9999999-dev http://github.com/dazz/oauth2-server-httpfoundation-webtest

A bridge for webtesting oauth2-server-php with bshaffer/oauth2-server-httpfoundation-bridge and silex

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hakin Dazs

test oauth auth oauth2 httpfoundation webtest