aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federation')
-rw-r--r--apps/federation/l10n/hu.js6
-rw-r--r--apps/federation/l10n/hu.json6
-rw-r--r--apps/federation/l10n/lb.js15
-rw-r--r--apps/federation/l10n/lb.json13
-rw-r--r--apps/federation/l10n/nl.js7
-rw-r--r--apps/federation/l10n/nl.json7
-rw-r--r--apps/federation/l10n/oc.js9
-rw-r--r--apps/federation/l10n/oc.json7
-rw-r--r--apps/federation/l10n/ro.js15
-rw-r--r--apps/federation/l10n/ro.json13
-rw-r--r--apps/federation/l10n/sw.js21
-rw-r--r--apps/federation/l10n/sw.json19
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php18
-rw-r--r--apps/federation/lib/BackgroundJob/RequestSharedSecret.php8
-rw-r--r--apps/federation/lib/Controller/OCSAuthAPIController.php10
-rw-r--r--apps/federation/lib/Settings/Admin.php1
-rw-r--r--apps/federation/lib/SyncJob.php1
-rw-r--r--apps/federation/lib/TrustedServers.php1
-rw-r--r--apps/federation/templates/settings-admin.php4
-rw-r--r--apps/federation/tests/BackgroundJob/GetSharedSecretTest.php64
-rw-r--r--apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php122
-rw-r--r--apps/federation/tests/Controller/OCSAuthAPIControllerTest.php57
-rw-r--r--apps/federation/tests/Controller/SettingsControllerTest.php38
-rw-r--r--apps/federation/tests/DAV/FedAuthTest.php20
-rw-r--r--apps/federation/tests/DbHandlerTest.php100
-rw-r--r--apps/federation/tests/Settings/AdminTest.php11
-rw-r--r--apps/federation/tests/SyncFederationAddressbooksTest.php84
-rw-r--r--apps/federation/tests/TrustedServersTest.php130
28 files changed, 330 insertions, 477 deletions
diff --git a/apps/federation/l10n/hu.js b/apps/federation/l10n/hu.js
index 66a52658118..953cd963196 100644
--- a/apps/federation/l10n/hu.js
+++ b/apps/federation/l10n/hu.js
@@ -2,14 +2,18 @@ OC.L10N.register(
"federation",
{
"Added to the list of trusted servers" : "Hozzáadva a megbízható kiszolgálók listájához",
+ "No server found with ID: %s" : "Nem található kiszolgáló az azonosítóval: %s",
+ "Could not remove server" : "Nem sikerült a kiszolgáló eltávolítása",
"Server is already in the list of trusted servers." : "A kiszolgáló már szerepel a megbízható kiszolgálók között.",
"No server to federate with found" : "Nem található olyan kiszolgáló, amellyel föderálni lehetne",
"Could not add server" : "A kiszolgáló nem adható hozzá",
"Trusted servers" : "Megbízható kiszolgálók",
"Federation" : "Föderáció",
"Federation allows you to connect with other trusted servers to exchange the account directory." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cserélhessenek.",
- "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fióókok a föderált megosztásnál.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fiókok a föderált megosztásnál.",
+ "External documentation for Federated Cloud Sharing" : "Külső dokumentáció a föderált felhőmegosztáshoz",
"Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fiókok a föderált megosztásnál. Nem szükséges egy kiszolgálót megbízhatóként hozzáadni ahhoz, hogy föderált megosztást hozzon létre.",
+ "Each server must validate the other. This process may require a few cron cycles." : "Minden kiszolgálónak ellenőriznie kell a másikat. Ez a folyat néhány cron ciklust vehet igénybe.",
"+ Add trusted server" : "+ Megbízható kiszolgáló hozzáadása",
"Trusted server" : "Megbízható kiszolgáló",
"Add" : "Hozzáadás"
diff --git a/apps/federation/l10n/hu.json b/apps/federation/l10n/hu.json
index 642ebe28217..d10201e424c 100644
--- a/apps/federation/l10n/hu.json
+++ b/apps/federation/l10n/hu.json
@@ -1,13 +1,17 @@
{ "translations": {
"Added to the list of trusted servers" : "Hozzáadva a megbízható kiszolgálók listájához",
+ "No server found with ID: %s" : "Nem található kiszolgáló az azonosítóval: %s",
+ "Could not remove server" : "Nem sikerült a kiszolgáló eltávolítása",
"Server is already in the list of trusted servers." : "A kiszolgáló már szerepel a megbízható kiszolgálók között.",
"No server to federate with found" : "Nem található olyan kiszolgáló, amellyel föderálni lehetne",
"Could not add server" : "A kiszolgáló nem adható hozzá",
"Trusted servers" : "Megbízható kiszolgálók",
"Federation" : "Föderáció",
"Federation allows you to connect with other trusted servers to exchange the account directory." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cserélhessenek.",
- "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fióókok a föderált megosztásnál.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fiókok a föderált megosztásnál.",
+ "External documentation for Federated Cloud Sharing" : "Külső dokumentáció a föderált felhőmegosztáshoz",
"Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "A föderáció lehetővé teszi a más megbízható kiszolgálókhoz kapcsolódást, hogy a kiszolgálók fiókjegyzéket cseréljenek. Például ennek segítségével lesznek automatikusan kiegészítve a külső fiókok a föderált megosztásnál. Nem szükséges egy kiszolgálót megbízhatóként hozzáadni ahhoz, hogy föderált megosztást hozzon létre.",
+ "Each server must validate the other. This process may require a few cron cycles." : "Minden kiszolgálónak ellenőriznie kell a másikat. Ez a folyat néhány cron ciklust vehet igénybe.",
"+ Add trusted server" : "+ Megbízható kiszolgáló hozzáadása",
"Trusted server" : "Megbízható kiszolgáló",
"Add" : "Hozzáadás"
diff --git a/apps/federation/l10n/lb.js b/apps/federation/l10n/lb.js
deleted file mode 100644
index df0f6d5d07a..00000000000
--- a/apps/federation/l10n/lb.js
+++ /dev/null
@@ -1,15 +0,0 @@
-OC.L10N.register(
- "federation",
- {
- "Server added to the list of trusted ownClouds" : "De Server gouf op d'Lëscht vun den zouverlässegen ownClouds gesat.",
- "Server is already in the list of trusted servers." : "De Server ass schonn op der Lëscht vun den zouverlässegen Serveren.",
- "No ownCloud server found" : "Keen ownCloud Server fonnt",
- "Could not add server" : "De Server konnt net derbäi gesat ginn",
- "Federation" : "Federatioun",
- "ownCloud Federation allows you to connect with other trusted ownClouds to exchange the user directory. For example this will be used to auto-complete external users for federated sharing." : "D'ownCloud Federatioun erlaabt der fir dech mat aneren zouverlässegen ownClouds ze verbannen an d'Benotzer Verzeechnes auszetauschen. Zum Beispill gëtt dëst hei benotzt fir extern Benotzer automatesch fir federatiivt Deelen ze vervollstännegen.",
- "Add server automatically once a federated share was created successfully" : "Setz de Server automatesch derbäi soubal e federativen Undeel erfollegräich erstallt gouf",
- "Trusted ownCloud Servers" : "Zouverlässeg ownCloud Serveren",
- "+ Add ownCloud server" : "+ ownCloud Server derbäi setzen",
- "ownCloud Server" : "ownCloud Server"
-},
-"nplurals=2; plural=(n != 1);");
diff --git a/apps/federation/l10n/lb.json b/apps/federation/l10n/lb.json
deleted file mode 100644
index 03179a4b8ee..00000000000
--- a/apps/federation/l10n/lb.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{ "translations": {
- "Server added to the list of trusted ownClouds" : "De Server gouf op d'Lëscht vun den zouverlässegen ownClouds gesat.",
- "Server is already in the list of trusted servers." : "De Server ass schonn op der Lëscht vun den zouverlässegen Serveren.",
- "No ownCloud server found" : "Keen ownCloud Server fonnt",
- "Could not add server" : "De Server konnt net derbäi gesat ginn",
- "Federation" : "Federatioun",
- "ownCloud Federation allows you to connect with other trusted ownClouds to exchange the user directory. For example this will be used to auto-complete external users for federated sharing." : "D'ownCloud Federatioun erlaabt der fir dech mat aneren zouverlässegen ownClouds ze verbannen an d'Benotzer Verzeechnes auszetauschen. Zum Beispill gëtt dëst hei benotzt fir extern Benotzer automatesch fir federatiivt Deelen ze vervollstännegen.",
- "Add server automatically once a federated share was created successfully" : "Setz de Server automatesch derbäi soubal e federativen Undeel erfollegräich erstallt gouf",
- "Trusted ownCloud Servers" : "Zouverlässeg ownCloud Serveren",
- "+ Add ownCloud server" : "+ ownCloud Server derbäi setzen",
- "ownCloud Server" : "ownCloud Server"
-},"pluralForm" :"nplurals=2; plural=(n != 1);"
-} \ No newline at end of file
diff --git a/apps/federation/l10n/nl.js b/apps/federation/l10n/nl.js
index 99aa1bfdd48..4633804db82 100644
--- a/apps/federation/l10n/nl.js
+++ b/apps/federation/l10n/nl.js
@@ -2,11 +2,18 @@ OC.L10N.register(
"federation",
{
"Added to the list of trusted servers" : "Toegevoegd aan de lijst met vertrouwde servers",
+ "No server found with ID: %s" : "Geen server gevonden met ID: %s",
+ "Could not remove server" : "Kon server niet verwijderen",
"Server is already in the list of trusted servers." : "Server bestaat reeds in de lijst van vertrouwde servers.",
"No server to federate with found" : "Geen server gevonden om mee te federeren",
"Could not add server" : "Kon server niet toevoegen",
"Trusted servers" : "Vertrouwde servers",
"Federation" : "Federatie",
+ "Federation allows you to connect with other trusted servers to exchange the account directory." : "Met Federatie kun je verbinding maken met andere vertrouwde servers om de accountmap uit te wisselen.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "Federatie stelt je in staat om verbinding te maken met andere vertrouwde servers om de accountdirectory uit te wisselen. Dit zal bijvoorbeeld worden gebruikt om externe accounts automatisch aan te vullen voor gefedereerd delen.",
+ "External documentation for Federated Cloud Sharing" : "Externe documentatie voor Federated Cloud Sharing",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "Federatie stelt je in staat om verbinding te maken met andere vertrouwde servers om de accountdirectory uit te wisselen. Dit zal bijvoorbeeld worden gebruikt om externe accounts automatisch aan te vullen voor gefedereerd delen. Het is niet nodig om een server als vertrouwde server toe te voegen om een gefedereerde share te maken.",
+ "Each server must validate the other. This process may require a few cron cycles." : "Elke server moet de andere valideren. Dit proces kan enkele croncycli duren.",
"+ Add trusted server" : "+ Toevoegen vertrouwde server",
"Trusted server" : "Vertrouwde server",
"Add" : "Toevoegen"
diff --git a/apps/federation/l10n/nl.json b/apps/federation/l10n/nl.json
index 8e7a78f072b..e217a0b03d3 100644
--- a/apps/federation/l10n/nl.json
+++ b/apps/federation/l10n/nl.json
@@ -1,10 +1,17 @@
{ "translations": {
"Added to the list of trusted servers" : "Toegevoegd aan de lijst met vertrouwde servers",
+ "No server found with ID: %s" : "Geen server gevonden met ID: %s",
+ "Could not remove server" : "Kon server niet verwijderen",
"Server is already in the list of trusted servers." : "Server bestaat reeds in de lijst van vertrouwde servers.",
"No server to federate with found" : "Geen server gevonden om mee te federeren",
"Could not add server" : "Kon server niet toevoegen",
"Trusted servers" : "Vertrouwde servers",
"Federation" : "Federatie",
+ "Federation allows you to connect with other trusted servers to exchange the account directory." : "Met Federatie kun je verbinding maken met andere vertrouwde servers om de accountmap uit te wisselen.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "Federatie stelt je in staat om verbinding te maken met andere vertrouwde servers om de accountdirectory uit te wisselen. Dit zal bijvoorbeeld worden gebruikt om externe accounts automatisch aan te vullen voor gefedereerd delen.",
+ "External documentation for Federated Cloud Sharing" : "Externe documentatie voor Federated Cloud Sharing",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "Federatie stelt je in staat om verbinding te maken met andere vertrouwde servers om de accountdirectory uit te wisselen. Dit zal bijvoorbeeld worden gebruikt om externe accounts automatisch aan te vullen voor gefedereerd delen. Het is niet nodig om een server als vertrouwde server toe te voegen om een gefedereerde share te maken.",
+ "Each server must validate the other. This process may require a few cron cycles." : "Elke server moet de andere valideren. Dit proces kan enkele croncycli duren.",
"+ Add trusted server" : "+ Toevoegen vertrouwde server",
"Trusted server" : "Vertrouwde server",
"Add" : "Toevoegen"
diff --git a/apps/federation/l10n/oc.js b/apps/federation/l10n/oc.js
deleted file mode 100644
index d65cc9bdef8..00000000000
--- a/apps/federation/l10n/oc.js
+++ /dev/null
@@ -1,9 +0,0 @@
-OC.L10N.register(
- "federation",
- {
- "No ownCloud server found" : "Cap de servidor ownCloud pas trobat",
- "Could not add server" : "Impossible d'apondre un servidor",
- "Federation" : "Federacion",
- "ownCloud Server" : "Servidor ownCloud"
-},
-"nplurals=2; plural=(n > 1);");
diff --git a/apps/federation/l10n/oc.json b/apps/federation/l10n/oc.json
deleted file mode 100644
index 809a86fcaa8..00000000000
--- a/apps/federation/l10n/oc.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{ "translations": {
- "No ownCloud server found" : "Cap de servidor ownCloud pas trobat",
- "Could not add server" : "Impossible d'apondre un servidor",
- "Federation" : "Federacion",
- "ownCloud Server" : "Servidor ownCloud"
-},"pluralForm" :"nplurals=2; plural=(n > 1);"
-} \ No newline at end of file
diff --git a/apps/federation/l10n/ro.js b/apps/federation/l10n/ro.js
deleted file mode 100644
index 19f37f329a1..00000000000
--- a/apps/federation/l10n/ro.js
+++ /dev/null
@@ -1,15 +0,0 @@
-OC.L10N.register(
- "federation",
- {
- "Server added to the list of trusted ownClouds" : "Server adăugat la lista serverelor ownCloud de încredere",
- "Server is already in the list of trusted servers." : "Serverul este deja pe lista celor de încredere.",
- "No ownCloud server found" : "Nu s-a găsit niciun server ownCloud",
- "Could not add server" : "Nu s-a putut adăuga serverul",
- "Federation" : "Federare",
- "ownCloud Federation allows you to connect with other trusted ownClouds to exchange the user directory. For example this will be used to auto-complete external users for federated sharing." : "Federarea ownCloud îți permite să te conectezi la alte servere ownCloud de încredere pentru a partaja baza de utilizatori. De exemplu, va permite completarea automată a numelor utilizatorilor externi pentru partajarea federată.",
- "Add server automatically once a federated share was created successfully" : "Adaugă serverul automat odată ce elementul partajat federat a fost creat cu succes",
- "Trusted ownCloud Servers" : "Servere ownCloud de încredere",
- "+ Add ownCloud server" : "+ Adaugă server ownCloud",
- "ownCloud Server" : "Server ownCloud"
-},
-"nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));");
diff --git a/apps/federation/l10n/ro.json b/apps/federation/l10n/ro.json
deleted file mode 100644
index 0acb4ebd962..00000000000
--- a/apps/federation/l10n/ro.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{ "translations": {
- "Server added to the list of trusted ownClouds" : "Server adăugat la lista serverelor ownCloud de încredere",
- "Server is already in the list of trusted servers." : "Serverul este deja pe lista celor de încredere.",
- "No ownCloud server found" : "Nu s-a găsit niciun server ownCloud",
- "Could not add server" : "Nu s-a putut adăuga serverul",
- "Federation" : "Federare",
- "ownCloud Federation allows you to connect with other trusted ownClouds to exchange the user directory. For example this will be used to auto-complete external users for federated sharing." : "Federarea ownCloud îți permite să te conectezi la alte servere ownCloud de încredere pentru a partaja baza de utilizatori. De exemplu, va permite completarea automată a numelor utilizatorilor externi pentru partajarea federată.",
- "Add server automatically once a federated share was created successfully" : "Adaugă serverul automat odată ce elementul partajat federat a fost creat cu succes",
- "Trusted ownCloud Servers" : "Servere ownCloud de încredere",
- "+ Add ownCloud server" : "+ Adaugă server ownCloud",
- "ownCloud Server" : "Server ownCloud"
-},"pluralForm" :"nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));"
-} \ No newline at end of file
diff --git a/apps/federation/l10n/sw.js b/apps/federation/l10n/sw.js
new file mode 100644
index 00000000000..4c09b59af82
--- /dev/null
+++ b/apps/federation/l10n/sw.js
@@ -0,0 +1,21 @@
+OC.L10N.register(
+ "federation",
+ {
+ "Added to the list of trusted servers" : " Imeongezwa kwenye orodha ya seva zinazoaminika",
+ "No server found with ID: %s" : "Hakuna seva iliyopatikana na kitambulisho: %s",
+ "Could not remove server" : "Isingeweza kuondoa seva",
+ "Server is already in the list of trusted servers." : "Seva tayari iko kwenye orodha ya seva zinazoaminika.",
+ "No server to federate with found" : "Hakuna seva ya kushirikiana na, iliyopatikana",
+ "Could not add server" : "Isingeweza kuongeza seva",
+ "Trusted servers" : "Seva zinazoaminiwa",
+ "Federation" : "Shirikisho",
+ "Federation allows you to connect with other trusted servers to exchange the account directory." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti. Kwa mfano hii itatumika kukamilisha kiotomatiki akaunti za nje kwa ushiriki wa shirikisho.",
+ "External documentation for Federated Cloud Sharing" : "Hati za nje za Ushirikiano wa Nextcloud Ulioshirikishwa",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti. Kwa mfano hii itatumika kukamilisha kiotomatiki akaunti za nje kwa kushiriki kwa shirikisho. Sio lazima kuongeza seva kama seva inayoaminika ili kuunda sehemu iliyoshirikishwa.",
+ "Each server must validate the other. This process may require a few cron cycles." : " Kila seva lazima ithibitishe nyingine. Mchakato huu unaweza kuhitaji mizunguko michache ya cron.",
+ "+ Add trusted server" : "+ ongeza seva inayoaminiwa",
+ "Trusted server" : "Seva inayoaminiwa",
+ "Add" : "Ongeza"
+},
+"nplurals=2; plural=(n != 1);");
diff --git a/apps/federation/l10n/sw.json b/apps/federation/l10n/sw.json
new file mode 100644
index 00000000000..6f9abc85cbc
--- /dev/null
+++ b/apps/federation/l10n/sw.json
@@ -0,0 +1,19 @@
+{ "translations": {
+ "Added to the list of trusted servers" : " Imeongezwa kwenye orodha ya seva zinazoaminika",
+ "No server found with ID: %s" : "Hakuna seva iliyopatikana na kitambulisho: %s",
+ "Could not remove server" : "Isingeweza kuondoa seva",
+ "Server is already in the list of trusted servers." : "Seva tayari iko kwenye orodha ya seva zinazoaminika.",
+ "No server to federate with found" : "Hakuna seva ya kushirikiana na, iliyopatikana",
+ "Could not add server" : "Isingeweza kuongeza seva",
+ "Trusted servers" : "Seva zinazoaminiwa",
+ "Federation" : "Shirikisho",
+ "Federation allows you to connect with other trusted servers to exchange the account directory." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti.",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti. Kwa mfano hii itatumika kukamilisha kiotomatiki akaunti za nje kwa ushiriki wa shirikisho.",
+ "External documentation for Federated Cloud Sharing" : "Hati za nje za Ushirikiano wa Nextcloud Ulioshirikishwa",
+ "Federation allows you to connect with other trusted servers to exchange the account directory. For example this will be used to auto-complete external accounts for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share." : "Shirikisho hukuruhusu kuunganishwa na seva zingine zinazoaminika ili kubadilishana saraka ya akaunti. Kwa mfano hii itatumika kukamilisha kiotomatiki akaunti za nje kwa kushiriki kwa shirikisho. Sio lazima kuongeza seva kama seva inayoaminika ili kuunda sehemu iliyoshirikishwa.",
+ "Each server must validate the other. This process may require a few cron cycles." : " Kila seva lazima ithibitishe nyingine. Mchakato huu unaweza kuhitaji mizunguko michache ya cron.",
+ "+ Add trusted server" : "+ ongeza seva inayoaminiwa",
+ "Trusted server" : "Seva inayoaminiwa",
+ "Add" : "Ongeza"
+},"pluralForm" :"nplurals=2; plural=(n != 1);"
+} \ No newline at end of file
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index fe3b360dd18..dc57db9fd62 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -99,12 +99,11 @@ class GetSharedSecret extends Job {
$result = $this->httpClient->get(
$url,
[
- 'query' =>
- [
- 'url' => $source,
- 'token' => $token,
- 'format' => 'json',
- ],
+ 'query' => [
+ 'url' => $source,
+ 'token' => $token,
+ 'format' => 'json',
+ ],
'timeout' => 3,
'connect_timeout' => 3,
'verify' => !$this->config->getSystemValue('sharing.federation.allowSelfSignedCertificates', false),
@@ -115,9 +114,9 @@ class GetSharedSecret extends Job {
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
- $this->logger->info($target . ' refused to exchange a shared secret with you.', ['app' => 'federation']);
+ $this->logger->info($target . ' refused to exchange a shared secret with you.');
} else {
- $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
+ $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
}
} catch (RequestException $e) {
$status = -1; // There is no status code if we could not connect
@@ -149,8 +148,7 @@ class GetSharedSecret extends Job {
);
} else {
$this->logger->error(
- 'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body,
- ['app' => 'federation']
+ 'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body
);
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
}
diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
index cc50ee75ca0..4d57d1f6aef 100644
--- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
@@ -126,16 +126,16 @@ class RequestSharedSecret extends Job {
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
- $this->logger->info($target . ' refused to ask for a shared secret.', ['app' => 'federation']);
+ $this->logger->info($target . ' refused to ask for a shared secret.');
} else {
- $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
+ $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
}
} catch (RequestException $e) {
$status = -1; // There is no status code if we could not connect
- $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']);
+ $this->logger->info('Could not connect to ' . $target);
} catch (\Throwable $e) {
$status = Http::STATUS_INTERNAL_SERVER_ERROR;
- $this->logger->error($e->getMessage(), ['app' => 'federation', 'exception' => $e]);
+ $this->logger->error($e->getMessage(), ['exception' => $e]);
}
// if we received a unexpected response we try again later
diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php
index 44725fa0dba..16b401be251 100644
--- a/apps/federation/lib/Controller/OCSAuthAPIController.php
+++ b/apps/federation/lib/Controller/OCSAuthAPIController.php
@@ -98,7 +98,7 @@ class OCSAuthAPIController extends OCSController {
public function requestSharedSecret(string $url, string $token): DataResponse {
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
- $this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']);
+ $this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret');
throw new OCSForbiddenException();
}
@@ -107,8 +107,7 @@ class OCSAuthAPIController extends OCSController {
$localToken = $this->dbHandler->getToken($url);
if (strcmp($localToken, $token) > 0) {
$this->logger->info(
- 'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
- ['app' => 'federation']
+ 'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.'
);
throw new OCSForbiddenException();
}
@@ -141,7 +140,7 @@ class OCSAuthAPIController extends OCSController {
public function getSharedSecret(string $url, string $token): DataResponse {
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
- $this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
+ $this->logger->error('remote server not trusted (' . $url . ') while getting shared secret');
throw new OCSForbiddenException();
}
@@ -149,8 +148,7 @@ class OCSAuthAPIController extends OCSController {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
$expectedToken = $this->dbHandler->getToken($url);
$this->logger->error(
- 'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret',
- ['app' => 'federation']
+ 'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret'
);
throw new OCSForbiddenException();
}
diff --git a/apps/federation/lib/Settings/Admin.php b/apps/federation/lib/Settings/Admin.php
index f9630c4b557..5cf5346bb85 100644
--- a/apps/federation/lib/Settings/Admin.php
+++ b/apps/federation/lib/Settings/Admin.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/federation/lib/SyncJob.php b/apps/federation/lib/SyncJob.php
index 21f8318f6f9..b802dfa9308 100644
--- a/apps/federation/lib/SyncJob.php
+++ b/apps/federation/lib/SyncJob.php
@@ -27,7 +27,6 @@ class SyncJob extends TimedJob {
$this->syncService->syncThemAll(function ($url, $ex): void {
if ($ex instanceof \Exception) {
$this->logger->error("Error while syncing $url.", [
- 'app' => 'fed-sync',
'exception' => $ex,
]);
}
diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php
index a62ddfa1275..3b849c80f17 100644
--- a/apps/federation/lib/TrustedServers.php
+++ b/apps/federation/lib/TrustedServers.php
@@ -169,7 +169,6 @@ class TrustedServers {
}
} catch (\Exception $e) {
$this->logger->error('No Nextcloud server.', [
- 'app' => 'federation',
'exception' => $e,
]);
return false;
diff --git a/apps/federation/templates/settings-admin.php b/apps/federation/templates/settings-admin.php
index 02110ebfdd3..857a8b23e37 100644
--- a/apps/federation/templates/settings-admin.php
+++ b/apps/federation/templates/settings-admin.php
@@ -37,8 +37,8 @@ $documentationLabel = $l->t('External documentation for Federated Cloud Sharing'
<span class="status success"></span>
<?php
} elseif (
- (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
- (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
+ (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING
+ || (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
) { ?>
<span class="status indeterminate"></span>
<?php } else {?>
diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
index 3da2e2e15e4..943bdf352de 100644
--- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -75,14 +76,9 @@ class GetSharedSecretTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestExecute
- *
- * @param bool $isTrustedServer
- * @param bool $retainBackgroundJob
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')]
public function testExecute(bool $isTrustedServer, bool $retainBackgroundJob): void {
- /** @var GetSharedSecret |\PHPUnit\Framework\MockObject\MockObject $getSharedSecret */
+ /** @var GetSharedSecret&MockObject $getSharedSecret */
$getSharedSecret = $this->getMockBuilder(GetSharedSecret::class)
->setConstructorArgs(
[
@@ -95,8 +91,10 @@ class GetSharedSecretTest extends TestCase {
$this->timeFactory,
$this->config,
]
- )->setMethods(['parentStart'])->getMock();
- $this->invokePrivate($getSharedSecret, 'argument', [['url' => 'url', 'token' => 'token']]);
+ )
+ ->onlyMethods(['parentStart'])
+ ->getMock();
+ self::invokePrivate($getSharedSecret, 'argument', [['url' => 'url', 'token' => 'token']]);
$this->trustedServers->expects($this->once())->method('isTrustedServer')
->with('url')->willReturn($isTrustedServer);
@@ -105,7 +103,7 @@ class GetSharedSecretTest extends TestCase {
} else {
$getSharedSecret->expects($this->never())->method('parentStart');
}
- $this->invokePrivate($getSharedSecret, 'retainJob', [$retainBackgroundJob]);
+ self::invokePrivate($getSharedSecret, 'retainJob', [$retainBackgroundJob]);
$this->jobList->expects($this->once())->method('remove');
$this->timeFactory->method('getTime')->willReturn(42);
@@ -128,7 +126,7 @@ class GetSharedSecretTest extends TestCase {
$getSharedSecret->start($this->jobList);
}
- public function dataTestExecute() {
+ public static function dataTestExecute(): array {
return [
[true, true],
[true, false],
@@ -136,12 +134,8 @@ class GetSharedSecretTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestRun
- *
- * @param int $statusCode
- */
- public function testRun($statusCode): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRun')]
+ public function testRun(int $statusCode): void {
$target = 'targetURL';
$source = 'sourceURL';
$token = 'token';
@@ -157,12 +151,11 @@ class GetSharedSecretTest extends TestCase {
->with(
$target . '/ocs/v2.php/apps/federation/api/v1/shared-secret',
[
- 'query' =>
- [
- 'url' => $source,
- 'token' => $token,
- 'format' => 'json',
- ],
+ 'query' => [
+ 'url' => $source,
+ 'token' => $token,
+ 'format' => 'json',
+ ],
'timeout' => 3,
'connect_timeout' => 3,
'verify' => true,
@@ -181,18 +174,18 @@ class GetSharedSecretTest extends TestCase {
$this->trustedServers->expects($this->never())->method('addSharedSecret');
}
- $this->invokePrivate($this->getSharedSecret, 'run', [$argument]);
+ self::invokePrivate($this->getSharedSecret, 'run', [$argument]);
if (
$statusCode !== Http::STATUS_OK
&& $statusCode !== Http::STATUS_FORBIDDEN
) {
- $this->assertTrue($this->invokePrivate($this->getSharedSecret, 'retainJob'));
+ $this->assertTrue(self::invokePrivate($this->getSharedSecret, 'retainJob'));
} else {
- $this->assertFalse($this->invokePrivate($this->getSharedSecret, 'retainJob'));
+ $this->assertFalse(self::invokePrivate($this->getSharedSecret, 'retainJob'));
}
}
- public function dataTestRun() {
+ public static function dataTestRun(): array {
return [
[Http::STATUS_OK],
[Http::STATUS_FORBIDDEN],
@@ -227,7 +220,7 @@ class GetSharedSecretTest extends TestCase {
TrustedServers::STATUS_FAILURE
);
- $this->invokePrivate($this->getSharedSecret, 'run', [$argument]);
+ self::invokePrivate($this->getSharedSecret, 'run', [$argument]);
}
public function testRunConnectionError(): void {
@@ -249,12 +242,11 @@ class GetSharedSecretTest extends TestCase {
->with(
$target . '/ocs/v2.php/apps/federation/api/v1/shared-secret',
[
- 'query' =>
- [
- 'url' => $source,
- 'token' => $token,
- 'format' => 'json',
- ],
+ 'query' => [
+ 'url' => $source,
+ 'token' => $token,
+ 'format' => 'json',
+ ],
'timeout' => 3,
'connect_timeout' => 3,
'verify' => true,
@@ -263,8 +255,8 @@ class GetSharedSecretTest extends TestCase {
$this->trustedServers->expects($this->never())->method('addSharedSecret');
- $this->invokePrivate($this->getSharedSecret, 'run', [$argument]);
+ self::invokePrivate($this->getSharedSecret, 'run', [$argument]);
- $this->assertTrue($this->invokePrivate($this->getSharedSecret, 'retainJob'));
+ $this->assertTrue(self::invokePrivate($this->getSharedSecret, 'retainJob'));
}
}
diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
index 68f8cc070c8..6ef579c7483 100644
--- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -24,50 +25,28 @@ use Psr\Log\LoggerInterface;
use Test\TestCase;
class RequestSharedSecretTest extends TestCase {
- /** @var MockObject|IClientService */
- private $httpClientService;
-
- /** @var MockObject|IClient */
- private $httpClient;
-
- /** @var MockObject|IJobList */
- private $jobList;
-
- /** @var MockObject|IURLGenerator */
- private $urlGenerator;
-
- /** @var MockObject|TrustedServers */
- private $trustedServers;
-
- /** @var MockObject|IResponse */
- private $response;
-
- /** @var MockObject|IDiscoveryService */
- private $discoveryService;
-
- /** @var MockObject|LoggerInterface */
- private $logger;
-
- /** @var MockObject|ITimeFactory */
- private $timeFactory;
-
- /** @var MockObject|IConfig */
- private $config;
-
- /** @var RequestSharedSecret */
- private $requestSharedSecret;
+ private IClientService&MockObject $httpClientService;
+ private IClient&MockObject $httpClient;
+ private IJobList&MockObject $jobList;
+ private IURLGenerator&MockObject $urlGenerator;
+ private TrustedServers&MockObject $trustedServers;
+ private IResponse&MockObject $response;
+ private IDiscoveryService&MockObject $discoveryService;
+ private LoggerInterface&MockObject $logger;
+ private ITimeFactory&MockObject $timeFactory;
+ private IConfig&MockObject $config;
+ private RequestSharedSecret $requestSharedSecret;
protected function setUp(): void {
parent::setUp();
$this->httpClientService = $this->createMock(IClientService::class);
- $this->httpClient = $this->getMockBuilder(IClient::class)->getMock();
- $this->jobList = $this->getMockBuilder(IJobList::class)->getMock();
- $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock();
- $this->trustedServers = $this->getMockBuilder(TrustedServers::class)
- ->disableOriginalConstructor()->getMock();
- $this->response = $this->getMockBuilder(IResponse::class)->getMock();
- $this->discoveryService = $this->getMockBuilder(IDiscoveryService::class)->getMock();
+ $this->httpClient = $this->createMock(IClient::class);
+ $this->jobList = $this->createMock(IJobList::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->trustedServers = $this->createMock(TrustedServers::class);
+ $this->response = $this->createMock(IResponse::class);
+ $this->discoveryService = $this->createMock(IDiscoveryService::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->config = $this->createMock(IConfig::class);
@@ -87,15 +66,10 @@ class RequestSharedSecretTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestStart
- *
- * @param bool $isTrustedServer
- * @param bool $retainBackgroundJob
- */
- public function testStart($isTrustedServer, $retainBackgroundJob): void {
- /** @var RequestSharedSecret |MockObject $requestSharedSecret */
- $requestSharedSecret = $this->getMockBuilder('OCA\Federation\BackgroundJob\RequestSharedSecret')
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestStart')]
+ public function testStart(bool $isTrustedServer, bool $retainBackgroundJob): void {
+ /** @var RequestSharedSecret&MockObject $requestSharedSecret */
+ $requestSharedSecret = $this->getMockBuilder(RequestSharedSecret::class)
->setConstructorArgs(
[
$this->httpClientService,
@@ -107,8 +81,10 @@ class RequestSharedSecretTest extends TestCase {
$this->timeFactory,
$this->config,
]
- )->setMethods(['parentStart'])->getMock();
- $this->invokePrivate($requestSharedSecret, 'argument', [['url' => 'url', 'token' => 'token']]);
+ )
+ ->onlyMethods(['parentStart'])
+ ->getMock();
+ self::invokePrivate($requestSharedSecret, 'argument', [['url' => 'url', 'token' => 'token']]);
$this->trustedServers->expects($this->once())->method('isTrustedServer')
->with('url')->willReturn($isTrustedServer);
@@ -117,7 +93,7 @@ class RequestSharedSecretTest extends TestCase {
} else {
$requestSharedSecret->expects($this->never())->method('parentStart');
}
- $this->invokePrivate($requestSharedSecret, 'retainJob', [$retainBackgroundJob]);
+ self::invokePrivate($requestSharedSecret, 'retainJob', [$retainBackgroundJob]);
$this->jobList->expects($this->once())->method('remove');
$this->timeFactory->method('getTime')->willReturn(42);
@@ -141,7 +117,7 @@ class RequestSharedSecretTest extends TestCase {
$requestSharedSecret->start($this->jobList);
}
- public function dataTestStart() {
+ public static function dataTestStart(): array {
return [
[true, true],
[true, false],
@@ -149,11 +125,7 @@ class RequestSharedSecretTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestRun
- *
- * @param int $statusCode
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRun')]
public function testRun(int $statusCode, int $attempt = 0): void {
$target = 'targetURL';
$source = 'sourceURL';
@@ -169,12 +141,11 @@ class RequestSharedSecretTest extends TestCase {
->with(
$target . '/ocs/v2.php/apps/federation/api/v1/request-shared-secret',
[
- 'body' =>
- [
- 'url' => $source,
- 'token' => $token,
- 'format' => 'json',
- ],
+ 'body' => [
+ 'url' => $source,
+ 'token' => $token,
+ 'format' => 'json',
+ ],
'timeout' => 3,
'connect_timeout' => 3,
'verify' => true,
@@ -184,18 +155,18 @@ class RequestSharedSecretTest extends TestCase {
$this->response->expects($this->once())->method('getStatusCode')
->willReturn($statusCode);
- $this->invokePrivate($this->requestSharedSecret, 'run', [$argument]);
+ self::invokePrivate($this->requestSharedSecret, 'run', [$argument]);
if (
$statusCode !== Http::STATUS_OK
&& ($statusCode !== Http::STATUS_FORBIDDEN || $attempt < 5)
) {
- $this->assertTrue($this->invokePrivate($this->requestSharedSecret, 'retainJob'));
+ $this->assertTrue(self::invokePrivate($this->requestSharedSecret, 'retainJob'));
} else {
- $this->assertFalse($this->invokePrivate($this->requestSharedSecret, 'retainJob'));
+ $this->assertFalse(self::invokePrivate($this->requestSharedSecret, 'retainJob'));
}
}
- public function dataTestRun() {
+ public static function dataTestRun(): array {
return [
[Http::STATUS_OK],
[Http::STATUS_FORBIDDEN, 5],
@@ -231,7 +202,7 @@ class RequestSharedSecretTest extends TestCase {
TrustedServers::STATUS_FAILURE
);
- $this->invokePrivate($this->requestSharedSecret, 'run', [$argument]);
+ self::invokePrivate($this->requestSharedSecret, 'run', [$argument]);
}
public function testRunConnectionError(): void {
@@ -255,19 +226,18 @@ class RequestSharedSecretTest extends TestCase {
->with(
$target . '/ocs/v2.php/apps/federation/api/v1/request-shared-secret',
[
- 'body' =>
- [
- 'url' => $source,
- 'token' => $token,
- 'format' => 'json',
- ],
+ 'body' => [
+ 'url' => $source,
+ 'token' => $token,
+ 'format' => 'json',
+ ],
'timeout' => 3,
'connect_timeout' => 3,
'verify' => true,
]
)->willThrowException($this->createMock(ConnectException::class));
- $this->invokePrivate($this->requestSharedSecret, 'run', [$argument]);
- $this->assertTrue($this->invokePrivate($this->requestSharedSecret, 'retainJob'));
+ self::invokePrivate($this->requestSharedSecret, 'run', [$argument]);
+ $this->assertTrue(self::invokePrivate($this->requestSharedSecret, 'retainJob'));
}
}
diff --git a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
index 9f2d41a1072..a054277c5cd 100644
--- a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
+++ b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -8,6 +9,7 @@
namespace OCA\Federation\Tests\Controller;
use OC\BackgroundJob\JobList;
+use OCA\Federation\BackgroundJob\GetSharedSecret;
use OCA\Federation\Controller\OCSAuthAPIController;
use OCA\Federation\DbHandler;
use OCA\Federation\TrustedServers;
@@ -16,34 +18,19 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ISecureRandom;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class OCSAuthAPIControllerTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject|IRequest */
- private $request;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|ISecureRandom */
- private $secureRandom;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|JobList */
- private $jobList;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|TrustedServers */
- private $trustedServers;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|DbHandler */
- private $dbHandler;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|LoggerInterface */
- private $logger;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|ITimeFactory */
- private $timeFactory;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|IThrottler */
- private $throttler;
-
+ private IRequest&MockObject $request;
+ private ISecureRandom&MockObject $secureRandom;
+ private JobList&MockObject $jobList;
+ private TrustedServers&MockObject $trustedServers;
+ private DbHandler&MockObject $dbHandler;
+ private LoggerInterface&MockObject $logger;
+ private ITimeFactory&MockObject $timeFactory;
+ private IThrottler&MockObject $throttler;
private OCSAuthAPIController $ocsAuthApi;
/** @var int simulated timestamp */
@@ -77,9 +64,7 @@ class OCSAuthAPIControllerTest extends TestCase {
->willReturn($this->currentTime);
}
- /**
- * @dataProvider dataTestRequestSharedSecret
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestRequestSharedSecret')]
public function testRequestSharedSecret(string $token, string $localToken, bool $isTrustedServer, bool $ok): void {
$url = 'url';
@@ -91,7 +76,7 @@ class OCSAuthAPIControllerTest extends TestCase {
if ($ok) {
$this->jobList->expects($this->once())->method('add')
- ->with('OCA\Federation\BackgroundJob\GetSharedSecret', ['url' => $url, 'token' => $token, 'created' => $this->currentTime]);
+ ->with(GetSharedSecret::class, ['url' => $url, 'token' => $token, 'created' => $this->currentTime]);
} else {
$this->jobList->expects($this->never())->method('add');
$this->jobList->expects($this->never())->method('remove');
@@ -111,7 +96,7 @@ class OCSAuthAPIControllerTest extends TestCase {
}
}
- public function dataTestRequestSharedSecret() {
+ public static function dataTestRequestSharedSecret(): array {
return [
['token2', 'token1', true, true],
['token1', 'token2', false, false],
@@ -119,15 +104,13 @@ class OCSAuthAPIControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestGetSharedSecret
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetSharedSecret')]
public function testGetSharedSecret(bool $isTrustedServer, bool $isValidToken, bool $ok): void {
$url = 'url';
$token = 'token';
- /** @var OCSAuthAPIController | \PHPUnit\Framework\MockObject\MockObject $ocsAuthApi */
- $ocsAuthApi = $this->getMockBuilder('OCA\Federation\Controller\OCSAuthAPIController')
+ /** @var OCSAuthAPIController&MockObject $ocsAuthApi */
+ $ocsAuthApi = $this->getMockBuilder(OCSAuthAPIController::class)
->setConstructorArgs(
[
'federation',
@@ -140,7 +123,9 @@ class OCSAuthAPIControllerTest extends TestCase {
$this->timeFactory,
$this->throttler
]
- )->setMethods(['isValidToken'])->getMock();
+ )
+ ->onlyMethods(['isValidToken'])
+ ->getMock();
$this->trustedServers
->expects($this->any())
@@ -171,7 +156,7 @@ class OCSAuthAPIControllerTest extends TestCase {
}
}
- public function dataTestGetSharedSecret() {
+ public static function dataTestGetSharedSecret(): array {
return [
[true, true, true],
[false, true, false],
diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php
index c3e83945e9a..b0a7a5e30c9 100644
--- a/apps/federation/tests/Controller/SettingsControllerTest.php
+++ b/apps/federation/tests/Controller/SettingsControllerTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -20,19 +22,18 @@ use Test\TestCase;
class SettingsControllerTest extends TestCase {
private SettingsController $controller;
- private MockObject&IRequest $request;
- private MockObject&IL10N $l10n;
- private MockObject&TrustedServers $trustedServers;
- private MockObject&LoggerInterface $logger;
+ private IRequest&MockObject $request;
+ private IL10N&MockObject $l10n;
+ private TrustedServers&MockObject $trustedServers;
+ private LoggerInterface&MockObject $logger;
protected function setUp(): void {
parent::setUp();
- $this->request = $this->getMockBuilder(IRequest::class)->getMock();
- $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
- $this->trustedServers = $this->getMockBuilder(TrustedServers::class)
- ->disableOriginalConstructor()->getMock();
- $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
+ $this->request = $this->createMock(IRequest::class);
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->trustedServers = $this->createMock(TrustedServers::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->controller = new SettingsController(
'SettingsControllerTest',
@@ -56,7 +57,7 @@ class SettingsControllerTest extends TestCase {
->willReturn(true);
$result = $this->controller->addServer('url');
- $this->assertTrue($result instanceof DataResponse);
+ $this->assertInstanceOf(DataResponse::class, $result);
$data = $result->getData();
$this->assertSame(200, $result->getStatus());
@@ -64,9 +65,7 @@ class SettingsControllerTest extends TestCase {
$this->assertArrayHasKey('id', $data);
}
- /**
- * @dataProvider checkServerFails
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('checkServerFails')]
public function testAddServerFail(bool $isTrustedServer, bool $isNextcloud): void {
$this->trustedServers
->expects($this->any())
@@ -110,13 +109,11 @@ class SettingsControllerTest extends TestCase {
->willReturn(true);
$this->assertNull(
- $this->invokePrivate($this->controller, 'checkServer', ['url'])
+ self::invokePrivate($this->controller, 'checkServer', ['url'])
);
}
- /**
- * @dataProvider checkServerFails
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('checkServerFails')]
public function testCheckServerFail(bool $isTrustedServer, bool $isNextcloud): void {
$this->trustedServers
->expects($this->any())
@@ -136,14 +133,11 @@ class SettingsControllerTest extends TestCase {
}
$this->assertTrue(
- $this->invokePrivate($this->controller, 'checkServer', ['url'])
+ self::invokePrivate($this->controller, 'checkServer', ['url'])
);
}
- /**
- * Data to simulate checkServer fails
- */
- public function checkServerFails(): array {
+ public static function checkServerFails(): array {
return [
[true, true],
[false, false]
diff --git a/apps/federation/tests/DAV/FedAuthTest.php b/apps/federation/tests/DAV/FedAuthTest.php
index d059fff0481..c95d3852b48 100644
--- a/apps/federation/tests/DAV/FedAuthTest.php
+++ b/apps/federation/tests/DAV/FedAuthTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -9,27 +10,22 @@ namespace OCA\Federation\Tests\DAV;
use OCA\Federation\DAV\FedAuth;
use OCA\Federation\DbHandler;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class FedAuthTest extends TestCase {
- /**
- * @dataProvider providesUser
- *
- * @param array $expected
- * @param string $user
- * @param string $password
- */
- public function testFedAuth($expected, $user, $password): void {
- /** @var DbHandler | \PHPUnit\Framework\MockObject\MockObject $db */
- $db = $this->getMockBuilder('OCA\Federation\DbHandler')->disableOriginalConstructor()->getMock();
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesUser')]
+ public function testFedAuth(bool $expected, string $user, string $password): void {
+ /** @var DbHandler&MockObject $db */
+ $db = $this->createMock(DbHandler::class);
$db->method('auth')->willReturn(true);
$auth = new FedAuth($db);
- $result = $this->invokePrivate($auth, 'validateUserPass', [$user, $password]);
+ $result = self::invokePrivate($auth, 'validateUserPass', [$user, $password]);
$this->assertEquals($expected, $result);
}
- public function providesUser() {
+ public static function providesUser(): array {
return [
[true, 'system', '123456']
];
diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php
index 1db9f7f2315..5452a48fc4a 100644
--- a/apps/federation/tests/DbHandlerTest.php
+++ b/apps/federation/tests/DbHandlerTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -12,30 +13,23 @@ use OCA\Federation\TrustedServers;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
/**
* @group DB
*/
class DbHandlerTest extends TestCase {
-
- /** @var DbHandler */
- private $dbHandler;
-
- /** @var IL10N | \PHPUnit\Framework\MockObject\MockObject */
- private $il10n;
-
- /** @var IDBConnection */
- private $connection;
-
- /** @var string */
- private $dbTable = 'trusted_servers';
+ private DbHandler $dbHandler;
+ private IL10N&MockObject $il10n;
+ private IDBConnection $connection;
+ private string $dbTable = 'trusted_servers';
protected function setUp(): void {
parent::setUp();
$this->connection = Server::get(IDBConnection::class);
- $this->il10n = $this->getMockBuilder(IL10N::class)->getMock();
+ $this->il10n = $this->createMock(IL10N::class);
$this->dbHandler = new DbHandler(
$this->connection,
@@ -44,26 +38,27 @@ class DbHandlerTest extends TestCase {
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $qResult = $query->execute();
+ $qResult = $query->executeQuery();
$result = $qResult->fetchAll();
$qResult->closeCursor();
$this->assertEmpty($result, 'we need to start with a empty trusted_servers table');
}
protected function tearDown(): void {
- parent::tearDown();
$query = $this->connection->getQueryBuilder()->delete($this->dbTable);
- $query->execute();
+ $query->executeStatement()
+ ;
+ parent::tearDown();
}
/**
- * @dataProvider dataTestAddServer
*
* @param string $url passed to the method
* @param string $expectedUrl the url we expect to be written to the db
* @param string $expectedHash the hash value we expect to be written to the db
*/
- public function testAddServer($url, $expectedUrl, $expectedHash): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestAddServer')]
+ public function testAddServer(string $url, string $expectedUrl, string $expectedHash): void {
$id = $this->dbHandler->addServer($url);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
@@ -71,14 +66,14 @@ class DbHandlerTest extends TestCase {
$qResult = $query->execute();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame($expectedUrl, $result[0]['url']);
$this->assertSame($id, (int)$result[0]['id']);
$this->assertSame($expectedHash, $result[0]['url_hash']);
$this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']);
}
- public function dataTestAddServer() {
+ public static function dataTestAddServer(): array {
return [
['http://owncloud.org', 'http://owncloud.org', sha1('owncloud.org')],
['https://owncloud.org', 'https://owncloud.org', sha1('owncloud.org')],
@@ -95,7 +90,7 @@ class DbHandlerTest extends TestCase {
$qResult = $query->execute();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(2, count($result));
+ $this->assertCount(2, $result);
$this->assertSame('server1', $result[0]['url']);
$this->assertSame('server2', $result[1]['url']);
$this->assertSame($id1, (int)$result[0]['id']);
@@ -107,7 +102,7 @@ class DbHandlerTest extends TestCase {
$qResult = $query->execute();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame('server1', $result[0]['url']);
$this->assertSame($id1, (int)$result[0]['id']);
}
@@ -133,21 +128,15 @@ class DbHandlerTest extends TestCase {
$this->assertSame($id2, (int)$result[1]['id']);
}
- /**
- * @dataProvider dataTestServerExists
- *
- * @param string $serverInTable
- * @param string $checkForServer
- * @param bool $expected
- */
- public function testServerExists($serverInTable, $checkForServer, $expected): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestServerExists')]
+ public function testServerExists(string $serverInTable, string $checkForServer, bool $expected): void {
$this->dbHandler->addServer($serverInTable);
$this->assertSame($expected,
$this->dbHandler->serverExists($checkForServer)
);
}
- public function dataTestServerExists() {
+ public static function dataTestServerExists(): array {
return [
['server1', 'server1', true],
['server1', 'http://server1', true],
@@ -159,18 +148,18 @@ class DbHandlerTest extends TestCase {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $qResult = $query->execute();
+ $qResult = $query->executeQuery();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame(null, $result[0]['token']);
$this->dbHandler->addToken('http://server1', 'token');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $qResult = $query->execute();
+ $qResult = $query->executeQuery();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame('token', $result[0]['token']);
}
@@ -189,7 +178,7 @@ class DbHandlerTest extends TestCase {
$qResult = $query->execute();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame(null, $result[0]['shared_secret']);
$this->dbHandler->addSharedSecret('http://server1', 'secret');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
@@ -197,7 +186,7 @@ class DbHandlerTest extends TestCase {
$qResult = $query->execute();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame('secret', $result[0]['shared_secret']);
}
@@ -213,18 +202,18 @@ class DbHandlerTest extends TestCase {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $qResult = $query->execute();
+ $qResult = $query->executeQuery();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']);
$this->dbHandler->setServerStatus('http://server1', TrustedServers::STATUS_OK);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $qResult = $query->execute();
+ $qResult = $query->executeQuery();
$result = $qResult->fetchAll();
$qResult->closeCursor();
- $this->assertSame(1, count($result));
+ $this->assertCount(1, $result);
$this->assertSame(TrustedServers::STATUS_OK, (int)$result[0]['status']);
}
@@ -243,19 +232,15 @@ class DbHandlerTest extends TestCase {
/**
* hash should always be computed with the normalized URL
- *
- * @dataProvider dataTestHash
- *
- * @param string $url
- * @param string $expected
*/
- public function testHash($url, $expected): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHash')]
+ public function testHash(string $url, string $expected): void {
$this->assertSame($expected,
$this->invokePrivate($this->dbHandler, 'hash', [$url])
);
}
- public function dataTestHash() {
+ public static function dataTestHash(): array {
return [
['server1', sha1('server1')],
['http://server1', sha1('server1')],
@@ -264,19 +249,14 @@ class DbHandlerTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestNormalizeUrl
- *
- * @param string $url
- * @param string $expected
- */
- public function testNormalizeUrl($url, $expected): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestNormalizeUrl')]
+ public function testNormalizeUrl(string $url, string $expected): void {
$this->assertSame($expected,
$this->invokePrivate($this->dbHandler, 'normalizeUrl', [$url])
);
}
- public function dataTestNormalizeUrl() {
+ public static function dataTestNormalizeUrl(): array {
return [
['owncloud.org', 'owncloud.org'],
['http://owncloud.org', 'owncloud.org'],
@@ -286,10 +266,8 @@ class DbHandlerTest extends TestCase {
];
}
- /**
- * @dataProvider providesAuth
- */
- public function testAuth($expectedResult, $user, $password): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesAuth')]
+ public function testAuth(bool $expectedResult, string $user, string $password): void {
if ($expectedResult) {
$this->dbHandler->addServer('url1');
$this->dbHandler->addSharedSecret('url1', $password);
@@ -298,7 +276,7 @@ class DbHandlerTest extends TestCase {
$this->assertEquals($expectedResult, $result);
}
- public function providesAuth() {
+ public static function providesAuth(): array {
return [
[false, 'foo', ''],
[true, 'system', '123456789'],
diff --git a/apps/federation/tests/Settings/AdminTest.php b/apps/federation/tests/Settings/AdminTest.php
index 3d58fae2d7b..b879547a8cd 100644
--- a/apps/federation/tests/Settings/AdminTest.php
+++ b/apps/federation/tests/Settings/AdminTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -9,17 +11,16 @@ use OCA\Federation\Settings\Admin;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AdminTest extends TestCase {
- /** @var Admin */
- private $admin;
- /** @var TrustedServers */
- private $trustedServers;
+ private TrustedServers&MockObject $trustedServers;
+ private Admin $admin;
protected function setUp(): void {
parent::setUp();
- $this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
+ $this->trustedServers = $this->createMock(TrustedServers::class);
$this->admin = new Admin(
$this->trustedServers,
$this->createMock(IL10N::class)
diff --git a/apps/federation/tests/SyncFederationAddressbooksTest.php b/apps/federation/tests/SyncFederationAddressbooksTest.php
index 39274a11ade..8b075204859 100644
--- a/apps/federation/tests/SyncFederationAddressbooksTest.php
+++ b/apps/federation/tests/SyncFederationAddressbooksTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -16,44 +17,33 @@ use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class SyncFederationAddressbooksTest extends \Test\TestCase {
-
- /** @var array */
- private $callBacks = [];
-
- /** @var MockObject | DiscoveryService */
- private $discoveryService;
-
- /** @var MockObject|LoggerInterface */
- private $logger;
+ private array $callBacks = [];
+ private DiscoveryService&MockObject $discoveryService;
+ private LoggerInterface&MockObject $logger;
protected function setUp(): void {
parent::setUp();
- $this->discoveryService = $this->getMockBuilder(DiscoveryService::class)
- ->disableOriginalConstructor()->getMock();
+ $this->discoveryService = $this->createMock(DiscoveryService::class);
$this->discoveryService->expects($this->any())->method('discover')->willReturn([]);
$this->logger = $this->createMock(LoggerInterface::class);
}
public function testSync(): void {
- /** @var DbHandler | MockObject $dbHandler */
- $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')
- ->disableOriginalConstructor()
- ->getMock();
+ /** @var DbHandler&MockObject $dbHandler */
+ $dbHandler = $this->createMock(DbHandler::class);
$dbHandler->method('getAllServer')
->willReturn([
[
- 'url' => 'https://cloud.drop.box',
+ 'url' => 'https://cloud.example.org',
'url_hash' => 'sha1',
- 'shared_secret' => 'iloveowncloud',
+ 'shared_secret' => 'ilovenextcloud',
'sync_token' => '0'
]
]);
- $dbHandler->expects($this->once())->method('setServerStatus')->
- with('https://cloud.drop.box', 1, '1');
- $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
- ->disableOriginalConstructor()
- ->getMock();
+ $dbHandler->expects($this->once())->method('setServerStatus')
+ ->with('https://cloud.example.org', 1, '1');
+ $syncService = $this->createMock(SyncService::class);
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willReturn('1');
@@ -62,26 +52,22 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
});
- $this->assertEquals('1', count($this->callBacks));
+ $this->assertCount(1, $this->callBacks);
}
public function testException(): void {
- /** @var DbHandler | MockObject $dbHandler */
- $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')->
- disableOriginalConstructor()->
- getMock();
- $dbHandler->method('getAllServer')->
- willReturn([
- [
- 'url' => 'https://cloud.drop.box',
- 'url_hash' => 'sha1',
- 'shared_secret' => 'iloveowncloud',
- 'sync_token' => '0'
- ]
- ]);
- $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
- ->disableOriginalConstructor()
- ->getMock();
+ /** @var DbHandler&MockObject $dbHandler */
+ $dbHandler = $this->createMock(DbHandler::class);
+ $dbHandler->method('getAllServer')
+ ->willReturn([
+ [
+ 'url' => 'https://cloud.example.org',
+ 'url_hash' => 'sha1',
+ 'shared_secret' => 'ilovenextcloud',
+ 'sync_token' => '0'
+ ]
+ ]);
+ $syncService = $this->createMock(SyncService::class);
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willThrowException(new \Exception('something did not work out'));
@@ -90,29 +76,25 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
});
- $this->assertEquals(2, count($this->callBacks));
+ $this->assertCount(2, $this->callBacks);
}
public function testSuccessfulSyncWithoutChangesAfterFailure(): void {
- /** @var DbHandler | MockObject $dbHandler */
- $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')
- ->disableOriginalConstructor()
- ->getMock();
+ /** @var DbHandler&MockObject $dbHandler */
+ $dbHandler = $this->createMock(DbHandler::class);
$dbHandler->method('getAllServer')
->willReturn([
[
- 'url' => 'https://cloud.drop.box',
+ 'url' => 'https://cloud.example.org',
'url_hash' => 'sha1',
'shared_secret' => 'ilovenextcloud',
'sync_token' => '0'
]
]);
$dbHandler->method('getServerStatus')->willReturn(TrustedServers::STATUS_FAILURE);
- $dbHandler->expects($this->once())->method('setServerStatus')->
- with('https://cloud.drop.box', 1);
- $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService')
- ->disableOriginalConstructor()
- ->getMock();
+ $dbHandler->expects($this->once())->method('setServerStatus')
+ ->with('https://cloud.example.org', 1);
+ $syncService = $this->createMock(SyncService::class);
$syncService->expects($this->once())->method('syncRemoteAddressBook')
->willReturn('0');
@@ -121,6 +103,6 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
$s->syncThemAll(function ($url, $ex): void {
$this->callBacks[] = [$url, $ex];
});
- $this->assertEquals('1', count($this->callBacks));
+ $this->assertCount(1, $this->callBacks);
}
}
diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php
index c3f0368858b..c8477f637cb 100644
--- a/apps/federation/tests/TrustedServersTest.php
+++ b/apps/federation/tests/TrustedServersTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -7,6 +8,7 @@
*/
namespace OCA\Federation\Tests;
+use OCA\Federation\BackgroundJob\RequestSharedSecret;
use OCA\Federation\DbHandler;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -19,57 +21,35 @@ use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
use OCP\Security\ISecureRandom;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class TrustedServersTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject | TrustedServers */
- private $trustedServers;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | DbHandler */
- private $dbHandler;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IClientService */
- private $httpClientService;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IClient */
- private $httpClient;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IResponse */
- private $response;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | LoggerInterface */
- private $logger;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IJobList */
- private $jobList;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | ISecureRandom */
- private $secureRandom;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IConfig */
- private $config;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject | IEventDispatcher */
- private $dispatcher;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|ITimeFactory */
- private $timeFactory;
+ private TrustedServers $trustedServers;
+ private DbHandler&MockObject $dbHandler;
+ private IClientService&MockObject $httpClientService;
+ private IClient&MockObject $httpClient;
+ private IResponse&MockObject $response;
+ private LoggerInterface&MockObject $logger;
+ private IJobList&MockObject $jobList;
+ private ISecureRandom&MockObject $secureRandom;
+ private IConfig&MockObject $config;
+ private IEventDispatcher&MockObject $dispatcher;
+ private ITimeFactory&MockObject $timeFactory;
protected function setUp(): void {
parent::setUp();
- $this->dbHandler = $this->getMockBuilder(DbHandler::class)
- ->disableOriginalConstructor()->getMock();
- $this->dispatcher = $this->getMockBuilder(IEventDispatcher::class)
- ->disableOriginalConstructor()->getMock();
- $this->httpClientService = $this->getMockBuilder(IClientService::class)->getMock();
- $this->httpClient = $this->getMockBuilder(IClient::class)->getMock();
- $this->response = $this->getMockBuilder(IResponse::class)->getMock();
- $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
- $this->jobList = $this->getMockBuilder(IJobList::class)->getMock();
- $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock();
- $this->config = $this->getMockBuilder(IConfig::class)->getMock();
+ $this->dbHandler = $this->createMock(DbHandler::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->httpClientService = $this->createMock(IClientService::class);
+ $this->httpClient = $this->createMock(IClient::class);
+ $this->response = $this->createMock(IResponse::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
+ $this->jobList = $this->createMock(IJobList::class);
+ $this->secureRandom = $this->createMock(ISecureRandom::class);
+ $this->config = $this->createMock(IConfig::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->trustedServers = new TrustedServers(
@@ -85,8 +65,8 @@ class TrustedServersTest extends TestCase {
}
public function testAddServer(): void {
- /** @var \PHPUnit\Framework\MockObject\MockObject|TrustedServers $trustedServers */
- $trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers')
+ /** @var TrustedServers&MockObject $trustedServers */
+ $trustedServers = $this->getMockBuilder(TrustedServers::class)
->setConstructorArgs(
[
$this->dbHandler,
@@ -99,7 +79,7 @@ class TrustedServersTest extends TestCase {
$this->timeFactory
]
)
- ->setMethods(['normalizeUrl', 'updateProtocol'])
+ ->onlyMethods(['updateProtocol'])
->getMock();
$trustedServers->expects($this->once())->method('updateProtocol')
->with('url')->willReturn('https://url');
@@ -112,12 +92,12 @@ class TrustedServersTest extends TestCase {
->willReturn('token');
$this->dbHandler->expects($this->once())->method('addToken')->with('https://url', 'token');
$this->jobList->expects($this->once())->method('add')
- ->with('OCA\Federation\BackgroundJob\RequestSharedSecret',
+ ->with(RequestSharedSecret::class,
['url' => 'https://url', 'token' => 'token', 'created' => 1234567]);
$this->assertSame(
- $trustedServers->addServer('url'),
- 1
+ 1,
+ $trustedServers->addServer('url')
);
}
@@ -190,14 +170,12 @@ class TrustedServersTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestIsNextcloudServer
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsNextcloudServer')]
public function testIsNextcloudServer(int $statusCode, bool $isValidNextcloudVersion, bool $expected): void {
$server = 'server1';
- /** @var \PHPUnit\Framework\MockObject\MockObject | TrustedServers $trustedServers */
- $trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers')
+ /** @var TrustedServers&MockObject $trustedServers */
+ $trustedServers = $this->getMockBuilder(TrustedServers::class)
->setConstructorArgs(
[
$this->dbHandler,
@@ -210,7 +188,7 @@ class TrustedServersTest extends TestCase {
$this->timeFactory
]
)
- ->setMethods(['checkNextcloudVersion'])
+ ->onlyMethods(['checkNextcloudVersion'])
->getMock();
$this->httpClientService->expects($this->once())->method('newClient')
@@ -236,7 +214,7 @@ class TrustedServersTest extends TestCase {
);
}
- public function dataTestIsNextcloudServer(): array {
+ public static function dataTestIsNextcloudServer(): array {
return [
[200, true, true],
[200, false, false],
@@ -244,63 +222,55 @@ class TrustedServersTest extends TestCase {
];
}
- /**
- * @expectedExceptionMessage simulated exception
- */
public function testIsNextcloudServerFail(): void {
$server = 'server1';
- $this->httpClientService->expects($this->once())->method('newClient')
+ $this->httpClientService->expects($this->once())
+ ->method('newClient')
->willReturn($this->httpClient);
- $this->httpClient->expects($this->once())->method('get')->with($server . '/status.php')
- ->willReturnCallback(function (): void {
- throw new \Exception('simulated exception');
- });
+ $this->httpClient->expects($this->once())
+ ->method('get')
+ ->with($server . '/status.php')
+ ->willThrowException(new \Exception('simulated exception'));
$this->assertFalse($this->trustedServers->isNextcloudServer($server));
}
- /**
- * @dataProvider dataTestCheckNextcloudVersion
- */
- public function testCheckNextcloudVersion($status): void {
- $this->assertTrue($this->invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status]));
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCheckNextcloudVersion')]
+ public function testCheckNextcloudVersion(string $status): void {
+ $this->assertTrue(self::invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status]));
}
- public function dataTestCheckNextcloudVersion(): array {
+ public static function dataTestCheckNextcloudVersion(): array {
return [
['{"version":"9.0.0"}'],
['{"version":"9.1.0"}']
];
}
- /**
- * @dataProvider dataTestCheckNextcloudVersionTooLow
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestCheckNextcloudVersionTooLow')]
public function testCheckNextcloudVersionTooLow(string $status): void {
$this->expectException(HintException::class);
$this->expectExceptionMessage('Remote server version is too low. 9.0 is required.');
- $this->invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status]);
+ self::invokePrivate($this->trustedServers, 'checkNextcloudVersion', [$status]);
}
- public function dataTestCheckNextcloudVersionTooLow(): array {
+ public static function dataTestCheckNextcloudVersionTooLow(): array {
return [
['{"version":"8.2.3"}'],
];
}
- /**
- * @dataProvider dataTestUpdateProtocol
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdateProtocol')]
public function testUpdateProtocol(string $url, string $expected): void {
$this->assertSame($expected,
- $this->invokePrivate($this->trustedServers, 'updateProtocol', [$url])
+ self::invokePrivate($this->trustedServers, 'updateProtocol', [$url])
);
}
- public function dataTestUpdateProtocol(): array {
+ public static function dataTestUpdateProtocol(): array {
return [
['http://owncloud.org', 'http://owncloud.org'],
['https://owncloud.org', 'https://owncloud.org'],