diff options
author | Florin Peter <github@florin-peter.de> | 2013-05-27 14:41:53 +0200 |
---|---|---|
committer | Florin Peter <github@florin-peter.de> | 2013-05-27 14:41:53 +0200 |
commit | 80433fc4c4b052d788d9a942ce9d332b0f526362 (patch) | |
tree | b12d522f99cdec249af1fb3bd4b00d7bd14a9c87 /apps | |
parent | 89f0c8f39d99b4c2bf0fb9dac1ad11cbe0781a3b (diff) | |
parent | 5e243b48bb51e94daa3ba32c9175945d579040c8 (diff) | |
download | nextcloud-server-80433fc4c4b052d788d9a942ce9d332b0f526362.tar.gz nextcloud-server-80433fc4c4b052d788d9a942ce9d332b0f526362.zip |
Merge branch 'master' into file_encryption_util_is_error
Conflicts:
apps/files_encryption/lib/util.php
Diffstat (limited to 'apps')
70 files changed, 949 insertions, 611 deletions
diff --git a/apps/files/l10n/hu_HU.php b/apps/files/l10n/hu_HU.php index 4520bfdd085..76b8bd420da 100644 --- a/apps/files/l10n/hu_HU.php +++ b/apps/files/l10n/hu_HU.php @@ -46,6 +46,7 @@ "{count} folders" => "{count} mappa", "1 file" => "1 fájl", "{count} files" => "{count} fájl", +"Invalid folder name. Usage of 'Shared' is reserved by ownCloud" => "Érvénytelen mappanév. A 'Shared' az ownCloud számára fenntartott elnevezés", "Unable to rename file" => "Nem lehet átnevezni a fájlt", "Upload" => "Feltöltés", "File handling" => "Fájlkezelés", diff --git a/apps/files_encryption/l10n/ar.php b/apps/files_encryption/l10n/ar.php index 43a81d1ef80..1adc158c6b8 100644 --- a/apps/files_encryption/l10n/ar.php +++ b/apps/files_encryption/l10n/ar.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "جاري الحفظ...", "Encryption" => "التشفير" ); diff --git a/apps/files_encryption/l10n/bg_BG.php b/apps/files_encryption/l10n/bg_BG.php index 7087a042697..f21f7641c1a 100644 --- a/apps/files_encryption/l10n/bg_BG.php +++ b/apps/files_encryption/l10n/bg_BG.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Записване...", "Encryption" => "Криптиране" ); diff --git a/apps/files_encryption/l10n/bn_BD.php b/apps/files_encryption/l10n/bn_BD.php index b8241b5bbd8..068de46e7a1 100644 --- a/apps/files_encryption/l10n/bn_BD.php +++ b/apps/files_encryption/l10n/bn_BD.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "সংরক্ষণ করা হচ্ছে..", "Encryption" => "সংকেতায়ন" ); diff --git a/apps/files_encryption/l10n/ca.php b/apps/files_encryption/l10n/ca.php index 57a5897a3d4..46e91d1f070 100644 --- a/apps/files_encryption/l10n/ca.php +++ b/apps/files_encryption/l10n/ca.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Desant...", "Encryption" => "Xifrat" ); diff --git a/apps/files_encryption/l10n/cs_CZ.php b/apps/files_encryption/l10n/cs_CZ.php index 27ab9d04640..f9b2dd06b6f 100644 --- a/apps/files_encryption/l10n/cs_CZ.php +++ b/apps/files_encryption/l10n/cs_CZ.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Ukládám...", "Encryption" => "Šifrování" ); diff --git a/apps/files_encryption/l10n/cy_GB.php b/apps/files_encryption/l10n/cy_GB.php index 98571bf9436..6e18a7913c8 100644 --- a/apps/files_encryption/l10n/cy_GB.php +++ b/apps/files_encryption/l10n/cy_GB.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Yn cadw...", "Encryption" => "Amgryptiad" ); diff --git a/apps/files_encryption/l10n/da.php b/apps/files_encryption/l10n/da.php index b008f7884f1..1cd43390aa3 100644 --- a/apps/files_encryption/l10n/da.php +++ b/apps/files_encryption/l10n/da.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Gemmer...", "Encryption" => "Kryptering" ); diff --git a/apps/files_encryption/l10n/de.php b/apps/files_encryption/l10n/de.php index e62f244539c..2ab77f480cf 100644 --- a/apps/files_encryption/l10n/de.php +++ b/apps/files_encryption/l10n/de.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Speichern...", "Encryption" => "Verschlüsselung" ); diff --git a/apps/files_encryption/l10n/de_DE.php b/apps/files_encryption/l10n/de_DE.php index e62f244539c..5ab283ccab3 100644 --- a/apps/files_encryption/l10n/de_DE.php +++ b/apps/files_encryption/l10n/de_DE.php @@ -1,3 +1,9 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Verschlüsselung" +"Password successfully changed." => "Das Passwort wurde erfolgreich geändert.", +"Could not change the password. Maybe the old password was not correct." => "Das Passwort konnte nicht geändert werden. Vielleicht war das alte Passwort nicht richtig.", +"Saving..." => "Speichern...", +"Encryption" => "Verschlüsselung", +"Enabled" => "Aktiviert", +"Disabled" => "Deaktiviert", +"Change Password" => "Passwort ändern" ); diff --git a/apps/files_encryption/l10n/el.php b/apps/files_encryption/l10n/el.php index aa439d40f0a..7067799cd2e 100644 --- a/apps/files_encryption/l10n/el.php +++ b/apps/files_encryption/l10n/el.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Γίνεται αποθήκευση...", "Encryption" => "Κρυπτογράφηση" ); diff --git a/apps/files_encryption/l10n/eo.php b/apps/files_encryption/l10n/eo.php index 41880005c58..ea405fda1ab 100644 --- a/apps/files_encryption/l10n/eo.php +++ b/apps/files_encryption/l10n/eo.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Konservante...", "Encryption" => "Ĉifrado" ); diff --git a/apps/files_encryption/l10n/es.php b/apps/files_encryption/l10n/es.php index 26ace24e336..7311a78f09b 100644 --- a/apps/files_encryption/l10n/es.php +++ b/apps/files_encryption/l10n/es.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Guardando...", "Encryption" => "Cifrado" ); diff --git a/apps/files_encryption/l10n/es_AR.php b/apps/files_encryption/l10n/es_AR.php index 2a6360beb69..857186a55fa 100644 --- a/apps/files_encryption/l10n/es_AR.php +++ b/apps/files_encryption/l10n/es_AR.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Guardando...", "Encryption" => "Encriptación" ); diff --git a/apps/files_encryption/l10n/et_EE.php b/apps/files_encryption/l10n/et_EE.php index 07540ed8c39..c8d5361c08a 100644 --- a/apps/files_encryption/l10n/et_EE.php +++ b/apps/files_encryption/l10n/et_EE.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Salvestamine...", "Encryption" => "Krüpteerimine" ); diff --git a/apps/files_encryption/l10n/eu.php b/apps/files_encryption/l10n/eu.php index f443a61d8a0..253953e5c52 100644 --- a/apps/files_encryption/l10n/eu.php +++ b/apps/files_encryption/l10n/eu.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Gordetzen...", "Encryption" => "Enkriptazioa" ); diff --git a/apps/files_encryption/l10n/fa.php b/apps/files_encryption/l10n/fa.php index 615e4b920ea..af2e36b2a83 100644 --- a/apps/files_encryption/l10n/fa.php +++ b/apps/files_encryption/l10n/fa.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "در حال ذخیره سازی...", "Encryption" => "رمزگذاری" ); diff --git a/apps/files_encryption/l10n/fi_FI.php b/apps/files_encryption/l10n/fi_FI.php index bc67b9d8581..a00cc8ab96e 100644 --- a/apps/files_encryption/l10n/fi_FI.php +++ b/apps/files_encryption/l10n/fi_FI.php @@ -1,3 +1,9 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Salaus" +"Password successfully changed." => "Salasana vaihdettiin onnistuneesti.", +"Could not change the password. Maybe the old password was not correct." => "Salasanan vaihto epäonnistui. Kenties vanha salasana oli väärin.", +"Saving..." => "Tallennetaan...", +"Encryption" => "Salaus", +"Enabled" => "Käytössä", +"Disabled" => "Ei käytössä", +"Change Password" => "Vaihda salasana" ); diff --git a/apps/files_encryption/l10n/fr.php b/apps/files_encryption/l10n/fr.php index 20952995c45..98fb70691df 100644 --- a/apps/files_encryption/l10n/fr.php +++ b/apps/files_encryption/l10n/fr.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Enregistrement...", "Encryption" => "Chiffrement" ); diff --git a/apps/files_encryption/l10n/gl.php b/apps/files_encryption/l10n/gl.php index 26ace24e336..4c53c7e3d2b 100644 --- a/apps/files_encryption/l10n/gl.php +++ b/apps/files_encryption/l10n/gl.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Cifrado" +"Recovery key successfully " => "O contrasinal foi recuperado satisfactoriamente", +"Could not " => "Non foi posíbel", +"Password successfully changed." => "O contrasinal foi cambiado satisfactoriamente", +"Could not change the password. Maybe the old password was not correct." => "Non foi posíbel cambiar o contrasinal. Probabelmente o contrasinal antigo non é o correcto.", +"Saving..." => "Gardando...", +"Encryption" => "Cifrado", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "Activar a chave de recuperación do cifrado de contrasinais (permite compartir a chave de recuperación):", +"Recovery account password" => "Recuperación do contrasinal da conta", +"Enabled" => "Activado", +"Disabled" => "Desactivado", +"Change encryption passwords recovery key:" => "Cambiar a chave de la recuperación do cifrado de contrasinais:", +"Old Recovery account password" => "Antigo contrasinal de recuperación da conta", +"New Recovery account password" => "Novo contrasinal de recuperación da conta", +"Change Password" => "Cambiar o contrasinal", +"Enable password recovery by sharing all files with your administrator:" => "Activar a recuperación de contrasinais compartindo todos os ficheiros co administrador:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "Ao activar esta opción permitiráselle volver a obter acceso aos ficheiros cifrados se perde o contrasinal", +"File recovery settings updated" => "Actualizouse o ficheiro de axustes de recuperación", +"Could not update file recovery" => "Non foi posíbel actualizar o ficheiro de recuperación" ); diff --git a/apps/files_encryption/l10n/he.php b/apps/files_encryption/l10n/he.php index 54d56c5fc08..7a80cfa2f9f 100644 --- a/apps/files_encryption/l10n/he.php +++ b/apps/files_encryption/l10n/he.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "שמירה…", "Encryption" => "הצפנה" ); diff --git a/apps/files_encryption/l10n/hr.php b/apps/files_encryption/l10n/hr.php new file mode 100644 index 00000000000..9b9284ddc5e --- /dev/null +++ b/apps/files_encryption/l10n/hr.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Saving..." => "Spremanje..." +); diff --git a/apps/files_encryption/l10n/hu_HU.php b/apps/files_encryption/l10n/hu_HU.php index a80613ec0fb..bf95c31f2c5 100644 --- a/apps/files_encryption/l10n/hu_HU.php +++ b/apps/files_encryption/l10n/hu_HU.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Mentés...", "Encryption" => "Titkosítás" ); diff --git a/apps/files_encryption/l10n/id.php b/apps/files_encryption/l10n/id.php index e8778d4b4ac..ad827b53791 100644 --- a/apps/files_encryption/l10n/id.php +++ b/apps/files_encryption/l10n/id.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Menyimpan...", "Encryption" => "Enkripsi" ); diff --git a/apps/files_encryption/l10n/is.php b/apps/files_encryption/l10n/is.php index 6ca1b6ef7be..0f98c6bd3bf 100644 --- a/apps/files_encryption/l10n/is.php +++ b/apps/files_encryption/l10n/is.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Er að vista ...", "Encryption" => "Dulkóðun" ); diff --git a/apps/files_encryption/l10n/it.php b/apps/files_encryption/l10n/it.php index 129e5c1da1c..8f7a4023b6f 100644 --- a/apps/files_encryption/l10n/it.php +++ b/apps/files_encryption/l10n/it.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Cifratura" +"Recovery key successfully " => "Chiave ripristinata correttamente", +"Could not " => "Impossibile", +"Password successfully changed." => "Password modificata correttamente.", +"Could not change the password. Maybe the old password was not correct." => "Impossibile cambiare la password. Forse la vecchia password non era corretta.", +"Saving..." => "Salvataggio in corso...", +"Encryption" => "Cifratura", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "Abilita la chiave di ripristino delle password di cifratura (consente di condividere la chiave di ripristino):", +"Recovery account password" => "Password di ripristino dell'account", +"Enabled" => "Abilitata", +"Disabled" => "Disabilitata", +"Change encryption passwords recovery key:" => "Cambia la chiave di ripristino delle password di cifratura:", +"Old Recovery account password" => "Vecchia password di ripristino dell'account", +"New Recovery account password" => "Nuova password di ripristino dell'account", +"Change Password" => "Modifica password", +"Enable password recovery by sharing all files with your administrator:" => "Abilita il ripristino della password condividendo tutti i file con l'amministratore:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "L'abilitazione di questa opzione ti consentirà di ottenere nuovamente accesso ai tuoi file cifrati in caso di smarrimento della password", +"File recovery settings updated" => "Impostazioni di ripristino dei file aggiornate", +"Could not update file recovery" => "Impossibile aggiornare il ripristino dei file" ); diff --git a/apps/files_encryption/l10n/ja_JP.php b/apps/files_encryption/l10n/ja_JP.php index 767c9642f6a..287091f6376 100644 --- a/apps/files_encryption/l10n/ja_JP.php +++ b/apps/files_encryption/l10n/ja_JP.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "暗号化" +"Recovery key successfully " => "鍵を復旧することができました。", +"Could not " => "できませんでした。", +"Password successfully changed." => "パスワードを変更できました。", +"Could not change the password. Maybe the old password was not correct." => "パスワードを変更できませんでした。古いパスワードが間違っているかもしれません。", +"Saving..." => "保存中...", +"Encryption" => "暗号化", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "暗号化パスワードの復旧キーを有効にする(復旧キーを共有することを許可):", +"Recovery account password" => "復旧アカウントのパスワード", +"Enabled" => "有効", +"Disabled" => "無効", +"Change encryption passwords recovery key:" => "復旧キーの暗号化パスワードを変更:", +"Old Recovery account password" => "古い復旧アカウントのパスワード", +"New Recovery account password" => "新しい復旧アカウントのパスワード", +"Change Password" => "パスワードを変更", +"Enable password recovery by sharing all files with your administrator:" => "管理者が全ての共有ファイルに対してパスワードによる復旧を有効にする:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "このオプションを有効にすると、もしパスワードが分からなくなったとしても、暗号化されたファイルに再度アクセスすることが出来るようになります。", +"File recovery settings updated" => "ファイル復旧設定が更新されました", +"Could not update file recovery" => "ファイル復旧を更新できませんでした" ); diff --git a/apps/files_encryption/l10n/ka_GE.php b/apps/files_encryption/l10n/ka_GE.php index 36b07bd3864..55a59f44341 100644 --- a/apps/files_encryption/l10n/ka_GE.php +++ b/apps/files_encryption/l10n/ka_GE.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "შენახვა...", "Encryption" => "ენკრიპცია" ); diff --git a/apps/files_encryption/l10n/ko.php b/apps/files_encryption/l10n/ko.php index 5935811bf2c..cf8149da3ab 100644 --- a/apps/files_encryption/l10n/ko.php +++ b/apps/files_encryption/l10n/ko.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "저장 중...", "Encryption" => "암호화" ); diff --git a/apps/files_encryption/l10n/ku_IQ.php b/apps/files_encryption/l10n/ku_IQ.php index ff6c34b71d3..61b720372ec 100644 --- a/apps/files_encryption/l10n/ku_IQ.php +++ b/apps/files_encryption/l10n/ku_IQ.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "پاشکهوتدهکات...", "Encryption" => "نهێنیکردن" ); diff --git a/apps/files_encryption/l10n/lb.php b/apps/files_encryption/l10n/lb.php new file mode 100644 index 00000000000..77bad681732 --- /dev/null +++ b/apps/files_encryption/l10n/lb.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Saving..." => "Speicheren..." +); diff --git a/apps/files_encryption/l10n/lt_LT.php b/apps/files_encryption/l10n/lt_LT.php index 7ec3a32e02f..6bc80ff44ab 100644 --- a/apps/files_encryption/l10n/lt_LT.php +++ b/apps/files_encryption/l10n/lt_LT.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Saugoma...", "Encryption" => "Šifravimas" ); diff --git a/apps/files_encryption/l10n/lv.php b/apps/files_encryption/l10n/lv.php index abcc0305c1e..04922854ceb 100644 --- a/apps/files_encryption/l10n/lv.php +++ b/apps/files_encryption/l10n/lv.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Saglabā...", "Encryption" => "Šifrēšana" ); diff --git a/apps/files_encryption/l10n/mk.php b/apps/files_encryption/l10n/mk.php index a355a8433a0..a7216f205ad 100644 --- a/apps/files_encryption/l10n/mk.php +++ b/apps/files_encryption/l10n/mk.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Снимам...", "Encryption" => "Енкрипција" ); diff --git a/apps/files_encryption/l10n/ms_MY.php b/apps/files_encryption/l10n/ms_MY.php new file mode 100644 index 00000000000..bb963cb72d2 --- /dev/null +++ b/apps/files_encryption/l10n/ms_MY.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Saving..." => "Simpan..." +); diff --git a/apps/files_encryption/l10n/nb_NO.php b/apps/files_encryption/l10n/nb_NO.php index b008f7884f1..d4e2b1ffb50 100644 --- a/apps/files_encryption/l10n/nb_NO.php +++ b/apps/files_encryption/l10n/nb_NO.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Lagrer...", "Encryption" => "Kryptering" ); diff --git a/apps/files_encryption/l10n/nl.php b/apps/files_encryption/l10n/nl.php index 11cdc1e7a63..e2f22b4d92f 100644 --- a/apps/files_encryption/l10n/nl.php +++ b/apps/files_encryption/l10n/nl.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Versleuteling" +"Recovery key successfully " => "Sleutelherstel succesvol", +"Could not " => "Kon niet", +"Password successfully changed." => "Wachtwoord succesvol gewijzigd.", +"Could not change the password. Maybe the old password was not correct." => "Kon wachtwoord niet wijzigen. Wellicht oude wachtwoord niet juist ingevoerd.", +"Saving..." => "Opslaan", +"Encryption" => "Versleuteling", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "Activeer versleuteling van wachtwoorden herstelsleutel (maak delen met herstel sleutel mogelijk):", +"Recovery account password" => "Herstel account wachtwoord", +"Enabled" => "Geactiveerd", +"Disabled" => "Gedeactiveerd", +"Change encryption passwords recovery key:" => "Wijzig versleuteling wachtwoord herstelsleutel", +"Old Recovery account password" => "Oude herstel account wachtwoord", +"New Recovery account password" => "Nieuwe herstel account wachtwoord", +"Change Password" => "Wijzigen wachtwoord", +"Enable password recovery by sharing all files with your administrator:" => "Activeer wachtwoordherstel door alle bestanden met uw beheerder te delen:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "Door deze optie te activeren kunt u toegang tot uw versleutelde bestanden krijgen als u uw wachtwoord kwijt bent", +"File recovery settings updated" => "Bestandsherstel instellingen bijgewerkt", +"Could not update file recovery" => "Kon bestandsherstel niet bijwerken" ); diff --git a/apps/files_encryption/l10n/nn_NO.php b/apps/files_encryption/l10n/nn_NO.php new file mode 100644 index 00000000000..97b3a27a9d0 --- /dev/null +++ b/apps/files_encryption/l10n/nn_NO.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Saving..." => "Lagrar …" +); diff --git a/apps/files_encryption/l10n/oc.php b/apps/files_encryption/l10n/oc.php new file mode 100644 index 00000000000..0a34c4cda12 --- /dev/null +++ b/apps/files_encryption/l10n/oc.php @@ -0,0 +1,3 @@ +<?php $TRANSLATIONS = array( +"Saving..." => "Enregistra..." +); diff --git a/apps/files_encryption/l10n/pl.php b/apps/files_encryption/l10n/pl.php index 02f827f8d57..313d27b70c9 100644 --- a/apps/files_encryption/l10n/pl.php +++ b/apps/files_encryption/l10n/pl.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Szyfrowanie" +"Recovery key successfully " => "Odzyskanie klucza udane", +"Could not " => "Nie można", +"Password successfully changed." => "Zmiana hasła udana.", +"Could not change the password. Maybe the old password was not correct." => "Nie można zmienić hasła. Może stare hasło nie było poprawne.", +"Saving..." => "Zapisywanie...", +"Encryption" => "Szyfrowanie", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "Włącz szyfrowanie odzyskiwanych haseł klucza (zezwalaj na odzyskiwanie klucza):", +"Recovery account password" => "Odzyskiwanie hasła konta", +"Enabled" => "Włączone", +"Disabled" => "Wyłączone", +"Change encryption passwords recovery key:" => "Zmiana klucza szyfrowania haseł odzyskiwania:", +"Old Recovery account password" => "Stare hasło odzyskiwania", +"New Recovery account password" => "Nowe hasło odzyskiwania", +"Change Password" => "Zmień hasło", +"Enable password recovery by sharing all files with your administrator:" => "Włączyć hasło odzyskiwania przez udostępnianie wszystkich plików z administratorem:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "Włączenie tej opcji umożliwia otrzymać dostęp do zaszyfrowanych plików w przypadku utraty hasła", +"File recovery settings updated" => "Ustawienia odzyskiwania plików zmienione", +"Could not update file recovery" => "Nie można zmienić pliku odzyskiwania" ); diff --git a/apps/files_encryption/l10n/pt_BR.php b/apps/files_encryption/l10n/pt_BR.php index 4da459593ad..91b4672f27e 100644 --- a/apps/files_encryption/l10n/pt_BR.php +++ b/apps/files_encryption/l10n/pt_BR.php @@ -1,3 +1,20 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Criptografia" +"Recovery key successfully " => "Recuperação de chave com sucesso", +"Could not " => "Não foi possível", +"Password successfully changed." => "Senha alterada com sucesso.", +"Could not change the password. Maybe the old password was not correct." => "Não foi possível alterar a senha. Talvez a senha antiga não estava correta.", +"Saving..." => "Salvando...", +"Encryption" => "Criptografia", +"Enable encryption passwords recovery key (allow sharing to recovery key):" => "Ativar a criptografia de chave de recuperação de senhas (permitir compartilhar a chave de recuperação):", +"Recovery account password" => "Recuperar a senha da conta", +"Enabled" => "Habilidado", +"Disabled" => "Desabilitado", +"Change encryption passwords recovery key:" => "Mudar a criptografia de chave de recuperação de senhas:", +"Old Recovery account password" => "Recuperação de senha de conta antiga", +"New Recovery account password" => "Senha Nova da conta de Recuperação", +"Change Password" => "Trocar Senha", +"Enable password recovery by sharing all files with your administrator:" => "Habilitar recuperação de senha através da partilha de todos os arquivos com o administrador:", +"Enabling this option will allow you to reobtain access to your encrypted files if your password is lost" => "Ativando esta opção irá permitir que você reobtainha acesso aos seus arquivos criptografados se sua senha for perdida", +"File recovery settings updated" => "Configurações de recuperação de arquivo atualizado", +"Could not update file recovery" => "Não foi possível atualizar a recuperação de arquivos" ); diff --git a/apps/files_encryption/l10n/pt_PT.php b/apps/files_encryption/l10n/pt_PT.php index eda3e275b2d..be75c0b768a 100644 --- a/apps/files_encryption/l10n/pt_PT.php +++ b/apps/files_encryption/l10n/pt_PT.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "A guardar...", "Encryption" => "Encriptação" ); diff --git a/apps/files_encryption/l10n/ro.php b/apps/files_encryption/l10n/ro.php index d24f3cf5dc3..9e04b627c42 100644 --- a/apps/files_encryption/l10n/ro.php +++ b/apps/files_encryption/l10n/ro.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Se salvează...", "Encryption" => "Încriptare" ); diff --git a/apps/files_encryption/l10n/ru.php b/apps/files_encryption/l10n/ru.php index 870557d835f..fac785730a8 100644 --- a/apps/files_encryption/l10n/ru.php +++ b/apps/files_encryption/l10n/ru.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Сохранение...", "Encryption" => "Шифрование" ); diff --git a/apps/files_encryption/l10n/ru_RU.php b/apps/files_encryption/l10n/ru_RU.php index 7222235485c..1351f63f89b 100644 --- a/apps/files_encryption/l10n/ru_RU.php +++ b/apps/files_encryption/l10n/ru_RU.php @@ -1,4 +1,3 @@ <?php $TRANSLATIONS = array( -"Encryption" => "Шифрование", -"None" => "Ни один" +"Saving..." => "Сохранение" ); diff --git a/apps/files_encryption/l10n/si_LK.php b/apps/files_encryption/l10n/si_LK.php index c55d5609a84..6c678bb3a4f 100644 --- a/apps/files_encryption/l10n/si_LK.php +++ b/apps/files_encryption/l10n/si_LK.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "සුරැකෙමින් පවතී...", "Encryption" => "ගුප්ත කේතනය" ); diff --git a/apps/files_encryption/l10n/sk_SK.php b/apps/files_encryption/l10n/sk_SK.php index bf15777fc19..fd77bb7e91d 100644 --- a/apps/files_encryption/l10n/sk_SK.php +++ b/apps/files_encryption/l10n/sk_SK.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Ukladám...", "Encryption" => "Šifrovanie" ); diff --git a/apps/files_encryption/l10n/sl.php b/apps/files_encryption/l10n/sl.php index 272c6e1bb34..a420fe161df 100644 --- a/apps/files_encryption/l10n/sl.php +++ b/apps/files_encryption/l10n/sl.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Poteka shranjevanje ...", "Encryption" => "Šifriranje" ); diff --git a/apps/files_encryption/l10n/sr.php b/apps/files_encryption/l10n/sr.php index 2e3698918f5..a36e37c1790 100644 --- a/apps/files_encryption/l10n/sr.php +++ b/apps/files_encryption/l10n/sr.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Чување у току...", "Encryption" => "Шифровање" ); diff --git a/apps/files_encryption/l10n/sv.php b/apps/files_encryption/l10n/sv.php index b008f7884f1..966963b5549 100644 --- a/apps/files_encryption/l10n/sv.php +++ b/apps/files_encryption/l10n/sv.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Sparar...", "Encryption" => "Kryptering" ); diff --git a/apps/files_encryption/l10n/ta_LK.php b/apps/files_encryption/l10n/ta_LK.php index adc5a69a1b7..63fe9ecde86 100644 --- a/apps/files_encryption/l10n/ta_LK.php +++ b/apps/files_encryption/l10n/ta_LK.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "சேமிக்கப்படுகிறது...", "Encryption" => "மறைக்குறியீடு" ); diff --git a/apps/files_encryption/l10n/th_TH.php b/apps/files_encryption/l10n/th_TH.php index 881e1d834bc..6cab4370ccf 100644 --- a/apps/files_encryption/l10n/th_TH.php +++ b/apps/files_encryption/l10n/th_TH.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "กำลังบันทึกข้อมูล...", "Encryption" => "การเข้ารหัส" ); diff --git a/apps/files_encryption/l10n/tr.php b/apps/files_encryption/l10n/tr.php index e7481153b1f..917ff0a0eae 100644 --- a/apps/files_encryption/l10n/tr.php +++ b/apps/files_encryption/l10n/tr.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Kaydediliyor...", "Encryption" => "Şifreleme" ); diff --git a/apps/files_encryption/l10n/ug.php b/apps/files_encryption/l10n/ug.php index 278fdc2ce80..954d95b4132 100644 --- a/apps/files_encryption/l10n/ug.php +++ b/apps/files_encryption/l10n/ug.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "ساقلاۋاتىدۇ…", "Encryption" => "شىفىرلاش" ); diff --git a/apps/files_encryption/l10n/uk.php b/apps/files_encryption/l10n/uk.php index cdbbd8801a2..1c176a39142 100644 --- a/apps/files_encryption/l10n/uk.php +++ b/apps/files_encryption/l10n/uk.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Зберігаю...", "Encryption" => "Шифрування" ); diff --git a/apps/files_encryption/l10n/vi.php b/apps/files_encryption/l10n/vi.php index 34ab60796d0..0af5bdc9a67 100644 --- a/apps/files_encryption/l10n/vi.php +++ b/apps/files_encryption/l10n/vi.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "Đang lưu...", "Encryption" => "Mã hóa" ); diff --git a/apps/files_encryption/l10n/zh_CN.GB2312.php b/apps/files_encryption/l10n/zh_CN.GB2312.php index 0a38a2ddf85..3c405a81ace 100644 --- a/apps/files_encryption/l10n/zh_CN.GB2312.php +++ b/apps/files_encryption/l10n/zh_CN.GB2312.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "保存中...", "Encryption" => "加密" ); diff --git a/apps/files_encryption/l10n/zh_CN.php b/apps/files_encryption/l10n/zh_CN.php index 0a38a2ddf85..e565fce801c 100644 --- a/apps/files_encryption/l10n/zh_CN.php +++ b/apps/files_encryption/l10n/zh_CN.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "保存中", "Encryption" => "加密" ); diff --git a/apps/files_encryption/l10n/zh_TW.php b/apps/files_encryption/l10n/zh_TW.php index 0a38a2ddf85..2bfadce8553 100644 --- a/apps/files_encryption/l10n/zh_TW.php +++ b/apps/files_encryption/l10n/zh_TW.php @@ -1,3 +1,4 @@ <?php $TRANSLATIONS = array( +"Saving..." => "儲存中...", "Encryption" => "加密" ); diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index f25ead1f5c3..4171b7cae50 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -442,7 +442,7 @@ class Util { // If the file uses old // encryption system - } elseif (Crypt::isLegacyEncryptedContent($this->tail($filePath, 3), $relPath)) { + } elseif ( Crypt::isLegacyEncryptedContent( $data, $relPath ) ) { $found['legacy'][] = array( 'name' => $file, @@ -699,43 +699,28 @@ class Util { $relPath = $plainFile['path']; //relative to /data - $rawPath = $this->userId . '/files/' . $plainFile['path']; + $rawPath = '/'.$this->userId . '/files/' . $plainFile['path']; // Open plain file handle for binary reading - $plainHandle1 = $this->view->fopen($rawPath, 'rb'); + $plainHandle = $this->view->fopen( $rawPath, 'rb' ); - // 2nd handle for moving plain file - view->rename() doesn't work, this is a workaround - $plainHandle2 = $this->view->fopen($rawPath . '.plaintmp', 'wb'); + // Open enc file handle for binary writing, with same filename as original plain file + $encHandle = fopen( 'crypt://' . $relPath.'.tmp', 'wb' ); // Move plain file to a temporary location - stream_copy_to_stream($plainHandle1, $plainHandle2); - - // Close access to original file - // $this->view->fclose( $plainHandle1 ); // not implemented in view{} - // Delete original plain file so we can rename enc file later - $this->view->unlink($rawPath); + $size = stream_copy_to_stream( $plainHandle, $encHandle ); - // Open enc file handle for binary writing, with same filename as original plain file - $encHandle = fopen('crypt://' . $relPath, 'wb'); + fclose($encHandle); - // Save data from plain stream to new encrypted file via enc stream - // NOTE: Stream{} will be invoked for handling - // the encryption, and should handle all keys - // and their generation etc. automatically - stream_copy_to_stream($plainHandle2, $encHandle); + $fakeRoot = $this->view->getRoot(); + $this->view->chroot('/'.$this->userId.'/files'); - // get file size - $size = $this->view->filesize($rawPath . '.plaintmp'); + $this->view->rename($relPath . '.tmp', $relPath); - // Delete temporary plain copy of file - $this->view->unlink($rawPath . '.plaintmp'); + $this->view->chroot($fakeRoot); // Add the file to the cache - \OC\Files\Filesystem::putFileInfo($plainFile['path'], array( - 'encrypted' => true, - 'size' => $size, - 'unencrypted_size' => $size - )); + \OC\Files\Filesystem::putFileInfo( $relPath, array( 'encrypted' => true, 'size' => $size, 'unencrypted_size' => $size ) ); } // Encrypt legacy encrypted files diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index 621941c52a1..74b4252a1d4 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -16,14 +16,16 @@ require_once realpath(dirname(__FILE__) . '/../lib/stream.php'); require_once realpath(dirname(__FILE__) . '/../lib/util.php'); require_once realpath(dirname(__FILE__) . '/../lib/helper.php'); require_once realpath(dirname(__FILE__) . '/../appinfo/app.php'); +require_once realpath(dirname(__FILE__) . '/util.php'); use OCA\Encryption; /** * Class Test_Encryption_Crypt */ -class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_CRYPT_USER1 = "test-crypt-user1"; public $userId; public $pass; @@ -39,12 +41,31 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase public $genPrivateKey; public $genPublicKey; - function setUp() - { + public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // Filesystem related hooks + \OCA\Encryption\Helper::registerUserHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1, true); + } + + function setUp() { + // set user id + \OC_User::setUserId(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1); + $this->userId = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1; + $this->pass = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1; + // set content for encrypting / decrypting in tests $this->dataLong = file_get_contents(realpath(dirname(__FILE__) . '/../lib/crypt.php')); $this->dataShort = 'hats'; @@ -60,53 +81,29 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $this->view = new \OC_FilesystemView('/'); - \OC_User::setUserId('admin'); - $this->userId = 'admin'; - $this->pass = 'admin'; - - $userHome = \OC_User::getHome($this->userId); - $this->dataDir = str_replace('/' . $this->userId, '', $userHome); - - // Filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - // Filesystem related hooks - \OCA\Encryption\Helper::registerUserHooks(); - - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); - - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); - - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); - } - function tearDown() - { - \OC_FileProxy::clearProxies(); - + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } } - function testGenerateKey() - { + public static function tearDownAfterClass() { + // cleanup test user + \OC_User::deleteUser(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1); + } + + function testGenerateKey() { # TODO: use more accurate (larger) string length for test confirmation @@ -119,8 +116,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @return String */ - function testGenerateIv() - { + function testGenerateIv() { $iv = Encryption\Crypt::generateIv(); @@ -133,8 +129,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @depends testGenerateIv */ - function testConcatIv($iv) - { + function testConcatIv($iv) { $catFile = Encryption\Crypt::concatIv($this->dataLong, $iv); @@ -157,7 +152,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase return array( 'iv' => $iv - , 'catfile' => $catFile + , + 'catfile' => $catFile ); } @@ -165,8 +161,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @depends testConcatIv */ - function testSplitIv($testConcatIv) - { + function testSplitIv($testConcatIv) { // Split catfile into components $splitCatfile = Encryption\Crypt::splitIv($testConcatIv['catfile']); @@ -182,8 +177,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @return string padded */ - function testAddPadding() - { + function testAddPadding() { $padded = Encryption\Crypt::addPadding($this->dataLong); @@ -198,8 +192,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @depends testAddPadding */ - function testRemovePadding($padded) - { + function testRemovePadding($padded) { $noPadding = Encryption\Crypt::RemovePadding($padded); @@ -207,8 +200,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testEncrypt() - { + function testEncrypt() { $random = openssl_random_pseudo_bytes(13); @@ -220,8 +212,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testDecrypt() - { + function testDecrypt() { $random = openssl_random_pseudo_bytes(13); @@ -235,8 +226,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testSymmetricEncryptFileContent() - { + function testSymmetricEncryptFileContent() { # TODO: search in keyfile for actual content as IV will ensure this test always passes @@ -251,8 +241,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testSymmetricStreamEncryptShortFileContent() - { + function testSymmetricStreamEncryptShortFileContent() { $filename = 'tmp-' . time() . '.test'; @@ -307,8 +296,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase * @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual * reassembly of its data */ - function testSymmetricStreamEncryptLongFileContent() - { + function testSymmetricStreamEncryptLongFileContent() { // Generate a a random filename $filename = 'tmp-' . time() . '.test'; @@ -339,7 +327,14 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase //print_r($r); // Join IVs and their respective data chunks - $e = array($r[0] . $r[1], $r[2] . $r[3], $r[4] . $r[5], $r[6] . $r[7], $r[8] . $r[9], $r[10] . $r[11]); //.$r[11], $r[12].$r[13], $r[14] ); + $e = array( + $r[0] . $r[1], + $r[2] . $r[3], + $r[4] . $r[5], + $r[6] . $r[7], + $r[8] . $r[9], + $r[10] . $r[11] + ); //.$r[11], $r[12].$r[13], $r[14] ); //print_r($e); @@ -384,8 +379,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @brief Test that data that is read by the crypto stream wrapper */ - function testSymmetricStreamDecryptShortFileContent() - { + function testSymmetricStreamDecryptShortFileContent() { $filename = 'tmp-' . time(); @@ -412,8 +406,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $this->view->unlink($this->userId . '/files/' . $filename); } - function testSymmetricStreamDecryptLongFileContent() - { + function testSymmetricStreamDecryptLongFileContent() { $filename = 'tmp-' . time(); @@ -432,8 +425,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $this->view->unlink($this->userId . '/files/' . $filename); } - function testSymmetricEncryptFileContentKeyfile() - { + function testSymmetricEncryptFileContentKeyfile() { # TODO: search in keyfile for actual content as IV will ensure this test always passes @@ -448,8 +440,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testIsEncryptedContent() - { + function testIsEncryptedContent() { $this->assertFalse(Encryption\Crypt::isCatfileContent($this->dataUrl)); @@ -461,8 +452,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testMultiKeyEncrypt() - { + function testMultiKeyEncrypt() { # TODO: search in keyfile for actual content as IV will ensure this test always passes @@ -486,8 +476,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testKeyEncrypt() - { + function testKeyEncrypt() { // Generate keypair $pair1 = Encryption\Crypt::createKeypair(); @@ -507,8 +496,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @brief test encryption using legacy blowfish method */ - function testLegacyEncryptShort() - { + function testLegacyEncryptShort() { $crypted = Encryption\Crypt::legacyEncrypt($this->dataShort, $this->pass); @@ -525,8 +513,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptShort */ - function testLegacyDecryptShort($crypted) - { + function testLegacyDecryptShort($crypted) { $decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass); @@ -537,8 +524,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase /** * @brief test encryption using legacy blowfish method */ - function testLegacyEncryptLong() - { + function testLegacyEncryptLong() { $crypted = Encryption\Crypt::legacyEncrypt($this->dataLong, $this->pass); @@ -555,8 +541,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptLong */ - function testLegacyDecryptLong($crypted) - { + function testLegacyDecryptLong($crypted) { $decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass); @@ -569,8 +554,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase * @brief test generation of legacy encryption key * @depends testLegacyDecryptShort */ - function testLegacyCreateKey() - { + function testLegacyCreateKey() { // Create encrypted key $encKey = Encryption\Crypt::legacyCreateKey($this->pass); @@ -589,8 +573,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptLong */ - function testLegacyKeyRecryptKeyfileEncrypt($crypted) - { + function testLegacyKeyRecryptKeyfileEncrypt($crypted) { $recrypted = Encryption\Crypt::LegacyKeyRecryptKeyfile($crypted, $this->pass, array($this->genPublicKey), $this->pass, ''); @@ -603,8 +586,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase } - function testRenameFile() - { + function testRenameFile() { $filename = 'tmp-' . time(); @@ -632,8 +614,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($newFilename); } - function testMoveFileIntoFolder() - { + function testMoveFileIntoFolder() { $filename = 'tmp-' . time(); @@ -663,8 +644,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($newFolder); } - function testMoveFolder() - { + function testMoveFolder() { $view = new \OC\Files\View('/' . $this->userId . '/files'); @@ -696,11 +676,11 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase // tear down $view->unlink($newFolder); + $view->unlink('/newfolder'); } - function testChangePassphrase() - { - $filename = 'tmp-' . time(); + function testChangePassphrase() { + $filename = 'tmp-' . time(); // Save long data as encrypted file using stream wrapper $cryptedFile = file_put_contents('crypt://' . $filename, $this->dataLong); @@ -733,8 +713,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($filename); } - function testViewFilePutAndGetContents() - { + function testViewFilePutAndGetContents() { $filename = '/tmp-' . time(); $view = new \OC\Files\View('/' . $this->userId . '/files'); @@ -765,8 +744,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($filename); } - function testTouchExistingFile() - { + function testTouchExistingFile() { $filename = '/tmp-' . time(); $view = new \OC\Files\View('/' . $this->userId . '/files'); @@ -787,8 +765,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($filename); } - function testTouchFile() - { + function testTouchFile() { $filename = '/tmp-' . time(); $view = new \OC\Files\View('/' . $this->userId . '/files'); @@ -809,8 +786,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase $view->unlink($filename); } - function testFopenFile() - { + function testFopenFile() { $filename = '/tmp-' . time(); $view = new \OC\Files\View('/' . $this->userId . '/files'); diff --git a/apps/files_encryption/tests/encryption.key b/apps/files_encryption/tests/encryption.key Binary files differindex 4495cee78e2..4ee962145c2 100644 --- a/apps/files_encryption/tests/encryption.key +++ b/apps/files_encryption/tests/encryption.key diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php index b1bae673e82..40ae1659a55 100644 --- a/apps/files_encryption/tests/keymanager.php +++ b/apps/files_encryption/tests/keymanager.php @@ -20,8 +20,7 @@ use OCA\Encryption; /** * Class Test_Encryption_Keymanager */ -class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase { public $userId; public $pass; @@ -33,14 +32,35 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase public $randomKey; public $dataShort; - function setUp() - { + public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // disable file proxy by default \OC_FileProxy::$enabled = false; + // setup filesystem + \OC_Util::tearDownFS(); + \OC_User::setUserId(''); + \OC\Files\Filesystem::tearDown(); + \OC_Util::setupFS('admin'); + \OC_User::setUserId('admin'); + + // login admin + $params['uid'] = 'admin'; + $params['password'] = 'admin'; + OCA\Encryption\Hooks::login($params); + } + + function setUp() { // set content for encrypting / decrypting in tests $this->dataLong = file_get_contents(realpath(dirname(__FILE__) . '/../lib/crypt.php')); $this->dataShort = 'hats'; @@ -62,44 +82,28 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase $userHome = \OC_User::getHome($this->userId); $this->dataDir = str_replace('/' . $this->userId, '', $userHome); - // Filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); - - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); - - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); } - function tearDown() - { - - \OC_FileProxy::$enabled = true; - \OC_FileProxy::clearProxies(); - + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } } - function testGetPrivateKey() - { + public static function tearDownAfterClass() { + \OC_FileProxy::$enabled = true; + } + + function testGetPrivateKey() { $key = Encryption\Keymanager::getPrivateKey($this->view, $this->userId); @@ -115,8 +119,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase } - function testGetPublicKey() - { + function testGetPublicKey() { $publiceKey = Encryption\Keymanager::getPublicKey($this->view, $this->userId); @@ -129,8 +132,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase $this->assertArrayHasKey('key', $sslInfo); } - function testSetFileKey() - { + function testSetFileKey() { # NOTE: This cannot be tested until we are able to break out # of the FileSystemView data directory root @@ -163,8 +165,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase } - function testGetUserKeys() - { + function testGetUserKeys() { $keys = Encryption\Keymanager::getUserKeys($this->view, $this->userId); @@ -187,8 +188,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase $this->assertArrayHasKey('key', $sslInfoPrivate); } - function testFixPartialFilePath() - { + function testFixPartialFilePath() { $partFilename = 'testfile.txt.part'; $filename = 'testfile.txt'; @@ -202,8 +202,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase $this->assertEquals('testfile.txt', Encryption\Keymanager::fixPartialFilePath($filename)); } - function testRecursiveDelShareKeys() - { + function testRecursiveDelShareKeys() { // generate filename $filename = '/tmp-' . time() . '.txt'; @@ -230,7 +229,8 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase Encryption\Keymanager::delShareKey($this->view, array('admin'), '/folder1/'); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/folder1/subfolder/subsubfolder/' . $filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/admin/files_encryption/share-keys/folder1/subfolder/subsubfolder/' . $filename . '.admin.shareKey')); // enable encryption proxy $proxyStatus = \OC_FileProxy::$enabled; diff --git a/apps/files_encryption/tests/legacy-encrypted-text.txt b/apps/files_encryption/tests/legacy-encrypted-text.txt index d38cb7d1b0d..1f5087178cd 100644 --- a/apps/files_encryption/tests/legacy-encrypted-text.txt +++ b/apps/files_encryption/tests/legacy-encrypted-text.txt @@ -1 +1 @@ -
ߕt.dS@t9QJ
\ No newline at end of file +5ǡiZgESlF=
\ No newline at end of file diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index 1d0cbfbc1de..6d92881ceb0 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -29,14 +29,20 @@ require_once realpath(dirname(__FILE__) . '/../lib/stream.php'); require_once realpath(dirname(__FILE__) . '/../lib/util.php'); require_once realpath(dirname(__FILE__) . '/../lib/helper.php'); require_once realpath(dirname(__FILE__) . '/../appinfo/app.php'); +require_once realpath(dirname(__FILE__) . '/util.php'); use OCA\Encryption; /** * Class Test_Encryption_Share */ -class Test_Encryption_Share extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_SHARE_USER1 = "test-share-user1"; + const TEST_ENCRYPTION_SHARE_USER2 = "test-share-user2"; + const TEST_ENCRYPTION_SHARE_USER3 = "test-share-user3"; + const TEST_ENCRYPTION_SHARE_USER4 = "test-share-user4"; + const TEST_ENCRYPTION_SHARE_GROUP1 = "test-share-group1"; public $stateFilesTrashbin; public $filename; @@ -49,24 +55,11 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase public $subfolder; public $subsubfolder; - function setUp() - { + public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); - $this->dataShort = 'hats'; - $this->view = new \OC_FilesystemView('/'); - - $userHome = \OC_User::getHome('admin'); - $this->dataDir = str_replace('/admin', '', $userHome); - - $this->folder1 = '/folder1'; - $this->subfolder = '/subfolder1'; - $this->subsubfolder = '/subsubfolder1'; - - $this->filename = 'share-tmp.test'; - // enable resharing \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes'); @@ -81,52 +74,66 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); + // clear and register hooks + \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new OCA\Encryption\Proxy()); - // remember files_trashbin state - $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); + // create users + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true); + + // create group and assign users + \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + } + + function setUp() { + $this->dataShort = 'hats'; + $this->view = new \OC_FilesystemView('/'); + + $this->folder1 = '/folder1'; + $this->subfolder = '/subfolder1'; + $this->subsubfolder = '/subsubfolder1'; + + $this->filename = 'share-tmp.test'; // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); - // create users - $this->loginHelper('user1', true); - $this->loginHelper('user2', true); - $this->loginHelper('user3', true); - - // create group and assign users - \OC_Group::createGroup('group1'); - \OC_Group::addToGroup('user2', 'group1'); - \OC_Group::addToGroup('user3', 'group1'); + // remember files_trashbin state + $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); } - function tearDown() - { + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } + } + public static function tearDownAfterClass() { // clean group - \OC_Group::deleteGroup('group1'); + \OC_Group::deleteGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); // cleanup users - \OC_User::deleteUser('user1'); - \OC_User::deleteUser('user2'); - \OC_User::deleteUser('user3'); - - \OC_FileProxy::clearProxies(); + \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); } /** * @param bool $withTeardown */ - function testShareFile($withTeardown = true) - { + function testShareFile($withTeardown = true) { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // save file with content $cryptedFile = file_put_contents('crypt://' . $this->filename, $this->dataShort); @@ -139,7 +146,8 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = false; // get the file info from previous created file - $fileInfo = $this->view->getFileInfo('/admin/files/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue(is_array($fileInfo)); @@ -151,19 +159,22 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user1.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user1/files/Shared/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -172,49 +183,57 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase if ($withTeardown) { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // unshare the file - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user1.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); + $this->view->unlink( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } /** * @param bool $withTeardown */ - function testReShareFile($withTeardown = true) - { + function testReShareFile($withTeardown = true) { $this->testShareFile(false); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // get the file info - $fileInfo = $this->view->getFileInfo('/user1/files/Shared/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename); // share the file with user2 - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user2', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user2 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as user2 - $this->loginHelper('user2'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user2/files/Shared/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared/' . $this->filename); // check if data is the same as previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -223,28 +242,35 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase if ($withTeardown) { // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // unshare the file with user2 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user2'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // unshare the file with user1 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user1.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); + $this->view->unlink( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } @@ -252,18 +278,21 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase * @param bool $withTeardown * @return array */ - function testShareFolder($withTeardown = true) - { + function testShareFolder($withTeardown = true) { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // create folder structure - $this->view->mkdir('/admin/files' . $this->folder1); - $this->view->mkdir('/admin/files' . $this->folder1 . $this->subfolder); - $this->view->mkdir('/admin/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); + $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder + . $this->subsubfolder); // save file with content - $cryptedFile = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); @@ -273,7 +302,8 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = false; // get the file info from previous created folder - $fileInfo = $this->view->getFileInfo('/admin/files' . $this->folder1); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); // check if we have a valid file info $this->assertTrue(is_array($fileInfo)); @@ -282,19 +312,24 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; // share the folder with user1 - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user1.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user1/files/Shared' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if data is the same $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -303,19 +338,25 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase if ($withTeardown) { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // unshare the folder with user1 - \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1'); + \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user1.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files' . $this->folder1); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } return $fileInfo; @@ -324,19 +365,20 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase /** * @param bool $withTeardown */ - function testReShareFolder($withTeardown = true) - { + function testReShareFolder($withTeardown = true) { $fileInfoFolder1 = $this->testShareFolder(false); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; // get the file info from previous created folder - $fileInfoSubFolder = $this->view->getFileInfo('/user1/files/Shared' . $this->folder1 . $this->subfolder); + $fileInfoSubFolder = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared' . $this->folder1 + . $this->subfolder); // check if we have a valid file info $this->assertTrue(is_array($fileInfoSubFolder)); @@ -345,43 +387,54 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; // share the file with user2 - \OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user2', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user2 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user2.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as user2 - $this->loginHelper('user2'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user2/files/Shared' . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared' . $this->subfolder + . $this->subsubfolder . '/' . $this->filename); // check if data is the same $this->assertEquals($this->dataShort, $retrievedCryptedFile); // get the file info - $fileInfo = $this->view->getFileInfo('/user2/files/Shared' . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared' . $this->subfolder + . $this->subsubfolder . '/' . $this->filename); // check if we have fileInfos $this->assertTrue(is_array($fileInfo)); // share the file with user3 - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user3', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user3 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user3.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user3 - $this->loginHelper('user3'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user3/files/Shared/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '/files/Shared/' . $this->filename); // check if data is the same $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -390,44 +443,57 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase if ($withTeardown) { // login as user2 - $this->loginHelper('user2'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // unshare the file with user3 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user3'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user3.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // unshare the folder with user2 - \OCP\Share::unshare('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user2'); + \OCP\Share::unshare('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user2.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // unshare the folder1 with user1 - \OCP\Share::unshare('folder', $fileInfoFolder1['fileid'], \OCP\Share::SHARE_TYPE_USER, 'user1'); + \OCP\Share::unshare('folder', $fileInfoFolder1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user1.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $this->view->unlink( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder + . $this->subsubfolder . '/' . $this->filename); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' + . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } - function testPublicShareFile() - { + function testPublicShareFile() { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // save file with content $cryptedFile = file_put_contents('crypt://' . $this->filename, $this->dataShort); @@ -440,7 +506,8 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = false; // get the file info from previous created file - $fileInfo = $this->view->getFileInfo('/admin/files/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue(is_array($fileInfo)); @@ -455,16 +522,18 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, false, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); $publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId'); // check if share key for public exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $publicShareKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $publicShareKeyId . '.shareKey')); // some hacking to simulate public link $GLOBALS['app'] = 'files_sharing'; - $GLOBALS['fileOwner'] = 'admin'; + $GLOBALS['fileOwner'] = \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1; \OC_User::setUserId(''); // get file contents @@ -476,25 +545,28 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase // tear down // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // unshare the file \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $publicShareKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $publicShareKeyId . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } - function testShareFileWithGroup() - { + function testShareFileWithGroup() { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // save file with content $cryptedFile = file_put_contents('crypt://' . $this->filename, $this->dataShort); @@ -507,7 +579,8 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = false; // get the file info from previous created file - $fileInfo = $this->view->getFileInfo('/admin/files/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue(is_array($fileInfo)); @@ -519,44 +592,57 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'group1', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user2 and user3 exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user3.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user1 - $this->loginHelper('user2'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); // get file contents - $retrievedCryptedFile = $this->view->file_get_contents('/user2/files/Shared/' . $this->filename); + $retrievedCryptedFile = $this->view->file_get_contents( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // unshare the file - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'group1'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user3.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } - function testRecoveryFile() - { + function testRecoveryFile() { + // login as admin + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123'); $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); @@ -564,9 +650,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $this->assertTrue($this->view->file_exists('/control-file/controlfile.enc')); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); - $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), 'admin'); + $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if recovery password match $this->assertTrue($util->checkRecoveryPassword('test123')); @@ -575,23 +661,37 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $this->assertTrue($util->setRecoveryForUser(1)); // create folder structure - $this->view->mkdir('/admin/files' . $this->folder1); - $this->view->mkdir('/admin/files' . $this->folder1 . $this->subfolder); - $this->view->mkdir('/admin/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); + $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder + . $this->subsubfolder); // save file with content $cryptedFile1 = file_put_contents('crypt://' . $this->filename, $this->dataShort); - $cryptedFile2 = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); + $cryptedFile2 = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile1)); $this->assertTrue(is_int($cryptedFile2)); // check if share key for admin and recovery exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.admin.shareKey')); - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.admin.shareKey')); - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); // disable recovery for admin $this->assertTrue($util->setRecoveryForUser(0)); @@ -600,8 +700,13 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $util->removeRecoveryKeys('/'); // check if share key for recovery not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); // enable recovery for admin $this->assertTrue($util->setRecoveryForUser(1)); @@ -610,26 +715,35 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $util->addRecoveryKeys('/'); // check if share key for admin and recovery exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); - $this->view->unlink('/admin/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->folder1); // check if share key for recovery not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); $this->assertTrue(\OCA\Encryption\Helper::adminEnableRecovery(null, 'test123')); $this->assertTrue(\OCA\Encryption\Helper::adminDisableRecovery('test123')); $this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled')); } - function testRecoveryForUser() - { + function testRecoveryForUser() { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123'); $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); @@ -638,58 +752,83 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $this->assertTrue($this->view->file_exists('/control-file/controlfile.enc')); // login as user1 - $this->loginHelper('user1'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); - $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), 'user1'); + $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); // enable recovery for admin $this->assertTrue($util->setRecoveryForUser(1)); // create folder structure - $this->view->mkdir('/user1/files' . $this->folder1); - $this->view->mkdir('/user1/files' . $this->folder1 . $this->subfolder); - $this->view->mkdir('/user1/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); + $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder); + $this->view->mkdir( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder + . $this->subsubfolder); // save file with content $cryptedFile1 = file_put_contents('crypt://' . $this->filename, $this->dataShort); - $cryptedFile2 = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); + $cryptedFile2 = file_put_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile1)); $this->assertTrue(is_int($cryptedFile2)); // check if share key for user and recovery exists - $this->assertTrue($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->filename . '.user1.shareKey')); - $this->assertTrue($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertTrue($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user1.shareKey')); - $this->assertTrue($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // change password - \OC_User::setPassword('user1', 'test', 'test123'); + \OC_User::setPassword(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'test', 'test123'); // login as user1 - $this->loginHelper('user1', false, 'test'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, false, 'test'); // get file contents $retrievedCryptedFile1 = file_get_contents('crypt://' . $this->filename); - $retrievedCryptedFile2 = file_get_contents('crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + $retrievedCryptedFile2 = file_get_contents( + 'crypt://' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile1); $this->assertEquals($this->dataShort, $retrievedCryptedFile2); // cleanup - $this->view->unlink('/user1/files' . $this->folder1); - $this->view->unlink('/user1/files' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->filename); // check if share key for user and recovery exists - $this->assertFalse($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->filename . '.user1.shareKey')); - $this->assertFalse($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); - $this->assertFalse($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.user1.shareKey')); - $this->assertFalse($this->view->file_exists('/user1/files_encryption/share-keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/share-keys/' . $this->folder1 + . $this->subfolder . $this->subsubfolder . '/' + . $this->filename . '.' . $recoveryKeyId . '.shareKey')); // enable recovery for admin $this->assertTrue($util->setRecoveryForUser(0)); @@ -698,10 +837,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled')); } - function testFailShareFile() - { + function testFailShareFile() { // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // save file with content $cryptedFile = file_put_contents('crypt://' . $this->filename, $this->dataShort); @@ -714,7 +852,8 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = false; // get the file info from previous created file - $fileInfo = $this->view->getFileInfo('/admin/files/' . $this->filename); + $fileInfo = $this->view->getFileInfo( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue(is_array($fileInfo)); @@ -723,68 +862,50 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); // break users public key - $this->view->rename('/public-keys/user2.public.key', '/public-keys/user2.public.key_backup'); + $this->view->rename('/public-keys/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.public.key', + '/public-keys/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.public.key_backup'); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'group1', OCP\PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, OCP\PERMISSION_ALL); // login as admin - $this->loginHelper('admin'); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; // break user1 public key - $this->view->rename('/public-keys/user2.public.key_backup', '/public-keys/user2.public.key'); + $this->view->rename( + '/public-keys/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.public.key_backup', + '/public-keys/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.public.key'); // remove share file - $this->view->unlink('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey'); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 + . '.shareKey'); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; // unshare the file with user1 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'group1'); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); // check if share key not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $this->filename . '.user2.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/' + . $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // cleanup - $this->view->unlink('/admin/files/' . $this->filename); + $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); } - - - /** - * @param $user - * @param bool $create - * @param bool $password - */ - function loginHelper($user, $create = false, $password = false) - { - if ($create) { - \OC_User::createUser($user, $user); - } - - if ($password === false) { - $password = $user; - } - - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($user); - \OC_User::setUserId($user); - - $params['uid'] = $user; - $params['password'] = $password; - OCA\Encryption\Hooks::login($params); - } } diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 3765d986e12..3d978767542 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -27,6 +27,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/proxy.php'); require_once realpath(dirname(__FILE__) . '/../lib/stream.php'); require_once realpath(dirname(__FILE__) . '/../lib/util.php'); require_once realpath(dirname(__FILE__) . '/../appinfo/app.php'); +require_once realpath(dirname(__FILE__) . '/util.php'); use OCA\Encryption; @@ -34,8 +35,9 @@ use OCA\Encryption; * Class Test_Encryption_Stream * @brief this class provide basic stream tests */ -class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_STREAM_USER1 = "test-stream-user1"; public $userId; public $pass; @@ -46,15 +48,27 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase public $dataShort; public $stateFilesTrashbin; - function setUp() - { + public static function setUpBeforeClass() { // reset backend + \OC_User::clearBackends(); \OC_User::useBackend('database'); + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true); + } + + function setUp() { // set user id - \OC_User::setUserId('admin'); - $this->userId = 'admin'; - $this->pass = 'admin'; + \OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); + $this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; + $this->pass = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; // init filesystem view $this->view = new \OC_FilesystemView('/'); @@ -62,42 +76,26 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase // init short data $this->dataShort = 'hats'; - // init filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - // register encryption file proxy - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); - - // init filesystem for user - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); - - // login user - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); } - function tearDown() - { + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } + } - // clear all proxies - \OC_FileProxy::clearProxies(); + public static function tearDownAfterClass() { + // cleanup test user + \OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); } function testStreamOptions() { @@ -113,7 +111,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase $handle = $view->fopen($filename, 'r'); // check if stream is at position zero - $this->assertEquals(0,ftell($handle)); + $this->assertEquals(0, ftell($handle)); // set stream options $this->assertTrue(flock($handle, LOCK_SH)); @@ -136,7 +134,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase $handle = $view->fopen($filename, 'r'); // set stream options - $this->assertTrue(stream_set_blocking($handle,1)); + $this->assertTrue(stream_set_blocking($handle, 1)); // tear down $view->unlink($filename); @@ -155,7 +153,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase $handle = $view->fopen($filename, 'r'); // set stream options - $this->assertFalse(stream_set_timeout($handle,1)); + $this->assertFalse(stream_set_timeout($handle, 1)); // tear down $view->unlink($filename); @@ -174,7 +172,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase $handle = $view->fopen($filename, 'r'); // set stream options - $this->assertEquals(0, stream_set_write_buffer($handle,1024)); + $this->assertEquals(0, stream_set_write_buffer($handle, 1024)); // tear down $view->unlink($filename); diff --git a/apps/files_encryption/tests/trashbin.php b/apps/files_encryption/tests/trashbin.php index cc8709b6f24..29f8fb5a396 100755 --- a/apps/files_encryption/tests/trashbin.php +++ b/apps/files_encryption/tests/trashbin.php @@ -28,6 +28,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/stream.php'); require_once realpath(dirname(__FILE__) . '/../lib/util.php'); require_once realpath(dirname(__FILE__) . '/../appinfo/app.php'); require_once realpath(dirname(__FILE__) . '/../../files_trashbin/appinfo/app.php'); +require_once realpath(dirname(__FILE__) . '/util.php'); use OCA\Encryption; @@ -35,8 +36,9 @@ use OCA\Encryption; * Class Test_Encryption_Trashbin * @brief this class provide basic trashbin app tests */ -class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_TRASHBIN_USER1 = "test-trashbin-user1"; public $userId; public $pass; @@ -50,15 +52,33 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase public $subfolder; public $subsubfolder; - function setUp() - { + public static function setUpBeforeClass() { // reset backend + \OC_User::clearBackends(); \OC_User::useBackend('database'); + \OC_Hook::clear('OC_Filesystem'); + \OC_Hook::clear('OC_User'); + + // trashbin hooks + \OCA\Files_Trashbin\Trashbin::registerHooks(); + + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1, true); + } + + function setUp() { // set user id - \OC_User::setUserId('admin'); - $this->userId = 'admin'; - $this->pass = 'admin'; + \OC_User::setUserId(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1); + $this->userId = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1; + $this->pass = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1; // init filesystem view $this->view = new \OC_FilesystemView('/'); @@ -70,48 +90,26 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $this->subfolder = '/subfolder1'; $this->subsubfolder = '/subsubfolder1'; - \OC_Hook::clear('OC_Filesystem'); - \OC_Hook::clear('OC_User'); - - // init filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - // register encryption file proxy - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - - // trashbin hooks - \OCA\Files_Trashbin\Trashbin::registerHooks(); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); - // we don't want to tests with app files_trashbin enabled + // we want to tests with app files_trashbin enabled \OC_App::enable('files_trashbin'); - - // init filesystem for user - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); - - // login user - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); } - function tearDown() - { + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } + } - // clear all proxies - \OC_FileProxy::clearProxies(); + public static function tearDownAfterClass() { + // cleanup test user + \OC_User::deleteUser(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1); } /** @@ -129,30 +127,40 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $this->assertTrue(is_int($cryptedFile)); // check if key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename + . '.key')); // check if share key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' + . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); // delete file \OC\FIles\Filesystem::unlink($filename); // check if file not exists - $this->assertFalse($this->view->file_exists('/admin/files/' . $filename)); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename)); // check if key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename + . '.key')); // check if share key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' + . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); // get files - $trashFiles = $this->view->getDirectoryContent('/admin/files_trashbin/files/'); + $trashFiles = $this->view->getDirectoryContent( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/'); $trashFileSuffix = null; // find created file with timestamp - foreach($trashFiles as $file) { - if(strncmp($file['path'], $filename, strlen($filename))) { + foreach ($trashFiles as $file) { + if (strncmp($file['path'], $filename, strlen($filename))) { $path_parts = pathinfo($file['name']); $trashFileSuffix = $path_parts['extension']; } @@ -162,10 +170,14 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $this->assertNotNull($trashFileSuffix); // check if key for admin not exists - $this->assertTrue($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix)); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename + . '.key.' . $trashFileSuffix)); // check if share key for admin not exists - $this->assertTrue($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix)); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename + . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix)); // return filename for next test return $filename . '.' . $trashFileSuffix; @@ -182,19 +194,24 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $path_parts = pathinfo($filename); $trashFileSuffix = $path_parts['extension']; $timestamp = str_replace('d', '', $trashFileSuffix); - $fileNameWithoutSuffix = str_replace('.'.$trashFileSuffix, '', $filename); + $fileNameWithoutSuffix = str_replace('.' . $trashFileSuffix, '', $filename); // restore file $this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename, $fileNameWithoutSuffix, $timestamp)); // check if file exists - $this->assertTrue($this->view->file_exists('/admin/files/' . $fileNameWithoutSuffix)); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $fileNameWithoutSuffix)); // check if key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $fileNameWithoutSuffix . '.key')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' + . $fileNameWithoutSuffix . '.key')); // check if share key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $fileNameWithoutSuffix . '.admin.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' + . $fileNameWithoutSuffix . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); } /** @@ -212,44 +229,51 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $this->assertTrue(is_int($cryptedFile)); // check if key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename + . '.key')); // check if share key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' + . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); // delete file \OC\FIles\Filesystem::unlink($filename); // check if file not exists - $this->assertFalse($this->view->file_exists('/admin/files/' . $filename)); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename)); // check if key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename + . '.key')); // check if share key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' + . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); - // get files - $trashFiles = $this->view->getDirectoryContent('/admin/files_trashbin/files/'); - - $trashFileSuffix = null; // find created file with timestamp - foreach($trashFiles as $file) { - if(strncmp($file['name'], $filename, strlen($filename)) == 0) { - $path_parts = pathinfo($file['name']); - $trashFileSuffix = $path_parts['extension']; - break; - } - } + $query = \OC_DB::prepare('SELECT `timestamp`,`type` FROM `*PREFIX*files_trash`' + . ' WHERE `id`=?'); + $result = $query->execute(array($filename))->fetchRow(); - // check if we found the file we created - $this->assertNotNull($trashFileSuffix); + $this->assertTrue(is_array($result)); + + // build suffix + $trashFileSuffix = 'd' . $result['timestamp']; // check if key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix)); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename + . '.key.' . $trashFileSuffix)); // check if share key for admin exists - $this->assertTrue($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix)); + $this->assertTrue($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename + . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix)); // get timestamp from file $timestamp = str_replace('d', '', $trashFileSuffix); @@ -258,13 +282,19 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase $this->assertGreaterThan(0, \OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)); // check if key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_trashbin/files/' . $filename . '.' . $trashFileSuffix)); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/' . $filename . '.' + . $trashFileSuffix)); // check if key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix)); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename + . '.key.' . $trashFileSuffix)); // check if share key for admin not exists - $this->assertFalse($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix)); + $this->assertFalse($this->view->file_exists( + '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename + . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix)); } }
\ No newline at end of file diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index a2be8a40417..2069cae27e5 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -19,8 +19,10 @@ use OCA\Encryption; /** * Class Test_Encryption_Util */ -class Test_Encryption_Util extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_UTIL_USER1 = "test-util-user1"; + const TEST_ENCRYPTION_UTIL_LEGACY_USER = "test-legacy-user"; public $userId; public $encryptionDir; @@ -40,16 +42,31 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase public $dataShort; public $legacyEncryptedData; public $legacyEncryptedDataKey; - public $lagacyKey; + public $legacyKey; + public $stateFilesTrashbin; - function setUp() - { + public static function setUpBeforeClass() { // reset backend + \OC_User::clearBackends(); \OC_User::useBackend('database'); - \OC_User::setUserId('admin'); - $this->userId = 'admin'; - $this->pass = 'admin'; + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true); + \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true); + } + + + function setUp() { + \OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); + $this->userId = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1; + $this->pass = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1; // set content for encrypting / decrypting in tests $this->dataUrl = realpath(dirname(__FILE__) . '/../lib/crypt.php'); @@ -58,7 +75,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase $this->legacyData = realpath(dirname(__FILE__) . '/legacy-text.txt'); $this->legacyEncryptedData = realpath(dirname(__FILE__) . '/legacy-encrypted-text.txt'); $this->legacyEncryptedDataKey = realpath(dirname(__FILE__) . '/encryption.key'); - $this->lagacyKey = '62829813025828180801'; + $this->legacyKey = '30943623843030686906'; $keypair = Encryption\Crypt::createKeypair(); @@ -68,43 +85,42 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase $this->publicKeyDir = '/' . 'public-keys'; $this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption'; $this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles'; - $this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key - $this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key + $this->publicKeyPath = + $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key + $this->privateKeyPath = + $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key $this->view = new \OC_FilesystemView('/'); - $userHome = \OC_User::getHome($this->userId); - $this->dataDir = str_replace('/' . $this->userId, '', $userHome); - - // Filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); + $this->util = new Encryption\Util($this->view, $this->userId); - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); + // remember files_trashbin state + $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); - $this->util = new Encryption\Util($this->view, $this->userId); + // we don't want to tests with app files_trashbin enabled + \OC_App::disable('files_trashbin'); } - function tearDown() - { + function tearDown() { + // reset app files_trashbin + if ($this->stateFilesTrashbin) { + OC_App::enable('files_trashbin'); + } + else { + OC_App::disable('files_trashbin'); + } + } - \OC_FileProxy::clearProxies(); + public static function tearDownAfterClass() { + // cleanup test user + \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); + \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); } /** * @brief test that paths set during User construction are correct */ - function testKeyPaths() - { + function testKeyPaths() { $util = new Encryption\Util($this->view, $this->userId); $this->assertEquals($this->publicKeyDir, $util->getPath('publicKeyDir')); @@ -118,39 +134,37 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase /** * @brief test setup of encryption directories */ - function testSetupServerSide() - { + function testSetupServerSide() { $this->assertEquals(true, $this->util->setupServerSide($this->pass)); } /** * @brief test checking whether account is ready for encryption, */ - function testUserIsReady() - { + function testUserIsReady() { $this->assertEquals(true, $this->util->ready()); } /** * @brief test checking whether account is not ready for encryption, */ - function testUserIsNotReady() - { - $this->view->unlink($this->publicKeyDir); - - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - $this->assertFalse(OCA\Encryption\Hooks::login($params)); - - $this->view->unlink($this->privateKeyPath); - } +// function testUserIsNotReady() { +// $this->view->unlink($this->publicKeyDir); +// +// $params['uid'] = $this->userId; +// $params['password'] = $this->pass; +// $this->assertFalse(OCA\Encryption\Hooks::login($params)); +// +// $this->view->unlink($this->privateKeyPath); +// } /** * @brief test checking whether account is not ready for encryption, */ - function testIsLagacyUser() - { - $userView = new \OC_FilesystemView( '/' . $this->userId ); + function testIsLegacyUser() { + \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); + + $userView = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -161,19 +175,18 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; - $params['uid'] = $this->userId; - $params['password'] = $this->pass; + $params['uid'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; + $params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; - $util = new Encryption\Util($this->view, $this->userId); + $util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); $util->setMigrationStatus(0); $this->assertTrue(OCA\Encryption\Hooks::login($params)); - $this->assertEquals($this->lagacyKey, $_SESSION['legacyKey']); + $this->assertEquals($this->legacyKey, $_SESSION['legacyKey']); } - function testRecoveryEnabledForUser() - { + function testRecoveryEnabledForUser() { $util = new Encryption\Util($this->view, $this->userId); @@ -193,10 +206,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase } - function testGetUidAndFilename() - { + function testGetUidAndFilename() { - \OC_User::setUserId('admin'); + \OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); $filename = 'tmp-' . time() . '.test'; @@ -213,9 +225,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase list($fileOwnerUid, $file) = $util->getUidAndFilename($filename); - $this->assertEquals('admin', $fileOwnerUid); + $this->assertEquals(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, $fileOwnerUid); $this->assertEquals($file, $filename); + + $this->view->unlink($this->userId . '/files/' . $filename); } function testIsSharedPath() { @@ -227,10 +241,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase $this->assertFalse($this->util->isSharedPath($path)); } - function testEncryptLagacyFiles() - { - $userView = new \OC_FilesystemView( '/' . $this->userId); - $view = new \OC_FilesystemView( '/' . $this->userId . '/files' ); + function testEncryptLegacyFiles() { + \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); + + $userView = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); + $view = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER . '/files'); // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -250,23 +265,23 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase \OC_FileProxy::$enabled = $proxyStatus; - $params['uid'] = $this->userId; - $params['password'] = $this->pass; + $params['uid'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; + $params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; - $util = new Encryption\Util($this->view, $this->userId); + $util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); $util->setMigrationStatus(0); $this->assertTrue(OCA\Encryption\Hooks::login($params)); - $this->assertEquals($this->lagacyKey, $_SESSION['legacyKey']); + $this->assertEquals($this->legacyKey, $_SESSION['legacyKey']); - $files = $util->findEncFiles('/' . $this->userId . '/files/'); + $files = $util->findEncFiles('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER . '/files/'); $this->assertTrue(is_array($files)); $found = false; - foreach($files['encrypted'] as $encryptedFile) { - if($encryptedFile['name'] === 'legacy-encrypted-text.txt') { + foreach ($files['encrypted'] as $encryptedFile) { + if ($encryptedFile['name'] === 'legacy-encrypted-text.txt') { $found = true; break; } @@ -274,4 +289,29 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase $this->assertTrue($found); } + + /** + * @param $user + * @param bool $create + * @param bool $password + */ + public static function loginHelper($user, $create = false, $password = false) { + if ($create) { + \OC_User::createUser($user, $user); + } + + if ($password === false) { + $password = $user; + } + + \OC_Util::tearDownFS(); + \OC_User::setUserId(''); + \OC\Files\Filesystem::tearDown(); + \OC_Util::setupFS($user); + \OC_User::setUserId($user); + + $params['uid'] = $user; + $params['password'] = $password; + OCA\Encryption\Hooks::login($params); + } }
\ No newline at end of file diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index 4b453d0c9d1..94d3ec3fa55 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -27,6 +27,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/proxy.php'); require_once realpath(dirname(__FILE__) . '/../lib/stream.php'); require_once realpath(dirname(__FILE__) . '/../lib/util.php'); require_once realpath(dirname(__FILE__) . '/../appinfo/app.php'); +require_once realpath(dirname(__FILE__) . '/util.php'); use OCA\Encryption; @@ -34,8 +35,9 @@ use OCA\Encryption; * Class Test_Encryption_Webdav * @brief this class provide basic webdav tests for PUT,GET and DELETE */ -class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase -{ +class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { + + const TEST_ENCRYPTION_WEBDAV_USER1 = "test-webdav-user1"; public $userId; public $pass; @@ -46,15 +48,33 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase public $dataShort; public $stateFilesTrashbin; - function setUp() - { + public static function setUpBeforeClass() { + // reset backend + \OC_User::clearBackends(); + \OC_User::useBackend('database'); + + // Filesystem related hooks + \OCA\Encryption\Helper::registerFilesystemHooks(); + + // Filesystem related hooks + \OCA\Encryption\Helper::registerUserHooks(); + + // clear and register hooks + \OC_FileProxy::clearProxies(); + \OC_FileProxy::register(new OCA\Encryption\Proxy()); + + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1, true); + } + + function setUp() { // reset backend \OC_User::useBackend('database'); // set user id - \OC_User::setUserId('admin'); - $this->userId = 'admin'; - $this->pass = 'admin'; + \OC_User::setUserId(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); + $this->userId = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1; + $this->pass = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1; // init filesystem view $this->view = new \OC_FilesystemView('/'); @@ -62,42 +82,29 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase // init short data $this->dataShort = 'hats'; - // init filesystem related hooks - \OCA\Encryption\Helper::registerFilesystemHooks(); - - // register encryption file proxy - \OC_FileProxy::register(new OCA\Encryption\Proxy()); - // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); - // init filesystem for user - \OC_Util::tearDownFS(); - \OC_User::setUserId(''); - \OC\Files\Filesystem::tearDown(); - \OC_Util::setupFS($this->userId); - \OC_User::setUserId($this->userId); - - // login user - $params['uid'] = $this->userId; - $params['password'] = $this->pass; - OCA\Encryption\Hooks::login($params); + // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); } - function tearDown() - { + function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); - } else { + } + else { OC_App::disable('files_trashbin'); } + } - // clear all proxies - \OC_FileProxy::clearProxies(); + public static function tearDownAfterClass() { + // cleanup test user + \OC_User::deleteUser(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); } /** @@ -125,10 +132,12 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase $this->assertTrue($this->view->file_exists('/' . $this->userId . '/files' . $filename)); // check if key-file was created - $this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles/' . $filename . '.key')); + $this->assertTrue($this->view->file_exists( + '/' . $this->userId . '/files_encryption/keyfiles/' . $filename . '.key')); // check if shareKey-file was created - $this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/share-keys/' . $filename . '.' . $this->userId . '.shareKey')); + $this->assertTrue($this->view->file_exists( + '/' . $this->userId . '/files_encryption/share-keys/' . $filename . '.' . $this->userId . '.shareKey')); // disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -194,10 +203,12 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase $this->assertFalse($this->view->file_exists('/' . $this->userId . '/files' . $filename)); // check if key-file was removed - $this->assertFalse($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles' . $filename . '.key')); + $this->assertFalse($this->view->file_exists( + '/' . $this->userId . '/files_encryption/keyfiles' . $filename . '.key')); // check if shareKey-file was removed - $this->assertFalse($this->view->file_exists('/' . $this->userId . '/files_encryption/share-keys' . $filename . '.' . $this->userId . '.shareKey')); + $this->assertFalse($this->view->file_exists( + '/' . $this->userId . '/files_encryption/share-keys' . $filename . '.' . $this->userId . '.shareKey')); } /** @@ -229,7 +240,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); // And off we go! - if($body) { + if ($body) { $server->httpRequest->setBody($body); } diff --git a/apps/user_ldap/l10n/hu_HU.php b/apps/user_ldap/l10n/hu_HU.php index cbbcc69edeb..a06d0bd5355 100644 --- a/apps/user_ldap/l10n/hu_HU.php +++ b/apps/user_ldap/l10n/hu_HU.php @@ -1,4 +1,5 @@ <?php $TRANSLATIONS = array( +"Failed to clear the mappings." => "Nem sikerült törölni a hozzárendeléseket.", "Failed to delete the server configuration" => "Nem sikerült törölni a kiszolgáló konfigurációját", "The configuration is valid and the connection could be established!" => "A konfiguráció érvényes, és a kapcsolat létrehozható!", "The configuration is valid, but the Bind failed. Please check the server settings and credentials." => "A konfiguráció érvényes, de a kapcsolat nem hozható létre. Kérem ellenőrizze a kiszolgáló beállításait, és az elérési adatokat.", @@ -7,6 +8,8 @@ "Take over settings from recent server configuration?" => "Vegyük át a beállításokat az előző konfigurációból?", "Keep settings?" => "Tartsuk meg a beállításokat?", "Cannot add server configuration" => "Az új kiszolgáló konfigurációja nem hozható létre", +"mappings cleared" => "Töröltük a hozzárendeléseket", +"Success" => "Sikeres végrehajtás", "Error" => "Hiba", "Connection test succeeded" => "A kapcsolatellenőrzés eredménye: sikerült", "Connection test failed" => "A kapcsolatellenőrzés eredménye: nem sikerült", @@ -71,6 +74,7 @@ "Email Field" => "Email mező", "User Home Folder Naming Rule" => "A home könyvtár elérési útvonala", "Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute." => "Hagyja üresen, ha a felhasználónevet kívánja használni. Ellenkező esetben adjon meg egy LDAP/AD attribútumot!", +"Internal Username" => "Belső felhasználónév", "Test Configuration" => "A beállítások tesztelése", "Help" => "Súgó" ); |