Skip to content

Commit

Permalink
Merge branch 'release/0.0.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Nov 18, 2014
2 parents 06d6324 + 1b80b27 commit 728718b
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 61 deletions.
31 changes: 31 additions & 0 deletions app/config/routing_test.php
Expand Up @@ -10,3 +10,34 @@
*/

require __DIR__.'/routing_dev.php';

$app->post('/dummy/v1.0/push/register', 'authbucket_push.push_controller:registerAction')
->bind('api_push_register');

$app->post('/dummy/v1.0/push/unregister', 'authbucket_push.push_controller:unregisterAction')
->bind('api_push_unregister');

$app->post('/dummy/v1.0/push/send', 'authbucket_push.push_controller:sendAction')
->bind('api_push_send');

foreach (array('service', 'device', 'message') as $type) {
$app->post('/dummy/v1.0/'.$type.'.{_format}', 'authbucket_push.'.$type.'_controller:createAction')
->bind('api_'.$type.'_create')
->assert('_format', 'json|xml');

$app->get('/dummy/v1.0/'.$type.'/{id}.{_format}', 'authbucket_push.'.$type.'_controller:readAction')
->bind('api_'.$type.'_read')
->assert('_format', 'json|xml');

$app->put('/dummy/v1.0/'.$type.'/{id}.{_format}', 'authbucket_push.'.$type.'_controller:updateAction')
->bind('api_'.$type.'_update')
->assert('_format', 'json|xml');

$app->delete('/dummy/v1.0/'.$type.'/{id}.{_format}', 'authbucket_push.'.$type.'_controller:deleteAction')
->bind('api_'.$type.'_delete')
->assert('_format', 'json|xml');

$app->get('/dummy/v1.0/'.$type.'.{_format}', 'authbucket_push.'.$type.'_controller:listAction')
->bind('api_'.$type.'_list')
->assert('_format', 'json|xml');
}
17 changes: 14 additions & 3 deletions app/config/security.php
Expand Up @@ -25,17 +25,28 @@
'http' => true,
'users' => $app['security.user_provider.admin'],
),
'api_oauth2_debug' => array(
'pattern' => '^/api/v1.0/oauth2/debug',
'dummy_oauth2_debug' => array(
'pattern' => '^/dummy/v1.0/oauth2/debug',
'anonymous' => true,
),
'dummy' => array(
'pattern' => '^/dummy/v1.0',
'oauth2_resource' => array(
'resource_type' => 'debug_endpoint',
'scope' => array(),
'options' => array(
'debug_endpoint' => '/dummy/v1.0/oauth2/debug',
'cache' => false,
),
),
),
'api' => array(
'pattern' => '^/api/v1.0',
'oauth2_resource' => array(
'resource_type' => 'debug_endpoint',
'scope' => array(),
'options' => array(
'debug_endpoint' => '/api/v1.0/oauth2/debug',
'debug_endpoint' => 'http://oauth2-php.authbucket.com/api/v1.0/oauth2/debug',
'cache' => false,
),
),
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -43,6 +43,7 @@
"require-dev": {
"doctrine/data-fixtures": "~1.0",
"doctrine/orm": "~2.2,>=2.2.3",
"ext-pdo_sqlite": "*",
"fabpot/php-cs-fixer": "@stable",
"monolog/monolog": "~1.0",
"phpunit/phpunit": "@stable",
Expand Down
36 changes: 18 additions & 18 deletions tests/AuthBucket/Push/Tests/Controller/DeviceControllerTest.php
Expand Up @@ -33,7 +33,7 @@ public function testCreateActionJson()
),
), 'json');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.json', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.json', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals($deviceToken, $response['deviceToken']);
}
Expand All @@ -55,7 +55,7 @@ public function testCreateActionXml()
),
), 'xml');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.xml', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.xml', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals($deviceToken, $response['deviceToken']);
}
Expand All @@ -66,7 +66,7 @@ public function testReadActionJson()
'HTTP_Authorization' => 'Bearer 18cdaa6481c0d5f323351ea1029fc065',
);
$client = $this->createClient();
$crawler = $client->request('GET', '/api/v1.0/device/1.json', array(), array(), $server);
$crawler = $client->request('GET', '/dummy/v1.0/device/1.json', array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals('0027956241e3ca5090de548fe468334d', $response['deviceToken']);
}
Expand All @@ -77,7 +77,7 @@ public function testReadActionXml()
'HTTP_Authorization' => 'Bearer 18cdaa6481c0d5f323351ea1029fc065',
);
$client = $this->createClient();
$crawler = $client->request('GET', '/api/v1.0/device/1.xml', array(), array(), $server);
$crawler = $client->request('GET', '/dummy/v1.0/device/1.xml', array(), array(), $server);
$response = simplexml_load_string($client->getResponse()->getContent());
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals('0027956241e3ca5090de548fe468334d', $response['deviceToken']);
Expand All @@ -100,20 +100,20 @@ public function testUpdateActionJson()
),
), 'json');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.json', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.json', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals($deviceToken, $response['deviceToken']);

