commit
c1632c3abd
|
@ -195,18 +195,6 @@ class ViewController extends Controller {
|
||||||
\OCP\Util::addscript('files', 'keyboardshortcuts');
|
\OCP\Util::addscript('files', 'keyboardshortcuts');
|
||||||
\OCP\Util::addscript('files', 'navigation');
|
\OCP\Util::addscript('files', 'navigation');
|
||||||
|
|
||||||
// if IE8 and "?dir=path&view=someview" was specified, reformat the URL to use a hash like "#?dir=path&view=someview"
|
|
||||||
$isIE8 = $this->request->isUserAgent([Request::USER_AGENT_IE_8]);
|
|
||||||
if ($isIE8 && ($dir !== '' || $view !== '')) {
|
|
||||||
$dir = !empty($dir) ? $dir : '/';
|
|
||||||
$view = !empty($view) ? $view : 'files';
|
|
||||||
$hash = '#?dir=' . \OCP\Util::encodePath($dir);
|
|
||||||
if ($view !== 'files') {
|
|
||||||
$hash .= '&view=' . urlencode($view);
|
|
||||||
}
|
|
||||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index') . $hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mostly for the home storage's free space
|
// mostly for the home storage's free space
|
||||||
// FIXME: Make non static
|
// FIXME: Make non static
|
||||||
$storageInfo = $this->getStorageInfo();
|
$storageInfo = $this->getStorageInfo();
|
||||||
|
|
|
@ -73,22 +73,22 @@ class ViewControllerTest extends TestCase {
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->request = $this->getMock('\OCP\IRequest');
|
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
|
||||||
$this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
|
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
|
||||||
$this->navigationManager = $this->getMock('\OCP\INavigationManager');
|
$this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
|
||||||
$this->l10n = $this->getMock('\OCP\IL10N');
|
$this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
|
||||||
$this->config = $this->getMock('\OCP\IConfig');
|
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
|
||||||
$this->eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
$this->eventDispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||||
$this->userSession = $this->getMock('\OCP\IUserSession');
|
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
|
||||||
$this->appManager = $this->getMock('\OCP\App\IAppManager');
|
$this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')->getMock();
|
||||||
$this->user = $this->getMock('\OCP\IUser');
|
$this->user = $this->getMockBuilder('\OCP\IUser')->getMock();
|
||||||
$this->user->expects($this->any())
|
$this->user->expects($this->any())
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('testuser1'));
|
->will($this->returnValue('testuser1'));
|
||||||
$this->userSession->expects($this->any())
|
$this->userSession->expects($this->any())
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
->will($this->returnValue($this->user));
|
->will($this->returnValue($this->user));
|
||||||
$this->rootFolder = $this->getMock('\OCP\Files\Folder');
|
$this->rootFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController')
|
$this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController')
|
||||||
->setConstructorArgs([
|
->setConstructorArgs([
|
||||||
'files',
|
'files',
|
||||||
|
@ -109,60 +109,7 @@ class ViewControllerTest extends TestCase {
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndexWithIE8RedirectAndDirDefined() {
|
|
||||||
$this->request
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isUserAgent')
|
|
||||||
->with(['/MSIE 8.0/'])
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$this->urlGenerator
|
|
||||||
->expects($this->once())
|
|
||||||
->method('linkToRoute')
|
|
||||||
->with('files.view.index')
|
|
||||||
->will($this->returnValue('/apps/files/'));
|
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse('/apps/files/#?dir=MyDir');
|
|
||||||
$this->assertEquals($expected, $this->viewController->index('MyDir'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIndexWithIE8RedirectAndViewDefined() {
|
|
||||||
$this->request
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isUserAgent')
|
|
||||||
->with(['/MSIE 8.0/'])
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$this->urlGenerator
|
|
||||||
->expects($this->once())
|
|
||||||
->method('linkToRoute')
|
|
||||||
->with('files.view.index')
|
|
||||||
->will($this->returnValue('/apps/files/'));
|
|
||||||
|
|
||||||
$expected = new Http\RedirectResponse('/apps/files/#?dir=/&view=MyView');
|
|
||||||
$this->assertEquals($expected, $this->viewController->index('', 'MyView'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIndexWithIE8RedirectAndViewAndDirDefined() {
|
|
||||||
$this->request
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isUserAgent')
|
|
||||||
->with(['/MSIE 8.0/'])
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$this->urlGenerator
|
|
||||||
->expects($this->once())
|
|
||||||
->method('linkToRoute')
|
|
||||||
->with('files.view.index')
|
|
||||||
->will($this->returnValue('/apps/files/'));
|
|
||||||
|
|
||||||
$expected = new RedirectResponse('/apps/files/#?dir=MyDir&view=MyView');
|
|
||||||
$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIndexWithRegularBrowser() {
|
public function testIndexWithRegularBrowser() {
|
||||||
$this->request
|
|
||||||
->expects($this->once())
|
|
||||||
->method('isUserAgent')
|
|
||||||
->with(['/MSIE 8.0/'])
|
|
||||||
->will($this->returnValue(false));
|
|
||||||
$this->viewController
|
$this->viewController
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getStorageInfo')
|
->method('getStorageInfo')
|
||||||
|
@ -329,12 +276,12 @@ class ViewControllerTest extends TestCase {
|
||||||
* @dataProvider showFileMethodProvider
|
* @dataProvider showFileMethodProvider
|
||||||
*/
|
*/
|
||||||
public function testShowFileRouteWithFolder($useShowFile) {
|
public function testShowFileRouteWithFolder($useShowFile) {
|
||||||
$node = $this->getMock('\OCP\Files\Folder');
|
$node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$node->expects($this->once())
|
$node->expects($this->once())
|
||||||
->method('getPath')
|
->method('getPath')
|
||||||
->will($this->returnValue('/testuser1/files/test/sub'));
|
->will($this->returnValue('/testuser1/files/test/sub'));
|
||||||
|
|
||||||
$baseFolder = $this->getMock('\OCP\Files\Folder');
|
$baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
|
|
||||||
$this->rootFolder->expects($this->once())
|
$this->rootFolder->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -368,19 +315,19 @@ class ViewControllerTest extends TestCase {
|
||||||
* @dataProvider showFileMethodProvider
|
* @dataProvider showFileMethodProvider
|
||||||
*/
|
*/
|
||||||
public function testShowFileRouteWithFile($useShowFile) {
|
public function testShowFileRouteWithFile($useShowFile) {
|
||||||
$parentNode = $this->getMock('\OCP\Files\Folder');
|
$parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$parentNode->expects($this->once())
|
$parentNode->expects($this->once())
|
||||||
->method('getPath')
|
->method('getPath')
|
||||||
->will($this->returnValue('testuser1/files/test'));
|
->will($this->returnValue('testuser1/files/test'));
|
||||||
|
|
||||||
$baseFolder = $this->getMock('\OCP\Files\Folder');
|
$baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
|
|
||||||
$this->rootFolder->expects($this->once())
|
$this->rootFolder->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('testuser1/files/')
|
->with('testuser1/files/')
|
||||||
->will($this->returnValue($baseFolder));
|
->will($this->returnValue($baseFolder));
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->expects($this->once())
|
$node->expects($this->once())
|
||||||
->method('getParent')
|
->method('getParent')
|
||||||
->will($this->returnValue($parentNode));
|
->will($this->returnValue($parentNode));
|
||||||
|
@ -415,7 +362,7 @@ class ViewControllerTest extends TestCase {
|
||||||
* @dataProvider showFileMethodProvider
|
* @dataProvider showFileMethodProvider
|
||||||
*/
|
*/
|
||||||
public function testShowFileRouteWithInvalidFileId($useShowFile) {
|
public function testShowFileRouteWithInvalidFileId($useShowFile) {
|
||||||
$baseFolder = $this->getMock('\OCP\Files\Folder');
|
$baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$this->rootFolder->expects($this->once())
|
$this->rootFolder->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('testuser1/files/')
|
->with('testuser1/files/')
|
||||||
|
@ -446,13 +393,13 @@ class ViewControllerTest extends TestCase {
|
||||||
->with('files_trashbin')
|
->with('files_trashbin')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$parentNode = $this->getMock('\OCP\Files\Folder');
|
$parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$parentNode->expects($this->once())
|
$parentNode->expects($this->once())
|
||||||
->method('getPath')
|
->method('getPath')
|
||||||
->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
|
->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
|
||||||
|
|
||||||
$baseFolderFiles = $this->getMock('\OCP\Files\Folder');
|
$baseFolderFiles = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
$baseFolderTrash = $this->getMock('\OCP\Files\Folder');
|
$baseFolderTrash = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||||
|
|
||||||
$this->rootFolder->expects($this->at(0))
|
$this->rootFolder->expects($this->at(0))
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -468,7 +415,7 @@ class ViewControllerTest extends TestCase {
|
||||||
->with(123)
|
->with(123)
|
||||||
->will($this->returnValue([]));
|
->will($this->returnValue([]));
|
||||||
|
|
||||||
$node = $this->getMock('\OCP\Files\File');
|
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||||
$node->expects($this->once())
|
$node->expects($this->once())
|
||||||
->method('getParent')
|
->method('getParent')
|
||||||
->will($this->returnValue($parentNode));
|
->will($this->returnValue($parentNode));
|
||||||
|
|
|
@ -150,14 +150,9 @@ class AvatarController extends Controller {
|
||||||
* @return DataResponse
|
* @return DataResponse
|
||||||
*/
|
*/
|
||||||
public function postAvatar($path) {
|
public function postAvatar($path) {
|
||||||
$userId = $this->userSession->getUser()->getUID();
|
|
||||||
$files = $this->request->getUploadedFile('files');
|
$files = $this->request->getUploadedFile('files');
|
||||||
|
|
||||||
$headers = [];
|
$headers = [];
|
||||||
if ($this->request->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE_8])) {
|
|
||||||
// due to upload iframe workaround, need to set content-type to text/plain
|
|
||||||
$headers['Content-Type'] = 'text/plain';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($path)) {
|
if (isset($path)) {
|
||||||
$path = stripslashes($path);
|
$path = stripslashes($path);
|
||||||
|
|
|
@ -56,7 +56,6 @@ use OCP\Security\ISecureRandom;
|
||||||
class Request implements \ArrayAccess, \Countable, IRequest {
|
class Request implements \ArrayAccess, \Countable, IRequest {
|
||||||
|
|
||||||
const USER_AGENT_IE = '/(MSIE)|(Trident)/';
|
const USER_AGENT_IE = '/(MSIE)|(Trident)/';
|
||||||
const USER_AGENT_IE_8 = '/MSIE 8.0/';
|
|
||||||
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
|
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
|
||||||
const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
|
const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
|
||||||
// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
|
// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
|
||||||
|
|
|
@ -86,10 +86,6 @@ class CertificateController extends Controller {
|
||||||
*/
|
*/
|
||||||
private function addCertificate(ICertificateManager $certificateManager) {
|
private function addCertificate(ICertificateManager $certificateManager) {
|
||||||
$headers = [];
|
$headers = [];
|
||||||
if ($this->request->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE_8])) {
|
|
||||||
// due to upload iframe workaround, need to set content-type to text/plain
|
|
||||||
$headers['Content-Type'] = 'text/plain';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isCertificateImportAllowed() === false) {
|
if ($this->isCertificateImportAllowed() === false) {
|
||||||
return new DataResponse(['message' => 'Individual certificate management disabled'], Http::STATUS_FORBIDDEN, $headers);
|
return new DataResponse(['message' => 'Individual certificate management disabled'], Http::STATUS_FORBIDDEN, $headers);
|
||||||
|
|
|
@ -51,11 +51,11 @@ class CertificateControllerTest extends \Test\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->request = $this->getMock('\OCP\IRequest');
|
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
|
||||||
$this->certificateManager = $this->getMock('\OCP\ICertificateManager');
|
$this->certificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock();
|
||||||
$this->systemCertificateManager = $this->getMock('\OCP\ICertificateManager');
|
$this->systemCertificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock();
|
||||||
$this->l10n = $this->getMock('\OCP\IL10N');
|
$this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
|
||||||
$this->appManager = $this->getMock('OCP\App\IAppManager');
|
$this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock();
|
||||||
|
|
||||||
$this->certificateController = $this->getMockBuilder('OC\Settings\Controller\CertificateController')
|
$this->certificateController = $this->getMockBuilder('OC\Settings\Controller\CertificateController')
|
||||||
->setConstructorArgs(
|
->setConstructorArgs(
|
||||||
|
@ -90,7 +90,7 @@ class CertificateControllerTest extends \Test\TestCase {
|
||||||
'name' => 'goodCertificate.crt',
|
'name' => 'goodCertificate.crt',
|
||||||
];
|
];
|
||||||
|
|
||||||
$certificate = $this->getMock('\OCP\ICertificate');
|
$certificate = $this->getMockBuilder('\OCP\ICertificate')->getMock();
|
||||||
$certificate
|
$certificate
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getName')
|
->method('getName')
|
||||||
|
|
Loading…
Reference in New Issue