Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ocs/v2.php/cloud/... routes #691

Merged
merged 1 commit into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/private/AppFramework/Routing/RouteConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ private function processOCS(array $routes) {
$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);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Route/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function loadRoutes($app = null) {

// Also add the OCS collection
$collection = $this->getCollection($app.'.ocs');
$collection->addPrefix('/ocsapp/apps/' . $app);
$collection->addPrefix('/ocsapp');
$this->root->addCollection($collection);
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/lib/AppFramework/Routing/RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testSimpleOCSRoute() {
]
];

$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()
Expand All @@ -42,7 +42,7 @@ public function testSimpleOCSRouteWithMissingVerb() {
]
];

$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()
Expand All @@ -60,7 +60,7 @@ public function testSimpleOCSRouteWithLowercaseVerb() {
]
];

$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()
Expand All @@ -78,7 +78,7 @@ public function testSimpleOCSRouteWithRequirements() {
]
];

$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()
Expand All @@ -97,7 +97,7 @@ public function testSimpleOCSRouteWithDefaults() {
]
];

$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()
Expand All @@ -115,7 +115,7 @@ public function testSimpleOCSRouteWithPostfix() {
]
];

$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');
}

/**
Expand Down Expand Up @@ -175,7 +175,7 @@ public function testSimpleOCSRouteWithUnderScoreNames() {
['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()
Expand Down