summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-08-09 20:52:49 +0200
committerGitHub <noreply@github.com>2016-08-09 20:52:49 +0200
commit5214b62d55b3907eb2da7c8e51a3c0c6cd09a00f (patch)
treecfd4304c4eac1a5696cf5dfcb91ad9b562a8bd0e
parentf3777f8271944103f780bd9869dbcc2f807ae901 (diff)
parent63f6d2d558f4b999f3851482122f3e3589ce4cfc (diff)
downloadnextcloud-server-5214b62d55b3907eb2da7c8e51a3c0c6cd09a00f.tar.gz
nextcloud-server-5214b62d55b3907eb2da7c8e51a3c0c6cd09a00f.zip
Merge pull request #691 from nextcloud/ocs_allow_all_old_routes
Allow ocs/v2.php/cloud/... routes
-rw-r--r--lib/private/AppFramework/Routing/RouteConfig.php8
-rw-r--r--lib/private/Route/Router.php2
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php14
3 files changed, 15 insertions, 9 deletions
diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php
index 066c0da1138..e94f2e50c1d 100644
--- a/lib/private/AppFramework/Routing/RouteConfig.php
+++ b/lib/private/AppFramework/Routing/RouteConfig.php
@@ -86,7 +86,13 @@ class RouteConfig {
$postfix = $ocsRoute['postfix'];
}
- $url = $ocsRoute['url'];
+ if (isset($ocsRoute['root'])) {
+ $root = $ocsRoute['root'];
+ } else {
+ $root = '/apps/'.$this->appName;
+ }
+
+ $url = $root . $ocsRoute['url'];
$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
$split = explode('#', $name, 2);
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php
index ac42c4025c2..9df74184448 100644
--- a/lib/private/Route/Router.php
+++ b/lib/private/Route/Router.php
@@ -154,7 +154,7 @@ class Router implements IRouter {
// Also add the OCS collection
$collection = $this->getCollection($app.'.ocs');
- $collection->addPrefix('/ocsapp/apps/' . $app);
+ $collection->addPrefix('/ocsapp');
$this->root->addCollection($collection);
}
}
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
index 6c8b0f40133..d395584d011 100644
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ b/tests/lib/AppFramework/Routing/RoutingTest.php
@@ -24,7 +24,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open');
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
}
public function testSimpleRouteWithMissingVerb()
@@ -42,7 +42,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open');
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
}
public function testSimpleRouteWithLowercaseVerb()
@@ -60,7 +60,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open');
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
}
public function testSimpleRouteWithRequirements()
@@ -78,7 +78,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
}
public function testSimpleRouteWithDefaults()
@@ -97,7 +97,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
}
public function testSimpleRouteWithPostfix()
@@ -115,7 +115,7 @@ class RoutingTest extends \Test\TestCase
]
];
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
+ $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
}
/**
@@ -175,7 +175,7 @@ class RoutingTest extends \Test\TestCase
['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
]];
- $this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent');
+ $this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/apps/app1/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent');
}
public function testResource()