Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
535 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the authbucket/oauth2-bundle package. | ||
* | ||
* (c) Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AuthBucket\Bundle\OAuth2Bundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class ModelController extends Controller | ||
{ | ||
public function createModelAction(Request $request, $type) | ||
{ | ||
return $this->get('authbucket_oauth2.model_controller')->createModelAction($request, $type); | ||
} | ||
|
||
public function readModelAction(Request $request, $type, $id) | ||
{ | ||
return $this->get('authbucket_oauth2.model_controller')->readModelAction($request, $type, $id); | ||
} | ||
|
||
public function updateModelAction(Request $request, $type, $id) | ||
{ | ||
return $this->get('authbucket_oauth2.model_controller')->updateModelAction($request, $type, $id); | ||
} | ||
|
||
public function deleteModelAction(Request $request, $type, $id) | ||
{ | ||
return $this->get('authbucket_oauth2.model_controller')->deleteModelAction($request, $type, $id); | ||
} | ||
|
||
public function listModelAction(Request $request, $type) | ||
{ | ||
return $this->get('authbucket_oauth2.model_controller')->listModelAction($request, $type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
oauth2_authorize: | ||
pattern: /authorize | ||
pattern: /oauth2/authorize | ||
defaults: { _controller: AuthBucketOAuth2Bundle:Authorize:authorize } | ||
|
||
oauth2_token: | ||
pattern: /token | ||
pattern: /oauth2/token | ||
defaults: { _controller: AuthBucketOAuth2Bundle:Token:token } | ||
|
||
oauth2_debug: | ||
pattern: /debug | ||
pattern: /oauth2/debug | ||
defaults: { _controller: AuthBucketOAuth2Bundle:Debug:debug } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the authbucket/oauth2-bundle package. | ||
* | ||
* (c) Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\Controller; | ||
|
||
use AuthBucket\Bundle\OAuth2Bundle\Tests\WebTestCase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class ModelControllerTest extends WebTestCase | ||
{ | ||
public function testCreateModelJson() | ||
{ | ||
$content = $this->get('serializer')->encode(array('scope' => 'demoscopeJson'), 'json'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.json', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals('demoscopeJson', $response['scope']); | ||
} | ||
|
||
public function testCreateModelXml() | ||
{ | ||
$content = $this->get('serializer')->encode(array('scope' => 'demoscopeXml'), 'xml'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.xml', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals('demoscopeXml', $response['scope']); | ||
} | ||
|
||
public function testReadModelJson() | ||
{ | ||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', '/oauth2/model/scope/1.json'); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals('debug', $response['scope']); | ||
} | ||
|
||
public function testReadModelXml() | ||
{ | ||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', '/oauth2/model/scope/1.xml'); | ||
$response = simplexml_load_string($client->getResponse()->getContent()); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals('debug', $response['scope']); | ||
} | ||
|
||
public function testUpdateModelJson() | ||
{ | ||
$scope = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scope), 'json'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.json', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$id = $response['id']; | ||
$scopeUpdated = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scopeUpdated), 'json'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('PUT', "/oauth2/model/scope/${id}.json", array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals($scopeUpdated, $response['scope']); | ||
|
||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', "/oauth2/model/scope/${id}.json"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals($scopeUpdated, $response['scope']); | ||
} | ||
|
||
public function testUpdateModelXml() | ||
{ | ||
$scope = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scope), 'xml'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.xml', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$id = $response['id']; | ||
$scopeUpdated = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scopeUpdated), 'xml'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('PUT', "/oauth2/model/scope/${id}.xml", array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals($scopeUpdated, $response['scope']); | ||
|
||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', "/oauth2/model/scope/${id}.xml"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals($scopeUpdated, $response['scope']); | ||
} | ||
|
||
public function testDeleteModelJson() | ||
{ | ||
$scope = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scope), 'json'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.json', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$id = $response['id']; | ||
$client = $this->createClient(); | ||
$crawler = $client->request('DELETE', "/oauth2/model/scope/${id}.json"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals(null, $response['id']); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', "/oauth2/model/scope/${id}.json"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals(null, $response); | ||
} | ||
|
||
public function testDeleteModelXml() | ||
{ | ||
$scope = substr(md5(uniqid(null, true)), 0, 8); | ||
$content = $this->get('serializer')->encode(array('scope' => $scope), 'xml'); | ||
$client = $this->createClient(); | ||
$crawler = $client->request('POST', '/oauth2/model/scope.xml', array(), array(), array(), $content); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$id = $response['id']; | ||
$client = $this->createClient(); | ||
$crawler = $client->request('DELETE', "/oauth2/model/scope/${id}.xml"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals(null, $response['id']); | ||
$this->assertEquals($scope, $response['scope']); | ||
|
||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', "/oauth2/model/scope/${id}.xml"); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals(null, $response); | ||
} | ||
|
||
public function testListModelJson() | ||
{ | ||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', '/oauth2/model/scope.json'); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'json'); | ||
$this->assertEquals('debug', $response[0]['scope']); | ||
} | ||
|
||
public function testListModelXml() | ||
{ | ||
$client = $this->createClient(); | ||
$crawler = $client->request('GET', '/oauth2/model/scope.xml'); | ||
$response = $this->get('serializer')->decode($client->getResponse()->getContent(), 'xml'); | ||
$this->assertEquals('debug', $response[0]['scope']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.