Ejemplo n.º 1
0
 public function testBug2()
 {
     \Slim\Environment::mock(array("SCRIPT_NAME" => "/index.php", "PATH_INFO" => "/status/foo"));
     $app = new \Slim\Slim();
     $app->get("/status/foo", function () {
         echo "Status";
     });
     $app->get("/status(/?)", function () {
         echo "Status";
     });
     $app->get("/stat", function () {
         echo "Stat";
     });
     $auth = new \Slim\Middleware\HttpBasicAuth(array("path" => "/stat", "realm" => "Protected", "users" => array("root" => "t00r", "user" => "passw0rd")));
     $auth->setApplication($app);
     $auth->setNextMiddleware($app);
     $auth->call();
     $this->assertEquals(200, $app->response()->status());
     $this->assertEquals("Status", $app->response()->body());
 }
 public function testBug3ShouldReturn401WithTrailingSlash()
 {
     \Slim\Environment::mock(array("SCRIPT_NAME" => "/index.php", "PATH_INFO" => "/admin/"));
     $app = new \Slim\Slim();
     $app->get("/admin(/?)", function () {
         echo "Admin";
     });
     $auth = new \Slim\Middleware\HttpBasicAuth(array("path" => "/", "realm" => "Protected", "users" => array("root" => "t00r", "user" => "passw0rd")));
     $auth->setApplication($app);
     $auth->setNextMiddleware($app);
     $auth->call();
     $this->assertEquals(401, $app->response()->status());
     $this->assertEquals("", $app->response()->body());
 }