$id = $response['id'];
$deviceTokenUpdated = md5(uniqid(null, true));
$content = $this->app['serializer']->encode(array('deviceToken' => $deviceTokenUpdated), 'json');
$client = $this->createClient();
$crawler = $client->request('PUT', "/api/v1.0/device/${id}.json", array(), array(), $server, $content);
$crawler = $client->request('PUT', "/dummy/v1.0/device/${id}.json", array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals($deviceTokenUpdated, $response['deviceToken']);

$client = $this->createClient();
$crawler = $client->request('GET', "/api/v1.0/device/${id}.json", array(), array(), $server);
$crawler = $client->request('GET', "/dummy/v1.0/device/${id}.json", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals($deviceTokenUpdated, $response['deviceToken']);
}
Expand All @@ -135,20 +135,20 @@ public function testUpdateActionXml()
),
), 'xml');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.xml', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.xml', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals($deviceToken, $response['deviceToken']);

$id = $response['id'];
$deviceTokenUpdated = md5(uniqid(null, true));
$content = $this->app['serializer']->encode(array('deviceToken' => $deviceTokenUpdated), 'xml');
$client = $this->createClient();
$crawler = $client->request('PUT', "/api/v1.0/device/${id}.xml", array(), array(), $server, $content);
$crawler = $client->request('PUT', "/dummy/v1.0/device/${id}.xml", array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals($deviceTokenUpdated, $response['deviceToken']);

$client = $this->createClient();
$crawler = $client->request('GET', "/api/v1.0/device/${id}.xml", array(), array(), $server);
$crawler = $client->request('GET', "/dummy/v1.0/device/${id}.xml", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals($deviceTokenUpdated, $response['deviceToken']);
}
Expand All @@ -170,19 +170,19 @@ public function testDeleteActionJson()
),
), 'json');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.json', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.json', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals($deviceToken, $response['deviceToken']);

$id = $response['id'];
$client = $this->createClient();
$crawler = $client->request('DELETE', "/api/v1.0/device/${id}.json", array(), array(), $server);
$crawler = $client->request('DELETE', "/dummy/v1.0/device/${id}.json", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals(null, $response['id']);
$this->assertEquals($deviceToken, $response['deviceToken']);

$client = $this->createClient();
$crawler = $client->request('GET', "/api/v1.0/device/${id}.json", array(), array(), $server);
$crawler = $client->request('GET', "/dummy/v1.0/device/${id}.json", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals(null, $response);
}
Expand All @@ -204,19 +204,19 @@ public function testDeleteActionXml()
),
), 'xml');
$client = $this->createClient();
$crawler = $client->request('POST', '/api/v1.0/device.xml', array(), array(), $server, $content);
$crawler = $client->request('POST', '/dummy/v1.0/device.xml', array(), array(), $server, $content);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals($deviceToken, $response['deviceToken']);

$id = $response['id'];
$client = $this->createClient();
$crawler = $client->request('DELETE', "/api/v1.0/device/${id}.xml", array(), array(), $server);
$crawler = $client->request('DELETE', "/dummy/v1.0/device/${id}.xml", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals(null, $response['id']);
$this->assertEquals($deviceToken, $response['deviceToken']);

$client = $this->createClient();
$crawler = $client->request('GET', "/api/v1.0/device/${id}.xml", array(), array(), $server);
$crawler = $client->request('GET', "/dummy/v1.0/device/${id}.xml", array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals(null, $response);
}
Expand All @@ -227,7 +227,7 @@ public function testListActionJson()
'HTTP_Authorization' => 'Bearer 18cdaa6481c0d5f323351ea1029fc065',
);
$client = $this->createClient();
$crawler = $client->request('GET', '/api/v1.0/device.json', array(), array(), $server);
$crawler = $client->request('GET', '/dummy/v1.0/device.json', array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'json');
$this->assertEquals('0027956241e3ca5090de548fe468334d', $response[0]['deviceToken']);
}
Expand All @@ -238,7 +238,7 @@ public function testListActionXml()
'HTTP_Authorization' => 'Bearer 18cdaa6481c0d5f323351ea1029fc065',
);
$client = $this->createClient();
$crawler = $client->request('GET', '/api/v1.0/device.xml', array(), array(), $server);
$crawler = $client->request('GET', '/dummy/v1.0/device.xml', array(), array(), $server);
$response = $this->app['serializer']->decode($client->getResponse()->getContent(), 'xml');
$this->assertEquals('0027956241e3ca5090de548fe468334d', $response[0]['deviceToken']);
}
Expand Down

0 comments on commit 728718b

Please sign in to comment.