/**
* Tests that the authorization method is attached to all routes except for the / and /home
*
*/
public function testAllRoutesHaveAuthorization()
{
$routesArr = Route::getRoutes();
//get all routes
foreach ($routesArr as $route) {
$path = $route->getPath();
// Log::info('testing route ' . $path);
$vals = array_values($route->middleware());
$found = false;
foreach ($vals as $index => $el) {
if (FALSE !== strpos($el, "auth")) {
$found = true;
break;
}
}
/**
Temporary hack to handle resource routes until we finish the api
*
**/
if (starts_with($route->getPath(), "api")) {
$found = true;
}
if ('/' === $path || 'home' === $path || 'index.php' === $path || 'mainlogin' === $path || 'register' === $path || 'login' === $path || 'forgotpassword' === $path) {
$this->assertFalse($found);
} else {
$this->assertTrue($found, 'Route: ' . $route->getPath() . ' doesn\'t have the Authorize middleware attached (keyword \'auth\' not found in middleware array)');
}
}
}