diff options
44 files changed, 1388 insertions, 1100 deletions
diff --git a/3rdparty b/3rdparty -Subproject ac2a9ef827f039f1a7cb1e5836723f89ecbea53 +Subproject 685012c78a2718f4fdfc1f5855abd3b07a39a49 diff --git a/apps/dav/lib/connector/sabre/auth.php b/apps/dav/lib/connector/sabre/auth.php index 803db78ecd7..4f319770234 100644 --- a/apps/dav/lib/connector/sabre/auth.php +++ b/apps/dav/lib/connector/sabre/auth.php @@ -160,7 +160,7 @@ class Auth extends AbstractBasic { return [true, $this->principalPrefix . $user]; } - if ($request->getHeader('X-Requested-With') === 'XMLHttpRequest') { + if (!$this->userSession->isLoggedIn() && $request->getHeader('X-Requested-With') === 'XMLHttpRequest') { // do not re-authenticate over ajax, use dummy auth name to prevent browser popup $response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"'); $response->setStatus(401); diff --git a/apps/dav/tests/unit/connector/sabre/auth.php b/apps/dav/tests/unit/connector/sabre/auth.php index 47dd237b761..217ff5fc3fa 100644 --- a/apps/dav/tests/unit/connector/sabre/auth.php +++ b/apps/dav/tests/unit/connector/sabre/auth.php @@ -309,6 +309,10 @@ class Auth extends TestCase { $httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') ->disableOriginalConstructor() ->getMock(); + $this->userSession + ->expects($this->any()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); $httpRequest ->expects($this->once()) ->method('getHeader') @@ -317,6 +321,32 @@ class Auth extends TestCase { $this->auth->check($httpRequest, $httpResponse); } + public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUserIsStillLoggedIn() { + /** @var \Sabre\HTTP\RequestInterface $httpRequest */ + $httpRequest = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); + /** @var \Sabre\HTTP\ResponseInterface $httpResponse */ + $httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->userSession + ->expects($this->any()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + $this->session + ->expects($this->once()) + ->method('get') + ->with('AUTHENTICATED_TO_DAV_BACKEND') + ->will($this->returnValue('MyTestUser')); + $httpRequest + ->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue(null)); + $this->auth->check($httpRequest, $httpResponse); + } + public function testAuthenticateValidCredentials() { $server = $this->getMockBuilder('\Sabre\DAV\Server') ->disableOriginalConstructor() diff --git a/apps/files/l10n/de_DE.js b/apps/files/l10n/de_DE.js index 6b5d0d00e7f..70355f66d46 100644 --- a/apps/files/l10n/de_DE.js +++ b/apps/files/l10n/de_DE.js @@ -40,6 +40,7 @@ OC.L10N.register( "Unable to determine date" : "Datum konnte nicht ermittelt werden", "This operation is forbidden" : "Diese Operation ist nicht erlaubt", "This directory is unavailable, please check the logs or contact the administrator" : "Dieses Verzeichnis ist nicht verfügbar, bitte überprüfen Sie die Logdateien oder kontaktieren Sie den Administrator", + "{newName} already exists" : "{newName} existiert bereits", "No entries in this folder match '{filter}'" : "Keine Einträge in diesem Ordner stimmen mit '{filter}' überein", "Name" : "Name", "Size" : "Größe", @@ -96,6 +97,7 @@ OC.L10N.register( "Currently scanning" : "Durchsuchen läuft", "No favorites" : "Keine Favoriten", "Files and folders you mark as favorite will show up here" : "Dateien und Ordner, die Sie als Favoriten kennzeichnen, werden hier erscheinen", - "Text file" : "Textdatei" + "Text file" : "Textdatei", + "New text file.txt" : "Neue Textdatei file.txt" }, "nplurals=2; plural=(n != 1);"); diff --git a/apps/files/l10n/de_DE.json b/apps/files/l10n/de_DE.json index d6076467ce9..c0e552b49b7 100644 --- a/apps/files/l10n/de_DE.json +++ b/apps/files/l10n/de_DE.json @@ -38,6 +38,7 @@ "Unable to determine date" : "Datum konnte nicht ermittelt werden", "This operation is forbidden" : "Diese Operation ist nicht erlaubt", "This directory is unavailable, please check the logs or contact the administrator" : "Dieses Verzeichnis ist nicht verfügbar, bitte überprüfen Sie die Logdateien oder kontaktieren Sie den Administrator", + "{newName} already exists" : "{newName} existiert bereits", "No entries in this folder match '{filter}'" : "Keine Einträge in diesem Ordner stimmen mit '{filter}' überein", "Name" : "Name", "Size" : "Größe", @@ -94,6 +95,7 @@ "Currently scanning" : "Durchsuchen läuft", "No favorites" : "Keine Favoriten", "Files and folders you mark as favorite will show up here" : "Dateien und Ordner, die Sie als Favoriten kennzeichnen, werden hier erscheinen", - "Text file" : "Textdatei" + "Text file" : "Textdatei", + "New text file.txt" : "Neue Textdatei file.txt" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/apps/files/l10n/ja.js b/apps/files/l10n/ja.js index 5b7bbbdb4cb..22d7cdf1ad9 100644 --- a/apps/files/l10n/ja.js +++ b/apps/files/l10n/ja.js @@ -41,6 +41,7 @@ OC.L10N.register( "This operation is forbidden" : "この操作は禁止されています", "This directory is unavailable, please check the logs or contact the administrator" : "このディレクトリは利用できません。ログを確認するか管理者に問い合わせてください。", "Could not move \"{file}\"" : "\"{file}\" を移動できませんでした", + "{newName} already exists" : "{newName} はすでに存在します", "Could not create file \"{file}\"" : "ファイル \"{file}\" を作成できませんでした", "Could not create file \"{file}\" because it already exists" : "ファイル \"{file}\"は既に存在するため作成できませんでした", "Could not create folder \"{dir}\"" : "フォルダー \"{dir}\" を作成できませんでした", diff --git a/apps/files/l10n/ja.json b/apps/files/l10n/ja.json index 11038907105..ffc3a1e5c40 100644 --- a/apps/files/l10n/ja.json +++ b/apps/files/l10n/ja.json @@ -39,6 +39,7 @@ "This operation is forbidden" : "この操作は禁止されています", "This directory is unavailable, please check the logs or contact the administrator" : "このディレクトリは利用できません。ログを確認するか管理者に問い合わせてください。", "Could not move \"{file}\"" : "\"{file}\" を移動できませんでした", + "{newName} already exists" : "{newName} はすでに存在します", "Could not create file \"{file}\"" : "ファイル \"{file}\" を作成できませんでした", "Could not create file \"{file}\" because it already exists" : "ファイル \"{file}\"は既に存在するため作成できませんでした", "Could not create folder \"{dir}\"" : "フォルダー \"{dir}\" を作成できませんでした", diff --git a/apps/files/l10n/oc.js b/apps/files/l10n/oc.js index 4890a818e12..a3088b663fd 100644 --- a/apps/files/l10n/oc.js +++ b/apps/files/l10n/oc.js @@ -40,6 +40,17 @@ OC.L10N.register( "Unable to determine date" : "Impossible de determinar la data", "This operation is forbidden" : "L'operacion es interdicha", "This directory is unavailable, please check the logs or contact the administrator" : "Aqueste repertòri es pas disponible. Consultatz los logs o contactatz vòstre administrator", + "Could not move \"{file}\", target exists" : "Impossible de desplaçar \"{file}\", la cibla existís", + "Could not move \"{file}\"" : "Impossible de desplaçar \"{file}\"", + "{newName} already exists" : "{newName} existís ja", + "Could not rename \"{fileName}\", it does not exist any more" : "Impossible de renomenar \"{file}\", existís pas mai", + "The name \"{targetName}\" is already used in the folder \"{dir}\". Please choose a different name." : "Lo nom \"{targetName}\" es ja utilizat dins lo dorsièr \"{dir}\". Mercé de causir un nom diferent.", + "Could not rename \"{fileName}\"" : "Impossible de renomenar \"{fileName}\"", + "Could not create file \"{file}\"" : "Impossible de crear lo fichièr \"{file}\"", + "Could not create file \"{file}\" because it already exists" : "Impossible de crear lo fichièr \"{file}\" perque existís ja", + "Could not create folder \"{dir}\"" : "Impossible de crear lo dorsièr \"{dir}\"", + "Could not create folder \"{dir}\" because it already exists" : "Impossible de crear lo dorsièr \"{dir}\" perque existís ja", + "Error deleting file \"{fileName}\"." : "Error pendent la supression del fichièr \"{fileName}\".", "No entries in this folder match '{filter}'" : "Cap d'entrada d'aqueste dorsièr correspond pas a '{filter}'", "Name" : "Nom", "Size" : "Talha", @@ -88,6 +99,8 @@ OC.L10N.register( "Maximum upload size" : "Talha max. de mandadís", "max. possible: " : "Max. possible :", "Save" : "Salvar", + "With PHP-FPM it might take 5 minutes for changes to be applied." : "Amb PHP-FPM se pòdon passar 5 minutas per que los cambiaments s'apliquen.", + "Missing permissions to edit from here." : "Manca de permissions per editar a partir d'aicí.", "Settings" : "Paramètres", "WebDAV" : "WebDAV", "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Utilizatz aquesta adreça per <a href=\"%s\" target=\"_blank\">accedir a vòstres fichièrs per WebDAV</a>", diff --git a/apps/files/l10n/oc.json b/apps/files/l10n/oc.json index 14477c71a33..c6048605696 100644 --- a/apps/files/l10n/oc.json +++ b/apps/files/l10n/oc.json @@ -38,6 +38,17 @@ "Unable to determine date" : "Impossible de determinar la data", "This operation is forbidden" : "L'operacion es interdicha", "This directory is unavailable, please check the logs or contact the administrator" : "Aqueste repertòri es pas disponible. Consultatz los logs o contactatz vòstre administrator", + "Could not move \"{file}\", target exists" : "Impossible de desplaçar \"{file}\", la cibla existís", + "Could not move \"{file}\"" : "Impossible de desplaçar \"{file}\"", + "{newName} already exists" : "{newName} existís ja", + "Could not rename \"{fileName}\", it does not exist any more" : "Impossible de renomenar \"{file}\", existís pas mai", + "The name \"{targetName}\" is already used in the folder \"{dir}\". Please choose a different name." : "Lo nom \"{targetName}\" es ja utilizat dins lo dorsièr \"{dir}\". Mercé de causir un nom diferent.", + "Could not rename \"{fileName}\"" : "Impossible de renomenar \"{fileName}\"", + "Could not create file \"{file}\"" : "Impossible de crear lo fichièr \"{file}\"", + "Could not create file \"{file}\" because it already exists" : "Impossible de crear lo fichièr \"{file}\" perque existís ja", + "Could not create folder \"{dir}\"" : "Impossible de crear lo dorsièr \"{dir}\"", + "Could not create folder \"{dir}\" because it already exists" : "Impossible de crear lo dorsièr \"{dir}\" perque existís ja", + "Error deleting file \"{fileName}\"." : "Error pendent la supression del fichièr \"{fileName}\".", "No entries in this folder match '{filter}'" : "Cap d'entrada d'aqueste dorsièr correspond pas a '{filter}'", "Name" : "Nom", "Size" : "Talha", @@ -86,6 +97,8 @@ "Maximum upload size" : "Talha max. de mandadís", "max. possible: " : "Max. possible :", "Save" : "Salvar", + "With PHP-FPM it might take 5 minutes for changes to be applied." : "Amb PHP-FPM se pòdon passar 5 minutas per que los cambiaments s'apliquen.", + "Missing permissions to edit from here." : "Manca de permissions per editar a partir d'aicí.", "Settings" : "Paramètres", "WebDAV" : "WebDAV", "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Utilizatz aquesta adreça per <a href=\"%s\" target=\"_blank\">accedir a vòstres fichièrs per WebDAV</a>", diff --git a/apps/files/l10n/th_TH.js b/apps/files/l10n/th_TH.js index 5812df14755..791b987a9b8 100644 --- a/apps/files/l10n/th_TH.js +++ b/apps/files/l10n/th_TH.js @@ -40,6 +40,16 @@ OC.L10N.register( "Unable to determine date" : "ไม่สามารถกำหนดวัน", "This operation is forbidden" : "การดำเนินการนี้ถูกห้าม", "This directory is unavailable, please check the logs or contact the administrator" : "ไม่สามารถใช้งานไดเรกทอรีนี้โปรดตรวจสอบบันทึกหรือติดต่อผู้ดูแลระบบ", + "Could not move \"{file}\", target exists" : "ไม่สามารถย้ายไฟล์ \"{file}\" ไม่มีไฟล์นั้นอยู่", + "Could not move \"{file}\"" : "ไม่สามารถย้ายไฟล์ \"{file}\"", + "{newName} already exists" : "{newName} มีอยู่แล้ว", + "Could not rename \"{fileName}\", it does not exist any more" : "ไม่สามารถเปลี่ยนชื่อไฟล์ \"{fileName}\" ไฟล์นั้นไม่มีอยู่", + "Could not rename \"{fileName}\"" : "ไม่สามารถเปลี่ยนชื่อไฟล์ \"{fileName}\"", + "Could not create file \"{file}\"" : "ไม่สามารถสร้างไฟล์ \"{file}\"", + "Could not create file \"{file}\" because it already exists" : "ไม่สามารถสร้างไฟล์ \"{file}\" เพราะมันมีอยู่แล้ว", + "Could not create folder \"{dir}\"" : "ไม่สามารถสร้างโฟลเดอร์ \"{dir}\"", + "Could not create folder \"{dir}\" because it already exists" : "ไม่สามารถสร้างโฟลเดอร์ \"{dir}\" เพราะมันมีอยู่แล้ว", + "Error deleting file \"{fileName}\"." : "เกิดข้อผิดพลาดขณะลบไฟล์ \"{fileName}\"", "No entries in this folder match '{filter}'" : "ไม่มีรายการในโฟลเดอร์นี้ที่ตรงกับ '{filter}'", "Name" : "ชื่อ", "Size" : "ขนาด", diff --git a/apps/files/l10n/th_TH.json b/apps/files/l10n/th_TH.json index 93f6c5c8d2d..f0a5263892e 100644 --- a/apps/files/l10n/th_TH.json +++ b/apps/files/l10n/th_TH.json @@ -38,6 +38,16 @@ "Unable to determine date" : "ไม่สามารถกำหนดวัน", "This operation is forbidden" : "การดำเนินการนี้ถูกห้าม", "This directory is unavailable, please check the logs or contact the administrator" : "ไม่สามารถใช้งานไดเรกทอรีนี้โปรดตรวจสอบบันทึกหรือติดต่อผู้ดูแลระบบ", + "Could not move \"{file}\", target exists" : "ไม่สามารถย้ายไฟล์ \"{file}\" ไม่มีไฟล์นั้นอยู่", + "Could not move \"{file}\"" : "ไม่สามารถย้ายไฟล์ \"{file}\"", + "{newName} already exists" : "{newName} มีอยู่แล้ว", + "Could not rename \"{fileName}\", it does not exist any more" : "ไม่สามารถเปลี่ยนชื่อไฟล์ \"{fileName}\" ไฟล์นั้นไม่มีอยู่", + "Could not rename \"{fileName}\"" : "ไม่สามารถเปลี่ยนชื่อไฟล์ \"{fileName}\"", + "Could not create file \"{file}\"" : "ไม่สามารถสร้างไฟล์ \"{file}\"", + "Could not create file \"{file}\" because it already exists" : "ไม่สามารถสร้างไฟล์ \"{file}\" เพราะมันมีอยู่แล้ว", + "Could not create folder \"{dir}\"" : "ไม่สามารถสร้างโฟลเดอร์ \"{dir}\"", + "Could not create folder \"{dir}\" because it already exists" : "ไม่สามารถสร้างโฟลเดอร์ \"{dir}\" เพราะมันมีอยู่แล้ว", + "Error deleting file \"{fileName}\"." : "เกิดข้อผิดพลาดขณะลบไฟล์ \"{fileName}\"", "No entries in this folder match '{filter}'" : "ไม่มีรายการในโฟลเดอร์นี้ที่ตรงกับ '{filter}'", "Name" : "ชื่อ", "Size" : "ขนาด", diff --git a/apps/files_external/l10n/de_DE.js b/apps/files_external/l10n/de_DE.js index 7187e4d97d4..d93fd5cb012 100644 --- a/apps/files_external/l10n/de_DE.js +++ b/apps/files_external/l10n/de_DE.js @@ -11,6 +11,7 @@ OC.L10N.register( "System" : "System", "Grant access" : "Zugriff gestatten", "Access granted" : "Zugriff gestattet", + "Error configuring OAuth1" : "Fehler beim Konfigurieren von OAuth1", "Generate keys" : "Schlüssel erzeugen", "Error generating key pair" : "Fehler beim Erzeugen des Schlüsselpaares", "Enable encryption" : "Verschlüsselung aktivieren", diff --git a/apps/files_external/l10n/de_DE.json b/apps/files_external/l10n/de_DE.json index c91d78eb0d2..4347a19749d 100644 --- a/apps/files_external/l10n/de_DE.json +++ b/apps/files_external/l10n/de_DE.json @@ -9,6 +9,7 @@ "System" : "System", "Grant access" : "Zugriff gestatten", "Access granted" : "Zugriff gestattet", + "Error configuring OAuth1" : "Fehler beim Konfigurieren von OAuth1", "Generate keys" : "Schlüssel erzeugen", "Error generating key pair" : "Fehler beim Erzeugen des Schlüsselpaares", "Enable encryption" : "Verschlüsselung aktivieren", diff --git a/apps/files_external/l10n/fr.js b/apps/files_external/l10n/fr.js index 7126864a9e7..8ff4fcdfdd9 100644 --- a/apps/files_external/l10n/fr.js +++ b/apps/files_external/l10n/fr.js @@ -33,6 +33,7 @@ OC.L10N.register( "Every time the filesystem is used" : "Chaque fois que le système de fichiers est utilisé", "All users. Type to select user or group." : "Tous les utilisateurs. Cliquez ici pour restreindre.", "(group)" : "(groupe)", + "Admin defined" : "Défini par l'administrateur", "Saved" : "Sauvegardé", "Access key" : "Clé d'accès", "Secret key" : "Clé secrète", diff --git a/apps/files_external/l10n/fr.json b/apps/files_external/l10n/fr.json index f6cdce79c67..9a610bd964b 100644 --- a/apps/files_external/l10n/fr.json +++ b/apps/files_external/l10n/fr.json @@ -31,6 +31,7 @@ "Every time the filesystem is used" : "Chaque fois que le système de fichiers est utilisé", "All users. Type to select user or group." : "Tous les utilisateurs. Cliquez ici pour restreindre.", "(group)" : "(groupe)", + "Admin defined" : "Défini par l'administrateur", "Saved" : "Sauvegardé", "Access key" : "Clé d'accès", "Secret key" : "Clé secrète", diff --git a/apps/files_external/l10n/ja.js b/apps/files_external/l10n/ja.js index 3dcae3f8afc..38c98caf7aa 100644 --- a/apps/files_external/l10n/ja.js +++ b/apps/files_external/l10n/ja.js @@ -72,7 +72,7 @@ OC.L10N.register( "Secure ftps://" : "Secure ftps://", "Google Drive" : "Google Drive", "Local" : "ローカル", - "Location" : "位置", + "Location" : "場所", "ownCloud" : "ownCloud", "SFTP" : "SFTP", "Root" : "ルート", diff --git a/apps/files_external/l10n/ja.json b/apps/files_external/l10n/ja.json index 4aaaac43a5a..be6f88f3155 100644 --- a/apps/files_external/l10n/ja.json +++ b/apps/files_external/l10n/ja.json @@ -70,7 +70,7 @@ "Secure ftps://" : "Secure ftps://", "Google Drive" : "Google Drive", "Local" : "ローカル", - "Location" : "位置", + "Location" : "場所", "ownCloud" : "ownCloud", "SFTP" : "SFTP", "Root" : "ルート", diff --git a/apps/files_external/l10n/th_TH.js b/apps/files_external/l10n/th_TH.js index 022fb9b55e3..6c1efa5aacd 100644 --- a/apps/files_external/l10n/th_TH.js +++ b/apps/files_external/l10n/th_TH.js @@ -33,6 +33,7 @@ OC.L10N.register( "Every time the filesystem is used" : "ทุกครั้งที่แฟ้มระบบถูกใช้งาน", "All users. Type to select user or group." : "ผู้ใช้ทุกคน พิมพ์เพื่อเลือกผู้ใช้หรือกลุ่ม", "(group)" : "(กลุ่ม)", + "Admin defined" : "ถูกกำหนดโดยผู้ดูแลระบบ", "Saved" : "บันทึกแล้ว", "Access key" : "คีย์การเข้าถึง", "Secret key" : "คีย์ลับ", diff --git a/apps/files_external/l10n/th_TH.json b/apps/files_external/l10n/th_TH.json index 5b3713f0ed1..3de48d733d3 100644 --- a/apps/files_external/l10n/th_TH.json +++ b/apps/files_external/l10n/th_TH.json @@ -31,6 +31,7 @@ "Every time the filesystem is used" : "ทุกครั้งที่แฟ้มระบบถูกใช้งาน", "All users. Type to select user or group." : "ผู้ใช้ทุกคน พิมพ์เพื่อเลือกผู้ใช้หรือกลุ่ม", "(group)" : "(กลุ่ม)", + "Admin defined" : "ถูกกำหนดโดยผู้ดูแลระบบ", "Saved" : "บันทึกแล้ว", "Access key" : "คีย์การเข้าถึง", "Secret key" : "คีย์ลับ", diff --git a/apps/files_sharing/l10n/ja.js b/apps/files_sharing/l10n/ja.js index b80be0c3315..e40acc0104a 100644 --- a/apps/files_sharing/l10n/ja.js +++ b/apps/files_sharing/l10n/ja.js @@ -26,9 +26,9 @@ OC.L10N.register( "Invalid ownCloud url" : "無効なownCloud URL です", "Shared by" : "共有者:", "Sharing" : "共有", - "A file or folder has been <strong>shared</strong>" : "ファイルまたはフォルダーが<strong>共有</strong>されました。", - "A file or folder was shared from <strong>another server</strong>" : "ファイルまたはフォルダーが<strong>他のサーバー</strong>から共有されました。", - "A public shared file or folder was <strong>downloaded</strong>" : "公開共有ファイルまたはフォルダーが<strong>ダウンロード</strong>されました。", + "A file or folder has been <strong>shared</strong>" : "ファイルまたはフォルダーが<strong>共有</strong>されたとき", + "A file or folder was shared from <strong>another server</strong>" : "ファイルまたはフォルダーが<strong>他のサーバー</strong>から共有されたとき", + "A public shared file or folder was <strong>downloaded</strong>" : "公開共有ファイルまたはフォルダーが<strong>ダウンロード</strong>されたとき", "You received a new remote share %2$s from %1$s" : "%1$s から新しいリモート共有のリクエスト %2$s を受け取りました。", "You received a new remote share from %s" : "%sからリモート共有のリクエストは\n届きました。", "%1$s accepted remote share %2$s" : "%1$s は %2$s のリモート共有を承認しました。", diff --git a/apps/files_sharing/l10n/ja.json b/apps/files_sharing/l10n/ja.json index 8f9efffb782..989a723b2a8 100644 --- a/apps/files_sharing/l10n/ja.json +++ b/apps/files_sharing/l10n/ja.json @@ -24,9 +24,9 @@ "Invalid ownCloud url" : "無効なownCloud URL です", "Shared by" : "共有者:", "Sharing" : "共有", - "A file or folder has been <strong>shared</strong>" : "ファイルまたはフォルダーが<strong>共有</strong>されました。", - "A file or folder was shared from <strong>another server</strong>" : "ファイルまたはフォルダーが<strong>他のサーバー</strong>から共有されました。", - "A public shared file or folder was <strong>downloaded</strong>" : "公開共有ファイルまたはフォルダーが<strong>ダウンロード</strong>されました。", + "A file or folder has been <strong>shared</strong>" : "ファイルまたはフォルダーが<strong>共有</strong>されたとき", + "A file or folder was shared from <strong>another server</strong>" : "ファイルまたはフォルダーが<strong>他のサーバー</strong>から共有されたとき", + "A public shared file or folder was <strong>downloaded</strong>" : "公開共有ファイルまたはフォルダーが<strong>ダウンロード</strong>されたとき", "You received a new remote share %2$s from %1$s" : "%1$s から新しいリモート共有のリクエスト %2$s を受け取りました。", "You received a new remote share from %s" : "%sからリモート共有のリクエストは\n届きました。", "%1$s accepted remote share %2$s" : "%1$s は %2$s のリモート共有を承認しました。", diff --git a/apps/files_trashbin/command/expire.php b/apps/files_trashbin/command/expire.php index f34c63b718b..cb4e803ddc5 100644 --- a/apps/files_trashbin/command/expire.php +++ b/apps/files_trashbin/command/expire.php @@ -37,17 +37,10 @@ class Expire implements ICommand { private $user; /** - * @var int - */ - private $trashBinSize; - - /** * @param string $user - * @param int $trashBinSize */ - function __construct($user, $trashBinSize) { + function __construct($user) { $this->user = $user; - $this->trashBinSize = $trashBinSize; } public function handle() { @@ -59,7 +52,7 @@ class Expire implements ICommand { \OC_Util::tearDownFS(); \OC_Util::setupFS($this->user); - Trashbin::expire($this->trashBinSize, $this->user); + Trashbin::expire($this->user); \OC_Util::tearDownFS(); } } diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 94975530799..d492810b95f 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -186,7 +186,6 @@ class Trashbin { // get the user for which the filesystem is setup $root = Filesystem::getRoot(); list(, $user) = explode('/', $root); - $size = 0; list($owner, $ownerPath) = self::getUidAndFilename($file_path); $ownerView = new \OC\Files\View('/' . $owner); @@ -207,8 +206,6 @@ class Trashbin { $location = $path_parts['dirname']; $timestamp = time(); - $userTrashSize = self::getTrashbinSize($user); - // disable proxy to prevent recursive calls $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; @@ -238,7 +235,6 @@ class Trashbin { $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); if ($sizeOfAddedFiles !== false) { - $size = $sizeOfAddedFiles; $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); $result = $query->execute(array($filename, $timestamp, $location, $owner)); if (!$result) { @@ -247,7 +243,7 @@ class Trashbin { \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => \OC\Files\Filesystem::normalizePath($file_path), 'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp))); - $size += self::retainVersions($filename, $owner, $ownerPath, $timestamp); + self::retainVersions($filename, $owner, $ownerPath, $timestamp); // if owner !== user we need to also add a copy to the owners trash if ($user !== $owner) { @@ -255,14 +251,11 @@ class Trashbin { } } - $userTrashSize += $size; - self::scheduleExpire($userTrashSize, $user); + self::scheduleExpire($user); // if owner !== user we also need to update the owners trash size if ($owner !== $user) { - $ownerTrashSize = self::getTrashbinSize($owner); - $ownerTrashSize += $size; - self::scheduleExpire($ownerTrashSize, $owner); + self::scheduleExpire($owner); } return ($sizeOfAddedFiles === false) ? false : true; @@ -628,17 +621,17 @@ class Trashbin { $freeSpace = self::calculateFreeSpace($size, $user); if ($freeSpace < 0) { - self::scheduleExpire($size, $user); + self::scheduleExpire($user); } } /** * clean up the trash bin * - * @param int $trashBinSize current size of the trash bin * @param string $user */ - public static function expire($trashBinSize, $user) { + public static function expire($user) { + $trashBinSize = self::getTrashbinSize($user); $availableSpace = self::calculateFreeSpace($trashBinSize, $user); $size = 0; @@ -654,15 +647,15 @@ class Trashbin { $size += self::deleteFiles(array_slice($dirContent, $count), $user, $availableSpace); } - /**@param int $trashBinSize current size of the trash bin + /** * @param string $user */ - private static function scheduleExpire($trashBinSize, $user) { + private static function scheduleExpire($user) { // let the admin disable auto expire $application = new Application(); $expiration = $application->getContainer()->query('Expiration'); if ($expiration->isEnabled()) { - \OC::$server->getCommandBus()->push(new Expire($user, $trashBinSize)); + \OC::$server->getCommandBus()->push(new Expire($user)); } } diff --git a/apps/files_trashbin/tests/command/expiretest.php b/apps/files_trashbin/tests/command/expiretest.php index a6a8a6d53a8..0d457db2807 100644 --- a/apps/files_trashbin/tests/command/expiretest.php +++ b/apps/files_trashbin/tests/command/expiretest.php @@ -26,7 +26,7 @@ use Test\TestCase; class ExpireTest extends TestCase { public function testExpireNonExistingUser() { - $command = new Expire('test', 0); + $command = new Expire('test'); $command->handle(); $this->assertTrue(true); diff --git a/build/integration/config/behat.yml b/build/integration/config/behat.yml index c9d6754a0fa..37ed2b117f3 100644 --- a/build/integration/config/behat.yml +++ b/build/integration/config/behat.yml @@ -12,6 +12,17 @@ default: - admin - admin regular_user_password: 123456 + federation: + paths: + - %paths.base%/../federation + contexts: + - FederationContext: + baseUrl: http://localhost:8080/ocs/ + admin: + - admin + - admin + regular_user_password: 123456 + extensions: jarnaiz\JUnitFormatter\JUnitFormatterExtension: diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php new file mode 100644 index 00000000000..01a288a6c6a --- /dev/null +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -0,0 +1,170 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + +trait BasicStructure{ + /** @var string */ + private $currentUser = ''; + + /** @var string */ + private $currentServer = ''; + + /** @var string */ + private $baseUrl = ''; + + /** @var ResponseInterface */ + private $response = null; + + public function __construct($baseUrl, $admin, $regular_user_password) { + + // Initialize your context here + $this->baseUrl = $baseUrl; + $this->adminUser = $admin; + $this->regularUser = $regular_user_password; + $this->localBaseUrl = substr($this->baseUrl, 0, -4); + $this->remoteBaseUrl = substr($this->baseUrl, 0, -4); + $this->currentServer = 'LOCAL'; + + // in case of ci deployment we take the server url from the environment + $testServerUrl = getenv('TEST_SERVER_URL'); + if ($testServerUrl !== false) { + $this->baseUrl = $testServerUrl; + $this->localBaseUrl = $testServerUrl; + } + + // federated server url from the environment + $testRemoteServerUrl = getenv('TEST_SERVER_FED_URL'); + if ($testRemoteServerUrl !== false) { + $this->remoteBaseUrl = $testRemoteServerUrl; + } + } + + /** + * @Given /^As an "([^"]*)"$/ + */ + public function asAn($user) { + $this->currentUser = $user; + } + + /** + * @Given /^Using server "([^"]*)"$/ + */ + public function usingServer($server) { + if ($server === 'LOCAL'){ + $this->baseUrl = $this->localBaseUrl; + $this->currentServer = 'LOCAL'; + } elseif ($server === 'REMOTE'){ + $this->baseUrl = $this->remoteBaseUrl; + $this->currentServer = 'REMOTE'; + } else{ + PHPUnit_Framework_Assert::fail("Server can only be LOCAL or REMOTE"); + } + } + + /** + * @When /^sending "([^"]*)" to "([^"]*)"$/ + */ + public function sendingTo($verb, $url) { + $this->sendingToWith($verb, $url, null); + } + + /** + * Parses the xml answer to get ocs response which doesn't match with + * http one in v1 of the api. + * @param ResponseInterface $response + * @return string + */ + public function getOCSResponse($response) { + return $response->xml()->meta[0]->statuscode; + } + + /** + * This function is needed to use a vertical fashion in the gherkin tables. + */ + public function simplifyArray($arrayOfArrays){ + $a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays); + return $a; + } + + /** + * @When /^sending "([^"]*)" to "([^"]*)" with$/ + * @param \Behat\Gherkin\Node\TableNode|null $formData + */ + public function sendingToWith($verb, $url, $body) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php" . $url; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUser]; + } + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + $options['body'] = $fd; + } + + try { + $this->response = $client->send($client->createRequest($verb, $fullUrl, $options)); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + } + + public function isExpectedUrl($possibleUrl, $finalPart){ + $baseUrlChopped = substr($this->baseUrl, 0, -4); + $endCharacter = strlen($baseUrlChopped) + strlen($finalPart); + return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart"); + } + + /** + * @Then /^the OCS status code should be "([^"]*)"$/ + */ + public function theOCSStatusCodeShouldBe($statusCode) { + PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response)); + } + + /** + * @Then /^the HTTP status code should be "([^"]*)"$/ + */ + public function theHTTPStatusCodeShouldBe($statusCode) { + PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode()); + } + + public static function removeFile($path, $filename){ + if (file_exists("$path" . "$filename")) { + unlink("$path" . "$filename"); + } + } + + /** + * @BeforeSuite + */ + public static function addFilesToSkeleton(){ + for ($i=0; $i<5; $i++){ + file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "ownCloud test text file\n"); + } + if (!file_exists("../../core/skeleton/FOLDER")) { + mkdir("../../core/skeleton/FOLDER", 0777, true); + } + + } + + /** + * @AfterSuite + */ + public static function removeFilesFromSkeleton(){ + for ($i=0; $i<5; $i++){ + self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt"); + } + if (is_dir("../../core/skeleton/FOLDER")) { + rmdir("../../core/skeleton/FOLDER"); + } + } +} + diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index b3d928bb21d..78ff4e7833d 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -7,1055 +7,13 @@ use GuzzleHttp\Message\ResponseInterface; require __DIR__ . '/../../vendor/autoload.php'; + /** * Features context. */ class FeatureContext implements Context, SnippetAcceptingContext { - - /** @var string */ - private $baseUrl = ''; - - /** @var ResponseInterface */ - private $response = null; - - /** @var string */ - private $currentUser = ''; - - /** @var int */ - private $apiVersion = 1; - - /** @var int */ - private $sharingApiVersion = 1; - - /** @var string*/ - private $davPath = "remote.php/webdav"; - - /** @var SimpleXMLElement */ - private $lastShareData = null; - - /** @var array */ - private $createdUsers = []; - - /** @var array */ - private $createdGroups = []; - - public function __construct($baseUrl, $admin, $regular_user_password) { - - // Initialize your context here - $this->baseUrl = $baseUrl; - $this->adminUser = $admin; - $this->regularUser = $regular_user_password; - - // in case of ci deployment we take the server url from the environment - $testServerUrl = getenv('TEST_SERVER_URL'); - if ($testServerUrl !== false) { - $this->baseUrl = $testServerUrl; - } - } - - /** - * @When /^sending "([^"]*)" to "([^"]*)"$/ - */ - public function sendingTo($verb, $url) { - $this->sendingToWith($verb, $url, null); - } - - /** - * Parses the xml answer to get ocs response which doesn't match with - * http one in v1 of the api. - * @param ResponseInterface $response - * @return string - */ - public function getOCSResponse($response) { - return $response->xml()->meta[0]->statuscode; - } - - /** - * Parses the xml answer to get the array of users returned. - * @param ResponseInterface $resp - * @return array - */ - public function getArrayOfUsersResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->users[0]->element; - $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); - return $extractedElementsArray; - } - - /** - * Parses the xml answer to get the array of groups returned. - * @param ResponseInterface $resp - * @return array - */ - public function getArrayOfGroupsResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->groups[0]->element; - $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); - return $extractedElementsArray; - } - - /** - * Parses the xml answer to get the array of subadmins returned. - * @param ResponseInterface $resp - * @return array - */ - public function getArrayOfSubadminsResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->element; - $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); - return $extractedElementsArray; - } - - /** - * Parses the xml answer to get the array of apps returned. - * @param ResponseInterface $resp - * @return array - */ - public function getArrayOfAppsResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->apps[0]->element; - $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); - return $extractedElementsArray; - } - - /** - * This function is needed to use a vertical fashion in the gherkin tables. - */ - public function simplifyArray($arrayOfArrays){ - $a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays); - return $a; - } - - /** - * @Then /^users returned are$/ - * @param \Behat\Gherkin\Node\TableNode|null $usersList - */ - public function theUsersShouldBe($usersList) { - if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { - $users = $usersList->getRows(); - $usersSimplified = $this->simplifyArray($users); - $respondedArray = $this->getArrayOfUsersResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($usersSimplified, $respondedArray, "", 0.0, 10, true); - } - - } - - /** - * @Then /^groups returned are$/ - * @param \Behat\Gherkin\Node\TableNode|null $groupsList - */ - public function theGroupsShouldBe($groupsList) { - if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { - $groups = $groupsList->getRows(); - $groupsSimplified = $this->simplifyArray($groups); - $respondedArray = $this->getArrayOfGroupsResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($groupsSimplified, $respondedArray, "", 0.0, 10, true); - } - - } - - /** - * @Then /^subadmin groups returned are$/ - * @param \Behat\Gherkin\Node\TableNode|null $groupsList - */ - public function theSubadminGroupsShouldBe($groupsList) { - if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { - $groups = $groupsList->getRows(); - $groupsSimplified = $this->simplifyArray($groups); - $respondedArray = $this->getArrayOfSubadminsResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($groupsSimplified, $respondedArray, "", 0.0, 10, true); - } - - } - - /** - * @Then /^subadmin users returned are$/ - * @param \Behat\Gherkin\Node\TableNode|null $groupsList - */ - public function theSubadminUsersShouldBe($groupsList) { - $this->theSubadminGroupsShouldBe($groupsList); - } - - /** - * @Then /^apps returned are$/ - * @param \Behat\Gherkin\Node\TableNode|null $appList - */ - public function theAppsShouldBe($appList) { - if ($appList instanceof \Behat\Gherkin\Node\TableNode) { - $apps = $appList->getRows(); - $appsSimplified = $this->simplifyArray($apps); - $respondedArray = $this->getArrayOfAppsResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($appsSimplified, $respondedArray, "", 0.0, 10, true); - } - - } - - /** - * @Then /^the OCS status code should be "([^"]*)"$/ - */ - public function theOCSStatusCodeShouldBe($statusCode) { - PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response)); - } - - /** - * @Then /^the HTTP status code should be "([^"]*)"$/ - */ - public function theHTTPStatusCodeShouldBe($statusCode) { - PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode()); - } - - /** - * @Given /^As an "([^"]*)"$/ - */ - public function asAn($user) { - $this->currentUser = $user; - } - - /** - * @Given /^using api version "([^"]*)"$/ - */ - public function usingApiVersion($version) { - $this->apiVersion = $version; - } - - /** - * @Given /^using dav path "([^"]*)"$/ - */ - public function usingDavPath($davPath) { - $this->davPath = $davPath; - } - - /** - * @Given /^user "([^"]*)" exists$/ - */ - public function assureUserExists($user) { - try { - $this->userExists($user); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->creatingTheUser($user); - $this->currentUser = $previous_user; - } - $this->userExists($user); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - - } - - public function userExists($user){ - $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user"; - $client = new Client(); - $options = []; - $options['auth'] = $this->adminUser; - - $this->response = $client->get($fullUrl, $options); - } - - /** - * @Then /^check that user "([^"]*)" belongs to group "([^"]*)"$/ - */ - public function checkThatUserBelongsToGroup($user, $group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfGroupsResponded($this->response); - sort($respondedArray); - PHPUnit_Framework_Assert::assertContains($group, $respondedArray); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - public function userBelongsToGroup($user, $group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $groups = array($group); - $respondedArray = $this->getArrayOfGroupsResponded($this->response); - - if (array_key_exists($group, $respondedArray)) { - return True; - } else{ - return False; - } - } - - /** - * @Given /^user "([^"]*)" belongs to group "([^"]*)"$/ - */ - public function assureUserBelongsToGroup($user, $group){ - if (!$this->userBelongsToGroup($user, $group)){ - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->addingUserToGroup($user, $group); - $this->currentUser = $previous_user; - } - $this->checkThatUserBelongsToGroup($user, $group); - - } - - /** - * @Given /^user "([^"]*)" does not belong to group "([^"]*)"$/ - */ - public function userDoesNotBelongToGroup($user, $group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $groups = array($group); - $respondedArray = $this->getArrayOfGroupsResponded($this->response); - PHPUnit_Framework_Assert::assertNotEquals($groups, $respondedArray, "", 0.0, 10, true); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - - /** - * @Given /^user "([^"]*)" is subadmin of group "([^"]*)"$/ - */ - public function userIsSubadminOfGroup($user, $group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfSubadminsResponded($this->response); - sort($respondedArray); - PHPUnit_Framework_Assert::assertContains($user, $respondedArray); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - /** - * @Given /^user "([^"]*)" is not a subadmin of group "([^"]*)"$/ - */ - public function userIsNotSubadminOfGroup($user, $group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfSubadminsResponded($this->response); - sort($respondedArray); - PHPUnit_Framework_Assert::assertNotContains($user, $respondedArray); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - /** - * @Given /^user "([^"]*)" does not exist$/ - */ - public function userDoesNotExist($user) { - try { - $this->userExists($user); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); - return; - } - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->deletingTheUser($user); - $this->currentUser = $previous_user; - try { - $this->userExists($user); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); - } - } - - /** - * @Given /^app "([^"]*)" is disabled$/ - */ - public function appIsDisabled($app) { - $fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=disabled"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfAppsResponded($this->response); - PHPUnit_Framework_Assert::assertContains($app, $respondedArray); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - /** - * @Given /^app "([^"]*)" is enabled$/ - */ - public function appIsEnabled($app) { - $fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=enabled"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->get($fullUrl, $options); - $respondedArray = $this->getArrayOfAppsResponded($this->response); - PHPUnit_Framework_Assert::assertContains($app, $respondedArray); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - public function createUser($user) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->creatingTheUser($user); - $this->userExists($user); - $this->currentUser = $previous_user; - } - - public function deleteUser($user) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->deletingTheUser($user); - $this->userDoesNotExist($user); - $this->currentUser = $previous_user; - } - - public function createGroup($group) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->creatingTheGroup($group); - $this->groupExists($group); - $this->currentUser = $previous_user; - } - - public function deleteGroup($group) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->deletingTheGroup($group); - $this->groupDoesNotExist($group); - $this->currentUser = $previous_user; - } - - public function creatingTheUser($user) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $options['body'] = [ - 'userid' => $user, - 'password' => '123456' - ]; - - $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - $this->createdUsers[$user] = $user; - } - - /** - * @When /^creating the group "([^"]*)"$/ - */ - public function creatingTheGroup($group) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $options['body'] = [ - 'groupid' => $group, - ]; - - $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - $this->createdGroups[$group] = $group; - } - - /** - * @When /^Deleting the user "([^"]*)"$/ - */ - public function deletingTheUser($user) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options)); - } - - /** - * @When /^Deleting the group "([^"]*)"$/ - */ - public function deletingTheGroup($group) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options)); - } - - /** - * @Given /^Add user "([^"]*)" to the group "([^"]*)"$/ - */ - public function addUserToGroup($user, $group) { - $this->userExists($user); - $this->groupExists($group); - $this->addingUserToGroup($user, $group); - - } - - /** - * @When /^User "([^"]*)" is added to the group "([^"]*)"$/ - */ - public function addingUserToGroup($user, $group) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/groups"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } - - $options['body'] = [ - 'groupid' => $group, - ]; - - $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - } - - - public function groupExists($group) { - $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group"; - $client = new Client(); - $options = []; - $options['auth'] = $this->adminUser; - - $this->response = $client->get($fullUrl, $options); - } - - /** - * @Given /^group "([^"]*)" exists$/ - */ - public function assureGroupExists($group) { - try { - $this->groupExists($group); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->creatingTheGroup($group); - $this->currentUser = $previous_user; - } - $this->groupExists($group); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - /** - * @Given /^group "([^"]*)" does not exist$/ - */ - public function groupDoesNotExist($group) { - try { - $this->groupExists($group); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); - return; - } - $previous_user = $this->currentUser; - $this->currentUser = "admin"; - $this->deletingTheGroup($group); - $this->currentUser = $previous_user; - try { - $this->groupExists($group); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); - } - } - - /** - * @When /^sending "([^"]*)" to "([^"]*)" with$/ - * @param \Behat\Gherkin\Node\TableNode|null $formData - */ - public function sendingToWith($verb, $url, $body) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php" . $url; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$this->currentUser, $this->regularUser]; - } - if ($body instanceof \Behat\Gherkin\Node\TableNode) { - $fd = $body->getRowsHash(); - $options['body'] = $fd; - } - - try { - $this->response = $client->send($client->createRequest($verb, $fullUrl, $options)); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - } - } - - /** - * @When /^creating a share with$/ - * @param \Behat\Gherkin\Node\TableNode|null $formData - */ - public function creatingShare($body) { - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v1/shares"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$this->currentUser, $this->regularUser]; - } - - if ($body instanceof \Behat\Gherkin\Node\TableNode) { - $fd = $body->getRowsHash(); - if (array_key_exists('expireDate', $fd)){ - $dateModification = $fd['expireDate']; - $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); - } - $options['body'] = $fd; - } - - try { - $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - } - - $this->lastShareData = $this->response->xml(); - } - - /** - * @Then /^Public shared file "([^"]*)" can be downloaded$/ - */ - public function checkPublicSharedFile($filename) { - $client = new Client(); - $options = []; - if (count($this->lastShareData->data->element) > 0){ - $url = $this->lastShareData->data[0]->url; - } - else{ - $url = $this->lastShareData->data->url; - } - $fullUrl = $url . "/download"; - $options['save_to'] = "./$filename"; - $this->response = $client->get($fullUrl, $options); - $finfo = new finfo; - $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); - PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); - if (file_exists("./$filename")) { - unlink("./$filename"); - } - } - - /** - * @Then /^Public shared file "([^"]*)" with password "([^"]*)" can be downloaded$/ - */ - public function checkPublicSharedFileWithPassword($filename, $password) { - $client = new Client(); - $options = []; - if (count($this->lastShareData->data->element) > 0){ - $token = $this->lastShareData->data[0]->token; - } - else{ - $token = $this->lastShareData->data->token; - } - - $fullUrl = substr($this->baseUrl, 0, -4) . "public.php/webdav"; - $options['auth'] = [$token, $password]; - $options['save_to'] = "./$filename"; - $this->response = $client->get($fullUrl, $options); - $finfo = new finfo; - $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); - PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); - if (file_exists("./$filename")) { - unlink("./$filename"); - } - } - - /** - * @When /^Adding expiration date to last share$/ - */ - public function addingExpirationDate() { - $share_id = $this->lastShareData->data[0]->id; - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$this->currentUser, $this->regularUser]; - } - $date = date('Y-m-d', strtotime("+3 days")); - $options['body'] = ['expireDate' => $date]; - $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - /** - * @When /^Updating last share with$/ - * @param \Behat\Gherkin\Node\TableNode|null $body - */ - public function updatingLastShare($body) { - $share_id = $this->lastShareData->data[0]->id; - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; - $client = new Client(); - $options = []; - if ($this->currentUser === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$this->currentUser, $this->regularUser]; - } - - if ($body instanceof \Behat\Gherkin\Node\TableNode) { - $fd = $body->getRowsHash(); - if (array_key_exists('expireDate', $fd)){ - $dateModification = $fd['expireDate']; - $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); - } - $options['body'] = $fd; - } - - try { - $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - } - - PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } - - - public function createShare($user, - $path = null, - $shareType = null, - $shareWith = null, - $publicUpload = null, - $password = null, - $permissions = null){ - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares"; - $client = new Client(); - $options = []; - - if ($user === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$user, $this->regularUser]; - } - $fd = []; - if (!is_null($path)){ - $fd['path'] = $path; - } - if (!is_null($shareType)){ - $fd['shareType'] = $shareType; - } - if (!is_null($shareWith)){ - $fd['shareWith'] = $shareWith; - } - if (!is_null($publicUpload)){ - $fd['publicUpload'] = $publicUpload; - } - if (!is_null($password)){ - $fd['password'] = $password; - } - if (!is_null($permissions)){ - $fd['permissions'] = $permissions; - } - - $options['body'] = $fd; - - try { - $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - $this->lastShareData = $this->response->xml(); - } catch (\GuzzleHttp\Exception\ClientException $ex) { - $this->response = $ex->getResponse(); - } - - } - - public function isExpectedUrl($possibleUrl, $finalPart){ - $baseUrlChopped = substr($this->baseUrl, 0, -4); - $endCharacter = strlen($baseUrlChopped) + strlen($finalPart); - return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart"); - } - - public function isFieldInResponse($field, $contentExpected){ - $data = $this->response->xml()->data[0]; - if ((string)$field == 'expiration'){ - $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; - } - if (count($data->element) > 0){ - foreach($data as $element) { - if ($contentExpected == "A_TOKEN"){ - return (strlen((string)$element->$field) == 15); - } - elseif ($contentExpected == "A_NUMBER"){ - return is_numeric((string)$element->$field); - } - elseif($contentExpected == "AN_URL"){ - return $this->isExpectedUrl((string)$element->$field, "index.php/s/"); - } - elseif ((string)$element->$field == $contentExpected){ - return True; - } - } - - return False; - } else { - if ($contentExpected == "A_TOKEN"){ - return (strlen((string)$data->$field) == 15); - } - elseif ($contentExpected == "A_NUMBER"){ - return is_numeric((string)$data->$field); - } - elseif($contentExpected == "AN_URL"){ - return $this->isExpectedUrl((string)$data->$field, "index.php/s/"); - } - elseif ($data->$field == $contentExpected){ - return True; - } - return False; - } - } - - /** - * @Then /^File "([^"]*)" should be included in the response$/ - */ - public function checkSharedFileInResponse($filename){ - PHPUnit_Framework_Assert::assertEquals(True, $this->isFieldInResponse('file_target', "/$filename")); - } - - /** - * @Then /^File "([^"]*)" should not be included in the response$/ - */ - public function checkSharedFileNotInResponse($filename){ - PHPUnit_Framework_Assert::assertEquals(False, $this->isFieldInResponse('file_target', "/$filename")); - } - - /** - * @Then /^User "([^"]*)" should be included in the response$/ - */ - public function checkSharedUserInResponse($user){ - PHPUnit_Framework_Assert::assertEquals(True, $this->isFieldInResponse('share_with', "$user")); - } - - /** - * @Then /^User "([^"]*)" should not be included in the response$/ - */ - public function checkSharedUserNotInResponse($user){ - PHPUnit_Framework_Assert::assertEquals(False, $this->isFieldInResponse('share_with', "$user")); - } - - public function isUserOrGroupInSharedData($userOrGroup){ - $data = $this->response->xml()->data[0]; - foreach($data as $element) { - if ($element->share_with == $userOrGroup){ - return True; - } - } - return False; - } - - /** - * @Given /^file "([^"]*)" from user "([^"]*)" is shared with user "([^"]*)"$/ - */ - public function assureFileIsShared($filepath, $user1, $user2){ - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath"; - $client = new Client(); - $options = []; - if ($user1 === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$user1, $this->regularUser]; - } - $this->response = $client->get($fullUrl, $options); - if ($this->isUserOrGroupInSharedData($user2)){ - return; - } else { - $this->createShare($user1, $filepath, 0, $user2, null, null, null); - } - $this->response = $client->get($fullUrl, $options); - PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($user2)); - } - - /** - * @Given /^file "([^"]*)" from user "([^"]*)" is shared with group "([^"]*)"$/ - */ - public function assureFileIsSharedWithGroup($filepath, $user, $group){ - $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath"; - $client = new Client(); - $options = []; - if ($user === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$user, $this->regularUser]; - } - $this->response = $client->get($fullUrl, $options); - if ($this->isUserOrGroupInSharedData($group)){ - return; - } else { - $this->createShare($user, $filepath, 1, $group, null, null, null); - } - $this->response = $client->get($fullUrl, $options); - PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($group)); - } - - public function makeDavRequest($user, $method, $path, $headers){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; - $client = new Client(); - $options = []; - if ($user === 'admin') { - $options['auth'] = $this->adminUser; - } else { - $options['auth'] = [$user, $this->regularUser]; - } - $request = $client->createRequest($method, $fullUrl, $options); - foreach ($headers as $key => $value) { - $request->addHeader($key, $value); - } - //$this->response = $client->send($request); - return $client->send($request); - } - - /** - * @Given /^User "([^"]*)" moved file "([^"]*)" to "([^"]*)"$/ - */ - public function userMovedFile($user, $fileSource, $fileDestination){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; - $headers['Destination'] = $fullUrl . $fileDestination; - $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); - PHPUnit_Framework_Assert::assertEquals(201, $this->response->getStatusCode()); - } - - /** - * @When /^User "([^"]*)" moves file "([^"]*)" to "([^"]*)"$/ - */ - public function userMovesFile($user, $fileSource, $fileDestination){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; - $headers['Destination'] = $fullUrl . $fileDestination; - $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); - } - - /** - * @When /^Deleting last share$/ - */ - public function deletingLastShare(){ - $share_id = $this->lastShareData->data[0]->id; - $url = "/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; - $this->sendingToWith("DELETE", $url, null); - } - - /** - * @When /^Getting info of last share$/ - */ - public function gettingInfoOfLastShare(){ - $share_id = $this->lastShareData->data[0]->id; - $url = "/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; - $this->sendingToWith("GET", $url, null); - } - - /** - * @Then /^last share_id is included in the answer$/ - */ - public function checkingLastShareIDIsIncluded(){ - $share_id = $this->lastShareData->data[0]->id; - if (!$this->isFieldInResponse('id', $share_id)){ - PHPUnit_Framework_Assert::fail("Share id $share_id not found in response"); - } - } - - /** - * @Then /^last share_id is not included in the answer$/ - */ - public function checkingLastShareIDIsNotIncluded(){ - $share_id = $this->lastShareData->data[0]->id; - if ($this->isFieldInResponse('id', $share_id)){ - PHPUnit_Framework_Assert::fail("Share id $share_id has been found in response"); - } - } - - /** - * @Then /^Share fields of last share match with$/ - * @param \Behat\Gherkin\Node\TableNode|null $formData - */ - public function checkShareFields($body){ - if ($body instanceof \Behat\Gherkin\Node\TableNode) { - $fd = $body->getRowsHash(); - - foreach($fd as $field => $value) { - if (!$this->isFieldInResponse($field, $value)){ - PHPUnit_Framework_Assert::fail("$field" . " doesn't have value " . "$value"); - } - } - } - } - - public static function removeFile($path, $filename){ - if (file_exists("$path" . "$filename")) { - unlink("$path" . "$filename"); - } - } - - /** - * @BeforeSuite - */ - public static function addFilesToSkeleton(){ - for ($i=0; $i<5; $i++){ - file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "ownCloud test text file\n"); - } - if (!file_exists("../../core/skeleton/FOLDER")) { - mkdir("../../core/skeleton/FOLDER", 0777, true); - } - - } - - /** - * @AfterSuite - */ - public static function removeFilesFromSkeleton(){ - for ($i=0; $i<5; $i++){ - self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt"); - } - if (is_dir("../../core/skeleton/FOLDER")) { - rmdir("../../core/skeleton/FOLDER"); - } - } - - /** - * @BeforeScenario - * @AfterScenario - */ - public function cleanupUsers() - { - foreach($this->createdUsers as $user) { - $this->deleteUser($user); - } - } - - - /** - * @BeforeScenario - * @AfterScenario - */ - public function cleanupGroups() - { - foreach($this->createdGroups as $group) { - $this->deleteGroup($group); - } - } + use BasicStructure; + use Provisioning; + use Sharing; + use WebDav; } diff --git a/build/integration/features/bootstrap/FederationContext.php b/build/integration/features/bootstrap/FederationContext.php new file mode 100644 index 00000000000..279b5206dee --- /dev/null +++ b/build/integration/features/bootstrap/FederationContext.php @@ -0,0 +1,27 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + +/** + * Federation context. + */ +class FederationContext implements Context, SnippetAcceptingContext { + + use BasicStructure; + use Provisioning; + use Sharing; + + /** + * @When /^User "([^"]*)" from server "([^"]*)" shares "([^"]*)" with user "([^"]*)" from server "([^"]*)"$/ + */ + public function federateSharing($userLocal, $serverLocal, $pathLocal, $userRemote, $serverRemote){ + $shareWith = "$userRemote@" . substr($this->remoteBaseUrl, 0, -4); + $this->createShare($userLocal, $pathLocal, 6, $shareWith, null, null, null); + } + +} diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php new file mode 100644 index 00000000000..05a8885d96d --- /dev/null +++ b/build/integration/features/bootstrap/Provisioning.php @@ -0,0 +1,548 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + +trait Provisioning { + + /** @var int */ + private $apiVersion = 1; + + /** @var array */ + private $createdUsers = []; + + /** @var array */ + private $createdRemoteUsers = []; + + /** @var array */ + private $createdRemoteGroups = []; + + /** @var array */ + private $createdGroups = []; + + /** + * @Given /^using api version "([^"]*)"$/ + */ + public function usingApiVersion($version) { + $this->apiVersion = $version; + } + + /** + * @Given /^user "([^"]*)" exists$/ + */ + public function assureUserExists($user) { + try { + $this->userExists($user); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->creatingTheUser($user); + $this->currentUser = $previous_user; + } + $this->userExists($user); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + + } + + /** + * @Given /^user "([^"]*)" does not exist$/ + */ + public function userDoesNotExist($user) { + try { + $this->userExists($user); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); + return; + } + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->deletingTheUser($user); + $this->currentUser = $previous_user; + try { + $this->userExists($user); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); + } + } + + public function creatingTheUser($user) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $options['body'] = [ + 'userid' => $user, + 'password' => '123456' + ]; + + $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); + if ($this->currentServer === 'LOCAL'){ + $this->createdUsers[$user] = $user; + } elseif ($this->currentServer === 'REMOTE') { + $this->createdRemoteUsers[$user] = $user; + } + + } + + public function createUser($user) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->creatingTheUser($user); + $this->userExists($user); + $this->currentUser = $previous_user; + } + + public function deleteUser($user) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->deletingTheUser($user); + $this->userDoesNotExist($user); + $this->currentUser = $previous_user; + } + + public function createGroup($group) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->creatingTheGroup($group); + $this->groupExists($group); + $this->currentUser = $previous_user; + } + + public function deleteGroup($group) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->deletingTheGroup($group); + $this->groupDoesNotExist($group); + $this->currentUser = $previous_user; + } + + public function userExists($user){ + $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user"; + $client = new Client(); + $options = []; + $options['auth'] = $this->adminUser; + + $this->response = $client->get($fullUrl, $options); + } + + /** + * @Then /^check that user "([^"]*)" belongs to group "([^"]*)"$/ + */ + public function checkThatUserBelongsToGroup($user, $group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + sort($respondedArray); + PHPUnit_Framework_Assert::assertContains($group, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + public function userBelongsToGroup($user, $group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $groups = array($group); + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + + if (array_key_exists($group, $respondedArray)) { + return True; + } else{ + return False; + } + } + + /** + * @Given /^user "([^"]*)" belongs to group "([^"]*)"$/ + */ + public function assureUserBelongsToGroup($user, $group){ + if (!$this->userBelongsToGroup($user, $group)){ + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->addingUserToGroup($user, $group); + $this->currentUser = $previous_user; + } + $this->checkThatUserBelongsToGroup($user, $group); + + } + + /** + * @Given /^user "([^"]*)" does not belong to group "([^"]*)"$/ + */ + public function userDoesNotBelongToGroup($user, $group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $groups = array($group); + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + PHPUnit_Framework_Assert::assertNotEquals($groups, $respondedArray, "", 0.0, 10, true); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @When /^creating the group "([^"]*)"$/ + */ + public function creatingTheGroup($group) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $options['body'] = [ + 'groupid' => $group, + ]; + + $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); + if ($this->currentServer === 'LOCAL'){ + $this->createdGroups[$group] = $group; + } elseif ($this->currentServer === 'REMOTE') { + $this->createdRemoteGroups[$group] = $group; + } + } + + /** + * @When /^Deleting the user "([^"]*)"$/ + */ + public function deletingTheUser($user) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options)); + } + + /** + * @When /^Deleting the group "([^"]*)"$/ + */ + public function deletingTheGroup($group) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options)); + } + + /** + * @Given /^Add user "([^"]*)" to the group "([^"]*)"$/ + */ + public function addUserToGroup($user, $group) { + $this->userExists($user); + $this->groupExists($group); + $this->addingUserToGroup($user, $group); + + } + + /** + * @When /^User "([^"]*)" is added to the group "([^"]*)"$/ + */ + public function addingUserToGroup($user, $group) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/groups"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $options['body'] = [ + 'groupid' => $group, + ]; + + $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); + } + + + public function groupExists($group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group"; + $client = new Client(); + $options = []; + $options['auth'] = $this->adminUser; + + $this->response = $client->get($fullUrl, $options); + } + + /** + * @Given /^group "([^"]*)" exists$/ + */ + public function assureGroupExists($group) { + try { + $this->groupExists($group); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->creatingTheGroup($group); + $this->currentUser = $previous_user; + } + $this->groupExists($group); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @Given /^group "([^"]*)" does not exist$/ + */ + public function groupDoesNotExist($group) { + try { + $this->groupExists($group); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); + return; + } + $previous_user = $this->currentUser; + $this->currentUser = "admin"; + $this->deletingTheGroup($group); + $this->currentUser = $previous_user; + try { + $this->groupExists($group); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + PHPUnit_Framework_Assert::assertEquals(404, $ex->getResponse()->getStatusCode()); + } + } + + /** + * @Given /^user "([^"]*)" is subadmin of group "([^"]*)"$/ + */ + public function userIsSubadminOfGroup($user, $group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfSubadminsResponded($this->response); + sort($respondedArray); + PHPUnit_Framework_Assert::assertContains($user, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @Given /^user "([^"]*)" is not a subadmin of group "([^"]*)"$/ + */ + public function userIsNotSubadminOfGroup($user, $group) { + $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfSubadminsResponded($this->response); + sort($respondedArray); + PHPUnit_Framework_Assert::assertNotContains($user, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @Then /^users returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $usersList + */ + public function theUsersShouldBe($usersList) { + if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { + $users = $usersList->getRows(); + $usersSimplified = $this->simplifyArray($users); + $respondedArray = $this->getArrayOfUsersResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($usersSimplified, $respondedArray, "", 0.0, 10, true); + } + + } + + /** + * @Then /^groups returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $groupsList + */ + public function theGroupsShouldBe($groupsList) { + if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { + $groups = $groupsList->getRows(); + $groupsSimplified = $this->simplifyArray($groups); + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($groupsSimplified, $respondedArray, "", 0.0, 10, true); + } + + } + + /** + * @Then /^subadmin groups returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $groupsList + */ + public function theSubadminGroupsShouldBe($groupsList) { + if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { + $groups = $groupsList->getRows(); + $groupsSimplified = $this->simplifyArray($groups); + $respondedArray = $this->getArrayOfSubadminsResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($groupsSimplified, $respondedArray, "", 0.0, 10, true); + } + + } + + /** + * @Then /^apps returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $appList + */ + public function theAppsShouldBe($appList) { + if ($appList instanceof \Behat\Gherkin\Node\TableNode) { + $apps = $appList->getRows(); + $appsSimplified = $this->simplifyArray($apps); + $respondedArray = $this->getArrayOfAppsResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($appsSimplified, $respondedArray, "", 0.0, 10, true); + } + + } + + /** + * @Then /^subadmin users returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $groupsList + */ + public function theSubadminUsersShouldBe($groupsList) { + $this->theSubadminGroupsShouldBe($groupsList); + } + + /** + * Parses the xml answer to get the array of users returned. + * @param ResponseInterface $resp + * @return array + */ + public function getArrayOfUsersResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->users[0]->element; + $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); + return $extractedElementsArray; + } + + /** + * Parses the xml answer to get the array of groups returned. + * @param ResponseInterface $resp + * @return array + */ + public function getArrayOfGroupsResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->groups[0]->element; + $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); + return $extractedElementsArray; + } + + /** + * Parses the xml answer to get the array of apps returned. + * @param ResponseInterface $resp + * @return array + */ + public function getArrayOfAppsResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->apps[0]->element; + $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); + return $extractedElementsArray; + } + + /** + * Parses the xml answer to get the array of subadmins returned. + * @param ResponseInterface $resp + * @return array + */ + public function getArrayOfSubadminsResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->element; + $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); + return $extractedElementsArray; + } + + + /** + * @Given /^app "([^"]*)" is disabled$/ + */ + public function appIsDisabled($app) { + $fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=disabled"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfAppsResponded($this->response); + PHPUnit_Framework_Assert::assertContains($app, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @Given /^app "([^"]*)" is enabled$/ + */ + public function appIsEnabled($app) { + $fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=enabled"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfAppsResponded($this->response); + PHPUnit_Framework_Assert::assertContains($app, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @BeforeScenario + * @AfterScenario + */ + public function cleanupUsers() + { + $previousServer = $this->currentServer; + $this->usingServer('LOCAL'); + foreach($this->createdUsers as $user) { + $this->deleteUser($user); + } + $this->usingServer('REMOTE'); + foreach($this->createdRemoteUsers as $remoteUser) { + $this->deleteUser($remoteUser); + } + $this->usingServer($previousServer); + } + + /** + * @BeforeScenario + * @AfterScenario + */ + public function cleanupGroups() + { + $previousServer = $this->currentServer; + $this->usingServer('LOCAL'); + foreach($this->createdGroups as $group) { + $this->deleteGroup($group); + } + $this->usingServer('REMOTE'); + foreach($this->createdRemoteGroups as $remoteGroup) { + $this->deleteUser($remoteGroup); + } + $this->usingServer($previousServer); + } +} diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php new file mode 100644 index 00000000000..9c5dc9f374b --- /dev/null +++ b/build/integration/features/bootstrap/Sharing.php @@ -0,0 +1,374 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + + + +trait Sharing{ + + /** @var int */ + private $sharingApiVersion = 1; + + /** @var SimpleXMLElement */ + private $lastShareData = null; + + /** + * @When /^creating a share with$/ + * @param \Behat\Gherkin\Node\TableNode|null $formData + */ + public function creatingShare($body) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v1/shares"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUser]; + } + + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + if (array_key_exists('expireDate', $fd)){ + $dateModification = $fd['expireDate']; + $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); + } + $options['body'] = $fd; + } + + try { + $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + + $this->lastShareData = $this->response->xml(); + } + + /** + * @Then /^Public shared file "([^"]*)" can be downloaded$/ + */ + public function checkPublicSharedFile($filename) { + $client = new Client(); + $options = []; + if (count($this->lastShareData->data->element) > 0){ + $url = $this->lastShareData->data[0]->url; + } + else{ + $url = $this->lastShareData->data->url; + } + $fullUrl = $url . "/download"; + $options['save_to'] = "./$filename"; + $this->response = $client->get($fullUrl, $options); + $finfo = new finfo; + $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); + PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); + if (file_exists("./$filename")) { + unlink("./$filename"); + } + } + + /** + * @Then /^Public shared file "([^"]*)" with password "([^"]*)" can be downloaded$/ + */ + public function checkPublicSharedFileWithPassword($filename, $password) { + $client = new Client(); + $options = []; + if (count($this->lastShareData->data->element) > 0){ + $token = $this->lastShareData->data[0]->token; + } + else{ + $token = $this->lastShareData->data->token; + } + + $fullUrl = substr($this->baseUrl, 0, -4) . "public.php/webdav"; + $options['auth'] = [$token, $password]; + $options['save_to'] = "./$filename"; + $this->response = $client->get($fullUrl, $options); + $finfo = new finfo; + $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); + PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); + if (file_exists("./$filename")) { + unlink("./$filename"); + } + } + + /** + * @When /^Adding expiration date to last share$/ + */ + public function addingExpirationDate() { + $share_id = $this->lastShareData->data[0]->id; + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUser]; + } + $date = date('Y-m-d', strtotime("+3 days")); + $options['body'] = ['expireDate' => $date]; + $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + /** + * @When /^Updating last share with$/ + * @param \Behat\Gherkin\Node\TableNode|null $body + */ + public function updatingLastShare($body) { + $share_id = $this->lastShareData->data[0]->id; + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUser]; + } + + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + if (array_key_exists('expireDate', $fd)){ + $dateModification = $fd['expireDate']; + $fd['expireDate'] = date('Y-m-d', strtotime($dateModification)); + } + $options['body'] = $fd; + } + + try { + $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + + PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); + } + + public function createShare($user, + $path = null, + $shareType = null, + $shareWith = null, + $publicUpload = null, + $password = null, + $permissions = null){ + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares"; + $client = new Client(); + $options = []; + + if ($user === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$user, $this->regularUser]; + } + $fd = []; + if (!is_null($path)){ + $fd['path'] = $path; + } + if (!is_null($shareType)){ + $fd['shareType'] = $shareType; + } + if (!is_null($shareWith)){ + $fd['shareWith'] = $shareWith; + } + if (!is_null($publicUpload)){ + $fd['publicUpload'] = $publicUpload; + } + if (!is_null($password)){ + $fd['password'] = $password; + } + if (!is_null($permissions)){ + $fd['permissions'] = $permissions; + } + + $options['body'] = $fd; + + try { + $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); + $this->lastShareData = $this->response->xml(); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + } + + public function isFieldInResponse($field, $contentExpected){ + $data = $this->response->xml()->data[0]; + if ((string)$field == 'expiration'){ + $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; + } + if (count($data->element) > 0){ + foreach($data as $element) { + if ($contentExpected == "A_TOKEN"){ + return (strlen((string)$element->$field) == 15); + } + elseif ($contentExpected == "A_NUMBER"){ + return is_numeric((string)$element->$field); + } + elseif($contentExpected == "AN_URL"){ + return $this->isExpectedUrl((string)$element->$field, "index.php/s/"); + } + elseif ((string)$element->$field == $contentExpected){ + return True; + } + } + + return False; + } else { + if ($contentExpected == "A_TOKEN"){ + return (strlen((string)$data->$field) == 15); + } + elseif ($contentExpected == "A_NUMBER"){ + return is_numeric((string)$data->$field); + } + elseif($contentExpected == "AN_URL"){ + return $this->isExpectedUrl((string)$data->$field, "index.php/s/"); + } + elseif ($data->$field == $contentExpected){ + return True; + } + return False; + } + } + + /** + * @Then /^File "([^"]*)" should be included in the response$/ + */ + public function checkSharedFileInResponse($filename){ + PHPUnit_Framework_Assert::assertEquals(True, $this->isFieldInResponse('file_target', "/$filename")); + } + + /** + * @Then /^File "([^"]*)" should not be included in the response$/ + */ + public function checkSharedFileNotInResponse($filename){ + PHPUnit_Framework_Assert::assertEquals(False, $this->isFieldInResponse('file_target', "/$filename")); + } + + /** + * @Then /^User "([^"]*)" should be included in the response$/ + */ + public function checkSharedUserInResponse($user){ + PHPUnit_Framework_Assert::assertEquals(True, $this->isFieldInResponse('share_with', "$user")); + } + + /** + * @Then /^User "([^"]*)" should not be included in the response$/ + */ + public function checkSharedUserNotInResponse($user){ + PHPUnit_Framework_Assert::assertEquals(False, $this->isFieldInResponse('share_with', "$user")); + } + + public function isUserOrGroupInSharedData($userOrGroup){ + $data = $this->response->xml()->data[0]; + foreach($data as $element) { + if ($element->share_with == $userOrGroup){ + return True; + } + } + return False; + } + + /** + * @Given /^file "([^"]*)" from user "([^"]*)" is shared with user "([^"]*)"$/ + */ + public function assureFileIsShared($filepath, $user1, $user2){ + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath"; + $client = new Client(); + $options = []; + if ($user1 === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$user1, $this->regularUser]; + } + $this->response = $client->get($fullUrl, $options); + if ($this->isUserOrGroupInSharedData($user2)){ + return; + } else { + $this->createShare($user1, $filepath, 0, $user2, null, null, null); + } + $this->response = $client->get($fullUrl, $options); + PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($user2)); + } + + /** + * @Given /^file "([^"]*)" from user "([^"]*)" is shared with group "([^"]*)"$/ + */ + public function assureFileIsSharedWithGroup($filepath, $user, $group){ + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath"; + $client = new Client(); + $options = []; + if ($user === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$user, $this->regularUser]; + } + $this->response = $client->get($fullUrl, $options); + if ($this->isUserOrGroupInSharedData($group)){ + return; + } else { + $this->createShare($user, $filepath, 1, $group, null, null, null); + } + $this->response = $client->get($fullUrl, $options); + PHPUnit_Framework_Assert::assertEquals(True, $this->isUserOrGroupInSharedData($group)); + } + + /** + * @When /^Deleting last share$/ + */ + public function deletingLastShare(){ + $share_id = $this->lastShareData->data[0]->id; + $url = "/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; + $this->sendingToWith("DELETE", $url, null); + } + + /** + * @When /^Getting info of last share$/ + */ + public function gettingInfoOfLastShare(){ + $share_id = $this->lastShareData->data[0]->id; + $url = "/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id"; + $this->sendingToWith("GET", $url, null); + } + + /** + * @Then /^last share_id is included in the answer$/ + */ + public function checkingLastShareIDIsIncluded(){ + $share_id = $this->lastShareData->data[0]->id; + if (!$this->isFieldInResponse('id', $share_id)){ + PHPUnit_Framework_Assert::fail("Share id $share_id not found in response"); + } + } + + /** + * @Then /^last share_id is not included in the answer$/ + */ + public function checkingLastShareIDIsNotIncluded(){ + $share_id = $this->lastShareData->data[0]->id; + if ($this->isFieldInResponse('id', $share_id)){ + PHPUnit_Framework_Assert::fail("Share id $share_id has been found in response"); + } + } + + /** + * @Then /^Share fields of last share match with$/ + * @param \Behat\Gherkin\Node\TableNode|null $formData + */ + public function checkShareFields($body){ + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + + foreach($fd as $field => $value) { + if (!$this->isFieldInResponse($field, $value)){ + PHPUnit_Framework_Assert::fail("$field" . " doesn't have value " . "$value"); + } + } + } + } + +} + diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php new file mode 100644 index 00000000000..1bda8175eeb --- /dev/null +++ b/build/integration/features/bootstrap/WebDav.php @@ -0,0 +1,60 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + + +trait WebDav{ + + /** @var string*/ + private $davPath = "remote.php/webdav"; + + /** + * @Given /^using dav path "([^"]*)"$/ + */ + public function usingDavPath($davPath) { + $this->davPath = $davPath; + } + + public function makeDavRequest($user, $method, $path, $headers){ + $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; + $client = new Client(); + $options = []; + if ($user === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$user, $this->regularUser]; + } + $request = $client->createRequest($method, $fullUrl, $options); + foreach ($headers as $key => $value) { + $request->addHeader($key, $value); + } + //$this->response = $client->send($request); + return $client->send($request); + } + + /** + * @Given /^User "([^"]*)" moved file "([^"]*)" to "([^"]*)"$/ + */ + public function userMovedFile($user, $fileSource, $fileDestination){ + $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; + $headers['Destination'] = $fullUrl . $fileDestination; + $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); + PHPUnit_Framework_Assert::assertEquals(201, $this->response->getStatusCode()); + } + + /** + * @When /^User "([^"]*)" moves file "([^"]*)" to "([^"]*)"$/ + */ + public function userMovesFile($user, $fileSource, $fileDestination){ + $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; + $headers['Destination'] = $fullUrl . $fileDestination; + $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); + } + +} + diff --git a/build/integration/federation/federated.feature b/build/integration/federation/federated.feature new file mode 100644 index 00000000000..5437d01dee2 --- /dev/null +++ b/build/integration/federation/federated.feature @@ -0,0 +1,26 @@ +Feature: federated + Background: + Given using api version "1" + + Scenario: Federate share a file with another server + Given Using server "REMOTE" + And user "user1" exists + And Using server "LOCAL" + And user "user0" exists + When User "user0" from server "LOCAL" shares "/textfile0.txt" with user "user1" from server "REMOTE" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + + + + + + + + + + + + + diff --git a/build/integration/run.sh b/build/integration/run.sh index 5456a784404..bd2c2856ac7 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -13,7 +13,16 @@ php -S localhost:$PORT -t ../.. & PHPPID=$! echo $PHPPID +PORT_FED=$((8180 + $EXECUTOR_NUMBER)) +echo $PORT_FED +php -S localhost:$PORT_FED -t ../.. & +PHPPID_FED=$! +echo $PHPPID_FED + export TEST_SERVER_URL="http://localhost:$PORT/ocs/" +export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/" + vendor/bin/behat -f junit -f pretty kill $PHPPID +kill $PHPPID_FED diff --git a/core/l10n/de_DE.js b/core/l10n/de_DE.js index 8dd5132dcd9..531d0c738a8 100644 --- a/core/l10n/de_DE.js +++ b/core/l10n/de_DE.js @@ -6,8 +6,10 @@ OC.L10N.register( "Turned on maintenance mode" : "Wartungsmodus eingeschaltet ", "Turned off maintenance mode" : "Wartungsmodus ausgeschaltet", "Maintenance mode is kept active" : "Wartungsmodus wird aktiv gehalten", + "Updating database schema" : "Das Datenbankschema wird aktualisiert", "Updated database" : "Datenbank aktualisiert", "Checked database schema update" : "Datenbankschema-Aktualisierung überprüft", + "Checking updates of apps" : "Es wird nach Updates für die Apps gesucht", "Checked database schema update for apps" : "Datenbankschema-Aktualisierung für Apps überprüft", "Updated \"%s\" to %s" : "„%s“ zu %s aktualisiert", "Repair warning: " : "Reperaturwarnung:", diff --git a/core/l10n/de_DE.json b/core/l10n/de_DE.json index a1b4a6e72d7..47520ce8670 100644 --- a/core/l10n/de_DE.json +++ b/core/l10n/de_DE.json @@ -4,8 +4,10 @@ "Turned on maintenance mode" : "Wartungsmodus eingeschaltet ", "Turned off maintenance mode" : "Wartungsmodus ausgeschaltet", "Maintenance mode is kept active" : "Wartungsmodus wird aktiv gehalten", + "Updating database schema" : "Das Datenbankschema wird aktualisiert", "Updated database" : "Datenbank aktualisiert", "Checked database schema update" : "Datenbankschema-Aktualisierung überprüft", + "Checking updates of apps" : "Es wird nach Updates für die Apps gesucht", "Checked database schema update for apps" : "Datenbankschema-Aktualisierung für Apps überprüft", "Updated \"%s\" to %s" : "„%s“ zu %s aktualisiert", "Repair warning: " : "Reperaturwarnung:", diff --git a/core/l10n/ja.js b/core/l10n/ja.js index 225948366f6..d5eb22d42f7 100644 --- a/core/l10n/ja.js +++ b/core/l10n/ja.js @@ -21,7 +21,7 @@ OC.L10N.register( "%s (3rdparty)" : "%s (サードパーティー)", "%s (incompatible)" : "%s (非互換)", "Following apps have been disabled: %s" : "以下のアプリが無効にされています: %s", - "Already up to date" : "全て更新済", + "Already up to date" : "すべて更新済", "File is too big" : "ファイルが大きすぎます", "Invalid file provided" : "無効なファイルが提供されました", "No image or file provided" : "画像もしくはファイルが提供されていません", diff --git a/core/l10n/ja.json b/core/l10n/ja.json index 21cd77dacbb..443b8038ea5 100644 --- a/core/l10n/ja.json +++ b/core/l10n/ja.json @@ -19,7 +19,7 @@ "%s (3rdparty)" : "%s (サードパーティー)", "%s (incompatible)" : "%s (非互換)", "Following apps have been disabled: %s" : "以下のアプリが無効にされています: %s", - "Already up to date" : "全て更新済", + "Already up to date" : "すべて更新済", "File is too big" : "ファイルが大きすぎます", "Invalid file provided" : "無効なファイルが提供されました", "No image or file provided" : "画像もしくはファイルが提供されていません", diff --git a/core/shipped.json b/core/shipped.json index a7466a41aef..28e99c4feba 100644 --- a/core/shipped.json +++ b/core/shipped.json @@ -6,6 +6,7 @@ "dav", "enterprise_key", "external", + "federation", "files", "files_antivirus", "files_drop", @@ -24,6 +25,7 @@ "gallery", "notifications", "objectstore", + "password_policy", "provisioning_api", "sharepoint", "templateeditor", @@ -32,8 +34,7 @@ "user_ldap", "user_shibboleth", "windows_network_drive", - "password_policy", - "federation" + "workflow" ], "alwaysEnabled": [ "files", diff --git a/lib/autoloader.php b/lib/autoloader.php index f0fbd9e9f27..e41b4a08a6a 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -170,7 +170,11 @@ class Autoloader { // No cache or cache miss $pathsToRequire = array(); foreach ($this->findClass($class) as $path) { - $fullPath = stream_resolve_include_path($path); + if ($path[0] === '/') { + $fullPath = file_exists($path) ? $path : false; + } else { + $fullPath = stream_resolve_include_path($path); + } if ($fullPath && $this->isValidPath($fullPath)) { $pathsToRequire[] = $fullPath; } diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php index a32d32fefc5..eeab9b96e59 100644 --- a/lib/private/appframework/dependencyinjection/dicontainer.php +++ b/lib/private/appframework/dependencyinjection/dicontainer.php @@ -225,6 +225,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerService('ServerContainer', function ($c) { return $this->getServer(); }); + $this->registerAlias('OCP\\IServerContainer', 'ServerContainer'); $this->registerService('Symfony\Component\EventDispatcher\EventDispatcherInterface', function ($c) { return $this->getServer()->getEventDispatcher(); diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index ea42c9a8967..2bbb70db0f8 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -541,7 +541,8 @@ class Request implements \ArrayAccess, \Countable, IRequest { if (isset($this->server['HTTPS']) && $this->server['HTTPS'] !== null - && $this->server['HTTPS'] !== 'off') { + && $this->server['HTTPS'] !== 'off' + && $this->server['HTTPS'] !== '') { return 'https'; } diff --git a/settings/l10n/ja.js b/settings/l10n/ja.js index f5204159125..9d6705aff3f 100644 --- a/settings/l10n/ja.js +++ b/settings/l10n/ja.js @@ -12,12 +12,10 @@ OC.L10N.register( "Log" : "ログ", "Tips & tricks" : "ヒントとコツ", "Updates" : "アップデート", - "Authentication error" : "認証エラー", - "Your full name has been changed." : "名前を変更しました。", - "Unable to change full name" : "名前を変更できません", "Couldn't remove app." : "アプリが削除できませんでした。", "Language changed" : "言語が変更されました", "Invalid request" : "不正なリクエスト", + "Authentication error" : "認証エラー", "Admins can't remove themself from the admin group" : "管理者は自身を管理者グループから削除できません。", "Unable to add user to group %s" : "ユーザーをグループ %s に追加できません", "Unable to remove user from group %s" : "ユーザーをグループ %s から削除できません", @@ -53,6 +51,8 @@ OC.L10N.register( "Invalid user" : "無効なユーザー", "Unable to change mail address" : "メールアドレスを変更できません", "Email saved" : "メールアドレスを保存しました", + "Your full name has been changed." : "名前を変更しました。", + "Unable to change full name" : "名前を変更できません", "Are you really sure you want add \"{domain}\" as trusted domain?" : "\"{domain}\" を信頼するドメインに追加してもよろしいでしょうか?", "Add trusted domain" : "信頼するドメイン名に追加", "Migration in progress. Please wait until the migration is finished" : "移行の処理中です。移行が完了するまでお待ちください。", @@ -158,7 +158,7 @@ OC.L10N.register( "Last cron job execution: %s. Something seems wrong." : "最終cronジョブ実行: %s 何らかの問題があります。", "Cron was not executed yet!" : "cronはまだ実行されていません!", "Execute one task with each page loaded" : "各ページの読み込み時にタスクを実行します。", - "cron.php is registered at a webcron service to call cron.php every 15 minutes over http." : "cron.phpは、HTTP経由で15分ごとにcron.phpを実行するようwebcronサービスに登録されています。", + "cron.php is registered at a webcron service to call cron.php every 15 minutes over http." : "cron.phpは、HTTP経由で15分ごとにcron.phpを実行するようwebcronサービスに登録されます。", "Use system's cron service to call the cron.php file every 15 minutes." : "システムのcronサービスを利用して、15分間隔でcron.phpファイルを実行します。", "Enable server-side encryption" : "サーバーサイド暗号化を有効にする", "Please read carefully before activating server-side encryption: " : "サーバーサイド暗号化を有効にする前によくお読みください:", @@ -177,7 +177,7 @@ OC.L10N.register( "Send mode" : "送信モード", "Encryption" : "暗号化", "From address" : "送信元アドレス", - "mail" : "メール", + "mail" : "mail", "Authentication method" : "認証方法", "Authentication required" : "認証を必要とする", "Server address" : "サーバーアドレス", diff --git a/settings/l10n/ja.json b/settings/l10n/ja.json index 5222cd8ec13..aa22a5ce9b3 100644 --- a/settings/l10n/ja.json +++ b/settings/l10n/ja.json @@ -10,12 +10,10 @@ "Log" : "ログ", "Tips & tricks" : "ヒントとコツ", "Updates" : "アップデート", - "Authentication error" : "認証エラー", - "Your full name has been changed." : "名前を変更しました。", - "Unable to change full name" : "名前を変更できません", "Couldn't remove app." : "アプリが削除できませんでした。", "Language changed" : "言語が変更されました", "Invalid request" : "不正なリクエスト", + "Authentication error" : "認証エラー", "Admins can't remove themself from the admin group" : "管理者は自身を管理者グループから削除できません。", "Unable to add user to group %s" : "ユーザーをグループ %s に追加できません", "Unable to remove user from group %s" : "ユーザーをグループ %s から削除できません", @@ -51,6 +49,8 @@ "Invalid user" : "無効なユーザー", "Unable to change mail address" : "メールアドレスを変更できません", "Email saved" : "メールアドレスを保存しました", + "Your full name has been changed." : "名前を変更しました。", + "Unable to change full name" : "名前を変更できません", "Are you really sure you want add \"{domain}\" as trusted domain?" : "\"{domain}\" を信頼するドメインに追加してもよろしいでしょうか?", "Add trusted domain" : "信頼するドメイン名に追加", "Migration in progress. Please wait until the migration is finished" : "移行の処理中です。移行が完了するまでお待ちください。", @@ -156,7 +156,7 @@ "Last cron job execution: %s. Something seems wrong." : "最終cronジョブ実行: %s 何らかの問題があります。", "Cron was not executed yet!" : "cronはまだ実行されていません!", "Execute one task with each page loaded" : "各ページの読み込み時にタスクを実行します。", - "cron.php is registered at a webcron service to call cron.php every 15 minutes over http." : "cron.phpは、HTTP経由で15分ごとにcron.phpを実行するようwebcronサービスに登録されています。", + "cron.php is registered at a webcron service to call cron.php every 15 minutes over http." : "cron.phpは、HTTP経由で15分ごとにcron.phpを実行するようwebcronサービスに登録されます。", "Use system's cron service to call the cron.php file every 15 minutes." : "システムのcronサービスを利用して、15分間隔でcron.phpファイルを実行します。", "Enable server-side encryption" : "サーバーサイド暗号化を有効にする", "Please read carefully before activating server-side encryption: " : "サーバーサイド暗号化を有効にする前によくお読みください:", @@ -175,7 +175,7 @@ "Send mode" : "送信モード", "Encryption" : "暗号化", "From address" : "送信元アドレス", - "mail" : "メール", + "mail" : "mail", "Authentication method" : "認証方法", "Authentication required" : "認証を必要とする", "Server address" : "サーバーアドレス", diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php index ab5fe154441..92a2cc01dd2 100644 --- a/tests/lib/appframework/http/RequestTest.php +++ b/tests/lib/appframework/http/RequestTest.php @@ -648,6 +648,26 @@ class RequestTest extends \Test\TestCase { $this->assertSame('http', $request->getServerProtocol()); } + public function testGetServerProtocolWithHttpsServerValueEmpty() { + $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('overwriteprotocol') + ->will($this->returnValue('')); + + $request = new Request( + [ + 'server' => [ + 'HTTPS' => '' + ], + ], + $this->secureRandom, + $this->config, + $this->stream + ); + $this->assertSame('http', $request->getServerProtocol()); + } + public function testGetServerProtocolDefault() { $this->config ->expects($this->once()) |