\n"
+"Language-Team: French \n"
"Language: fr\n"
-"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Plural-Forms: nplurals=2; plural=n > 1;\n"
+"X-Generator: Weblate 4.0.4\n"
+"Content-Transfer-Encoding: 8bit\n"
msgid "can't be blank"
msgstr "ne peut être vide"
@@ -35,10 +43,10 @@ msgid "does not match confirmation"
msgstr "ne correspondent pas"
msgid "is still associated with this entry"
-msgstr ""
+msgstr "est toujours associé à cette entrée"
msgid "are still associated with this entry"
-msgstr ""
+msgstr "sont toujours associés à cette entrée"
msgid "should be %{count} character(s)"
msgid_plural "should be %{count} character(s)"
@@ -85,375 +93,375 @@ msgstr "doit être supérieur ou égal à %{number}"
msgid "must be equal to %{number}"
msgstr "doit égal à %{number}"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:381
+#, elixir-format
msgid "Account not found"
msgstr "Compte non trouvé"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:153
+#, elixir-format
msgid "Already voted"
msgstr "A déjà voté"
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:263
+#, elixir-format
msgid "Bad request"
msgstr "Requête Invalide"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:254
+#, elixir-format
msgid "Can't delete object"
msgstr "Ne peut supprimer cet objet"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:569
+#, elixir-format
msgid "Can't delete this post"
msgstr "Ne peut supprimer ce message"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1731
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1737
+#, elixir-format
msgid "Can't display this activity"
msgstr "Ne peut afficher cette activitée"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:195
+#, elixir-format
msgid "Can't find user"
msgstr "Compte non trouvé"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1148
+#, elixir-format
msgid "Can't get favorites"
msgstr "Favoris non trouvables"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:263
+#, elixir-format
msgid "Can't like object"
msgstr "Ne peut aimer cet objet"
-#, elixir-format
#: lib/pleroma/web/common_api/utils.ex:518
+#, elixir-format
msgid "Cannot post an empty status without attachments"
msgstr "Ne peut envoyer un status vide sans attachements"
-#, elixir-format
#: lib/pleroma/web/common_api/utils.ex:461
+#, elixir-format
msgid "Comment must be up to %{max_size} characters"
msgstr "Le commentaire ne doit faire plus de %{max_size} charactères"
-#, elixir-format
#: lib/pleroma/web/admin_api/config.ex:63
+#, elixir-format
msgid "Config with params %{params} not found"
msgstr "Configuration avec les paramètres %{params} non trouvée"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:78
+#, elixir-format
msgid "Could not delete"
msgstr "Échec de la suppression"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:110
+#, elixir-format
msgid "Could not favorite"
msgstr "Échec de mise en favoris"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:310
+#, elixir-format
msgid "Could not pin"
msgstr "Échec de l'épinglage"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:89
+#, elixir-format
msgid "Could not repeat"
msgstr "Échec de création la répétition"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:120
+#, elixir-format
msgid "Could not unfavorite"
msgstr "Échec de suppression des favoris"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:327
+#, elixir-format
msgid "Could not unpin"
msgstr "Échec du dépinglage"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:99
+#, elixir-format
msgid "Could not unrepeat"
msgstr "Échec de suppression de la répétition"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:392
+#, elixir-format
msgid "Could not update state"
msgstr "Échec de la mise à jour du status"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1271
+#, elixir-format
msgid "Error."
msgstr "Erreur."
-#, elixir-format
#: lib/pleroma/captcha/kocaptcha.ex:36
+#, elixir-format
msgid "Invalid CAPTCHA"
msgstr "CAPTCHA invalide"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1700
#: lib/pleroma/web/oauth/oauth_controller.ex:465
+#, elixir-format
msgid "Invalid credentials"
msgstr "Paramètres d'authentification invalides"
-#, elixir-format
#: lib/pleroma/plugs/ensure_authenticated_plug.ex:20
+#, elixir-format
msgid "Invalid credentials."
msgstr "Paramètres d'authentification invalides."
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:154
+#, elixir-format
msgid "Invalid indices"
msgstr "Indices invalides"
-#, elixir-format
#: lib/pleroma/web/admin_api/admin_api_controller.ex:411
+#, elixir-format
msgid "Invalid parameters"
msgstr "Paramètres invalides"
-#, elixir-format
#: lib/pleroma/web/common_api/utils.ex:377
+#, elixir-format
msgid "Invalid password."
msgstr "Mot de passe invalide."
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:163
+#, elixir-format
msgid "Invalid request"
msgstr "Requête invalide"
-#, elixir-format
#: lib/pleroma/captcha/kocaptcha.ex:16
+#, elixir-format
msgid "Kocaptcha service unavailable"
msgstr "Service Kocaptcha non disponible"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1696
+#, elixir-format
msgid "Missing parameters"
msgstr "Paramètres manquants"
-#, elixir-format
#: lib/pleroma/web/common_api/utils.ex:496
+#, elixir-format
msgid "No such conversation"
msgstr "Conversation inconnue"
-#, elixir-format
#: lib/pleroma/web/admin_api/admin_api_controller.ex:163
#: lib/pleroma/web/admin_api/admin_api_controller.ex:206
+#, elixir-format
msgid "No such permission_group"
msgstr "Groupe de permission inconnu"
-#, elixir-format
#: lib/pleroma/plugs/uploaded_media.ex:69
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:311
#: lib/pleroma/web/admin_api/admin_api_controller.ex:399
#: lib/pleroma/web/mastodon_api/subscription_controller.ex:63
#: lib/pleroma/web/ostatus/ostatus_controller.ex:248
+#, elixir-format
msgid "Not found"
msgstr "Non Trouvé"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:152
+#, elixir-format
msgid "Poll's author can't vote"
msgstr "L'auteur·rice d'un sondage ne peut voter"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:443
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:444
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:473
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:476
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1180
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1564
+#, elixir-format
msgid "Record not found"
msgstr "Enregistrement non trouvé"
-#, elixir-format
#: lib/pleroma/web/admin_api/admin_api_controller.ex:417
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1570
#: lib/pleroma/web/mastodon_api/subscription_controller.ex:69
#: lib/pleroma/web/ostatus/ostatus_controller.ex:252
+#, elixir-format
msgid "Something went wrong"
msgstr "Erreur inconnue"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:253
+#, elixir-format
msgid "The message visibility must be direct"
msgstr "La visibilitée du message doit être « direct »"
-#, elixir-format
#: lib/pleroma/web/common_api/utils.ex:521
+#, elixir-format
msgid "The status is over the character limit"
msgstr "Le status est au-delà de la limite de charactères"
-#, elixir-format
#: lib/pleroma/plugs/ensure_public_or_authenticated_plug.ex:27
+#, elixir-format
msgid "This resource requires authentication."
msgstr "Cette resource nécessite une authentification."
-#, elixir-format
#: lib/pleroma/plugs/rate_limiter.ex:89
+#, elixir-format
msgid "Throttled"
msgstr "Limité"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:155
+#, elixir-format
msgid "Too many choices"
msgstr "Trop de choix"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:268
+#, elixir-format
msgid "Unhandled activity type"
msgstr "Type d'activitée non-gérée"
-#, elixir-format
#: lib/pleroma/plugs/user_is_admin_plug.ex:20
+#, elixir-format
msgid "User is not admin."
msgstr "Le compte n'est pas admin."
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:380
+#, elixir-format
msgid "Valid `account_id` required"
msgstr "Un `account_id` valide est requis"
-#, elixir-format
#: lib/pleroma/web/admin_api/admin_api_controller.ex:185
+#, elixir-format
msgid "You can't revoke your own admin status."
msgstr "Vous ne pouvez révoquer votre propre status d'admin."
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:216
+#, elixir-format
msgid "Your account is currently disabled"
msgstr "Votre compte est actuellement désactivé"
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:158
#: lib/pleroma/web/oauth/oauth_controller.ex:213
+#, elixir-format
msgid "Your login is missing a confirmed e-mail address"
msgstr "Une confirmation de l'addresse de couriel est requise pour l'authentification"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:221
+#, elixir-format
msgid "can't read inbox of %{nickname} as %{as_nickname}"
msgstr "Ne peut lire la boite de réception de %{nickname} en tant que %{as_nickname}"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:297
+#, elixir-format
msgid "can't update outbox of %{nickname} as %{as_nickname}"
msgstr "Ne peut poster dans la boite d'émission de %{nickname} en tant que %{as_nickname}"
-#, elixir-format
#: lib/pleroma/web/common_api/common_api.ex:335
+#, elixir-format
msgid "conversation is already muted"
msgstr "la conversation est déjà baillonée"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:192
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:317
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1196
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:1247
+#, elixir-format
msgid "error"
msgstr "erreur"
-#, elixir-format
#: lib/pleroma/web/mastodon_api/mastodon_api_controller.ex:789
+#, elixir-format
msgid "mascots can only be images"
msgstr "les mascottes ne peuvent être que des images"
-#, elixir-format
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:34
+#, elixir-format
msgid "not found"
msgstr "non trouvé"
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:298
+#, elixir-format
msgid "Bad OAuth request."
msgstr "Requête OAuth invalide."
-#, elixir-format
#: lib/pleroma/captcha/captcha.ex:92
+#, elixir-format
msgid "CAPTCHA already used"
msgstr "CAPTCHA déjà utilisé"
-#, elixir-format
#: lib/pleroma/captcha/captcha.ex:89
+#, elixir-format
msgid "CAPTCHA expired"
msgstr "CAPTCHA expiré"
-#, elixir-format
#: lib/pleroma/plugs/uploaded_media.ex:50
+#, elixir-format
msgid "Failed"
msgstr "Échec"
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:314
-msgid "Failed to authenticate: %{message}."
-msgstr "Échec de l'authentification: %{message}"
-
#, elixir-format
+msgid "Failed to authenticate: %{message}."
+msgstr "Échec de l'authentification : %{message}."
+
#: lib/pleroma/web/oauth/oauth_controller.ex:345
+#, elixir-format
msgid "Failed to set up user account."
msgstr "Échec de création de votre compte."
-#, elixir-format
#: lib/pleroma/plugs/oauth_scopes_plug.ex:37
-msgid "Insufficient permissions: %{permissions}."
-msgstr "Permissions insuffisantes: %{permissions}."
-
#, elixir-format
+msgid "Insufficient permissions: %{permissions}."
+msgstr "Permissions insuffisantes : %{permissions}."
+
#: lib/pleroma/plugs/uploaded_media.ex:89
+#, elixir-format
msgid "Internal Error"
msgstr "Erreur interne"
-#, elixir-format
#: lib/pleroma/web/oauth/fallback_controller.ex:22
#: lib/pleroma/web/oauth/fallback_controller.ex:29
+#, elixir-format
msgid "Invalid Username/Password"
msgstr "Nom d'utilisateur/mot de passe invalide"
-#, elixir-format
#: lib/pleroma/captcha/captcha.ex:107
+#, elixir-format
msgid "Invalid answer data"
msgstr "Réponse invalide"
-#, elixir-format
#: lib/pleroma/web/nodeinfo/nodeinfo_controller.ex:204
+#, elixir-format
msgid "Nodeinfo schema version not handled"
msgstr "Version du schéma nodeinfo non géré"
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:145
-msgid "This action is outside the authorized scopes"
-msgstr "Cette action est en dehors des authorisations" # "scopes" ?
-
#, elixir-format
+msgid "This action is outside the authorized scopes"
+msgstr "Cette action est en dehors des authorisations" # "scopes"
+
#: lib/pleroma/web/oauth/fallback_controller.ex:14
+#, elixir-format
msgid "Unknown error, please check the details and try again."
msgstr "Erreur inconnue, veuillez vérifier les détails et réessayer."
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:93
#: lib/pleroma/web/oauth/oauth_controller.ex:131
+#, elixir-format
msgid "Unlisted redirect_uri."
msgstr "redirect_uri non listé."
-#, elixir-format
#: lib/pleroma/web/oauth/oauth_controller.ex:294
+#, elixir-format
msgid "Unsupported OAuth provider: %{provider}."
msgstr "Fournisseur OAuth non supporté : %{provider}."
-#, elixir-format
#: lib/pleroma/uploaders/uploader.ex:71
-msgid "Uploader callback timeout"
-msgstr ""
-## msgstr "Attente écoulée"
-
#, elixir-format
+msgid "Uploader callback timeout"
+msgstr "Temps d'attente du téléverseur écoulé"
+
+## msgstr "Attente écoulée"
#: lib/pleroma/web/uploader_controller.ex:11
#: lib/pleroma/web/uploader_controller.ex:23
+#, elixir-format
msgid "bad request"
msgstr "requête invalide"
diff --git a/priv/repo/migrations/20200415181818_update_markers.exs b/priv/repo/migrations/20200415181818_update_markers.exs
index 976363565..bb9d8e860 100644
--- a/priv/repo/migrations/20200415181818_update_markers.exs
+++ b/priv/repo/migrations/20200415181818_update_markers.exs
@@ -32,9 +32,13 @@ defp update_markers do
|> Map.put_new(:updated_at, now)
end)
- Repo.insert_all("markers", markers_attrs,
- on_conflict: {:replace, [:last_read_id]},
- conflict_target: [:user_id, :timeline]
- )
+ markers_attrs
+ |> Enum.chunk_every(1000)
+ |> Enum.each(fn markers_attrs_chunked ->
+ Repo.insert_all("markers", markers_attrs_chunked,
+ on_conflict: {:replace, [:last_read_id]},
+ conflict_target: [:user_id, :timeline]
+ )
+ end)
end
end
diff --git a/priv/repo/migrations/20200428221338_insert_skeletons_for_deleted_users.exs b/priv/repo/migrations/20200428221338_insert_skeletons_for_deleted_users.exs
index 11d9a70ba..2adc38186 100644
--- a/priv/repo/migrations/20200428221338_insert_skeletons_for_deleted_users.exs
+++ b/priv/repo/migrations/20200428221338_insert_skeletons_for_deleted_users.exs
@@ -30,7 +30,7 @@ def change do
Repo,
"select distinct unnest(nonexistent_locals.recipients) from activities, lateral (select array_agg(recipient) as recipients from unnest(activities.recipients) as recipient where recipient similar to '#{
instance_uri
- }/users/[A-Za-z0-9]*' and not(recipient in (select ap_id from users where local = true))) nonexistent_locals;",
+ }/users/[A-Za-z0-9]*' and not(recipient in (select ap_id from users))) nonexistent_locals;",
[],
timeout: :infinity
)
diff --git a/priv/static/index.html b/priv/static/index.html
index 4fac5c100..b37cbaa67 100644
--- a/priv/static/index.html
+++ b/priv/static/index.html
@@ -1 +1 @@
-Pleroma
\ No newline at end of file
+Pleroma
\ No newline at end of file
diff --git a/priv/static/static/font/fontello.1588419330867.woff b/priv/static/static/font/fontello.1588419330867.woff
deleted file mode 100644
index 2bf4cbc16..000000000
Binary files a/priv/static/static/font/fontello.1588419330867.woff and /dev/null differ
diff --git a/priv/static/static/font/fontello.1588419330867.woff2 b/priv/static/static/font/fontello.1588419330867.woff2
deleted file mode 100644
index a31bf3f29..000000000
Binary files a/priv/static/static/font/fontello.1588419330867.woff2 and /dev/null differ
diff --git a/priv/static/static/font/fontello.1588419330867.eot b/priv/static/static/font/fontello.1588947937982.eot
similarity index 90%
rename from priv/static/static/font/fontello.1588419330867.eot
rename to priv/static/static/font/fontello.1588947937982.eot
index 7f8c61e38..b1297072e 100644
Binary files a/priv/static/static/font/fontello.1588419330867.eot and b/priv/static/static/font/fontello.1588947937982.eot differ
diff --git a/priv/static/static/font/fontello.1588419330867.svg b/priv/static/static/font/fontello.1588947937982.svg
similarity index 98%
rename from priv/static/static/font/fontello.1588419330867.svg
rename to priv/static/static/font/fontello.1588947937982.svg
index 71f81f435..e63fb7529 100644
--- a/priv/static/static/font/fontello.1588419330867.svg
+++ b/priv/static/static/font/fontello.1588947937982.svg
@@ -114,6 +114,8 @@
+
+
diff --git a/priv/static/static/font/fontello.1588419330867.ttf b/priv/static/static/font/fontello.1588947937982.ttf
similarity index 90%
rename from priv/static/static/font/fontello.1588419330867.ttf
rename to priv/static/static/font/fontello.1588947937982.ttf
index 7dc4f108b..443801c4f 100644
Binary files a/priv/static/static/font/fontello.1588419330867.ttf and b/priv/static/static/font/fontello.1588947937982.ttf differ
diff --git a/priv/static/static/font/fontello.1588947937982.woff b/priv/static/static/font/fontello.1588947937982.woff
new file mode 100644
index 000000000..e96fea757
Binary files /dev/null and b/priv/static/static/font/fontello.1588947937982.woff differ
diff --git a/priv/static/static/font/fontello.1588947937982.woff2 b/priv/static/static/font/fontello.1588947937982.woff2
new file mode 100644
index 000000000..50318a670
Binary files /dev/null and b/priv/static/static/font/fontello.1588947937982.woff2 differ
diff --git a/priv/static/static/fontello.1588419330867.css b/priv/static/static/fontello.1588947937982.css
similarity index 88%
rename from priv/static/static/fontello.1588419330867.css
rename to priv/static/static/fontello.1588947937982.css
index 198eff184..d3d77a8b5 100644
Binary files a/priv/static/static/fontello.1588419330867.css and b/priv/static/static/fontello.1588947937982.css differ
diff --git a/priv/static/static/fontello.json b/priv/static/static/fontello.json
index 5963b68b4..7f0e7cdd5 100755
--- a/priv/static/static/fontello.json
+++ b/priv/static/static/fontello.json
@@ -346,6 +346,12 @@
"code": 59427,
"src": "fontawesome"
},
+ {
+ "uid": "4aad6bb50b02c18508aae9cbe14e784e",
+ "css": "share",
+ "code": 61920,
+ "src": "fontawesome"
+ },
{
"uid": "8b80d36d4ef43889db10bc1f0dc9a862",
"css": "user",
diff --git a/priv/static/static/js/2.1c407059cd79fca99e19.js b/priv/static/static/js/2.18e4adec273c4ce867a8.js
similarity index 80%
rename from priv/static/static/js/2.1c407059cd79fca99e19.js
rename to priv/static/static/js/2.18e4adec273c4ce867a8.js
index 14018d92a..d191aa852 100644
Binary files a/priv/static/static/js/2.1c407059cd79fca99e19.js and b/priv/static/static/js/2.18e4adec273c4ce867a8.js differ
diff --git a/priv/static/static/js/2.1c407059cd79fca99e19.js.map b/priv/static/static/js/2.18e4adec273c4ce867a8.js.map
similarity index 98%
rename from priv/static/static/js/2.1c407059cd79fca99e19.js.map
rename to priv/static/static/js/2.18e4adec273c4ce867a8.js.map
index cfee79ea8..a7f98bfef 100644
Binary files a/priv/static/static/js/2.1c407059cd79fca99e19.js.map and b/priv/static/static/js/2.18e4adec273c4ce867a8.js.map differ
diff --git a/priv/static/static/js/app.996428ccaaaa7f28cb8d.js b/priv/static/static/js/app.996428ccaaaa7f28cb8d.js
new file mode 100644
index 000000000..00f3a28e0
Binary files /dev/null and b/priv/static/static/js/app.996428ccaaaa7f28cb8d.js differ
diff --git a/priv/static/static/js/app.996428ccaaaa7f28cb8d.js.map b/priv/static/static/js/app.996428ccaaaa7f28cb8d.js.map
new file mode 100644
index 000000000..9daca3ff5
Binary files /dev/null and b/priv/static/static/js/app.996428ccaaaa7f28cb8d.js.map differ
diff --git a/priv/static/static/js/app.fa89b90e606f4facd209.js b/priv/static/static/js/app.fa89b90e606f4facd209.js
deleted file mode 100644
index a2cbcc337..000000000
Binary files a/priv/static/static/js/app.fa89b90e606f4facd209.js and /dev/null differ
diff --git a/priv/static/static/js/app.fa89b90e606f4facd209.js.map b/priv/static/static/js/app.fa89b90e606f4facd209.js.map
deleted file mode 100644
index 5722844a9..000000000
Binary files a/priv/static/static/js/app.fa89b90e606f4facd209.js.map and /dev/null differ
diff --git a/priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js b/priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js
similarity index 87%
rename from priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js
rename to priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js
index 1d62bb0a4..d1f1a1830 100644
Binary files a/priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js and b/priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js differ
diff --git a/priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js.map b/priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js.map
new file mode 100644
index 000000000..0d4a859ea
Binary files /dev/null and b/priv/static/static/js/vendors~app.561a1c605d1dfb0e6f74.js.map differ
diff --git a/priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js.map b/priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js.map
deleted file mode 100644
index ce0c86939..000000000
Binary files a/priv/static/static/js/vendors~app.8aa781e6dd81307f544b.js.map and /dev/null differ
diff --git a/priv/static/sw-pleroma.js b/priv/static/sw-pleroma.js
index 88244a549..d2be1782b 100644
Binary files a/priv/static/sw-pleroma.js and b/priv/static/sw-pleroma.js differ
diff --git a/test/activity_test.exs b/test/activity_test.exs
index 0c19f481b..2a92327d1 100644
--- a/test/activity_test.exs
+++ b/test/activity_test.exs
@@ -11,6 +11,11 @@ defmodule Pleroma.ActivityTest do
alias Pleroma.ThreadMute
import Pleroma.Factory
+ setup_all do
+ Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+ :ok
+ end
+
test "returns an activity by it's AP id" do
activity = insert(:note_activity)
found_activity = Activity.get_by_ap_id(activity.data["id"])
@@ -107,8 +112,6 @@ test "when association is not loaded" do
describe "search" do
setup do
- Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
-
user = insert(:user)
params = %{
@@ -125,8 +128,8 @@ test "when association is not loaded" do
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
- {:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
- {:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "更新情報"})
+ {:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "find me!"})
+ {:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "更新情報"})
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
{:ok, remote_activity} = ObanHelpers.perform(job)
@@ -225,8 +228,8 @@ test "get_by_id/1" do
test "all_by_actor_and_id/2" do
user = insert(:user)
- {:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofe"})
- {:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofefe"})
+ {:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
+ {:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofefe"})
assert [] == Activity.all_by_actor_and_id(user, [])
diff --git a/test/bbs/handler_test.exs b/test/bbs/handler_test.exs
index 74982547b..eb716486e 100644
--- a/test/bbs/handler_test.exs
+++ b/test/bbs/handler_test.exs
@@ -21,8 +21,8 @@ test "getting the home timeline" do
{:ok, user} = User.follow(user, followed)
- {:ok, _first} = CommonAPI.post(user, %{"status" => "hey"})
- {:ok, _second} = CommonAPI.post(followed, %{"status" => "hello"})
+ {:ok, _first} = CommonAPI.post(user, %{status: "hey"})
+ {:ok, _second} = CommonAPI.post(followed, %{status: "hello"})
output =
capture_io(fn ->
@@ -62,7 +62,7 @@ test "replying" do
user = insert(:user)
another_user = insert(:user)
- {:ok, activity} = CommonAPI.post(another_user, %{"status" => "this is a test post"})
+ {:ok, activity} = CommonAPI.post(another_user, %{status: "this is a test post"})
activity_object = Object.normalize(activity)
output =
diff --git a/test/bookmark_test.exs b/test/bookmark_test.exs
index 021f79322..2726fe7cd 100644
--- a/test/bookmark_test.exs
+++ b/test/bookmark_test.exs
@@ -11,7 +11,7 @@ defmodule Pleroma.BookmarkTest do
describe "create/2" do
test "with valid params" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Some cool information"})
{:ok, bookmark} = Bookmark.create(user.id, activity.id)
assert bookmark.user_id == user.id
assert bookmark.activity_id == activity.id
@@ -32,7 +32,7 @@ test "with invalid params" do
test "with valid params" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Some cool information"})
{:ok, _bookmark} = Bookmark.create(user.id, activity.id)
{:ok, _deleted_bookmark} = Bookmark.destroy(user.id, activity.id)
@@ -45,7 +45,7 @@ test "gets a bookmark" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Scientists Discover The Secret Behind Tenshi Eating A Corndog Being So Cute – Science Daily"
})
diff --git a/test/config/config_db_test.exs b/test/config/config_db_test.exs
index 6b0e7b4b6..a8e947365 100644
--- a/test/config/config_db_test.exs
+++ b/test/config/config_db_test.exs
@@ -43,11 +43,9 @@ test "get_all_as_keyword/0" do
{ConfigDB.from_string(saved.key), ConfigDB.from_binary(saved.value)}
]
- assert config[:quack] == [
- level: :info,
- meta: [:none],
- webhook_url: "https://hooks.slack.com/services/KEY/some_val"
- ]
+ assert config[:quack][:level] == :info
+ assert config[:quack][:meta] == [:none]
+ assert config[:quack][:webhook_url] == "https://hooks.slack.com/services/KEY/some_val"
end
describe "update_or_create/1" do
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs
index 3536842e8..59a1b6492 100644
--- a/test/conversation/participation_test.exs
+++ b/test/conversation/participation_test.exs
@@ -16,7 +16,7 @@ test "getting a participation will also preload things" do
other_user = insert(:user)
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
[participation] = Participation.for_user(user)
@@ -30,7 +30,7 @@ test "for a new conversation or a reply, it doesn't mark the author's participat
other_user = insert(:user)
{:ok, _} =
- CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
user = User.get_cached_by_id(user.id)
other_user = User.get_cached_by_id(other_user.id)
@@ -43,9 +43,9 @@ test "for a new conversation or a reply, it doesn't mark the author's participat
{:ok, _} =
CommonAPI.post(other_user, %{
- "status" => "Hey @#{user.nickname}.",
- "visibility" => "direct",
- "in_reply_to_conversation_id" => participation.id
+ status: "Hey @#{user.nickname}.",
+ visibility: "direct",
+ in_reply_to_conversation_id: participation.id
})
user = User.get_cached_by_id(user.id)
@@ -64,7 +64,7 @@ test "for a new conversation, it sets the recipents of the participation" do
third_user = insert(:user)
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
user = User.get_cached_by_id(user.id)
other_user = User.get_cached_by_id(other_user.id)
@@ -79,9 +79,9 @@ test "for a new conversation, it sets the recipents of the participation" do
{:ok, _activity} =
CommonAPI.post(user, %{
- "in_reply_to_status_id" => activity.id,
- "status" => "Hey @#{third_user.nickname}.",
- "visibility" => "direct"
+ in_reply_to_status_id: activity.id,
+ status: "Hey @#{third_user.nickname}.",
+ visibility: "direct"
})
[participation] = Participation.for_user(user)
@@ -154,14 +154,14 @@ test "it marks all the user's participations as read" do
test "gets all the participations for a user, ordered by updated at descending" do
user = insert(:user)
- {:ok, activity_one} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
- {:ok, activity_two} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
+ {:ok, activity_one} = CommonAPI.post(user, %{status: "x", visibility: "direct"})
+ {:ok, activity_two} = CommonAPI.post(user, %{status: "x", visibility: "direct"})
{:ok, activity_three} =
CommonAPI.post(user, %{
- "status" => "x",
- "visibility" => "direct",
- "in_reply_to_status_id" => activity_one.id
+ status: "x",
+ visibility: "direct",
+ in_reply_to_status_id: activity_one.id
})
# Offset participations because the accuracy of updated_at is down to a second
@@ -201,7 +201,7 @@ test "gets all the participations for a user, ordered by updated at descending"
test "Doesn't die when the conversation gets empty" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
[participation] = Participation.for_user_with_last_activity_id(user)
assert participation.last_activity_id == activity.id
@@ -215,7 +215,7 @@ test "it sets recipients, always keeping the owner of the participation even whe
user = insert(:user)
other_user = insert(:user)
- {:ok, _activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
[participation] = Participation.for_user_with_last_activity_id(user)
participation = Repo.preload(participation, :recipients)
@@ -239,26 +239,26 @@ test "when the user blocks a recipient, the existing conversations with them are
{:ok, _direct1} =
CommonAPI.post(third_user, %{
- "status" => "Hi @#{blocker.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}",
+ visibility: "direct"
})
{:ok, _direct2} =
CommonAPI.post(third_user, %{
- "status" => "Hi @#{blocker.nickname}, @#{blocked.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}, @#{blocked.nickname}",
+ visibility: "direct"
})
{:ok, _direct3} =
CommonAPI.post(blocked, %{
- "status" => "Hi @#{blocker.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}",
+ visibility: "direct"
})
{:ok, _direct4} =
CommonAPI.post(blocked, %{
- "status" => "Hi @#{blocker.nickname}, @#{third_user.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}, @#{third_user.nickname}",
+ visibility: "direct"
})
assert [%{read: false}, %{read: false}, %{read: false}, %{read: false}] =
@@ -293,8 +293,8 @@ test "the new conversation with the blocked user is not marked as unread " do
# When the blocked user is the author
{:ok, _direct1} =
CommonAPI.post(blocked, %{
- "status" => "Hi @#{blocker.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}",
+ visibility: "direct"
})
assert [%{read: true}] = Participation.for_user(blocker)
@@ -303,8 +303,8 @@ test "the new conversation with the blocked user is not marked as unread " do
# When the blocked user is a recipient
{:ok, _direct2} =
CommonAPI.post(third_user, %{
- "status" => "Hi @#{blocker.nickname}, @#{blocked.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}, @#{blocked.nickname}",
+ visibility: "direct"
})
assert [%{read: true}, %{read: true}] = Participation.for_user(blocker)
@@ -321,8 +321,8 @@ test "the conversation with the blocked user is not marked as unread on a reply"
{:ok, _direct1} =
CommonAPI.post(blocker, %{
- "status" => "Hi @#{third_user.nickname}, @#{blocked.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{third_user.nickname}, @#{blocked.nickname}",
+ visibility: "direct"
})
{:ok, _user_relationship} = User.block(blocker, blocked)
@@ -334,9 +334,9 @@ test "the conversation with the blocked user is not marked as unread on a reply"
# When it's a reply from the blocked user
{:ok, _direct2} =
CommonAPI.post(blocked, %{
- "status" => "reply",
- "visibility" => "direct",
- "in_reply_to_conversation_id" => blocked_participation.id
+ status: "reply",
+ visibility: "direct",
+ in_reply_to_conversation_id: blocked_participation.id
})
assert [%{read: true}] = Participation.for_user(blocker)
@@ -347,9 +347,9 @@ test "the conversation with the blocked user is not marked as unread on a reply"
# When it's a reply from the third user
{:ok, _direct3} =
CommonAPI.post(third_user, %{
- "status" => "reply",
- "visibility" => "direct",
- "in_reply_to_conversation_id" => third_user_participation.id
+ status: "reply",
+ visibility: "direct",
+ in_reply_to_conversation_id: third_user_participation.id
})
assert [%{read: true}] = Participation.for_user(blocker)
diff --git a/test/conversation_test.exs b/test/conversation_test.exs
index 056a0e920..359aa6840 100644
--- a/test/conversation_test.exs
+++ b/test/conversation_test.exs
@@ -18,7 +18,7 @@ test "it goes through old direct conversations" do
other_user = insert(:user)
{:ok, _activity} =
- CommonAPI.post(user, %{"visibility" => "direct", "status" => "hey @#{other_user.nickname}"})
+ CommonAPI.post(user, %{visibility: "direct", status: "hey @#{other_user.nickname}"})
Pleroma.Tests.ObanHelpers.perform_all()
@@ -46,7 +46,7 @@ test "it creates a conversation for given ap_id" do
test "public posts don't create conversations" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Hey"})
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
@@ -62,7 +62,7 @@ test "it creates or updates a conversation and participations for a given DM" do
tridi = insert(:user)
{:ok, activity} =
- CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "direct"})
+ CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
object = Pleroma.Object.normalize(activity)
context = object.data["context"]
@@ -81,9 +81,9 @@ test "it creates or updates a conversation and participations for a given DM" do
{:ok, activity} =
CommonAPI.post(jafnhar, %{
- "status" => "Hey @#{har.nickname}",
- "visibility" => "direct",
- "in_reply_to_status_id" => activity.id
+ status: "Hey @#{har.nickname}",
+ visibility: "direct",
+ in_reply_to_status_id: activity.id
})
object = Pleroma.Object.normalize(activity)
@@ -105,9 +105,9 @@ test "it creates or updates a conversation and participations for a given DM" do
{:ok, activity} =
CommonAPI.post(tridi, %{
- "status" => "Hey @#{har.nickname}",
- "visibility" => "direct",
- "in_reply_to_status_id" => activity.id
+ status: "Hey @#{har.nickname}",
+ visibility: "direct",
+ in_reply_to_status_id: activity.id
})
object = Pleroma.Object.normalize(activity)
@@ -149,14 +149,14 @@ test "create_or_bump_for returns the conversation with participations" do
jafnhar = insert(:user, local: false)
{:ok, activity} =
- CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "direct"})
+ CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
{:ok, conversation} = Conversation.create_or_bump_for(activity)
assert length(conversation.participations) == 2
{:ok, activity} =
- CommonAPI.post(har, %{"status" => "Hey @#{jafnhar.nickname}", "visibility" => "public"})
+ CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "public"})
assert {:error, _} = Conversation.create_or_bump_for(activity)
end
diff --git a/test/html_test.exs b/test/html_test.exs
index a006fd492..0a4b4ebbc 100644
--- a/test/html_test.exs
+++ b/test/html_test.exs
@@ -171,7 +171,7 @@ test "extracts the url" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"I think I just found the best github repo https://github.com/komeiji-satori/Dress"
})
@@ -186,7 +186,7 @@ test "skips mentions" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"@#{other_user.nickname} install misskey! https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
})
@@ -203,8 +203,7 @@ test "skips hashtags" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
- "#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
+ status: "#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
})
object = Object.normalize(activity)
@@ -218,9 +217,9 @@ test "skips microformats hashtags" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140",
- "content_type" => "text/html"
+ content_type: "text/html"
})
object = Object.normalize(activity)
@@ -232,8 +231,7 @@ test "skips microformats hashtags" do
test "does not crash when there is an HTML entity in a link" do
user = insert(:user)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "\"http://cofe.com/?boomer=ok&foo=bar\""})
+ {:ok, activity} = CommonAPI.post(user, %{status: "\"http://cofe.com/?boomer=ok&foo=bar\""})
object = Object.normalize(activity)
diff --git a/test/http/connection_test.exs b/test/http/connection_test.exs
index 5cc78ad5b..7c94a50b2 100644
--- a/test/http/connection_test.exs
+++ b/test/http/connection_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.ConnectionTest do
- use ExUnit.Case, async: true
+ use ExUnit.Case
use Pleroma.Tests.Helpers
import ExUnit.CaptureLog
diff --git a/test/http/request_builder_test.exs b/test/http/request_builder_test.exs
index f11528c3f..fab909905 100644
--- a/test/http/request_builder_test.exs
+++ b/test/http/request_builder_test.exs
@@ -3,23 +3,19 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.RequestBuilderTest do
- use ExUnit.Case, async: true
+ use ExUnit.Case
use Pleroma.Tests.Helpers
- alias Pleroma.Config
alias Pleroma.HTTP.Request
alias Pleroma.HTTP.RequestBuilder
describe "headers/2" do
- setup do: clear_config([:http, :send_user_agent])
- setup do: clear_config([:http, :user_agent])
-
test "don't send pleroma user agent" do
assert RequestBuilder.headers(%Request{}, []) == %Request{headers: []}
end
test "send pleroma user agent" do
- Config.put([:http, :send_user_agent], true)
- Config.put([:http, :user_agent], :default)
+ clear_config([:http, :send_user_agent], true)
+ clear_config([:http, :user_agent], :default)
assert RequestBuilder.headers(%Request{}, []) == %Request{
headers: [{"user-agent", Pleroma.Application.user_agent()}]
@@ -27,8 +23,8 @@ test "send pleroma user agent" do
end
test "send custom user agent" do
- Config.put([:http, :send_user_agent], true)
- Config.put([:http, :user_agent], "totally-not-pleroma")
+ clear_config([:http, :send_user_agent], true)
+ clear_config([:http, :user_agent], "totally-not-pleroma")
assert RequestBuilder.headers(%Request{}, []) == %Request{
headers: [{"user-agent", "totally-not-pleroma"}]
diff --git a/test/integration/mastodon_websocket_test.exs b/test/integration/mastodon_websocket_test.exs
index 109c7b4cb..ea17e9feb 100644
--- a/test/integration/mastodon_websocket_test.exs
+++ b/test/integration/mastodon_websocket_test.exs
@@ -32,7 +32,7 @@ def start_socket(qs \\ nil, headers \\ []) do
test "refuses invalid requests" do
capture_log(fn ->
- assert {:error, {400, _}} = start_socket()
+ assert {:error, {404, _}} = start_socket()
assert {:error, {404, _}} = start_socket("?stream=ncjdk")
Process.sleep(30)
end)
@@ -40,8 +40,8 @@ test "refuses invalid requests" do
test "requires authentication and a valid token for protected streams" do
capture_log(fn ->
- assert {:error, {403, _}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
- assert {:error, {403, _}} = start_socket("?stream=user")
+ assert {:error, {401, _}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
+ assert {:error, {401, _}} = start_socket("?stream=user")
Process.sleep(30)
end)
end
@@ -55,7 +55,7 @@ test "allows public streams without authentication" do
test "receives well formatted events" do
user = insert(:user)
{:ok, _} = start_socket("?stream=public")
- {:ok, activity} = CommonAPI.post(user, %{"status" => "nice echo chamber"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "nice echo chamber"})
assert_receive {:text, raw_json}, 1_000
assert {:ok, json} = Jason.decode(raw_json)
@@ -100,7 +100,7 @@ test "accepts the 'user' stream", %{token: token} = _state do
assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
assert capture_log(fn ->
- assert {:error, {403, "Forbidden"}} = start_socket("?stream=user")
+ assert {:error, {401, _}} = start_socket("?stream=user")
Process.sleep(30)
end) =~ ":badarg"
end
@@ -109,7 +109,7 @@ test "accepts the 'user:notification' stream", %{token: token} = _state do
assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
assert capture_log(fn ->
- assert {:error, {403, "Forbidden"}} = start_socket("?stream=user:notification")
+ assert {:error, {401, _}} = start_socket("?stream=user:notification")
Process.sleep(30)
end) =~ ":badarg"
end
@@ -118,7 +118,7 @@ test "accepts valid token on Sec-WebSocket-Protocol header", %{token: token} do
assert {:ok, _} = start_socket("?stream=user", [{"Sec-WebSocket-Protocol", token.token}])
assert capture_log(fn ->
- assert {:error, {403, "Forbidden"}} =
+ assert {:error, {401, _}} =
start_socket("?stream=user", [{"Sec-WebSocket-Protocol", "I am a friend"}])
Process.sleep(30)
diff --git a/test/mfa_test.exs b/test/mfa_test.exs
index 94bc48c26..8875cefd9 100644
--- a/test/mfa_test.exs
+++ b/test/mfa_test.exs
@@ -6,7 +6,6 @@ defmodule Pleroma.MFATest do
use Pleroma.DataCase
import Pleroma.Factory
- alias Comeonin.Pbkdf2
alias Pleroma.MFA
describe "mfa_settings" do
@@ -31,8 +30,8 @@ test "returns backup codes" do
{:ok, [code1, code2]} = MFA.generate_backup_codes(user)
updated_user = refresh_record(user)
[hash1, hash2] = updated_user.multi_factor_authentication_settings.backup_codes
- assert Pbkdf2.checkpw(code1, hash1)
- assert Pbkdf2.checkpw(code2, hash2)
+ assert Pbkdf2.verify_pass(code1, hash1)
+ assert Pbkdf2.verify_pass(code2, hash2)
end
end
diff --git a/test/notification_test.exs b/test/notification_test.exs
index 24e5f0c73..111ff09f4 100644
--- a/test/notification_test.exs
+++ b/test/notification_test.exs
@@ -25,7 +25,7 @@ test "creates a notification for an emoji reaction" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "yeah"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "yeah"})
{:ok, activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
{:ok, [notification]} = Notification.create_notifications(activity)
@@ -40,7 +40,7 @@ test "notifies someone when they are directly addressed" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname} and @#{third_user.nickname}"
+ status: "hey @#{other_user.nickname} and @#{third_user.nickname}"
})
{:ok, [notification, other_notification]} = Notification.create_notifications(activity)
@@ -60,7 +60,7 @@ test "it creates a notification for subscribed users" do
User.subscribe(subscriber, user)
- {:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
+ {:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
{:ok, [notification]} = Notification.create_notifications(status)
assert notification.user_id == subscriber.id
@@ -73,12 +73,12 @@ test "does not create a notification for subscribed users if status is a reply"
User.subscribe(subscriber, other_user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
{:ok, _reply_activity} =
CommonAPI.post(other_user, %{
- "status" => "test reply",
- "in_reply_to_status_id" => activity.id
+ status: "test reply",
+ in_reply_to_status_id: activity.id
})
user_notifications = Notification.for_user(user)
@@ -98,7 +98,7 @@ test "does not create a notification for subscribed users if status is a reply"
blocker = insert(:user)
{:ok, _user_relationship} = User.block(blocker, user)
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "hey @#{blocker.nickname}!"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "hey @#{blocker.nickname}!"})
blocker_id = blocker.id
assert [%Notification{user_id: ^blocker_id}] = Repo.all(Notification)
@@ -113,7 +113,7 @@ test "does not create a notification for subscribed users if status is a reply"
muter = insert(:user)
{:ok, _user_relationships} = User.mute(muter, user)
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "hey @#{muter.nickname}!"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "hey @#{muter.nickname}!"})
muter_id = muter.id
assert [%Notification{user_id: ^muter_id}] = Repo.all(Notification)
@@ -127,14 +127,14 @@ test "does not create a notification for subscribed users if status is a reply"
user = insert(:user)
thread_muter = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{thread_muter.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{thread_muter.nickname}!"})
{:ok, _} = CommonAPI.add_mute(thread_muter, activity)
{:ok, _same_context_activity} =
CommonAPI.post(user, %{
- "status" => "hey-hey-hey @#{thread_muter.nickname}!",
- "in_reply_to_status_id" => activity.id
+ status: "hey-hey-hey @#{thread_muter.nickname}!",
+ in_reply_to_status_id: activity.id
})
[pre_mute_notification, post_mute_notification] =
@@ -170,13 +170,13 @@ test "it creates a notification for user and send to the 'user' and the 'user:no
task =
Task.async(fn ->
- Streamer.add_socket("user", user)
+ Streamer.get_topic_and_add_socket("user", user)
assert_receive {:render_with_user, _, _, _}, 4_000
end)
task_user_notification =
Task.async(fn ->
- Streamer.add_socket("user:notification", user)
+ Streamer.get_topic_and_add_socket("user:notification", user)
assert_receive {:render_with_user, _, _, _}, 4_000
end)
@@ -202,7 +202,7 @@ test "it creates a notification for the user if the user mutes the activity auth
muted = insert(:user)
{:ok, _} = User.mute(muter, muted)
muter = Repo.get(User, muter.id)
- {:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
+ {:ok, activity} = CommonAPI.post(muted, %{status: "Hi @#{muter.nickname}"})
assert Notification.create_notification(activity, muter)
end
@@ -213,7 +213,7 @@ test "notification created if user is muted without notifications" do
{:ok, _user_relationships} = User.mute(muter, muted, false)
- {:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
+ {:ok, activity} = CommonAPI.post(muted, %{status: "Hi @#{muter.nickname}"})
assert Notification.create_notification(activity, muter)
end
@@ -221,13 +221,13 @@ test "notification created if user is muted without notifications" do
test "it creates a notification for an activity from a muted thread" do
muter = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(muter, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(muter, %{status: "hey"})
CommonAPI.add_mute(muter, activity)
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "Hi @#{muter.nickname}",
- "in_reply_to_status_id" => activity.id
+ status: "Hi @#{muter.nickname}",
+ in_reply_to_status_id: activity.id
})
assert Notification.create_notification(activity, muter)
@@ -240,7 +240,7 @@ test "it disables notifications from followers" do
insert(:user, notification_settings: %Pleroma.User.NotificationSetting{followers: false})
User.follow(follower, followed)
- {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
+ {:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
refute Notification.create_notification(activity, followed)
end
@@ -252,7 +252,7 @@ test "it disables notifications from non-followers" do
notification_settings: %Pleroma.User.NotificationSetting{non_followers: false}
)
- {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
+ {:ok, activity} = CommonAPI.post(follower, %{status: "hey @#{followed.nickname}"})
refute Notification.create_notification(activity, followed)
end
@@ -263,7 +263,7 @@ test "it disables notifications from people the user follows" do
followed = insert(:user)
User.follow(follower, followed)
follower = Repo.get(User, follower.id)
- {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
+ {:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
refute Notification.create_notification(activity, follower)
end
@@ -272,7 +272,7 @@ test "it disables notifications from people the user does not follow" do
insert(:user, notification_settings: %Pleroma.User.NotificationSetting{non_follows: false})
followed = insert(:user)
- {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
+ {:ok, activity} = CommonAPI.post(followed, %{status: "hey @#{follower.nickname}"})
refute Notification.create_notification(activity, follower)
end
@@ -289,7 +289,7 @@ test "it doesn't create duplicate notifications for follow+subscribed users" do
{:ok, _, _, _} = CommonAPI.follow(subscriber, user)
User.subscribe(subscriber, user)
- {:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
+ {:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
{:ok, [_notif]} = Notification.create_notifications(status)
end
@@ -299,7 +299,7 @@ test "it doesn't create subscription notifications if the recipient cannot see t
User.subscribe(subscriber, user)
- {:ok, status} = CommonAPI.post(user, %{"status" => "inwisible", "visibility" => "direct"})
+ {:ok, status} = CommonAPI.post(user, %{status: "inwisible", visibility: "direct"})
assert {:ok, []} == Notification.create_notifications(status)
end
@@ -370,7 +370,7 @@ test "it gets a notification that belongs to the user" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
{:ok, notification} = Notification.get(other_user, notification.id)
@@ -382,7 +382,7 @@ test "it returns error if the notification doesn't belong to the user" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
{:error, _notification} = Notification.get(user, notification.id)
@@ -394,7 +394,7 @@ test "it dismisses a notification that belongs to the user" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
{:ok, notification} = Notification.dismiss(other_user, notification.id)
@@ -406,7 +406,7 @@ test "it returns error if the notification doesn't belong to the user" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
{:error, _notification} = Notification.dismiss(user, notification.id)
@@ -421,14 +421,14 @@ test "it clears all notifications belonging to the user" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname} and @#{third_user.nickname} !"
+ status: "hey @#{other_user.nickname} and @#{third_user.nickname} !"
})
{:ok, _notifs} = Notification.create_notifications(activity)
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
+ status: "hey again @#{other_user.nickname} and @#{third_user.nickname} !"
})
{:ok, _notifs} = Notification.create_notifications(activity)
@@ -446,12 +446,12 @@ test "it sets all notifications as read up to a specified notification ID" do
{:ok, _activity} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname}!"
+ status: "hey @#{other_user.nickname}!"
})
{:ok, _activity} =
CommonAPI.post(user, %{
- "status" => "hey again @#{other_user.nickname}!"
+ status: "hey again @#{other_user.nickname}!"
})
[n2, n1] = notifs = Notification.for_user(other_user)
@@ -461,7 +461,7 @@ test "it sets all notifications as read up to a specified notification ID" do
{:ok, _activity} =
CommonAPI.post(user, %{
- "status" => "hey yet again @#{other_user.nickname}!"
+ status: "hey yet again @#{other_user.nickname}!"
})
Notification.set_read_up_to(other_user, n2.id)
@@ -500,7 +500,7 @@ test "Returns recent notifications" do
Enum.each(0..10, fn i ->
{:ok, _activity} =
CommonAPI.post(user1, %{
- "status" => "hey ##{i} @#{user2.nickname}!"
+ status: "hey ##{i} @#{user2.nickname}!"
})
end)
@@ -536,7 +536,7 @@ test "it sends notifications to addressed users in new messages" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname}!"
+ status: "hey @#{other_user.nickname}!"
})
{enabled_receivers, _disabled_receivers} = Notification.get_notified_from_activity(activity)
@@ -605,7 +605,7 @@ test "it does not send notification to mentioned users in likes" do
{:ok, activity_one} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname}!"
+ status: "hey @#{other_user.nickname}!"
})
{:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id)
@@ -623,7 +623,7 @@ test "it only notifies the post's author in likes" do
{:ok, activity_one} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname}!"
+ status: "hey @#{other_user.nickname}!"
})
{:ok, like_data, _} = Builder.like(third_user, activity_one.object)
@@ -645,7 +645,7 @@ test "it does not send notification to mentioned users in announces" do
{:ok, activity_one} =
CommonAPI.post(user, %{
- "status" => "hey @#{other_user.nickname}!"
+ status: "hey @#{other_user.nickname}!"
})
{:ok, activity_two, _} = CommonAPI.repeat(activity_one.id, third_user)
@@ -661,7 +661,7 @@ test "it returns blocking recipient in disabled recipients list" do
other_user = insert(:user)
{:ok, _user_relationship} = User.block(other_user, user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
@@ -674,7 +674,7 @@ test "it returns notification-muting recipient in disabled recipients list" do
other_user = insert(:user)
{:ok, _user_relationships} = User.mute(other_user, user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
@@ -686,14 +686,14 @@ test "it returns thread-muting recipient in disabled recipients list" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{:ok, _} = CommonAPI.add_mute(other_user, activity)
{:ok, same_context_activity} =
CommonAPI.post(user, %{
- "status" => "hey-hey-hey @#{other_user.nickname}!",
- "in_reply_to_status_id" => activity.id
+ status: "hey-hey-hey @#{other_user.nickname}!",
+ in_reply_to_status_id: activity.id
})
{enabled_receivers, disabled_receivers} =
@@ -710,7 +710,7 @@ test "it returns non-following domain-blocking recipient in disabled recipients
{:ok, other_user} = User.block_domain(other_user, blocked_domain)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
@@ -726,7 +726,7 @@ test "it returns following domain-blocking recipient in enabled recipients list"
{:ok, other_user} = User.block_domain(other_user, blocked_domain)
{:ok, other_user} = User.follow(other_user, user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{enabled_receivers, disabled_receivers} = Notification.get_notified_from_activity(activity)
@@ -740,7 +740,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is de
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -757,7 +757,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is un
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -774,7 +774,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -791,7 +791,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -808,7 +808,7 @@ test "liking an activity which is already deleted does not generate a notificati
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -825,7 +825,7 @@ test "repeating an activity which is already deleted does not generate a notific
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
assert Enum.empty?(Notification.for_user(user))
@@ -842,13 +842,13 @@ test "replying to a deleted post without tagging does not generate a notificatio
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
{:ok, _deletion_activity} = CommonAPI.delete(activity.id, user)
{:ok, _reply_activity} =
CommonAPI.post(other_user, %{
- "status" => "test reply",
- "in_reply_to_status_id" => activity.id
+ status: "test reply",
+ in_reply_to_status_id: activity.id
})
assert Enum.empty?(Notification.for_user(user))
@@ -859,7 +859,7 @@ test "notifications are deleted if a local user is deleted" do
other_user = insert(:user)
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "hi @#{other_user.nickname}", visibility: "direct"})
refute Enum.empty?(Notification.for_user(other_user))
@@ -970,7 +970,7 @@ test "it returns notifications for muted user without notifications" do
muted = insert(:user)
{:ok, _user_relationships} = User.mute(user, muted, false)
- {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
assert length(Notification.for_user(user)) == 1
end
@@ -980,7 +980,7 @@ test "it doesn't return notifications for muted user with notifications" do
muted = insert(:user)
{:ok, _user_relationships} = User.mute(user, muted)
- {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
assert Notification.for_user(user) == []
end
@@ -990,7 +990,7 @@ test "it doesn't return notifications for blocked user" do
blocked = insert(:user)
{:ok, _user_relationship} = User.block(user, blocked)
- {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
assert Notification.for_user(user) == []
end
@@ -1000,7 +1000,7 @@ test "it doesn't return notifications for domain-blocked non-followed user" do
blocked = insert(:user, ap_id: "http://some-domain.com")
{:ok, user} = User.block_domain(user, "some-domain.com")
- {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
assert Notification.for_user(user) == []
end
@@ -1012,7 +1012,7 @@ test "it returns notifications for domain-blocked but followed user" do
{:ok, user} = User.block_domain(user, "some-domain.com")
{:ok, _} = User.follow(user, blocked)
- {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
assert length(Notification.for_user(user)) == 1
end
@@ -1021,7 +1021,7 @@ test "it doesn't return notifications for muted thread" do
user = insert(:user)
another_user = insert(:user)
- {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(another_user, %{status: "hey @#{user.nickname}"})
{:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
assert Notification.for_user(user) == []
@@ -1032,7 +1032,7 @@ test "it returns notifications from a muted user when with_muted is set" do
muted = insert(:user)
{:ok, _user_relationships} = User.mute(user, muted)
- {:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(muted, %{status: "hey @#{user.nickname}"})
assert length(Notification.for_user(user, %{with_muted: true})) == 1
end
@@ -1042,7 +1042,7 @@ test "it doesn't return notifications from a blocked user when with_muted is set
blocked = insert(:user)
{:ok, _user_relationship} = User.block(user, blocked)
- {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
assert Enum.empty?(Notification.for_user(user, %{with_muted: true}))
end
@@ -1053,7 +1053,7 @@ test "when with_muted is set, " <>
blocked = insert(:user, ap_id: "http://some-domain.com")
{:ok, user} = User.block_domain(user, "some-domain.com")
- {:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(blocked, %{status: "hey @#{user.nickname}"})
assert Enum.empty?(Notification.for_user(user, %{with_muted: true}))
end
@@ -1062,7 +1062,7 @@ test "it returns notifications from muted threads when with_muted is set" do
user = insert(:user)
another_user = insert(:user)
- {:ok, activity} = CommonAPI.post(another_user, %{"status" => "hey @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(another_user, %{status: "hey @#{user.nickname}"})
{:ok, _} = Pleroma.ThreadMute.add_mute(user.id, activity.data["context"])
assert length(Notification.for_user(user, %{with_muted: true})) == 1
diff --git a/test/plugs/authentication_plug_test.exs b/test/plugs/authentication_plug_test.exs
index 646bda9d3..c8ede71c0 100644
--- a/test/plugs/authentication_plug_test.exs
+++ b/test/plugs/authentication_plug_test.exs
@@ -16,7 +16,7 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
user = %User{
id: 1,
name: "dude",
- password_hash: Comeonin.Pbkdf2.hashpwsalt("guy")
+ password_hash: Pbkdf2.hash_pwd_salt("guy")
}
conn =
@@ -79,6 +79,13 @@ test "check sha512-crypt hash" do
assert AuthenticationPlug.checkpw("password", hash)
end
+ test "check bcrypt hash" do
+ hash = "$2a$10$uyhC/R/zoE1ndwwCtMusK.TLVzkQ/Ugsbqp3uXI.CTTz0gBw.24jS"
+
+ assert AuthenticationPlug.checkpw("password", hash)
+ refute AuthenticationPlug.checkpw("password1", hash)
+ end
+
test "it returns false when hash invalid" do
hash =
"psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
diff --git a/test/stats_test.exs b/test/stats_test.exs
index c1aeb2c7f..4b76e2e78 100644
--- a/test/stats_test.exs
+++ b/test/stats_test.exs
@@ -22,26 +22,26 @@ test "on new status" do
user = insert(:user)
other_user = insert(:user)
- CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+ CommonAPI.post(user, %{visibility: "public", status: "hey"})
Enum.each(0..1, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "unlisted",
- "status" => "hey"
+ visibility: "unlisted",
+ status: "hey"
})
end)
Enum.each(0..2, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => "hey @#{other_user.nickname}"
+ visibility: "direct",
+ status: "hey @#{other_user.nickname}"
})
end)
Enum.each(0..3, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "private",
- "status" => "hey"
+ visibility: "private",
+ status: "hey"
})
end)
@@ -51,7 +51,7 @@ test "on new status" do
test "on status delete" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
assert %{public: 1} = Pleroma.Stats.get_status_visibility_count()
CommonAPI.delete(activity.id, user)
assert %{public: 0} = Pleroma.Stats.get_status_visibility_count()
@@ -59,16 +59,16 @@ test "on status delete" do
test "on status visibility update" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
assert %{public: 1, private: 0} = Pleroma.Stats.get_status_visibility_count()
- {:ok, _} = CommonAPI.update_activity_scope(activity.id, %{"visibility" => "private"})
+ {:ok, _} = CommonAPI.update_activity_scope(activity.id, %{visibility: "private"})
assert %{public: 0, private: 1} = Pleroma.Stats.get_status_visibility_count()
end
test "doesn't count unrelated activities" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{visibility: "public", status: "hey"})
_ = CommonAPI.follow(user, other_user)
CommonAPI.favorite(other_user, activity.id)
CommonAPI.repeat(activity.id, other_user)
diff --git a/test/support/builders/user_builder.ex b/test/support/builders/user_builder.ex
index 0d0490714..0c687c029 100644
--- a/test/support/builders/user_builder.ex
+++ b/test/support/builders/user_builder.ex
@@ -7,7 +7,7 @@ def build(data \\ %{}) do
email: "test@example.org",
name: "Test Name",
nickname: "testname",
- password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
+ password_hash: Pbkdf2.hash_pwd_salt("test"),
bio: "A tester.",
ap_id: "some id",
last_digest_emailed_at: NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second),
diff --git a/test/support/factory.ex b/test/support/factory.ex
index c8c45e2a7..d4284831c 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -29,7 +29,7 @@ def user_factory do
name: sequence(:name, &"Test テスト User #{&1}"),
email: sequence(:email, &"user#{&1}@example.com"),
nickname: sequence(:nickname, &"nick#{&1}"),
- password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
+ password_hash: Pbkdf2.hash_pwd_salt("test"),
bio: sequence(:bio, &"Tester Number #{&1}"),
last_digest_emailed_at: NaiveDateTime.utc_now(),
last_refreshed_at: NaiveDateTime.utc_now(),
diff --git a/test/tasks/count_statuses_test.exs b/test/tasks/count_statuses_test.exs
index 73c2ea690..c5cd16960 100644
--- a/test/tasks/count_statuses_test.exs
+++ b/test/tasks/count_statuses_test.exs
@@ -13,11 +13,11 @@ defmodule Mix.Tasks.Pleroma.CountStatusesTest do
test "counts statuses" do
user = insert(:user)
- {:ok, _} = CommonAPI.post(user, %{"status" => "test"})
- {:ok, _} = CommonAPI.post(user, %{"status" => "test2"})
+ {:ok, _} = CommonAPI.post(user, %{status: "test"})
+ {:ok, _} = CommonAPI.post(user, %{status: "test2"})
user2 = insert(:user)
- {:ok, _} = CommonAPI.post(user2, %{"status" => "test3"})
+ {:ok, _} = CommonAPI.post(user2, %{status: "test3"})
user = refresh_record(user)
user2 = refresh_record(user2)
diff --git a/test/tasks/database_test.exs b/test/tasks/database_test.exs
index 7b05993d3..883828d77 100644
--- a/test/tasks/database_test.exs
+++ b/test/tasks/database_test.exs
@@ -26,7 +26,7 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
describe "running remove_embedded_objects" do
test "it replaces objects with references" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test"})
new_data = Map.put(activity.data, "object", activity.object.data)
{:ok, activity} =
@@ -99,8 +99,8 @@ test "following and followers count are updated" do
test "it turns OrderedCollection likes into empty arrays" do
[user, user2] = insert_pair(:user)
- {:ok, %{id: id, object: object}} = CommonAPI.post(user, %{"status" => "test"})
- {:ok, %{object: object2}} = CommonAPI.post(user, %{"status" => "test test"})
+ {:ok, %{id: id, object: object}} = CommonAPI.post(user, %{status: "test"})
+ {:ok, %{object: object2}} = CommonAPI.post(user, %{status: "test test"})
CommonAPI.favorite(user2, id)
diff --git a/test/tasks/digest_test.exs b/test/tasks/digest_test.exs
index 96d762685..eefbc8936 100644
--- a/test/tasks/digest_test.exs
+++ b/test/tasks/digest_test.exs
@@ -25,7 +25,7 @@ test "Sends digest to the given user" do
Enum.each(0..10, fn i ->
{:ok, _activity} =
CommonAPI.post(user1, %{
- "status" => "hey ##{i} @#{user2.nickname}!"
+ status: "hey ##{i} @#{user2.nickname}!"
})
end)
diff --git a/test/tasks/refresh_counter_cache_test.exs b/test/tasks/refresh_counter_cache_test.exs
index b63f44c08..851971a77 100644
--- a/test/tasks/refresh_counter_cache_test.exs
+++ b/test/tasks/refresh_counter_cache_test.exs
@@ -12,26 +12,26 @@ test "counts statuses" do
user = insert(:user)
other_user = insert(:user)
- CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+ CommonAPI.post(user, %{visibility: "public", status: "hey"})
Enum.each(0..1, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "unlisted",
- "status" => "hey"
+ visibility: "unlisted",
+ status: "hey"
})
end)
Enum.each(0..2, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => "hey @#{other_user.nickname}"
+ visibility: "direct",
+ status: "hey @#{other_user.nickname}"
})
end)
Enum.each(0..3, fn _ ->
CommonAPI.post(user, %{
- "visibility" => "private",
- "status" => "hey"
+ visibility: "private",
+ status: "hey"
})
end)
diff --git a/test/tasks/user_test.exs b/test/tasks/user_test.exs
index e0fee7290..4aa873f0b 100644
--- a/test/tasks/user_test.exs
+++ b/test/tasks/user_test.exs
@@ -3,9 +3,12 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UserTest do
+ alias Pleroma.Activity
+ alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
+ alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth.Authorization
alias Pleroma.Web.OAuth.Token
@@ -103,6 +106,28 @@ test "user is deleted" do
end
end
+ test "a remote user's create activity is deleted when the object has been pruned" do
+ user = insert(:user)
+
+ {:ok, post} = CommonAPI.post(user, %{status: "uguu"})
+ object = Object.normalize(post)
+ Object.prune(object)
+
+ with_mock Pleroma.Web.Federator,
+ publish: fn _ -> nil end do
+ Mix.Tasks.Pleroma.User.run(["rm", user.nickname])
+ ObanHelpers.perform_all()
+
+ assert_received {:mix_shell, :info, [message]}
+ assert message =~ " deleted"
+ assert %{deactivated: true} = User.get_by_nickname(user.nickname)
+
+ assert called(Pleroma.Web.Federator.publish(:_))
+ end
+
+ refute Activity.get_by_id(post.id)
+ end
+
test "no user to delete" do
Mix.Tasks.Pleroma.User.run(["rm", "nonexistent"])
diff --git a/test/uploaders/s3_test.exs b/test/uploaders/s3_test.exs
index 6950ccb25..d949c90a5 100644
--- a/test/uploaders/s3_test.exs
+++ b/test/uploaders/s3_test.exs
@@ -58,7 +58,7 @@ test "it returns path with bucket namespace when namespace is set" do
name: "image-tet.jpg",
content_type: "image/jpg",
path: "test_folder/image-tet.jpg",
- tempfile: Path.absname("test/fixtures/image_tmp.jpg")
+ tempfile: Path.absname("test/instance_static/add/shortcode.png")
}
[file_upload: file_upload]
diff --git a/test/user_test.exs b/test/user_test.exs
index a3c75aa9b..6b9df60a4 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -990,7 +990,7 @@ test "works for announces" do
actor = insert(:user)
user = insert(:user, local: true)
- {:ok, activity} = CommonAPI.post(actor, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(actor, %{status: "hello"})
{:ok, announce, _} = CommonAPI.repeat(activity.id, user)
recipients = User.get_recipients_from_activity(announce)
@@ -1007,7 +1007,7 @@ test "get recipients" do
{:ok, activity} =
CommonAPI.post(actor, %{
- "status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
+ status: "hey @#{addressed.nickname} @#{addressed_remote.nickname}"
})
assert Enum.map([actor, addressed], & &1.ap_id) --
@@ -1029,7 +1029,7 @@ test "has following" do
{:ok, activity} =
CommonAPI.post(actor, %{
- "status" => "hey @#{addressed.nickname}"
+ status: "hey @#{addressed.nickname}"
})
assert Enum.map([actor, addressed], & &1.ap_id) --
@@ -1090,7 +1090,7 @@ test "hide a user's statuses from timelines and notifications" do
{:ok, user2} = User.follow(user2, user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{user2.nickname}"})
activity = Repo.preload(activity, :bookmark)
@@ -1126,7 +1126,7 @@ test "hide a user's statuses from timelines and notifications" do
setup do: clear_config([:instance, :federating])
test ".delete_user_activities deletes all create activities", %{user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "2hu"})
User.delete_user_activities(user)
@@ -1411,7 +1411,7 @@ test "Only includes users who has no recent activity" do
{:ok, _} =
CommonAPI.post(user, %{
- "status" => "hey @#{to.nickname}"
+ status: "hey @#{to.nickname}"
})
end)
@@ -1443,12 +1443,12 @@ test "Only includes users with no read notifications" do
Enum.each(recipients, fn to ->
{:ok, _} =
CommonAPI.post(sender, %{
- "status" => "hey @#{to.nickname}"
+ status: "hey @#{to.nickname}"
})
{:ok, _} =
CommonAPI.post(sender, %{
- "status" => "hey again @#{to.nickname}"
+ status: "hey again @#{to.nickname}"
})
end)
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index 776ddc8d4..c432c90e3 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -341,7 +341,7 @@ test "it caches a response", %{conn: conn} do
test "cached purged after activity deletion", %{conn: conn} do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "cofe"})
uuid = String.split(activity.data["id"], "/") |> List.last()
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 0739cbfef..77bd07edf 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -32,7 +32,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
describe "streaming out participations" do
test "it streams them out" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
{:ok, conversation} = Pleroma.Conversation.create_or_bump_for(activity)
@@ -56,8 +56,8 @@ test "streams them out on activity creation" do
stream: fn _, _ -> nil end do
{:ok, activity} =
CommonAPI.post(user_one, %{
- "status" => "@#{user_two.nickname}",
- "visibility" => "direct"
+ status: "@#{user_two.nickname}",
+ visibility: "direct"
})
conversation =
@@ -74,15 +74,13 @@ test "streams them out on activity creation" do
test "it restricts by the appropriate visibility" do
user = insert(:user)
- {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
+ {:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
- {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
- {:ok, unlisted_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
+ {:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
- {:ok, private_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
activities =
ActivityPub.fetch_activities([], %{:visibility => "direct", "actor_id" => user.ap_id})
@@ -118,15 +116,13 @@ test "it restricts by the appropriate visibility" do
test "it excludes by the appropriate visibility" do
user = insert(:user)
- {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
+ {:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
- {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
- {:ok, unlisted_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
+ {:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
- {:ok, private_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
activities =
ActivityPub.fetch_activities([], %{
@@ -193,9 +189,9 @@ test "it returns a user that is invisible" do
test "it fetches the appropriate tag-restricted posts" do
user = insert(:user)
- {:ok, status_one} = CommonAPI.post(user, %{"status" => ". #test"})
- {:ok, status_two} = CommonAPI.post(user, %{"status" => ". #essais"})
- {:ok, status_three} = CommonAPI.post(user, %{"status" => ". #test #reject"})
+ {:ok, status_one} = CommonAPI.post(user, %{status: ". #test"})
+ {:ok, status_two} = CommonAPI.post(user, %{status: ". #essais"})
+ {:ok, status_three} = CommonAPI.post(user, %{status: ". #test #reject"})
fetch_one = ActivityPub.fetch_activities([], %{"type" => "Create", "tag" => "test"})
@@ -432,26 +428,26 @@ test "increases user note count only for public activities" do
{:ok, _} =
CommonAPI.post(User.get_cached_by_id(user.id), %{
- "status" => "1",
- "visibility" => "public"
+ status: "1",
+ visibility: "public"
})
{:ok, _} =
CommonAPI.post(User.get_cached_by_id(user.id), %{
- "status" => "2",
- "visibility" => "unlisted"
+ status: "2",
+ visibility: "unlisted"
})
{:ok, _} =
CommonAPI.post(User.get_cached_by_id(user.id), %{
- "status" => "2",
- "visibility" => "private"
+ status: "2",
+ visibility: "private"
})
{:ok, _} =
CommonAPI.post(User.get_cached_by_id(user.id), %{
- "status" => "3",
- "visibility" => "direct"
+ status: "3",
+ visibility: "direct"
})
user = User.get_cached_by_id(user.id)
@@ -462,27 +458,27 @@ test "increases replies count" do
user = insert(:user)
user2 = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "1", "visibility" => "public"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "1", visibility: "public"})
ap_id = activity.data["id"]
- reply_data = %{"status" => "1", "in_reply_to_status_id" => activity.id}
+ reply_data = %{status: "1", in_reply_to_status_id: activity.id}
# public
- {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "public"))
+ {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "public"))
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
assert object.data["repliesCount"] == 1
# unlisted
- {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "unlisted"))
+ {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "unlisted"))
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
assert object.data["repliesCount"] == 2
# private
- {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "private"))
+ {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "private"))
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
assert object.data["repliesCount"] == 2
# direct
- {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "direct"))
+ {:ok, _} = CommonAPI.post(user2, Map.put(reply_data, :visibility, "direct"))
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
assert object.data["repliesCount"] == 2
end
@@ -569,13 +565,13 @@ test "doesn't return transitive interactions concerning blocked users" do
{:ok, _user_relationship} = User.block(blocker, blockee)
- {:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
+ {:ok, activity_one} = CommonAPI.post(friend, %{status: "hey!"})
- {:ok, activity_two} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
+ {:ok, activity_two} = CommonAPI.post(friend, %{status: "hey! @#{blockee.nickname}"})
- {:ok, activity_three} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
+ {:ok, activity_three} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
- {:ok, activity_four} = CommonAPI.post(blockee, %{"status" => "hey! @#{blocker.nickname}"})
+ {:ok, activity_four} = CommonAPI.post(blockee, %{status: "hey! @#{blocker.nickname}"})
activities = ActivityPub.fetch_activities([], %{"blocking_user" => blocker})
@@ -592,9 +588,9 @@ test "doesn't return announce activities concerning blocked users" do
{:ok, _user_relationship} = User.block(blocker, blockee)
- {:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
+ {:ok, activity_one} = CommonAPI.post(friend, %{status: "hey!"})
- {:ok, activity_two} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
+ {:ok, activity_two} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
{:ok, activity_three, _} = CommonAPI.repeat(activity_two.id, friend)
@@ -774,10 +770,9 @@ test "excludes reblogs on request" do
test "doesn't retrieve unlisted activities" do
user = insert(:user)
- {:ok, _unlisted_activity} =
- CommonAPI.post(user, %{"status" => "yeah", "visibility" => "unlisted"})
+ {:ok, _unlisted_activity} = CommonAPI.post(user, %{status: "yeah", visibility: "unlisted"})
- {:ok, listed_activity} = CommonAPI.post(user, %{"status" => "yeah"})
+ {:ok, listed_activity} = CommonAPI.post(user, %{status: "yeah"})
[activity] = ActivityPub.fetch_public_activities()
@@ -912,7 +907,7 @@ test "reverts annouce from object on error" do
describe "announcing a private object" do
test "adds an announce activity to the db if the audience is not widened" do
user = insert(:user)
- {:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
object = Object.normalize(note_activity)
{:ok, announce_activity, object} = ActivityPub.announce(user, object, nil, true, false)
@@ -926,7 +921,7 @@ test "adds an announce activity to the db if the audience is not widened" do
test "does not add an announce activity to the db if the audience is widened" do
user = insert(:user)
- {:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
object = Object.normalize(note_activity)
assert {:error, _} = ActivityPub.announce(user, object, nil, true, true)
@@ -935,7 +930,7 @@ test "does not add an announce activity to the db if the audience is widened" do
test "does not add an announce activity to the db if the announcer is not the author" do
user = insert(:user)
announcer = insert(:user)
- {:ok, note_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, note_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
object = Object.normalize(note_activity)
assert {:error, _} = ActivityPub.announce(announcer, object, nil, true, false)
@@ -956,7 +951,7 @@ test "copies the file to the configured folder" do
test "works with base64 encoded images" do
file = %{
- "img" => data_uri()
+ img: data_uri()
}
{:ok, %Object{}} = ActivityPub.upload(file)
@@ -1061,14 +1056,38 @@ test "reverts block activity on error" do
end
test "creates a block activity" do
+ clear_config([:instance, :federating], true)
blocker = insert(:user)
blocked = insert(:user)
- {:ok, activity} = ActivityPub.block(blocker, blocked)
+ with_mock Pleroma.Web.Federator,
+ publish: fn _ -> nil end do
+ {:ok, activity} = ActivityPub.block(blocker, blocked)
- assert activity.data["type"] == "Block"
- assert activity.data["actor"] == blocker.ap_id
- assert activity.data["object"] == blocked.ap_id
+ assert activity.data["type"] == "Block"
+ assert activity.data["actor"] == blocker.ap_id
+ assert activity.data["object"] == blocked.ap_id
+
+ assert called(Pleroma.Web.Federator.publish(activity))
+ end
+ end
+
+ test "works with outgoing blocks disabled, but doesn't federate" do
+ clear_config([:instance, :federating], true)
+ clear_config([:activitypub, :outgoing_blocks], false)
+ blocker = insert(:user)
+ blocked = insert(:user)
+
+ with_mock Pleroma.Web.Federator,
+ publish: fn _ -> nil end do
+ {:ok, activity} = ActivityPub.block(blocker, blocked)
+
+ assert activity.data["type"] == "Block"
+ assert activity.data["actor"] == blocker.ap_id
+ assert activity.data["object"] == blocked.ap_id
+
+ refute called(Pleroma.Web.Federator.publish(:_))
+ end
end
end
@@ -1087,23 +1106,22 @@ test "it filters broken threads" do
{:ok, user3} = User.follow(user3, user2)
assert User.following?(user3, user2)
- {:ok, public_activity} = CommonAPI.post(user3, %{"status" => "hi 1"})
+ {:ok, public_activity} = CommonAPI.post(user3, %{status: "hi 1"})
- {:ok, private_activity_1} =
- CommonAPI.post(user3, %{"status" => "hi 2", "visibility" => "private"})
+ {:ok, private_activity_1} = CommonAPI.post(user3, %{status: "hi 2", visibility: "private"})
{:ok, private_activity_2} =
CommonAPI.post(user2, %{
- "status" => "hi 3",
- "visibility" => "private",
- "in_reply_to_status_id" => private_activity_1.id
+ status: "hi 3",
+ visibility: "private",
+ in_reply_to_status_id: private_activity_1.id
})
{:ok, private_activity_3} =
CommonAPI.post(user3, %{
- "status" => "hi 4",
- "visibility" => "private",
- "in_reply_to_status_id" => private_activity_2.id
+ status: "hi 4",
+ visibility: "private",
+ in_reply_to_status_id: private_activity_2.id
})
activities =
@@ -1153,9 +1171,9 @@ test "returned pinned statuses" do
Config.put([:instance, :max_pinned_statuses], 3)
user = insert(:user)
- {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"})
- {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
- {:ok, activity_three} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity_one} = CommonAPI.post(user, %{status: "HI!!!"})
+ {:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
+ {:ok, activity_three} = CommonAPI.post(user, %{status: "HI!!!"})
CommonAPI.pin(activity_one.id, user)
user = refresh_record(user)
@@ -1176,7 +1194,7 @@ test "returned pinned statuses" do
reporter = insert(:user)
target_account = insert(:user)
content = "foobar"
- {:ok, activity} = CommonAPI.post(target_account, %{"status" => content})
+ {:ok, activity} = CommonAPI.post(target_account, %{status: content})
context = Utils.generate_context_id()
reporter_ap_id = reporter.ap_id
@@ -1272,8 +1290,7 @@ test "fetch_activities/2 returns activities addressed to a list " do
{:ok, list} = Pleroma.List.create("foo", user)
{:ok, list} = Pleroma.List.follow(list, member)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
activity = Repo.preload(activity, :bookmark)
activity = %Activity{activity | thread_muted?: !!activity.thread_muted?}
@@ -1291,8 +1308,8 @@ test "fetches private posts for followed users" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "thought I looked cute might delete later :3",
- "visibility" => "private"
+ status: "thought I looked cute might delete later :3",
+ visibility: "private"
})
[result] = ActivityPub.fetch_activities_bounded([user.follower_address], [])
@@ -1301,12 +1318,12 @@ test "fetches private posts for followed users" do
test "fetches only public posts for other users" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe", "visibility" => "public"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe", visibility: "public"})
{:ok, _private_activity} =
CommonAPI.post(user, %{
- "status" => "why is tenshi eating a corndog so cute?",
- "visibility" => "private"
+ status: "why is tenshi eating a corndog so cute?",
+ visibility: "private"
})
[result] = ActivityPub.fetch_activities_bounded([], [user.follower_address])
@@ -1434,11 +1451,11 @@ test "returns a favourite activities sorted by adds to favorite" do
other_user = insert(:user)
user1 = insert(:user)
user2 = insert(:user)
- {:ok, a1} = CommonAPI.post(user1, %{"status" => "bla"})
- {:ok, _a2} = CommonAPI.post(user2, %{"status" => "traps are happy"})
- {:ok, a3} = CommonAPI.post(user2, %{"status" => "Trees Are "})
- {:ok, a4} = CommonAPI.post(user2, %{"status" => "Agent Smith "})
- {:ok, a5} = CommonAPI.post(user1, %{"status" => "Red or Blue "})
+ {:ok, a1} = CommonAPI.post(user1, %{status: "bla"})
+ {:ok, _a2} = CommonAPI.post(user2, %{status: "traps are happy"})
+ {:ok, a3} = CommonAPI.post(user2, %{status: "Trees Are "})
+ {:ok, a4} = CommonAPI.post(user2, %{status: "Agent Smith "})
+ {:ok, a5} = CommonAPI.post(user1, %{status: "Red or Blue "})
{:ok, _} = CommonAPI.favorite(user, a4.id)
{:ok, _} = CommonAPI.favorite(other_user, a3.id)
@@ -1518,10 +1535,9 @@ test "old user must be in the new user's `also_known_as` list" do
test "doesn't retrieve replies activities with exclude_replies" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "yeah"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "yeah"})
- {:ok, _reply} =
- CommonAPI.post(user, %{"status" => "yeah", "in_reply_to_status_id" => activity.id})
+ {:ok, _reply} = CommonAPI.post(user, %{status: "yeah", in_reply_to_status_id: activity.id})
[result] = ActivityPub.fetch_public_activities(%{"exclude_replies" => "true"})
@@ -1834,84 +1850,84 @@ defp public_messages(_) do
{:ok, u2} = User.follow(u2, u3)
{:ok, u3} = User.follow(u3, u2)
- {:ok, a1} = CommonAPI.post(u1, %{"status" => "Status"})
+ {:ok, a1} = CommonAPI.post(u1, %{status: "Status"})
{:ok, r1_1} =
CommonAPI.post(u2, %{
- "status" => "@#{u1.nickname} reply from u2 to u1",
- "in_reply_to_status_id" => a1.id
+ status: "@#{u1.nickname} reply from u2 to u1",
+ in_reply_to_status_id: a1.id
})
{:ok, r1_2} =
CommonAPI.post(u3, %{
- "status" => "@#{u1.nickname} reply from u3 to u1",
- "in_reply_to_status_id" => a1.id
+ status: "@#{u1.nickname} reply from u3 to u1",
+ in_reply_to_status_id: a1.id
})
{:ok, r1_3} =
CommonAPI.post(u4, %{
- "status" => "@#{u1.nickname} reply from u4 to u1",
- "in_reply_to_status_id" => a1.id
+ status: "@#{u1.nickname} reply from u4 to u1",
+ in_reply_to_status_id: a1.id
})
- {:ok, a2} = CommonAPI.post(u2, %{"status" => "Status"})
+ {:ok, a2} = CommonAPI.post(u2, %{status: "Status"})
{:ok, r2_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u2.nickname} reply from u1 to u2",
- "in_reply_to_status_id" => a2.id
+ status: "@#{u2.nickname} reply from u1 to u2",
+ in_reply_to_status_id: a2.id
})
{:ok, r2_2} =
CommonAPI.post(u3, %{
- "status" => "@#{u2.nickname} reply from u3 to u2",
- "in_reply_to_status_id" => a2.id
+ status: "@#{u2.nickname} reply from u3 to u2",
+ in_reply_to_status_id: a2.id
})
{:ok, r2_3} =
CommonAPI.post(u4, %{
- "status" => "@#{u2.nickname} reply from u4 to u2",
- "in_reply_to_status_id" => a2.id
+ status: "@#{u2.nickname} reply from u4 to u2",
+ in_reply_to_status_id: a2.id
})
- {:ok, a3} = CommonAPI.post(u3, %{"status" => "Status"})
+ {:ok, a3} = CommonAPI.post(u3, %{status: "Status"})
{:ok, r3_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u3.nickname} reply from u1 to u3",
- "in_reply_to_status_id" => a3.id
+ status: "@#{u3.nickname} reply from u1 to u3",
+ in_reply_to_status_id: a3.id
})
{:ok, r3_2} =
CommonAPI.post(u2, %{
- "status" => "@#{u3.nickname} reply from u2 to u3",
- "in_reply_to_status_id" => a3.id
+ status: "@#{u3.nickname} reply from u2 to u3",
+ in_reply_to_status_id: a3.id
})
{:ok, r3_3} =
CommonAPI.post(u4, %{
- "status" => "@#{u3.nickname} reply from u4 to u3",
- "in_reply_to_status_id" => a3.id
+ status: "@#{u3.nickname} reply from u4 to u3",
+ in_reply_to_status_id: a3.id
})
- {:ok, a4} = CommonAPI.post(u4, %{"status" => "Status"})
+ {:ok, a4} = CommonAPI.post(u4, %{status: "Status"})
{:ok, r4_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u4.nickname} reply from u1 to u4",
- "in_reply_to_status_id" => a4.id
+ status: "@#{u4.nickname} reply from u1 to u4",
+ in_reply_to_status_id: a4.id
})
{:ok, r4_2} =
CommonAPI.post(u2, %{
- "status" => "@#{u4.nickname} reply from u2 to u4",
- "in_reply_to_status_id" => a4.id
+ status: "@#{u4.nickname} reply from u2 to u4",
+ in_reply_to_status_id: a4.id
})
{:ok, r4_3} =
CommonAPI.post(u3, %{
- "status" => "@#{u4.nickname} reply from u3 to u4",
- "in_reply_to_status_id" => a4.id
+ status: "@#{u4.nickname} reply from u3 to u4",
+ in_reply_to_status_id: a4.id
})
{:ok,
@@ -1935,68 +1951,68 @@ defp private_messages(_) do
{:ok, u2} = User.follow(u2, u3)
{:ok, u3} = User.follow(u3, u2)
- {:ok, a1} = CommonAPI.post(u1, %{"status" => "Status", "visibility" => "private"})
+ {:ok, a1} = CommonAPI.post(u1, %{status: "Status", visibility: "private"})
{:ok, r1_1} =
CommonAPI.post(u2, %{
- "status" => "@#{u1.nickname} reply from u2 to u1",
- "in_reply_to_status_id" => a1.id,
- "visibility" => "private"
+ status: "@#{u1.nickname} reply from u2 to u1",
+ in_reply_to_status_id: a1.id,
+ visibility: "private"
})
{:ok, r1_2} =
CommonAPI.post(u3, %{
- "status" => "@#{u1.nickname} reply from u3 to u1",
- "in_reply_to_status_id" => a1.id,
- "visibility" => "private"
+ status: "@#{u1.nickname} reply from u3 to u1",
+ in_reply_to_status_id: a1.id,
+ visibility: "private"
})
{:ok, r1_3} =
CommonAPI.post(u4, %{
- "status" => "@#{u1.nickname} reply from u4 to u1",
- "in_reply_to_status_id" => a1.id,
- "visibility" => "private"
+ status: "@#{u1.nickname} reply from u4 to u1",
+ in_reply_to_status_id: a1.id,
+ visibility: "private"
})
- {:ok, a2} = CommonAPI.post(u2, %{"status" => "Status", "visibility" => "private"})
+ {:ok, a2} = CommonAPI.post(u2, %{status: "Status", visibility: "private"})
{:ok, r2_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u2.nickname} reply from u1 to u2",
- "in_reply_to_status_id" => a2.id,
- "visibility" => "private"
+ status: "@#{u2.nickname} reply from u1 to u2",
+ in_reply_to_status_id: a2.id,
+ visibility: "private"
})
{:ok, r2_2} =
CommonAPI.post(u3, %{
- "status" => "@#{u2.nickname} reply from u3 to u2",
- "in_reply_to_status_id" => a2.id,
- "visibility" => "private"
+ status: "@#{u2.nickname} reply from u3 to u2",
+ in_reply_to_status_id: a2.id,
+ visibility: "private"
})
- {:ok, a3} = CommonAPI.post(u3, %{"status" => "Status", "visibility" => "private"})
+ {:ok, a3} = CommonAPI.post(u3, %{status: "Status", visibility: "private"})
{:ok, r3_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u3.nickname} reply from u1 to u3",
- "in_reply_to_status_id" => a3.id,
- "visibility" => "private"
+ status: "@#{u3.nickname} reply from u1 to u3",
+ in_reply_to_status_id: a3.id,
+ visibility: "private"
})
{:ok, r3_2} =
CommonAPI.post(u2, %{
- "status" => "@#{u3.nickname} reply from u2 to u3",
- "in_reply_to_status_id" => a3.id,
- "visibility" => "private"
+ status: "@#{u3.nickname} reply from u2 to u3",
+ in_reply_to_status_id: a3.id,
+ visibility: "private"
})
- {:ok, a4} = CommonAPI.post(u4, %{"status" => "Status", "visibility" => "private"})
+ {:ok, a4} = CommonAPI.post(u4, %{status: "Status", visibility: "private"})
{:ok, r4_1} =
CommonAPI.post(u1, %{
- "status" => "@#{u4.nickname} reply from u1 to u4",
- "in_reply_to_status_id" => a4.id,
- "visibility" => "private"
+ status: "@#{u4.nickname} reply from u1 to u4",
+ in_reply_to_status_id: a4.id,
+ visibility: "private"
})
{:ok,
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs
index f382adf3e..96eff1c30 100644
--- a/test/web/activity_pub/object_validator_test.exs
+++ b/test/web/activity_pub/object_validator_test.exs
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
describe "EmojiReacts" do
setup do
user = insert(:user)
- {:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
+ {:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
object = Pleroma.Object.get_by_ap_id(post_activity.data["object"])
@@ -53,7 +53,7 @@ test "it is not valid with a non-emoji content field", %{valid_emoji_react: vali
describe "Undos" do
setup do
user = insert(:user)
- {:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
+ {:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
{:ok, like} = CommonAPI.favorite(user, post_activity.id)
{:ok, valid_like_undo, []} = Builder.undo(user, like)
@@ -93,7 +93,7 @@ test "it does not validate if the object is missing", %{valid_like_undo: valid_l
describe "deletes" do
setup do
user = insert(:user)
- {:ok, post_activity} = CommonAPI.post(user, %{"status" => "cancel me daddy"})
+ {:ok, post_activity} = CommonAPI.post(user, %{status: "cancel me daddy"})
{:ok, valid_post_delete, _} = Builder.delete(user, post_activity.data["object"])
{:ok, valid_user_delete, _} = Builder.delete(user, user.ap_id)
@@ -185,7 +185,7 @@ test "it's valid if the actor of the object is a local superuser",
describe "likes" do
setup do
user = insert(:user)
- {:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
+ {:ok, post_activity} = CommonAPI.post(user, %{status: "uguu"})
valid_like = %{
"to" => [user.ap_id],
diff --git a/test/web/activity_pub/side_effects_test.exs b/test/web/activity_pub/side_effects_test.exs
index b29a7a7be..797f00d08 100644
--- a/test/web/activity_pub/side_effects_test.exs
+++ b/test/web/activity_pub/side_effects_test.exs
@@ -25,17 +25,58 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
user = insert(:user)
other_user = insert(:user)
- {:ok, op} = CommonAPI.post(other_user, %{"status" => "big oof"})
- {:ok, post} = CommonAPI.post(user, %{"status" => "hey", "in_reply_to_id" => op})
+ {:ok, op} = CommonAPI.post(other_user, %{status: "big oof"})
+ {:ok, post} = CommonAPI.post(user, %{status: "hey", in_reply_to_id: op})
+ {:ok, favorite} = CommonAPI.favorite(user, post.id)
object = Object.normalize(post)
{:ok, delete_data, _meta} = Builder.delete(user, object.data["id"])
{:ok, delete_user_data, _meta} = Builder.delete(user, user.ap_id)
{:ok, delete, _meta} = ActivityPub.persist(delete_data, local: true)
{:ok, delete_user, _meta} = ActivityPub.persist(delete_user_data, local: true)
- %{user: user, delete: delete, post: post, object: object, delete_user: delete_user, op: op}
+
+ %{
+ user: user,
+ delete: delete,
+ post: post,
+ object: object,
+ delete_user: delete_user,
+ op: op,
+ favorite: favorite
+ }
end
test "it handles object deletions", %{
+ delete: delete,
+ post: post,
+ object: object,
+ user: user,
+ op: op,
+ favorite: favorite
+ } do
+ with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough],
+ stream_out: fn _ -> nil end,
+ stream_out_participations: fn _, _ -> nil end do
+ {:ok, delete, _} = SideEffects.handle(delete)
+ user = User.get_cached_by_ap_id(object.data["actor"])
+
+ assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(delete))
+ assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out_participations(object, user))
+ end
+
+ object = Object.get_by_id(object.id)
+ assert object.data["type"] == "Tombstone"
+ refute Activity.get_by_id(post.id)
+ refute Activity.get_by_id(favorite.id)
+
+ user = User.get_by_id(user.id)
+ assert user.note_count == 0
+
+ object = Object.normalize(op.data["object"], false)
+
+ assert object.data["repliesCount"] == 0
+ end
+
+ test "it handles object deletions when the object itself has been pruned", %{
delete: delete,
post: post,
object: object,
@@ -77,7 +118,7 @@ test "it handles user deletions", %{delete_user: delete, user: user} do
poster = insert(:user)
user = insert(:user)
- {:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
+ {:ok, post} = CommonAPI.post(poster, %{status: "hey"})
{:ok, emoji_react_data, []} = Builder.emoji_react(user, post.object, "👌")
{:ok, emoji_react, _meta} = ActivityPub.persist(emoji_react_data, local: true)
@@ -103,7 +144,7 @@ test "creates a notification", %{emoji_react: emoji_react, poster: poster} do
setup do
poster = insert(:user)
user = insert(:user)
- {:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
+ {:ok, post} = CommonAPI.post(poster, %{status: "hey"})
{:ok, like} = CommonAPI.favorite(user, post.id)
{:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍")
{:ok, announce, _} = CommonAPI.repeat(post.id, user)
@@ -203,7 +244,7 @@ test "deletes the original like", %{like_undo: like_undo, like: like} do
setup do
poster = insert(:user)
user = insert(:user)
- {:ok, post} = CommonAPI.post(poster, %{"status" => "hey"})
+ {:ok, post} = CommonAPI.post(poster, %{status: "hey"})
{:ok, like_data, _meta} = Builder.like(user, post.object)
{:ok, like, _meta} = ActivityPub.persist(like_data, local: true)
diff --git a/test/web/activity_pub/transmogrifier/delete_handling_test.exs b/test/web/activity_pub/transmogrifier/delete_handling_test.exs
index f235a8e63..c9a53918c 100644
--- a/test/web/activity_pub/transmogrifier/delete_handling_test.exs
+++ b/test/web/activity_pub/transmogrifier/delete_handling_test.exs
@@ -44,6 +44,34 @@ test "it works for incoming deletes" do
assert object.data["type"] == "Tombstone"
end
+ test "it works for incoming when the object has been pruned" do
+ activity = insert(:note_activity)
+
+ {:ok, object} =
+ Object.normalize(activity.data["object"])
+ |> Repo.delete()
+
+ Cachex.del(:object_cache, "object:#{object.data["id"]}")
+
+ deleting_user = insert(:user)
+
+ data =
+ File.read!("test/fixtures/mastodon-delete.json")
+ |> Poison.decode!()
+ |> Map.put("actor", deleting_user.ap_id)
+ |> put_in(["object", "id"], activity.data["object"])
+
+ {:ok, %Activity{actor: actor, local: false, data: %{"id" => id}}} =
+ Transmogrifier.handle_incoming(data)
+
+ assert id == data["id"]
+
+ # We delete the Create activity because we base our timelines on it.
+ # This should be changed after we unify objects and activities
+ refute Activity.get_by_id(activity.id)
+ assert actor == deleting_user.ap_id
+ end
+
test "it fails for incoming deletes with spoofed origin" do
activity = insert(:note_activity)
%{ap_id: ap_id} = insert(:user, ap_id: "https://gensokyo.2hu/users/raymoo")
diff --git a/test/web/activity_pub/transmogrifier/emoji_react_handling_test.exs b/test/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
index 6988e3e0a..0fb056b50 100644
--- a/test/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
+++ b/test/web/activity_pub/transmogrifier/emoji_react_handling_test.exs
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
test "it works for incoming emoji reactions" do
user = insert(:user)
other_user = insert(:user, local: false)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
data =
File.read!("test/fixtures/emoji-reaction.json")
@@ -40,7 +40,7 @@ test "it works for incoming emoji reactions" do
test "it reject invalid emoji reactions" do
user = insert(:user)
other_user = insert(:user, local: false)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
data =
File.read!("test/fixtures/emoji-reaction-too-long.json")
diff --git a/test/web/activity_pub/transmogrifier/like_handling_test.exs b/test/web/activity_pub/transmogrifier/like_handling_test.exs
index 54a5c1dbc..53fe1d550 100644
--- a/test/web/activity_pub/transmogrifier/like_handling_test.exs
+++ b/test/web/activity_pub/transmogrifier/like_handling_test.exs
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
test "it works for incoming likes" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
data =
File.read!("test/fixtures/mastodon-like.json")
@@ -36,7 +36,7 @@ test "it works for incoming likes" do
test "it works for incoming misskey likes, turning them into EmojiReacts" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
data =
File.read!("test/fixtures/misskey-like.json")
@@ -57,7 +57,7 @@ test "it works for incoming misskey likes, turning them into EmojiReacts" do
test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReacts" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
data =
File.read!("test/fixtures/misskey-like.json")
diff --git a/test/web/activity_pub/transmogrifier/undo_handling_test.exs b/test/web/activity_pub/transmogrifier/undo_handling_test.exs
index eaf58adf7..01dd6c370 100644
--- a/test/web/activity_pub/transmogrifier/undo_handling_test.exs
+++ b/test/web/activity_pub/transmogrifier/undo_handling_test.exs
@@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
test "it works for incoming emoji reaction undos" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hello"})
{:ok, reaction_activity} = CommonAPI.react_with_emoji(activity.id, user, "👌")
data =
@@ -34,7 +34,7 @@ test "it works for incoming emoji reaction undos" do
test "it returns an error for incoming unlikes wihout a like activity" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
data =
File.read!("test/fixtures/mastodon-undo-like.json")
@@ -46,7 +46,7 @@ test "it returns an error for incoming unlikes wihout a like activity" do
test "it works for incoming unlikes with an existing like activity" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
like_data =
File.read!("test/fixtures/mastodon-like.json")
@@ -77,7 +77,7 @@ test "it works for incoming unlikes with an existing like activity" do
test "it works for incoming unlikes with an existing like activity and a compact object" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "leave a like pls"})
like_data =
File.read!("test/fixtures/mastodon-like.json")
@@ -104,7 +104,7 @@ test "it works for incoming unlikes with an existing like activity and a compact
test "it works for incoming unannounces with an existing notice" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
announce_data =
File.read!("test/fixtures/mastodon-announce.json")
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 2914c90ea..0a54e3bb9 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -212,8 +212,8 @@ test "it rewrites Note votes to Answers and increments vote counters on question
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "suya...",
- "poll" => %{"options" => ["suya", "suya.", "suya.."], "expires_in" => 10}
+ status: "suya...",
+ poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
})
object = Object.normalize(activity)
@@ -260,6 +260,24 @@ test "it works for incoming notices with to/cc not being an array (kroeg)" do
"henlo from my Psion netBook
message sent from my Psion netBook
"
end
+ test "it works for incoming honk announces" do
+ _user = insert(:user, ap_id: "https://honktest/u/test", local: false)
+ other_user = insert(:user)
+ {:ok, post} = CommonAPI.post(other_user, %{status: "bonkeronk"})
+
+ announce = %{
+ "@context" => "https://www.w3.org/ns/activitystreams",
+ "actor" => "https://honktest/u/test",
+ "id" => "https://honktest/u/test/bonk/1793M7B9MQ48847vdx",
+ "object" => post.data["object"],
+ "published" => "2019-06-25T19:33:58Z",
+ "to" => "https://www.w3.org/ns/activitystreams#Public",
+ "type" => "Announce"
+ }
+
+ {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(announce)
+ end
+
test "it works for incoming announces with actor being inlined (kroeg)" do
data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Poison.decode!()
@@ -344,7 +362,7 @@ test "it works for incoming announces" do
test "it works for incoming announces with an existing activity" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
data =
File.read!("test/fixtures/mastodon-announce.json")
@@ -394,7 +412,7 @@ test "it rejects incoming announces with an inlined activity from another origin
test "it does not clobber the addressing on announce activities" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
data =
File.read!("test/fixtures/mastodon-announce.json")
@@ -480,7 +498,7 @@ test "it strips internal likes" do
test "it strips internal reactions" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "📢")
%{object: object} = Activity.get_by_id_with_object(activity.id)
@@ -815,6 +833,12 @@ test "it works for incoming accepts which are referenced by IRI only" do
follower = User.get_cached_by_id(follower.id)
assert User.following?(follower, followed) == true
+
+ follower = User.get_by_id(follower.id)
+ assert follower.following_count == 1
+
+ followed = User.get_by_id(followed.id)
+ assert followed.follower_count == 1
end
test "it fails for incoming accepts which cannot be correlated" do
@@ -972,7 +996,7 @@ test "it accepts Flag activities" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test post"})
object = Object.normalize(activity)
note_obj = %{
@@ -1116,13 +1140,13 @@ test "does NOT schedule background fetching of `replies` beyond max thread depth
setup do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "post1"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "post1"})
{:ok, reply1} =
- CommonAPI.post(user, %{"status" => "reply1", "in_reply_to_status_id" => activity.id})
+ CommonAPI.post(user, %{status: "reply1", in_reply_to_status_id: activity.id})
{:ok, reply2} =
- CommonAPI.post(user, %{"status" => "reply2", "in_reply_to_status_id" => activity.id})
+ CommonAPI.post(user, %{status: "reply2", in_reply_to_status_id: activity.id})
replies_uris = Enum.map([reply1, reply2], fn a -> a.object.data["id"] end)
@@ -1162,7 +1186,7 @@ test "does NOT schedule background fetching of `replies` beyond max thread depth
test "it inlines private announced objects" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey", "visibility" => "private"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey", visibility: "private"})
{:ok, announce_activity, _} = CommonAPI.repeat(activity.id, user)
@@ -1177,7 +1201,7 @@ test "it turns mentions into tags" do
other_user = insert(:user)
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "hey, @#{other_user.nickname}, how are ya? #2hu"})
+ CommonAPI.post(user, %{status: "hey, @#{other_user.nickname}, how are ya? #2hu"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
object = modified["object"]
@@ -1201,7 +1225,7 @@ test "it turns mentions into tags" do
test "it adds the sensitive property" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#nsfw hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#nsfw hey"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
assert modified["object"]["sensitive"]
@@ -1210,7 +1234,7 @@ test "it adds the sensitive property" do
test "it adds the json-ld context and the conversation property" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
assert modified["@context"] ==
@@ -1222,7 +1246,7 @@ test "it adds the json-ld context and the conversation property" do
test "it sets the 'attributedTo' property to the actor of the object if it doesn't have one" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
@@ -1231,7 +1255,7 @@ test "it sets the 'attributedTo' property to the actor of the object if it doesn
test "it strips internal hashtag data" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#2hu"})
expected_tag = %{
"href" => Pleroma.Web.Endpoint.url() <> "/tags/2hu",
@@ -1247,7 +1271,7 @@ test "it strips internal hashtag data" do
test "it strips internal fields" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu :firefox:"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#2hu :firefox:"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
@@ -1279,14 +1303,13 @@ test "the directMessage flag is present" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "2hu :moominmamma:"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "2hu :moominmamma:"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
assert modified["directMessage"] == false
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "@#{other_user.nickname} :moominmamma:"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "@#{other_user.nickname} :moominmamma:"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
@@ -1294,8 +1317,8 @@ test "the directMessage flag is present" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "@#{other_user.nickname} :moominmamma:",
- "visibility" => "direct"
+ status: "@#{other_user.nickname} :moominmamma:",
+ visibility: "direct"
})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
@@ -1307,8 +1330,7 @@ test "it strips BCC field" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
@@ -1343,8 +1365,8 @@ test "it upgrades a user to activitypub" do
user_two = insert(:user)
Pleroma.FollowingRelationship.follow(user_two, user, :follow_accept)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
- {:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test"})
+ {:ok, unrelated_activity} = CommonAPI.post(user_two, %{status: "test"})
assert "http://localhost:4001/users/rye@niu.moe/followers" in activity.recipients
user = User.get_cached_by_id(user.id)
@@ -1510,8 +1532,8 @@ test "Rewrites Answers to Notes" do
{:ok, poll_activity} =
CommonAPI.post(user, %{
- "status" => "suya...",
- "poll" => %{"options" => ["suya", "suya.", "suya.."], "expires_in" => 10}
+ status: "suya...",
+ poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
})
poll_object = Object.normalize(poll_activity)
@@ -1854,28 +1876,27 @@ test "returns unmodified object if activity doesn't have self-replies" do
test "sets `replies` collection with a limited number of self-replies" do
[user, another_user] = insert_list(2, :user)
- {:ok, %{id: id1} = activity} = CommonAPI.post(user, %{"status" => "1"})
+ {:ok, %{id: id1} = activity} = CommonAPI.post(user, %{status: "1"})
{:ok, %{id: id2} = self_reply1} =
- CommonAPI.post(user, %{"status" => "self-reply 1", "in_reply_to_status_id" => id1})
+ CommonAPI.post(user, %{status: "self-reply 1", in_reply_to_status_id: id1})
{:ok, self_reply2} =
- CommonAPI.post(user, %{"status" => "self-reply 2", "in_reply_to_status_id" => id1})
+ CommonAPI.post(user, %{status: "self-reply 2", in_reply_to_status_id: id1})
# Assuming to _not_ be present in `replies` due to :note_replies_output_limit is set to 2
- {:ok, _} =
- CommonAPI.post(user, %{"status" => "self-reply 3", "in_reply_to_status_id" => id1})
+ {:ok, _} = CommonAPI.post(user, %{status: "self-reply 3", in_reply_to_status_id: id1})
{:ok, _} =
CommonAPI.post(user, %{
- "status" => "self-reply to self-reply",
- "in_reply_to_status_id" => id2
+ status: "self-reply to self-reply",
+ in_reply_to_status_id: id2
})
{:ok, _} =
CommonAPI.post(another_user, %{
- "status" => "another user's reply",
- "in_reply_to_status_id" => id1
+ status: "another user's reply",
+ in_reply_to_status_id: id1
})
object = Object.normalize(activity)
diff --git a/test/web/activity_pub/utils_test.exs b/test/web/activity_pub/utils_test.exs
index b8d811c73..9e0a0f1c4 100644
--- a/test/web/activity_pub/utils_test.exs
+++ b/test/web/activity_pub/utils_test.exs
@@ -120,7 +120,7 @@ test "addresses actor's follower address if the activity is public", %{
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"hey @#{other_user.nickname}, @#{third_user.nickname} how about beering together this weekend?"
})
@@ -139,8 +139,8 @@ test "does not adress actor's follower address if the activity is not public", %
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "@#{other_user.nickname} @#{third_user.nickname} bought a new swimsuit!",
- "visibility" => "private"
+ status: "@#{other_user.nickname} @#{third_user.nickname} bought a new swimsuit!",
+ visibility: "private"
})
%{"to" => to, "cc" => cc} = Utils.make_like_data(other_user, activity, nil)
@@ -168,11 +168,11 @@ test "fetches existing votes" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "How do I pronounce LaTeX?",
- "poll" => %{
- "options" => ["laytekh", "lahtekh", "latex"],
- "expires_in" => 20,
- "multiple" => true
+ status: "How do I pronounce LaTeX?",
+ poll: %{
+ options: ["laytekh", "lahtekh", "latex"],
+ expires_in: 20,
+ multiple: true
}
})
@@ -187,10 +187,10 @@ test "fetches only Create activities" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Are we living in a society?",
- "poll" => %{
- "options" => ["yes", "no"],
- "expires_in" => 20
+ status: "Are we living in a society?",
+ poll: %{
+ options: ["yes", "no"],
+ expires_in: 20
}
})
@@ -469,7 +469,7 @@ test "returns empty map when params is invalid" do
test "returns map with Flag object" do
reporter = insert(:user)
target_account = insert(:user)
- {:ok, activity} = CommonAPI.post(target_account, %{"status" => "foobar"})
+ {:ok, activity} = CommonAPI.post(target_account, %{status: "foobar"})
context = Utils.generate_context_id()
content = "foobar"
diff --git a/test/web/activity_pub/views/object_view_test.exs b/test/web/activity_pub/views/object_view_test.exs
index 6c006206b..43f0617f0 100644
--- a/test/web/activity_pub/views/object_view_test.exs
+++ b/test/web/activity_pub/views/object_view_test.exs
@@ -44,7 +44,7 @@ test "renders `replies` collection for a note activity" do
activity = insert(:note_activity, user: user)
{:ok, self_reply1} =
- CommonAPI.post(user, %{"status" => "self-reply 1", "in_reply_to_status_id" => activity.id})
+ CommonAPI.post(user, %{status: "self-reply 1", in_reply_to_status_id: activity.id})
replies_uris = [self_reply1.object.data["id"]]
result = ObjectView.render("object.json", %{object: refresh_record(activity)})
diff --git a/test/web/activity_pub/views/user_view_test.exs b/test/web/activity_pub/views/user_view_test.exs
index 8d00893a5..20b0f223c 100644
--- a/test/web/activity_pub/views/user_view_test.exs
+++ b/test/web/activity_pub/views/user_view_test.exs
@@ -164,7 +164,7 @@ test "activity collection page aginates correctly" do
posts =
for i <- 0..25 do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "post #{i}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "post #{i}"})
activity
end
diff --git a/test/web/activity_pub/visibilty_test.exs b/test/web/activity_pub/visibilty_test.exs
index 5b91630d4..8e9354c65 100644
--- a/test/web/activity_pub/visibilty_test.exs
+++ b/test/web/activity_pub/visibilty_test.exs
@@ -21,21 +21,21 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
Pleroma.List.follow(list, unrelated)
{:ok, public} =
- CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "public"})
+ CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "public"})
{:ok, private} =
- CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "private"})
+ CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "private"})
{:ok, direct} =
- CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "direct"})
{:ok, unlisted} =
- CommonAPI.post(user, %{"status" => "@#{mentioned.nickname}", "visibility" => "unlisted"})
+ CommonAPI.post(user, %{status: "@#{mentioned.nickname}", visibility: "unlisted"})
{:ok, list} =
CommonAPI.post(user, %{
- "status" => "@#{mentioned.nickname}",
- "visibility" => "list:#{list.id}"
+ status: "@#{mentioned.nickname}",
+ visibility: "list:#{list.id}"
})
%{
diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs
index 4697af50e..9b7120712 100644
--- a/test/web/admin_api/admin_api_controller_test.exs
+++ b/test/web/admin_api/admin_api_controller_test.exs
@@ -1747,7 +1747,7 @@ test "toggle sensitive flag", %{conn: conn, id: id, admin: admin} do
test "change visibility flag", %{conn: conn, id: id, admin: admin} do
response =
conn
- |> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "public"})
+ |> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "public"})
|> json_response(:ok)
assert response["visibility"] == "public"
@@ -1759,21 +1759,21 @@ test "change visibility flag", %{conn: conn, id: id, admin: admin} do
response =
conn
- |> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "private"})
+ |> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "private"})
|> json_response(:ok)
assert response["visibility"] == "private"
response =
conn
- |> put("/api/pleroma/admin/statuses/#{id}", %{"visibility" => "unlisted"})
+ |> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "unlisted"})
|> json_response(:ok)
assert response["visibility"] == "unlisted"
end
test "returns 400 when visibility is unknown", %{conn: conn, id: id} do
- conn = put(conn, "/api/pleroma/admin/statuses/#{id}", %{"visibility" => "test"})
+ conn = put(conn, "/api/pleroma/admin/statuses/#{id}", %{visibility: "test"})
assert json_response(conn, :bad_request) == "Unsupported visibility"
end
@@ -2862,26 +2862,25 @@ test "proxy tuple localhost", %{conn: conn} do
group: ":pleroma",
key: ":http",
value: [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
+ %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]}
]
}
]
})
- assert json_response(conn, 200) == %{
+ assert %{
"configs" => [
%{
"group" => ":pleroma",
"key" => ":http",
- "value" => [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
- ],
- "db" => [":proxy_url", ":send_user_agent"]
+ "value" => value,
+ "db" => db
}
]
- }
+ } = json_response(conn, 200)
+
+ assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]} in value
+ assert ":proxy_url" in db
end
test "proxy tuple domain", %{conn: conn} do
@@ -2892,26 +2891,25 @@ test "proxy tuple domain", %{conn: conn} do
group: ":pleroma",
key: ":http",
value: [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
+ %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]}
]
}
]
})
- assert json_response(conn, 200) == %{
+ assert %{
"configs" => [
%{
"group" => ":pleroma",
"key" => ":http",
- "value" => [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
- ],
- "db" => [":proxy_url", ":send_user_agent"]
+ "value" => value,
+ "db" => db
}
]
- }
+ } = json_response(conn, 200)
+
+ assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]} in value
+ assert ":proxy_url" in db
end
test "proxy tuple ip", %{conn: conn} do
@@ -2922,26 +2920,52 @@ test "proxy tuple ip", %{conn: conn} do
group: ":pleroma",
key: ":http",
value: [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
+ %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]}
]
}
]
})
- assert json_response(conn, 200) == %{
+ assert %{
"configs" => [
%{
"group" => ":pleroma",
"key" => ":http",
- "value" => [
- %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]},
- %{"tuple" => [":send_user_agent", false]}
- ],
- "db" => [":proxy_url", ":send_user_agent"]
+ "value" => value,
+ "db" => db
}
]
- }
+ } = json_response(conn, 200)
+
+ assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]} in value
+ assert ":proxy_url" in db
+ end
+
+ test "doesn't set keys not in the whitelist", %{conn: conn} do
+ clear_config(:database_config_whitelist, [
+ {:pleroma, :key1},
+ {:pleroma, :key2},
+ {:pleroma, Pleroma.Captcha.NotReal},
+ {:not_real}
+ ])
+
+ post(conn, "/api/pleroma/admin/config", %{
+ configs: [
+ %{group: ":pleroma", key: ":key1", value: "value1"},
+ %{group: ":pleroma", key: ":key2", value: "value2"},
+ %{group: ":pleroma", key: ":key3", value: "value3"},
+ %{group: ":pleroma", key: "Pleroma.Web.Endpoint.NotReal", value: "value4"},
+ %{group: ":pleroma", key: "Pleroma.Captcha.NotReal", value: "value5"},
+ %{group: ":not_real", key: ":anything", value: "value6"}
+ ]
+ })
+
+ assert Application.get_env(:pleroma, :key1) == "value1"
+ assert Application.get_env(:pleroma, :key2) == "value2"
+ assert Application.get_env(:pleroma, :key3) == nil
+ assert Application.get_env(:pleroma, Pleroma.Web.Endpoint.NotReal) == nil
+ assert Application.get_env(:pleroma, Pleroma.Captcha.NotReal) == "value5"
+ assert Application.get_env(:not_real, :anything) == "value6"
end
end
@@ -2977,13 +3001,12 @@ test "returns all public and unlisted statuses", %{conn: conn, admin: admin} do
user = insert(:user)
User.block(admin, blocked)
- {:ok, _} =
- CommonAPI.post(user, %{"status" => "@#{admin.nickname}", "visibility" => "direct"})
+ {:ok, _} = CommonAPI.post(user, %{status: "@#{admin.nickname}", visibility: "direct"})
- {:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
- {:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
- {:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
- {:ok, _} = CommonAPI.post(blocked, %{"status" => ".", "visibility" => "public"})
+ {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
+ {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "private"})
+ {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"})
+ {:ok, _} = CommonAPI.post(blocked, %{status: ".", visibility: "public"})
response =
conn
@@ -3011,11 +3034,10 @@ test "returns only local statuses with local_only on", %{conn: conn} do
test "returns private and direct statuses with godmode on", %{conn: conn, admin: admin} do
user = insert(:user)
- {:ok, _} =
- CommonAPI.post(user, %{"status" => "@#{admin.nickname}", "visibility" => "direct"})
+ {:ok, _} = CommonAPI.post(user, %{status: "@#{admin.nickname}", visibility: "direct"})
- {:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
- {:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
+ {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "private"})
+ {:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"})
conn = get(conn, "/api/pleroma/admin/statuses?godmode=true")
assert json_response(conn, 200) |> length() == 3
end
@@ -3049,11 +3071,9 @@ test "renders user's statuses with a limit", %{conn: conn, user: user} do
end
test "doesn't return private statuses by default", %{conn: conn, user: user} do
- {:ok, _private_status} =
- CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
+ {:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
- {:ok, _public_status} =
- CommonAPI.post(user, %{"status" => "public", "visibility" => "public"})
+ {:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses")
@@ -3061,11 +3081,9 @@ test "doesn't return private statuses by default", %{conn: conn, user: user} do
end
test "returns private statuses with godmode on", %{conn: conn, user: user} do
- {:ok, _private_status} =
- CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
+ {:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
- {:ok, _public_status} =
- CommonAPI.post(user, %{"status" => "public", "visibility" => "public"})
+ {:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses?godmode=true")
@@ -3074,7 +3092,7 @@ test "returns private statuses with godmode on", %{conn: conn, user: user} do
test "excludes reblogs by default", %{conn: conn, user: user} do
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "."})
+ {:ok, activity} = CommonAPI.post(user, %{status: "."})
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, other_user)
conn_res = get(conn, "/api/pleroma/admin/users/#{other_user.nickname}/statuses")
@@ -3580,28 +3598,63 @@ test "it deletes the note", %{conn: conn, report_id: report_id} do
end
end
- test "GET /api/pleroma/admin/config/descriptions", %{conn: conn} do
- admin = insert(:user, is_admin: true)
+ describe "GET /api/pleroma/admin/config/descriptions" do
+ test "structure", %{conn: conn} do
+ admin = insert(:user, is_admin: true)
- conn =
- assign(conn, :user, admin)
- |> get("/api/pleroma/admin/config/descriptions")
+ conn =
+ assign(conn, :user, admin)
+ |> get("/api/pleroma/admin/config/descriptions")
- assert [child | _others] = json_response(conn, 200)
+ assert [child | _others] = json_response(conn, 200)
- assert child["children"]
- assert child["key"]
- assert String.starts_with?(child["group"], ":")
- assert child["description"]
+ assert child["children"]
+ assert child["key"]
+ assert String.starts_with?(child["group"], ":")
+ assert child["description"]
+ end
+
+ test "filters by database configuration whitelist", %{conn: conn} do
+ clear_config(:database_config_whitelist, [
+ {:pleroma, :instance},
+ {:pleroma, :activitypub},
+ {:pleroma, Pleroma.Upload},
+ {:esshd}
+ ])
+
+ admin = insert(:user, is_admin: true)
+
+ conn =
+ assign(conn, :user, admin)
+ |> get("/api/pleroma/admin/config/descriptions")
+
+ children = json_response(conn, 200)
+
+ assert length(children) == 4
+
+ assert Enum.count(children, fn c -> c["group"] == ":pleroma" end) == 3
+
+ instance = Enum.find(children, fn c -> c["key"] == ":instance" end)
+ assert instance["children"]
+
+ activitypub = Enum.find(children, fn c -> c["key"] == ":activitypub" end)
+ assert activitypub["children"]
+
+ web_endpoint = Enum.find(children, fn c -> c["key"] == "Pleroma.Upload" end)
+ assert web_endpoint["children"]
+
+ esshd = Enum.find(children, fn c -> c["group"] == ":esshd" end)
+ assert esshd["children"]
+ end
end
describe "/api/pleroma/admin/stats" do
test "status visibility count", %{conn: conn} do
admin = insert(:user, is_admin: true)
user = insert(:user)
- CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
- CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
- CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
+ CommonAPI.post(user, %{visibility: "public", status: "hey"})
+ CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
+ CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
response =
conn
diff --git a/test/web/admin_api/views/report_view_test.exs b/test/web/admin_api/views/report_view_test.exs
index 8cfa1dcfa..f00b0afb2 100644
--- a/test/web/admin_api/views/report_view_test.exs
+++ b/test/web/admin_api/views/report_view_test.exs
@@ -45,7 +45,7 @@ test "renders a report" do
test "includes reported statuses" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "toot"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "toot"})
{:ok, report_activity} =
CommonAPI.report(user, %{account_id: other_user.id, status_ids: [activity.id]})
diff --git a/test/web/auth/basic_auth_test.exs b/test/web/auth/basic_auth_test.exs
index 64f8a6863..bf6e3d2fc 100644
--- a/test/web/auth/basic_auth_test.exs
+++ b/test/web/auth/basic_auth_test.exs
@@ -11,7 +11,7 @@ test "with HTTP Basic Auth used, grants access to OAuth scope-restricted endpoin
conn: conn
} do
user = insert(:user)
- assert Comeonin.Pbkdf2.checkpw("test", user.password_hash)
+ assert Pbkdf2.verify_pass("test", user.password_hash)
basic_auth_contents =
(URI.encode_www_form(user.nickname) <> ":" <> URI.encode_www_form("test"))
diff --git a/test/web/auth/pleroma_authenticator_test.exs b/test/web/auth/pleroma_authenticator_test.exs
index 7125c5081..5a421e5ed 100644
--- a/test/web/auth/pleroma_authenticator_test.exs
+++ b/test/web/auth/pleroma_authenticator_test.exs
@@ -11,7 +11,7 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticatorTest do
setup do
password = "testpassword"
name = "AgentSmith"
- user = insert(:user, nickname: name, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ user = insert(:user, nickname: name, password_hash: Pbkdf2.hash_pwd_salt(password))
{:ok, [user: user, name: name, password: password]}
end
diff --git a/test/web/auth/totp_authenticator_test.exs b/test/web/auth/totp_authenticator_test.exs
index e08069490..e502e0ae8 100644
--- a/test/web/auth/totp_authenticator_test.exs
+++ b/test/web/auth/totp_authenticator_test.exs
@@ -34,7 +34,7 @@ test "checks backup codes" do
hashed_codes =
backup_codes
- |> Enum.map(&Comeonin.Pbkdf2.hashpwsalt(&1))
+ |> Enum.map(&Pbkdf2.hash_pwd_salt(&1))
user =
insert(:user,
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 2fd17a1b8..26e41c313 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -24,10 +24,28 @@ defmodule Pleroma.Web.CommonAPITest do
setup do: clear_config([:instance, :max_pinned_statuses])
describe "deletion" do
+ test "it works with pruned objects" do
+ user = insert(:user)
+
+ {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
+
+ Object.normalize(post, false)
+ |> Object.prune()
+
+ with_mock Pleroma.Web.Federator,
+ publish: fn _ -> nil end do
+ assert {:ok, delete} = CommonAPI.delete(post.id, user)
+ assert delete.local
+ assert called(Pleroma.Web.Federator.publish(delete))
+ end
+
+ refute Activity.get_by_id(post.id)
+ end
+
test "it allows users to delete their posts" do
user = insert(:user)
- {:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
+ {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
with_mock Pleroma.Web.Federator,
publish: fn _ -> nil end do
@@ -43,7 +61,7 @@ test "it does not allow a user to delete their posts" do
user = insert(:user)
other_user = insert(:user)
- {:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
+ {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
assert {:error, "Could not delete"} = CommonAPI.delete(post.id, other_user)
assert Activity.get_by_id(post.id)
@@ -53,7 +71,7 @@ test "it allows moderators to delete other user's posts" do
user = insert(:user)
moderator = insert(:user, is_moderator: true)
- {:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
+ {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
assert delete.local
@@ -65,7 +83,7 @@ test "it allows admins to delete other user's posts" do
user = insert(:user)
moderator = insert(:user, is_admin: true)
- {:ok, post} = CommonAPI.post(user, %{"status" => "namu amida butsu"})
+ {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
assert delete.local
@@ -106,7 +124,7 @@ test "favoriting race condition" do
users_serial = insert_list(10, :user)
users = insert_list(10, :user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "."})
+ {:ok, activity} = CommonAPI.post(user, %{status: "."})
users_serial
|> Enum.map(fn user ->
@@ -133,7 +151,7 @@ test "repeating race condition" do
users_serial = insert_list(10, :user)
users = insert_list(10, :user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "."})
+ {:ok, activity} = CommonAPI.post(user, %{status: "."})
users_serial
|> Enum.map(fn user ->
@@ -157,12 +175,12 @@ test "repeating race condition" do
test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
[participation] = Participation.for_user(user)
{:ok, convo_reply} =
- CommonAPI.post(user, %{"status" => ".", "in_reply_to_conversation_id" => participation.id})
+ CommonAPI.post(user, %{status: ".", in_reply_to_conversation_id: participation.id})
assert Visibility.is_direct?(convo_reply)
@@ -176,8 +194,8 @@ test "when replying to a conversation / participation, it only mentions the reci
{:ok, activity} =
CommonAPI.post(har, %{
- "status" => "@#{jafnhar.nickname} hey",
- "visibility" => "direct"
+ status: "@#{jafnhar.nickname} hey",
+ visibility: "direct"
})
assert har.ap_id in activity.recipients
@@ -187,10 +205,10 @@ test "when replying to a conversation / participation, it only mentions the reci
{:ok, activity} =
CommonAPI.post(har, %{
- "status" => "I don't really like @#{tridi.nickname}",
- "visibility" => "direct",
- "in_reply_to_status_id" => activity.id,
- "in_reply_to_conversation_id" => participation.id
+ status: "I don't really like @#{tridi.nickname}",
+ visibility: "direct",
+ in_reply_to_status_id: activity.id,
+ in_reply_to_conversation_id: participation.id
})
assert har.ap_id in activity.recipients
@@ -207,8 +225,8 @@ test "with the safe_dm_mention option set, it does not mention people beyond the
{:ok, activity} =
CommonAPI.post(har, %{
- "status" => "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
- "visibility" => "direct"
+ status: "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
+ visibility: "direct"
})
refute tridi.ap_id in activity.recipients
@@ -217,7 +235,7 @@ test "with the safe_dm_mention option set, it does not mention people beyond the
test "it de-duplicates tags" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu #2HU"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#2hu #2HU"})
object = Object.normalize(activity)
@@ -226,7 +244,7 @@ test "it de-duplicates tags" do
test "it adds emoji in the object" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ":firefox:"})
+ {:ok, activity} = CommonAPI.post(user, %{status: ":firefox:"})
assert Object.normalize(activity).data["emoji"]["firefox"]
end
@@ -240,9 +258,9 @@ test "it supports explicit addressing" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Hey, I think @#{user_three.nickname} is ugly. @#{user_four.nickname} is alright though.",
- "to" => [user_two.nickname, user_four.nickname, "nonexistent"]
+ to: [user_two.nickname, user_four.nickname, "nonexistent"]
})
assert user.ap_id in activity.recipients
@@ -258,8 +276,8 @@ test "it filters out obviously bad tags when accepting a post as HTML" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => post,
- "content_type" => "text/html"
+ status: post,
+ content_type: "text/html"
})
object = Object.normalize(activity)
@@ -274,8 +292,8 @@ test "it filters out obviously bad tags when accepting a post as Markdown" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => post,
- "content_type" => "text/markdown"
+ status: post,
+ content_type: "text/markdown"
})
object = Object.normalize(activity)
@@ -286,21 +304,21 @@ test "it filters out obviously bad tags when accepting a post as Markdown" do
test "it does not allow replies to direct messages that are not direct messages themselves" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "suya..", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "suya..", visibility: "direct"})
assert {:ok, _} =
CommonAPI.post(user, %{
- "status" => "suya..",
- "visibility" => "direct",
- "in_reply_to_status_id" => activity.id
+ status: "suya..",
+ visibility: "direct",
+ in_reply_to_status_id: activity.id
})
Enum.each(["public", "private", "unlisted"], fn visibility ->
assert {:error, "The message visibility must be direct"} =
CommonAPI.post(user, %{
- "status" => "suya..",
- "visibility" => visibility,
- "in_reply_to_status_id" => activity.id
+ status: "suya..",
+ visibility: visibility,
+ in_reply_to_status_id: activity.id
})
end)
end
@@ -309,8 +327,7 @@ test "it allows to address a list" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
assert activity.data["bcc"] == [list.ap_id]
assert activity.recipients == [list.ap_id, user.ap_id]
@@ -321,7 +338,7 @@ test "it returns error when status is empty and no attachments" do
user = insert(:user)
assert {:error, "Cannot post an empty status without attachments"} =
- CommonAPI.post(user, %{"status" => ""})
+ CommonAPI.post(user, %{status: ""})
end
test "it validates character limits are correctly enforced" do
@@ -330,9 +347,9 @@ test "it validates character limits are correctly enforced" do
user = insert(:user)
assert {:error, "The status is over the character limit"} =
- CommonAPI.post(user, %{"status" => "foobar"})
+ CommonAPI.post(user, %{status: "foobar"})
- assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"})
+ assert {:ok, activity} = CommonAPI.post(user, %{status: "12345"})
end
test "it can handle activities that expire" do
@@ -343,8 +360,7 @@ test "it can handle activities that expire" do
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(1_000_000, :second)
- assert {:ok, activity} =
- CommonAPI.post(user, %{"status" => "chai", "expires_in" => 1_000_000})
+ assert {:ok, activity} = CommonAPI.post(user, %{status: "chai", expires_in: 1_000_000})
assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
assert expiration.scheduled_at == expires_at
@@ -356,14 +372,14 @@ test "reacting to a status with an emoji" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
assert reaction.data["actor"] == user.ap_id
assert reaction.data["content"] == "👍"
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:error, _} = CommonAPI.react_with_emoji(activity.id, user, ".")
end
@@ -372,7 +388,7 @@ test "unreacting to a status with an emoji" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
{:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍")
@@ -386,7 +402,7 @@ test "repeating a status" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
end
@@ -394,7 +410,7 @@ test "repeating a status" do
test "can't repeat a repeat" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{} = announce, _} = CommonAPI.repeat(activity.id, other_user)
@@ -405,10 +421,10 @@ test "repeating a status privately" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{} = announce_activity, _} =
- CommonAPI.repeat(activity.id, user, %{"visibility" => "private"})
+ CommonAPI.repeat(activity.id, user, %{visibility: "private"})
assert Visibility.is_private?(announce_activity)
end
@@ -417,7 +433,7 @@ test "favoriting a status" do
user = insert(:user)
other_user = insert(:user)
- {:ok, post_activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
assert data["type"] == "Like"
@@ -429,7 +445,7 @@ test "retweeting a status twice returns the status" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{} = announce, object} = CommonAPI.repeat(activity.id, user)
{:ok, ^announce, ^object} = CommonAPI.repeat(activity.id, user)
end
@@ -438,7 +454,7 @@ test "favoriting a status twice returns ok, but without the like activity" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
{:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
end
@@ -449,7 +465,7 @@ test "favoriting a status twice returns ok, but without the like activity" do
Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
[user: user, activity: activity]
end
@@ -466,8 +482,8 @@ test "pin status", %{user: user, activity: activity} do
test "pin poll", %{user: user} do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "How is fediverse today?",
- "poll" => %{"options" => ["Absolutely outstanding", "Not good"], "expires_in" => 20}
+ status: "How is fediverse today?",
+ poll: %{options: ["Absolutely outstanding", "Not good"], expires_in: 20}
})
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
@@ -479,7 +495,7 @@ test "pin poll", %{user: user} do
end
test "unlisted statuses can be pinned", %{user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!", visibility: "unlisted"})
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
end
@@ -490,7 +506,7 @@ test "only self-authored can be pinned", %{activity: activity} do
end
test "max pinned statuses", %{user: user, activity: activity_one} do
- {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
@@ -558,7 +574,7 @@ test "creates a report" do
reporter = insert(:user)
target_user = insert(:user)
- {:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"})
+ {:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
reporter_ap_id = reporter.ap_id
target_ap_id = target_user.ap_id
@@ -795,8 +811,8 @@ test "does not allow to vote twice" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Am I cute?",
- "poll" => %{"options" => ["Yes", "No"], "expires_in" => 20}
+ status: "Am I cute?",
+ poll: %{options: ["Yes", "No"], expires_in: 20}
})
object = Object.normalize(activity)
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs
index 18a3b3b87..5708db6a4 100644
--- a/test/web/common_api/common_api_utils_test.exs
+++ b/test/web/common_api/common_api_utils_test.exs
@@ -228,7 +228,7 @@ test "for public posts, a reply" do
user = insert(:user)
mentioned_user = insert(:user)
third_user = insert(:user)
- {:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
+ {:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
mentions = [mentioned_user.ap_id]
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "public", nil)
@@ -261,7 +261,7 @@ test "for unlisted posts, a reply" do
user = insert(:user)
mentioned_user = insert(:user)
third_user = insert(:user)
- {:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
+ {:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
mentions = [mentioned_user.ap_id]
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "unlisted", nil)
@@ -292,7 +292,7 @@ test "for private posts, a reply" do
user = insert(:user)
mentioned_user = insert(:user)
third_user = insert(:user)
- {:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
+ {:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
mentions = [mentioned_user.ap_id]
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "private", nil)
@@ -322,7 +322,7 @@ test "for direct posts, a reply" do
user = insert(:user)
mentioned_user = insert(:user)
third_user = insert(:user)
- {:ok, activity} = CommonAPI.post(third_user, %{"status" => "uguu"})
+ {:ok, activity} = CommonAPI.post(third_user, %{status: "uguu"})
mentions = [mentioned_user.ap_id]
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "direct", nil)
@@ -463,8 +463,8 @@ test "returns attachments with descs" do
desc = Jason.encode!(%{object.id => "test-desc"})
assert Utils.attachments_from_ids(%{
- "media_ids" => ["#{object.id}"],
- "descriptions" => desc
+ media_ids: ["#{object.id}"],
+ descriptions: desc
}) == [
Map.merge(object.data, %{"name" => "test-desc"})
]
@@ -472,7 +472,7 @@ test "returns attachments with descs" do
test "returns attachments without descs" do
object = insert(:note)
- assert Utils.attachments_from_ids(%{"media_ids" => ["#{object.id}"]}) == [object.data]
+ assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}) == [object.data]
end
test "returns [] when not pass media_ids" do
diff --git a/test/web/federator_test.exs b/test/web/federator_test.exs
index 261518ef0..de90aa6e0 100644
--- a/test/web/federator_test.exs
+++ b/test/web/federator_test.exs
@@ -29,7 +29,7 @@ defmodule Pleroma.Web.FederatorTest do
describe "Publish an activity" do
setup do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI"})
relay_mock = {
Pleroma.Web.ActivityPub.Relay,
@@ -96,7 +96,7 @@ test "it federates only to reachable instances via AP" do
Instances.set_consistently_unreachable(URI.parse(inbox2).host)
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
+ CommonAPI.post(user, %{status: "HI @nick1@domain.com, @nick2@domain2.com!"})
expected_dt = NaiveDateTime.to_iso8601(dt)
diff --git a/test/web/feed/tag_controller_test.exs b/test/web/feed/tag_controller_test.exs
index d95aac108..3c29cd94f 100644
--- a/test/web/feed/tag_controller_test.exs
+++ b/test/web/feed/tag_controller_test.exs
@@ -21,7 +21,7 @@ test "gets a feed (ATOM)", %{conn: conn} do
)
user = insert(:user)
- {:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
+ {:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
object = Object.normalize(activity1)
@@ -43,9 +43,9 @@ test "gets a feed (ATOM)", %{conn: conn} do
|> Ecto.Changeset.change(data: object_data)
|> Pleroma.Repo.update()
- {:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
+ {:ok, activity2} = CommonAPI.post(user, %{status: "42 This is :moominmamma #PleromaArt"})
- {:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
+ {:ok, _activity3} = CommonAPI.post(user, %{status: "This is :moominmamma"})
response =
conn
@@ -88,7 +88,7 @@ test "gets a feed (RSS)", %{conn: conn} do
)
user = insert(:user)
- {:ok, activity1} = CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
+ {:ok, activity1} = CommonAPI.post(user, %{status: "yeah #PleromaArt"})
object = Object.normalize(activity1)
@@ -110,9 +110,9 @@ test "gets a feed (RSS)", %{conn: conn} do
|> Ecto.Changeset.change(data: object_data)
|> Pleroma.Repo.update()
- {:ok, activity2} = CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
+ {:ok, activity2} = CommonAPI.post(user, %{status: "42 This is :moominmamma #PleromaArt"})
- {:ok, _activity3} = CommonAPI.post(user, %{"status" => "This is :moominmamma"})
+ {:ok, _activity3} = CommonAPI.post(user, %{status: "This is :moominmamma"})
response =
conn
@@ -138,8 +138,8 @@ test "gets a feed (RSS)", %{conn: conn} do
]
assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [
- FeedView.pub_date(activity1.data["published"]),
- FeedView.pub_date(activity2.data["published"])
+ FeedView.pub_date(activity2.data["published"]),
+ FeedView.pub_date(activity1.data["published"])
]
assert xpath(xml, ~x"//channel/item/enclosure/@url"sl) == [
diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs
index 256a8b304..280bd6aca 100644
--- a/test/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/web/mastodon_api/controllers/account_controller_test.exs
@@ -222,13 +222,40 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "user timelines" do
setup do: oauth_access(["read:statuses"])
+ test "works with announces that are just addressed to public", %{conn: conn} do
+ user = insert(:user, ap_id: "https://honktest/u/test", local: false)
+ other_user = insert(:user)
+
+ {:ok, post} = CommonAPI.post(other_user, %{status: "bonkeronk"})
+
+ {:ok, announce, _} =
+ %{
+ "@context" => "https://www.w3.org/ns/activitystreams",
+ "actor" => "https://honktest/u/test",
+ "id" => "https://honktest/u/test/bonk/1793M7B9MQ48847vdx",
+ "object" => post.data["object"],
+ "published" => "2019-06-25T19:33:58Z",
+ "to" => ["https://www.w3.org/ns/activitystreams#Public"],
+ "type" => "Announce"
+ }
+ |> ActivityPub.persist(local: false)
+
+ assert resp =
+ conn
+ |> get("/api/v1/accounts/#{user.id}/statuses")
+ |> json_response_and_validate_schema(200)
+
+ assert [%{"id" => id}] = resp
+ assert id == announce.id
+ end
+
test "respects blocks", %{user: user_one, conn: conn} do
user_two = insert(:user)
user_three = insert(:user)
User.block(user_one, user_two)
- {:ok, activity} = CommonAPI.post(user_two, %{"status" => "User one sux0rz"})
+ {:ok, activity} = CommonAPI.post(user_two, %{status: "User one sux0rz"})
{:ok, repeat, _} = CommonAPI.repeat(activity.id, user_three)
assert resp =
@@ -271,16 +298,16 @@ test "gets users statuses", %{conn: conn} do
{:ok, _user_three} = User.follow(user_three, user_one)
- {:ok, activity} = CommonAPI.post(user_one, %{"status" => "HI!!!"})
+ {:ok, activity} = CommonAPI.post(user_one, %{status: "HI!!!"})
{:ok, direct_activity} =
CommonAPI.post(user_one, %{
- "status" => "Hi, @#{user_two.nickname}.",
- "visibility" => "direct"
+ status: "Hi, @#{user_two.nickname}.",
+ visibility: "direct"
})
{:ok, private_activity} =
- CommonAPI.post(user_one, %{"status" => "private", "visibility" => "private"})
+ CommonAPI.post(user_one, %{status: "private", visibility: "private"})
# TODO!!!
resp =
@@ -335,8 +362,7 @@ test "gets an users media", %{conn: conn} do
{:ok, %{id: media_id}} = ActivityPub.upload(file, actor: user.ap_id)
- {:ok, %{id: image_post_id}} =
- CommonAPI.post(user, %{"status" => "cofe", "media_ids" => [media_id]})
+ {:ok, %{id: image_post_id}} = CommonAPI.post(user, %{status: "cofe", media_ids: [media_id]})
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?only_media=true")
@@ -348,7 +374,7 @@ test "gets an users media", %{conn: conn} do
end
test "gets a user's statuses without reblogs", %{user: user, conn: conn} do
- {:ok, %{id: post_id}} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "HI!!!"})
{:ok, _, _} = CommonAPI.repeat(post_id, user)
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?exclude_reblogs=true")
@@ -359,8 +385,8 @@ test "gets a user's statuses without reblogs", %{user: user, conn: conn} do
end
test "filters user's statuses by a hashtag", %{user: user, conn: conn} do
- {:ok, %{id: post_id}} = CommonAPI.post(user, %{"status" => "#hashtag"})
- {:ok, _post} = CommonAPI.post(user, %{"status" => "hashtag"})
+ {:ok, %{id: post_id}} = CommonAPI.post(user, %{status: "#hashtag"})
+ {:ok, _post} = CommonAPI.post(user, %{status: "hashtag"})
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?tagged=hashtag")
assert [%{"id" => ^post_id}] = json_response_and_validate_schema(conn, 200)
@@ -371,9 +397,9 @@ test "the user views their own timelines and excludes direct messages", %{
conn: conn
} do
{:ok, %{id: public_activity_id}} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
+ CommonAPI.post(user, %{status: ".", visibility: "public"})
- {:ok, _direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, _direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?exclude_visibilities[]=direct")
assert [%{"id" => ^public_activity_id}] = json_response_and_validate_schema(conn, 200)
@@ -651,7 +677,7 @@ test "following without reblogs" do
assert %{"showing_reblogs" => false} = json_response_and_validate_schema(ret_conn, 200)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hey"})
{:ok, %{id: reblog_id}, _} = CommonAPI.repeat(activity.id, followed)
assert [] ==
@@ -750,7 +776,7 @@ test "without notifications", %{conn: conn} do
describe "pinned statuses" do
setup do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
%{conn: conn} = oauth_access(["read:statuses"], user: user)
[conn: conn, user: user, activity: activity]
diff --git a/test/web/mastodon_api/controllers/conversation_controller_test.exs b/test/web/mastodon_api/controllers/conversation_controller_test.exs
index 04695572e..693ba51e5 100644
--- a/test/web/mastodon_api/controllers/conversation_controller_test.exs
+++ b/test/web/mastodon_api/controllers/conversation_controller_test.exs
@@ -22,16 +22,16 @@ test "returns a list of conversations", %{user: user_one, conn: conn} do
{:ok, direct} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
+ visibility: "direct"
})
assert User.get_cached_by_id(user_two.id).unread_conversation_count == 1
{:ok, _follower_only} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "private"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "private"
})
res_conn = get(conn, "/api/v1/conversations")
@@ -63,32 +63,32 @@ test "filters conversations by recipients", %{user: user_one, conn: conn} do
{:ok, direct1} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "direct"
})
{:ok, _direct2} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_three.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_three.nickname}!",
+ visibility: "direct"
})
{:ok, direct3} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
+ visibility: "direct"
})
{:ok, _direct4} =
CommonAPI.post(user_two, %{
- "status" => "Hi @#{user_three.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_three.nickname}!",
+ visibility: "direct"
})
{:ok, direct5} =
CommonAPI.post(user_two, %{
- "status" => "Hi @#{user_one.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_one.nickname}!",
+ visibility: "direct"
})
assert [conversation1, conversation2] =
@@ -112,15 +112,15 @@ test "updates the last_status on reply", %{user: user_one, conn: conn} do
{:ok, direct} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}",
+ visibility: "direct"
})
{:ok, direct_reply} =
CommonAPI.post(user_two, %{
- "status" => "reply",
- "visibility" => "direct",
- "in_reply_to_status_id" => direct.id
+ status: "reply",
+ visibility: "direct",
+ in_reply_to_status_id: direct.id
})
[%{"last_status" => res_last_status}] =
@@ -136,8 +136,8 @@ test "the user marks a conversation as read", %{user: user_one, conn: conn} do
{:ok, direct} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}",
+ visibility: "direct"
})
assert User.get_cached_by_id(user_one.id).unread_conversation_count == 0
@@ -167,9 +167,9 @@ test "the user marks a conversation as read", %{user: user_one, conn: conn} do
# The conversation is marked as unread on reply
{:ok, _} =
CommonAPI.post(user_two, %{
- "status" => "reply",
- "visibility" => "direct",
- "in_reply_to_status_id" => direct.id
+ status: "reply",
+ visibility: "direct",
+ in_reply_to_status_id: direct.id
})
[%{"unread" => true}] =
@@ -183,9 +183,9 @@ test "the user marks a conversation as read", %{user: user_one, conn: conn} do
# A reply doesn't increment the user's unread_conversation_count if the conversation is unread
{:ok, _} =
CommonAPI.post(user_two, %{
- "status" => "reply",
- "visibility" => "direct",
- "in_reply_to_status_id" => direct.id
+ status: "reply",
+ visibility: "direct",
+ in_reply_to_status_id: direct.id
})
assert User.get_cached_by_id(user_one.id).unread_conversation_count == 1
@@ -197,8 +197,8 @@ test "(vanilla) Mastodon frontend behaviour", %{user: user_one, conn: conn} do
{:ok, direct} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "direct"
})
res_conn = get(conn, "/api/v1/statuses/#{direct.id}/context")
diff --git a/test/web/mastodon_api/controllers/instance_controller_test.exs b/test/web/mastodon_api/controllers/instance_controller_test.exs
index 90840d5ab..2c61dc5ba 100644
--- a/test/web/mastodon_api/controllers/instance_controller_test.exs
+++ b/test/web/mastodon_api/controllers/instance_controller_test.exs
@@ -50,7 +50,7 @@ test "get instance stats", %{conn: conn} do
insert(:user, %{local: false, nickname: "u@peer1.com"})
insert(:user, %{local: false, nickname: "u@peer2.com"})
- {:ok, _} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofe"})
+ {:ok, _} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
Pleroma.Stats.force_update()
diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs
index db380f76a..d9356a844 100644
--- a/test/web/mastodon_api/controllers/notification_controller_test.exs
+++ b/test/web/mastodon_api/controllers/notification_controller_test.exs
@@ -18,7 +18,7 @@ test "does NOT render account/pleroma/relationship if this is disabled by defaul
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [_notification]} = Notification.create_notifications(activity)
response =
@@ -36,7 +36,7 @@ test "list of notifications" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [_notification]} = Notification.create_notifications(activity)
@@ -60,7 +60,7 @@ test "getting a single notification" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
@@ -79,7 +79,7 @@ test "dismissing a single notification (deprecated endpoint)" do
%{user: user, conn: conn} = oauth_access(["write:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
@@ -96,7 +96,7 @@ test "dismissing a single notification" do
%{user: user, conn: conn} = oauth_access(["write:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
@@ -112,7 +112,7 @@ test "clearing all notifications" do
%{user: user, conn: conn} = oauth_access(["write:notifications", "read:notifications"])
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
{:ok, [_notification]} = Notification.create_notifications(activity)
@@ -130,10 +130,10 @@ test "paginates notifications using min_id, since_id, max_id, and limit" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, activity1} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, activity2} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, activity3} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, activity4} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity1} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, activity2} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, activity3} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, activity4} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
notification1_id = get_notification_id_by_activity(activity1)
notification2_id = get_notification_id_by_activity(activity2)
@@ -173,16 +173,16 @@ test "filters notifications for mentions" do
other_user = insert(:user)
{:ok, public_activity} =
- CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "public"})
+ CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "public"})
{:ok, direct_activity} =
- CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "direct"})
{:ok, unlisted_activity} =
- CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "unlisted"})
+ CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "unlisted"})
{:ok, private_activity} =
- CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "private"})
+ CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "private"})
query = params_to_query(%{exclude_visibilities: ["public", "unlisted", "private"]})
conn_res = get(conn, "/api/v1/notifications?" <> query)
@@ -213,17 +213,15 @@ test "filters notifications for Like activities" do
user = insert(:user)
%{user: other_user, conn: conn} = oauth_access(["read:notifications"])
- {:ok, public_activity} =
- CommonAPI.post(other_user, %{"status" => ".", "visibility" => "public"})
+ {:ok, public_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "public"})
{:ok, direct_activity} =
- CommonAPI.post(other_user, %{"status" => "@#{user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(other_user, %{status: "@#{user.nickname}", visibility: "direct"})
{:ok, unlisted_activity} =
- CommonAPI.post(other_user, %{"status" => ".", "visibility" => "unlisted"})
+ CommonAPI.post(other_user, %{status: ".", visibility: "unlisted"})
- {:ok, private_activity} =
- CommonAPI.post(other_user, %{"status" => ".", "visibility" => "private"})
+ {:ok, private_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "private"})
{:ok, _} = CommonAPI.favorite(user, public_activity.id)
{:ok, _} = CommonAPI.favorite(user, direct_activity.id)
@@ -279,11 +277,10 @@ test "filters notifications for Announce activities" do
user = insert(:user)
%{user: other_user, conn: conn} = oauth_access(["read:notifications"])
- {:ok, public_activity} =
- CommonAPI.post(other_user, %{"status" => ".", "visibility" => "public"})
+ {:ok, public_activity} = CommonAPI.post(other_user, %{status: ".", visibility: "public"})
{:ok, unlisted_activity} =
- CommonAPI.post(other_user, %{"status" => ".", "visibility" => "unlisted"})
+ CommonAPI.post(other_user, %{status: ".", visibility: "unlisted"})
{:ok, _, _} = CommonAPI.repeat(public_activity.id, user)
{:ok, _, _} = CommonAPI.repeat(unlisted_activity.id, user)
@@ -303,8 +300,8 @@ test "filters notifications using exclude_types" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
- {:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"})
+ {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
@@ -341,8 +338,8 @@ test "filters notifications using include_types" do
%{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user)
- {:ok, mention_activity} = CommonAPI.post(other_user, %{"status" => "hey @#{user.nickname}"})
- {:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, mention_activity} = CommonAPI.post(other_user, %{status: "hey @#{user.nickname}"})
+ {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, favorite_activity} = CommonAPI.favorite(other_user, create_activity.id)
{:ok, reblog_activity, _} = CommonAPI.repeat(create_activity.id, other_user)
{:ok, _, _, follow_activity} = CommonAPI.follow(other_user, user)
@@ -388,10 +385,10 @@ test "destroy multiple" do
%{user: user, conn: conn} = oauth_access(["read:notifications", "write:notifications"])
other_user = insert(:user)
- {:ok, activity1} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, activity2} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, activity3} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
- {:ok, activity4} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
+ {:ok, activity1} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, activity2} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
+ {:ok, activity3} = CommonAPI.post(user, %{status: "hi @#{other_user.nickname}"})
+ {:ok, activity4} = CommonAPI.post(user, %{status: "hi @#{other_user.nickname}"})
notification1_id = get_notification_id_by_activity(activity1)
notification2_id = get_notification_id_by_activity(activity2)
@@ -435,7 +432,7 @@ test "doesn't see notifications after muting user with notifications" do
user2 = insert(:user)
{:ok, _, _, _} = CommonAPI.follow(user, user2)
- {:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
ret_conn = get(conn, "/api/v1/notifications")
@@ -453,7 +450,7 @@ test "see notifications after muting user without notifications" do
user2 = insert(:user)
{:ok, _, _, _} = CommonAPI.follow(user, user2)
- {:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
ret_conn = get(conn, "/api/v1/notifications")
@@ -471,7 +468,7 @@ test "see notifications after muting user with notifications and with_muted para
user2 = insert(:user)
{:ok, _, _, _} = CommonAPI.follow(user, user2)
- {:ok, _} = CommonAPI.post(user2, %{"status" => "hey @#{user.nickname}"})
+ {:ok, _} = CommonAPI.post(user2, %{status: "hey @#{user.nickname}"})
ret_conn = get(conn, "/api/v1/notifications")
@@ -518,14 +515,14 @@ test "preserves parameters in link headers" do
{:ok, activity1} =
CommonAPI.post(other_user, %{
- "status" => "hi @#{user.nickname}",
- "visibility" => "public"
+ status: "hi @#{user.nickname}",
+ visibility: "public"
})
{:ok, activity2} =
CommonAPI.post(other_user, %{
- "status" => "hi @#{user.nickname}",
- "visibility" => "public"
+ status: "hi @#{user.nickname}",
+ visibility: "public"
})
notification1 = Repo.get_by(Notification, activity_id: activity1.id)
@@ -550,8 +547,8 @@ test "account_id" do
%{id: account_id} = other_user1 = insert(:user)
other_user2 = insert(:user)
- {:ok, _activity} = CommonAPI.post(other_user1, %{"status" => "hi @#{user.nickname}"})
- {:ok, _activity} = CommonAPI.post(other_user2, %{"status" => "bye @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(other_user1, %{status: "hi @#{user.nickname}"})
+ {:ok, _activity} = CommonAPI.post(other_user2, %{status: "bye @#{user.nickname}"})
assert [%{"account" => %{"id" => ^account_id}}] =
conn
diff --git a/test/web/mastodon_api/controllers/poll_controller_test.exs b/test/web/mastodon_api/controllers/poll_controller_test.exs
index d8f34aa86..f41de6448 100644
--- a/test/web/mastodon_api/controllers/poll_controller_test.exs
+++ b/test/web/mastodon_api/controllers/poll_controller_test.exs
@@ -16,8 +16,8 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
test "returns poll entity for object id", %{user: user, conn: conn} do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Pleroma does",
- "poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20}
+ status: "Pleroma does",
+ poll: %{options: ["what Mastodon't", "n't what Mastodoes"], expires_in: 20}
})
object = Object.normalize(activity)
@@ -34,9 +34,9 @@ test "does not expose polls for private statuses", %{conn: conn} do
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "Pleroma does",
- "poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20},
- "visibility" => "private"
+ status: "Pleroma does",
+ poll: %{options: ["what Mastodon't", "n't what Mastodoes"], expires_in: 20},
+ visibility: "private"
})
object = Object.normalize(activity)
@@ -55,11 +55,11 @@ test "votes are added to the poll", %{conn: conn} do
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "A very delicious sandwich",
- "poll" => %{
- "options" => ["Lettuce", "Grilled Bacon", "Tomato"],
- "expires_in" => 20,
- "multiple" => true
+ status: "A very delicious sandwich",
+ poll: %{
+ options: ["Lettuce", "Grilled Bacon", "Tomato"],
+ expires_in: 20,
+ multiple: true
}
})
@@ -81,8 +81,8 @@ test "votes are added to the poll", %{conn: conn} do
test "author can't vote", %{user: user, conn: conn} do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Am I cute?",
- "poll" => %{"options" => ["Yes", "No"], "expires_in" => 20}
+ status: "Am I cute?",
+ poll: %{options: ["Yes", "No"], expires_in: 20}
})
object = Object.normalize(activity)
@@ -102,8 +102,8 @@ test "does not allow multiple choices on a single-choice question", %{conn: conn
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "The glass is",
- "poll" => %{"options" => ["half empty", "half full"], "expires_in" => 20}
+ status: "The glass is",
+ poll: %{options: ["half empty", "half full"], expires_in: 20}
})
object = Object.normalize(activity)
@@ -125,8 +125,8 @@ test "does not allow choice index to be greater than options count", %{conn: con
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "Am I cute?",
- "poll" => %{"options" => ["Yes", "No"], "expires_in" => 20}
+ status: "Am I cute?",
+ poll: %{options: ["Yes", "No"], expires_in: 20}
})
object = Object.normalize(activity)
@@ -153,9 +153,9 @@ test "returns 404 when poll is private and not available for user", %{conn: conn
{:ok, activity} =
CommonAPI.post(other_user, %{
- "status" => "Am I cute?",
- "poll" => %{"options" => ["Yes", "No"], "expires_in" => 20},
- "visibility" => "private"
+ status: "Am I cute?",
+ poll: %{options: ["Yes", "No"], expires_in: 20},
+ visibility: "private"
})
object = Object.normalize(activity)
diff --git a/test/web/mastodon_api/controllers/report_controller_test.exs b/test/web/mastodon_api/controllers/report_controller_test.exs
index 21b037237..6636cff96 100644
--- a/test/web/mastodon_api/controllers/report_controller_test.exs
+++ b/test/web/mastodon_api/controllers/report_controller_test.exs
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.ReportControllerTest do
setup do
target_user = insert(:user)
- {:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"})
+ {:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
[target_user: target_user, activity: activity]
end
diff --git a/test/web/mastodon_api/controllers/search_controller_test.exs b/test/web/mastodon_api/controllers/search_controller_test.exs
index 02476acb6..7d0cafccc 100644
--- a/test/web/mastodon_api/controllers/search_controller_test.exs
+++ b/test/web/mastodon_api/controllers/search_controller_test.exs
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
import Tesla.Mock
import Mock
- setup do
+ setup_all do
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end
@@ -42,15 +42,15 @@ test "search", %{conn: conn} do
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
- {:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu private 天子"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "This is about 2hu private 天子"})
{:ok, _activity} =
CommonAPI.post(user, %{
- "status" => "This is about 2hu, but private",
- "visibility" => "private"
+ status: "This is about 2hu, but private",
+ visibility: "private"
})
- {:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
+ {:ok, _} = CommonAPI.post(user_two, %{status: "This isn't"})
results =
conn
@@ -80,9 +80,9 @@ test "excludes a blocked users from search results", %{conn: conn} do
user_smith = insert(:user, %{nickname: "Agent", name: "I love 2hu"})
user_neo = insert(:user, %{nickname: "Agent Neo", name: "Agent"})
- {:ok, act1} = CommonAPI.post(user, %{"status" => "This is about 2hu private 天子"})
- {:ok, act2} = CommonAPI.post(user_smith, %{"status" => "Agent Smith"})
- {:ok, act3} = CommonAPI.post(user_neo, %{"status" => "Agent Smith"})
+ {:ok, act1} = CommonAPI.post(user, %{status: "This is about 2hu private 天子"})
+ {:ok, act2} = CommonAPI.post(user_smith, %{status: "Agent Smith"})
+ {:ok, act3} = CommonAPI.post(user_neo, %{status: "Agent Smith"})
Pleroma.User.block(user, user_smith)
results =
@@ -161,15 +161,15 @@ test "search", %{conn: conn} do
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
- {:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "This is about 2hu"})
{:ok, _activity} =
CommonAPI.post(user, %{
- "status" => "This is about 2hu, but private",
- "visibility" => "private"
+ status: "This is about 2hu, but private",
+ visibility: "private"
})
- {:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
+ {:ok, _} = CommonAPI.post(user_two, %{status: "This isn't"})
results =
conn
@@ -189,7 +189,7 @@ test "search fetches remote statuses and prefers them over other results", %{con
capture_log(fn ->
{:ok, %{id: activity_id}} =
CommonAPI.post(insert(:user), %{
- "status" => "check out https://shitposter.club/notice/2827873"
+ status: "check out https://shitposter.club/notice/2827873"
})
results =
@@ -207,8 +207,8 @@ test "search fetches remote statuses and prefers them over other results", %{con
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
{:ok, activity} =
CommonAPI.post(insert(:user), %{
- "status" => "This is about 2hu, but private",
- "visibility" => "private"
+ status: "This is about 2hu, but private",
+ visibility: "private"
})
capture_log(fn ->
@@ -251,8 +251,8 @@ test "search with limit and offset", %{conn: conn} do
_user_two = insert(:user, %{nickname: "shp@shitposter.club"})
_user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
- {:ok, _activity1} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
- {:ok, _activity2} = CommonAPI.post(user, %{"status" => "This is also about 2hu"})
+ {:ok, _activity1} = CommonAPI.post(user, %{status: "This is about 2hu"})
+ {:ok, _activity2} = CommonAPI.post(user, %{status: "This is also about 2hu"})
result =
conn
@@ -277,7 +277,7 @@ test "search returns results only for the given type", %{conn: conn} do
user = insert(:user)
_user_two = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "This is about 2hu"})
assert %{"statuses" => [_activity], "accounts" => [], "hashtags" => []} =
conn
@@ -294,8 +294,8 @@ test "search uses account_id to filter statuses by the author", %{conn: conn} do
user = insert(:user, %{nickname: "shp@shitposter.club"})
user_two = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
- {:ok, activity1} = CommonAPI.post(user, %{"status" => "This is about 2hu"})
- {:ok, activity2} = CommonAPI.post(user_two, %{"status" => "This is also about 2hu"})
+ {:ok, activity1} = CommonAPI.post(user, %{status: "This is about 2hu"})
+ {:ok, activity2} = CommonAPI.post(user_two, %{status: "This is also about 2hu"})
results =
conn
diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs
index 85068edd0..a4403132c 100644
--- a/test/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/web/mastodon_api/controllers/status_controller_test.exs
@@ -32,13 +32,14 @@ test "posting a status does not increment reblog_count when relaying", %{conn: c
response =
conn
+ |> put_req_header("content-type", "application/json")
|> post("api/v1/statuses", %{
"content_type" => "text/plain",
"source" => "Pleroma FE",
"status" => "Hello world",
"visibility" => "public"
})
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert response["reblogs_count"] == 0
ObanHelpers.perform_all()
@@ -46,7 +47,7 @@ test "posting a status does not increment reblog_count when relaying", %{conn: c
response =
conn
|> get("api/v1/statuses/#{response["id"]}", %{})
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert response["reblogs_count"] == 0
end
@@ -56,6 +57,7 @@ test "posting a status", %{conn: conn} do
conn_one =
conn
+ |> put_req_header("content-type", "application/json")
|> put_req_header("idempotency-key", idempotency_key)
|> post("/api/v1/statuses", %{
"status" => "cofe",
@@ -68,12 +70,13 @@ test "posting a status", %{conn: conn} do
assert ttl > :timer.seconds(6 * 60 * 60 - 1)
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} =
- json_response(conn_one, 200)
+ json_response_and_validate_schema(conn_one, 200)
assert Activity.get_by_id(id)
conn_two =
conn
+ |> put_req_header("content-type", "application/json")
|> put_req_header("idempotency-key", idempotency_key)
|> post("/api/v1/statuses", %{
"status" => "cofe",
@@ -86,13 +89,14 @@ test "posting a status", %{conn: conn} do
conn_three =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses", %{
"status" => "cofe",
"spoiler_text" => "2hu",
"sensitive" => "false"
})
- assert %{"id" => third_id} = json_response(conn_three, 200)
+ assert %{"id" => third_id} = json_response_and_validate_schema(conn_three, 200)
refute id == third_id
# An activity that will expire:
@@ -101,12 +105,15 @@ test "posting a status", %{conn: conn} do
conn_four =
conn
+ |> put_req_header("content-type", "application/json")
|> post("api/v1/statuses", %{
"status" => "oolong",
"expires_in" => expires_in
})
- assert fourth_response = %{"id" => fourth_id} = json_response(conn_four, 200)
+ assert fourth_response =
+ %{"id" => fourth_id} = json_response_and_validate_schema(conn_four, 200)
+
assert activity = Activity.get_by_id(fourth_id)
assert expiration = ActivityExpiration.get_by_activity_id(fourth_id)
@@ -130,22 +137,24 @@ test "it fails to create a status if `expires_in` is less or equal than an hour"
assert %{"error" => "Expiry date is too soon"} =
conn
+ |> put_req_header("content-type", "application/json")
|> post("api/v1/statuses", %{
"status" => "oolong",
"expires_in" => expires_in
})
- |> json_response(422)
+ |> json_response_and_validate_schema(422)
# 30 minutes
expires_in = 30 * 60
assert %{"error" => "Expiry date is too soon"} =
conn
+ |> put_req_header("content-type", "application/json")
|> post("api/v1/statuses", %{
"status" => "oolong",
"expires_in" => expires_in
})
- |> json_response(422)
+ |> json_response_and_validate_schema(422)
end
test "posting an undefined status with an attachment", %{user: user, conn: conn} do
@@ -158,21 +167,24 @@ test "posting an undefined status with an attachment", %{user: user, conn: conn}
{:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"media_ids" => [to_string(upload.id)]
})
- assert json_response(conn, 200)
+ assert json_response_and_validate_schema(conn, 200)
end
test "replying to a status", %{user: user, conn: conn} do
- {:ok, replied_to} = CommonAPI.post(user, %{"status" => "cofe"})
+ {:ok, replied_to} = CommonAPI.post(user, %{status: "cofe"})
conn =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => replied_to.id})
- assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
+ assert %{"content" => "xD", "id" => id} = json_response_and_validate_schema(conn, 200)
activity = Activity.get_by_id(id)
@@ -184,43 +196,56 @@ test "replying to a direct message with visibility other than direct", %{
user: user,
conn: conn
} do
- {:ok, replied_to} = CommonAPI.post(user, %{"status" => "suya..", "visibility" => "direct"})
+ {:ok, replied_to} = CommonAPI.post(user, %{status: "suya..", visibility: "direct"})
Enum.each(["public", "private", "unlisted"], fn visibility ->
conn =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses", %{
"status" => "@#{user.nickname} hey",
"in_reply_to_id" => replied_to.id,
"visibility" => visibility
})
- assert json_response(conn, 422) == %{"error" => "The message visibility must be direct"}
+ assert json_response_and_validate_schema(conn, 422) == %{
+ "error" => "The message visibility must be direct"
+ }
end)
end
test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
- conn = post(conn, "/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => ""})
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => ""})
- assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
+ assert %{"content" => "xD", "id" => id} = json_response_and_validate_schema(conn, 200)
assert Activity.get_by_id(id)
end
test "posting a sensitive status", %{conn: conn} do
- conn = post(conn, "/api/v1/statuses", %{"status" => "cofe", "sensitive" => true})
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{"status" => "cofe", "sensitive" => true})
+
+ assert %{"content" => "cofe", "id" => id, "sensitive" => true} =
+ json_response_and_validate_schema(conn, 200)
- assert %{"content" => "cofe", "id" => id, "sensitive" => true} = json_response(conn, 200)
assert Activity.get_by_id(id)
end
test "posting a fake status", %{conn: conn} do
real_conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" =>
"\"Tenshi Eating a Corndog\" is a much discussed concept on /jp/. The significance of it is disputed, so I will focus on one core concept: the symbolism behind it"
})
- real_status = json_response(real_conn, 200)
+ real_status = json_response_and_validate_schema(real_conn, 200)
assert real_status
assert Object.get_by_ap_id(real_status["uri"])
@@ -234,13 +259,15 @@ test "posting a fake status", %{conn: conn} do
|> Kernel.put_in(["pleroma", "conversation_id"], nil)
fake_conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" =>
"\"Tenshi Eating a Corndog\" is a much discussed concept on /jp/. The significance of it is disputed, so I will focus on one core concept: the symbolism behind it",
"preview" => true
})
- fake_status = json_response(fake_conn, 200)
+ fake_status = json_response_and_validate_schema(fake_conn, 200)
assert fake_status
refute Object.get_by_ap_id(fake_status["uri"])
@@ -261,11 +288,15 @@ test "posting a status with OGP link preview", %{conn: conn} do
Config.put([:rich_media, :enabled], true)
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "https://example.com/ogp"
})
- assert %{"id" => id, "card" => %{"title" => "The Rock"}} = json_response(conn, 200)
+ assert %{"id" => id, "card" => %{"title" => "The Rock"}} =
+ json_response_and_validate_schema(conn, 200)
+
assert Activity.get_by_id(id)
end
@@ -273,9 +304,12 @@ test "posting a direct status", %{conn: conn} do
user2 = insert(:user)
content = "direct cofe @#{user2.nickname}"
- conn = post(conn, "api/v1/statuses", %{"status" => content, "visibility" => "direct"})
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("api/v1/statuses", %{"status" => content, "visibility" => "direct"})
- assert %{"id" => id} = response = json_response(conn, 200)
+ assert %{"id" => id} = response = json_response_and_validate_schema(conn, 200)
assert response["visibility"] == "direct"
assert response["pleroma"]["direct_conversation_id"]
assert activity = Activity.get_by_id(id)
@@ -289,32 +323,45 @@ test "posting a direct status", %{conn: conn} do
setup do: oauth_access(["write:statuses"])
test "creates a scheduled activity", %{conn: conn} do
- scheduled_at = NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(120), :millisecond)
+ scheduled_at =
+ NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(120), :millisecond)
+ |> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "scheduled",
"scheduled_at" => scheduled_at
})
- assert %{"scheduled_at" => expected_scheduled_at} = json_response(conn, 200)
+ assert %{"scheduled_at" => expected_scheduled_at} =
+ json_response_and_validate_schema(conn, 200)
+
assert expected_scheduled_at == CommonAPI.Utils.to_masto_date(scheduled_at)
assert [] == Repo.all(Activity)
end
test "ignores nil values", %{conn: conn} do
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "not scheduled",
"scheduled_at" => nil
})
- assert result = json_response(conn, 200)
+ assert result = json_response_and_validate_schema(conn, 200)
assert Activity.get_by_id(result["id"])
end
test "creates a scheduled activity with a media attachment", %{user: user, conn: conn} do
- scheduled_at = NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(120), :millisecond)
+ scheduled_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.add(:timer.minutes(120), :millisecond)
+ |> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
file = %Plug.Upload{
content_type: "image/jpg",
@@ -325,13 +372,17 @@ test "creates a scheduled activity with a media attachment", %{user: user, conn:
{:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"media_ids" => [to_string(upload.id)],
"status" => "scheduled",
"scheduled_at" => scheduled_at
})
- assert %{"media_attachments" => [media_attachment]} = json_response(conn, 200)
+ assert %{"media_attachments" => [media_attachment]} =
+ json_response_and_validate_schema(conn, 200)
+
assert %{"type" => "image"} = media_attachment
end
@@ -339,14 +390,18 @@ test "skips the scheduling and creates the activity if scheduled_at is earlier t
%{conn: conn} do
scheduled_at =
NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(5) - 1, :millisecond)
+ |> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "not scheduled",
"scheduled_at" => scheduled_at
})
- assert %{"content" => "not scheduled"} = json_response(conn, 200)
+ assert %{"content" => "not scheduled"} = json_response_and_validate_schema(conn, 200)
assert [] == Repo.all(ScheduledActivity)
end
@@ -355,14 +410,19 @@ test "returns error when daily user limit is exceeded", %{user: user, conn: conn
NaiveDateTime.utc_now()
|> NaiveDateTime.add(:timer.minutes(6), :millisecond)
|> NaiveDateTime.to_iso8601()
+ # TODO
+ |> Kernel.<>("Z")
attrs = %{params: %{}, scheduled_at: today}
{:ok, _} = ScheduledActivity.create(user, attrs)
{:ok, _} = ScheduledActivity.create(user, attrs)
- conn = post(conn, "/api/v1/statuses", %{"status" => "scheduled", "scheduled_at" => today})
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{"status" => "scheduled", "scheduled_at" => today})
- assert %{"error" => "daily limit exceeded"} == json_response(conn, 422)
+ assert %{"error" => "daily limit exceeded"} == json_response_and_validate_schema(conn, 422)
end
test "returns error when total user limit is exceeded", %{user: user, conn: conn} do
@@ -370,11 +430,13 @@ test "returns error when total user limit is exceeded", %{user: user, conn: conn
NaiveDateTime.utc_now()
|> NaiveDateTime.add(:timer.minutes(6), :millisecond)
|> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
tomorrow =
NaiveDateTime.utc_now()
|> NaiveDateTime.add(:timer.hours(36), :millisecond)
|> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
attrs = %{params: %{}, scheduled_at: today}
{:ok, _} = ScheduledActivity.create(user, attrs)
@@ -382,9 +444,11 @@ test "returns error when total user limit is exceeded", %{user: user, conn: conn
{:ok, _} = ScheduledActivity.create(user, %{params: %{}, scheduled_at: tomorrow})
conn =
- post(conn, "/api/v1/statuses", %{"status" => "scheduled", "scheduled_at" => tomorrow})
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{"status" => "scheduled", "scheduled_at" => tomorrow})
- assert %{"error" => "total limit exceeded"} == json_response(conn, 422)
+ assert %{"error" => "total limit exceeded"} == json_response_and_validate_schema(conn, 422)
end
end
@@ -395,12 +459,17 @@ test "posting a poll", %{conn: conn} do
time = NaiveDateTime.utc_now()
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "Who is the #bestgrill?",
- "poll" => %{"options" => ["Rei", "Asuka", "Misato"], "expires_in" => 420}
+ "poll" => %{
+ "options" => ["Rei", "Asuka", "Misato"],
+ "expires_in" => 420
+ }
})
- response = json_response(conn, 200)
+ response = json_response_and_validate_schema(conn, 200)
assert Enum.all?(response["poll"]["options"], fn %{"title" => title} ->
title in ["Rei", "Asuka", "Misato"]
@@ -419,12 +488,14 @@ test "option limit is enforced", %{conn: conn} do
limit = Config.get([:instance, :poll_limits, :max_options])
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "desu~",
"poll" => %{"options" => Enum.map(0..limit, fn _ -> "desu" end), "expires_in" => 1}
})
- %{"error" => error} = json_response(conn, 422)
+ %{"error" => error} = json_response_and_validate_schema(conn, 422)
assert error == "Poll can't contain more than #{limit} options"
end
@@ -432,7 +503,9 @@ test "option character limit is enforced", %{conn: conn} do
limit = Config.get([:instance, :poll_limits, :max_option_chars])
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "...",
"poll" => %{
"options" => [Enum.reduce(0..limit, "", fn _, acc -> acc <> "." end)],
@@ -440,7 +513,7 @@ test "option character limit is enforced", %{conn: conn} do
}
})
- %{"error" => error} = json_response(conn, 422)
+ %{"error" => error} = json_response_and_validate_schema(conn, 422)
assert error == "Poll options cannot be longer than #{limit} characters each"
end
@@ -448,7 +521,9 @@ test "minimal date limit is enforced", %{conn: conn} do
limit = Config.get([:instance, :poll_limits, :min_expiration])
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "imagine arbitrary limits",
"poll" => %{
"options" => ["this post was made by pleroma gang"],
@@ -456,7 +531,7 @@ test "minimal date limit is enforced", %{conn: conn} do
}
})
- %{"error" => error} = json_response(conn, 422)
+ %{"error" => error} = json_response_and_validate_schema(conn, 422)
assert error == "Expiration date is too soon"
end
@@ -464,7 +539,9 @@ test "maximum date limit is enforced", %{conn: conn} do
limit = Config.get([:instance, :poll_limits, :max_expiration])
conn =
- post(conn, "/api/v1/statuses", %{
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
"status" => "imagine arbitrary limits",
"poll" => %{
"options" => ["this post was made by pleroma gang"],
@@ -472,7 +549,7 @@ test "maximum date limit is enforced", %{conn: conn} do
}
})
- %{"error" => error} = json_response(conn, 422)
+ %{"error" => error} = json_response_and_validate_schema(conn, 422)
assert error == "Expiration date is too far in the future"
end
end
@@ -483,7 +560,7 @@ test "get a status" do
conn = get(conn, "/api/v1/statuses/#{activity.id}")
- assert %{"id" => id} = json_response(conn, 200)
+ assert %{"id" => id} = json_response_and_validate_schema(conn, 200)
assert id == to_string(activity.id)
end
@@ -503,13 +580,13 @@ defp local_and_remote_activities do
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert json_response(res_conn, :not_found) == %{
+ assert json_response_and_validate_schema(res_conn, :not_found) == %{
"error" => "Record not found"
}
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert json_response(res_conn, :not_found) == %{
+ assert json_response_and_validate_schema(res_conn, :not_found) == %{
"error" => "Record not found"
}
end
@@ -517,10 +594,10 @@ test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} d
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
end
end
@@ -532,21 +609,21 @@ test "if user is authenticated", %{local: local, remote: remote} do
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert json_response(res_conn, :not_found) == %{
+ assert json_response_and_validate_schema(res_conn, :not_found) == %{
"error" => "Record not found"
}
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
end
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
end
end
@@ -557,11 +634,11 @@ test "if user is authenticated", %{local: local, remote: remote} do
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert json_response(res_conn, :not_found) == %{
+ assert json_response_and_validate_schema(res_conn, :not_found) == %{
"error" => "Record not found"
}
end
@@ -569,10 +646,10 @@ test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} d
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
res_conn = get(conn, "/api/v1/statuses/#{remote.id}")
- assert %{"id" => _} = json_response(res_conn, 200)
+ assert %{"id" => _} = json_response_and_validate_schema(res_conn, 200)
end
end
@@ -582,7 +659,7 @@ test "getting a status that doesn't exist returns 404" do
conn = get(conn, "/api/v1/statuses/#{String.downcase(activity.id)}")
- assert json_response(conn, 404) == %{"error" => "Record not found"}
+ assert json_response_and_validate_schema(conn, 404) == %{"error" => "Record not found"}
end
test "get a direct status" do
@@ -590,7 +667,7 @@ test "get a direct status" do
other_user = insert(:user)
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "@#{other_user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "@#{other_user.nickname}", visibility: "direct"})
conn =
conn
@@ -599,7 +676,7 @@ test "get a direct status" do
[participation] = Participation.for_user(user)
- res = json_response(conn, 200)
+ res = json_response_and_validate_schema(conn, 200)
assert res["pleroma"]["direct_conversation_id"] == participation.id
end
@@ -611,7 +688,8 @@ test "get statuses by IDs" do
query_string = "ids[]=#{id1}&ids[]=#{id2}"
conn = get(conn, "/api/v1/statuses/?#{query_string}")
- assert [%{"id" => ^id1}, %{"id" => ^id2}] = Enum.sort_by(json_response(conn, :ok), & &1["id"])
+ assert [%{"id" => ^id1}, %{"id" => ^id2}] =
+ Enum.sort_by(json_response_and_validate_schema(conn, :ok), & &1["id"])
end
describe "getting statuses by ids with restricted unauthenticated for local and remote" do
@@ -622,17 +700,17 @@ test "get statuses by IDs" do
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
- assert json_response(res_conn, 200) == []
+ assert json_response_and_validate_schema(res_conn, 200) == []
end
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
- assert length(json_response(res_conn, 200)) == 2
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -642,18 +720,18 @@ test "if user is authenticated", %{local: local, remote: remote} do
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
remote_id = remote.id
- assert [%{"id" => ^remote_id}] = json_response(res_conn, 200)
+ assert [%{"id" => ^remote_id}] = json_response_and_validate_schema(res_conn, 200)
end
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
- assert length(json_response(res_conn, 200)) == 2
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -663,18 +741,18 @@ test "if user is authenticated", %{local: local, remote: remote} do
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
local_id = local.id
- assert [%{"id" => ^local_id}] = json_response(res_conn, 200)
+ assert [%{"id" => ^local_id}] = json_response_and_validate_schema(res_conn, 200)
end
test "if user is authenticated", %{local: local, remote: remote} do
%{conn: conn} = oauth_access(["read"])
- res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
+ res_conn = get(conn, "/api/v1/statuses?ids[]=#{local.id}&ids[]=#{remote.id}")
- assert length(json_response(res_conn, 200)) == 2
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -688,7 +766,7 @@ test "when you created it" do
|> assign(:user, author)
|> delete("/api/v1/statuses/#{activity.id}")
- assert %{} = json_response(conn, 200)
+ assert %{} = json_response_and_validate_schema(conn, 200)
refute Activity.get_by_id(activity.id)
end
@@ -702,7 +780,7 @@ test "when it doesn't exist" do
|> assign(:user, author)
|> delete("/api/v1/statuses/#{String.downcase(activity.id)}")
- assert %{"error" => "Record not found"} == json_response(conn, 404)
+ assert %{"error" => "Record not found"} == json_response_and_validate_schema(conn, 404)
end
test "when you didn't create it" do
@@ -711,7 +789,7 @@ test "when you didn't create it" do
conn = delete(conn, "/api/v1/statuses/#{activity.id}")
- assert %{"error" => _} = json_response(conn, 403)
+ assert %{"error" => _} = json_response_and_validate_schema(conn, 403)
assert Activity.get_by_id(activity.id) == activity
end
@@ -728,7 +806,7 @@ test "when you're an admin or moderator", %{conn: conn} do
|> assign(:token, insert(:oauth_token, user: admin, scopes: ["write:statuses"]))
|> delete("/api/v1/statuses/#{activity1.id}")
- assert %{} = json_response(res_conn, 200)
+ assert %{} = json_response_and_validate_schema(res_conn, 200)
res_conn =
conn
@@ -736,7 +814,7 @@ test "when you're an admin or moderator", %{conn: conn} do
|> assign(:token, insert(:oauth_token, user: moderator, scopes: ["write:statuses"]))
|> delete("/api/v1/statuses/#{activity2.id}")
- assert %{} = json_response(res_conn, 200)
+ assert %{} = json_response_and_validate_schema(res_conn, 200)
refute Activity.get_by_id(activity1.id)
refute Activity.get_by_id(activity2.id)
@@ -749,12 +827,15 @@ test "when you're an admin or moderator", %{conn: conn} do
test "reblogs and returns the reblogged status", %{conn: conn} do
activity = insert(:note_activity)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/reblog")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/reblog")
assert %{
"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1},
"reblogged" => true
- } = json_response(conn, 200)
+ } = json_response_and_validate_schema(conn, 200)
assert to_string(activity.id) == id
end
@@ -762,21 +843,30 @@ test "reblogs and returns the reblogged status", %{conn: conn} do
test "returns 404 if the reblogged status doesn't exist", %{conn: conn} do
activity = insert(:note_activity)
- conn = post(conn, "/api/v1/statuses/#{String.downcase(activity.id)}/reblog")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{String.downcase(activity.id)}/reblog")
- assert %{"error" => "Record not found"} = json_response(conn, 404)
+ assert %{"error" => "Record not found"} = json_response_and_validate_schema(conn, 404)
end
test "reblogs privately and returns the reblogged status", %{conn: conn} do
activity = insert(:note_activity)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/reblog", %{"visibility" => "private"})
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post(
+ "/api/v1/statuses/#{activity.id}/reblog",
+ %{"visibility" => "private"}
+ )
assert %{
"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1},
"reblogged" => true,
"visibility" => "private"
- } = json_response(conn, 200)
+ } = json_response_and_validate_schema(conn, 200)
assert to_string(activity.id) == id
end
@@ -802,7 +892,7 @@ test "reblogged status for another user" do
"reblogged" => false,
"favourited" => false,
"bookmarked" => false
- } = json_response(conn_res, 200)
+ } = json_response_and_validate_schema(conn_res, 200)
conn_res =
build_conn()
@@ -815,7 +905,7 @@ test "reblogged status for another user" do
"reblogged" => true,
"favourited" => true,
"bookmarked" => true
- } = json_response(conn_res, 200)
+ } = json_response_and_validate_schema(conn_res, 200)
assert to_string(activity.id) == id
end
@@ -829,17 +919,24 @@ test "unreblogs and returns the unreblogged status", %{user: user, conn: conn} d
{:ok, _, _} = CommonAPI.repeat(activity.id, user)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/unreblog")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/unreblog")
- assert %{"id" => id, "reblogged" => false, "reblogs_count" => 0} = json_response(conn, 200)
+ assert %{"id" => id, "reblogged" => false, "reblogs_count" => 0} =
+ json_response_and_validate_schema(conn, 200)
assert to_string(activity.id) == id
end
test "returns 404 error when activity does not exist", %{conn: conn} do
- conn = post(conn, "/api/v1/statuses/foo/unreblog")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/foo/unreblog")
- assert json_response(conn, 404) == %{"error" => "Record not found"}
+ assert json_response_and_validate_schema(conn, 404) == %{"error" => "Record not found"}
end
end
@@ -849,10 +946,13 @@ test "returns 404 error when activity does not exist", %{conn: conn} do
test "favs a status and returns it", %{conn: conn} do
activity = insert(:note_activity)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/favourite")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/favourite")
assert %{"id" => id, "favourites_count" => 1, "favourited" => true} =
- json_response(conn, 200)
+ json_response_and_validate_schema(conn, 200)
assert to_string(activity.id) == id
end
@@ -860,18 +960,23 @@ test "favs a status and returns it", %{conn: conn} do
test "favoriting twice will just return 200", %{conn: conn} do
activity = insert(:note_activity)
- post(conn, "/api/v1/statuses/#{activity.id}/favourite")
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/favourite")
- assert post(conn, "/api/v1/statuses/#{activity.id}/favourite")
- |> json_response(200)
+ assert conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/favourite")
+ |> json_response_and_validate_schema(200)
end
test "returns 404 error for a wrong id", %{conn: conn} do
conn =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses/1/favourite")
- assert json_response(conn, 404) == %{"error" => "Record not found"}
+ assert json_response_and_validate_schema(conn, 404) == %{"error" => "Record not found"}
end
end
@@ -883,18 +988,24 @@ test "unfavorites a status and returns it", %{user: user, conn: conn} do
{:ok, _} = CommonAPI.favorite(user, activity.id)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/unfavourite")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/unfavourite")
assert %{"id" => id, "favourites_count" => 0, "favourited" => false} =
- json_response(conn, 200)
+ json_response_and_validate_schema(conn, 200)
assert to_string(activity.id) == id
end
test "returns 404 error for a wrong id", %{conn: conn} do
- conn = post(conn, "/api/v1/statuses/1/unfavourite")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/1/unfavourite")
- assert json_response(conn, 404) == %{"error" => "Record not found"}
+ assert json_response_and_validate_schema(conn, 404) == %{"error" => "Record not found"}
end
end
@@ -902,7 +1013,7 @@ test "returns 404 error for a wrong id", %{conn: conn} do
setup do: oauth_access(["write:accounts"])
setup %{user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
%{activity: activity}
end
@@ -914,21 +1025,25 @@ test "pin status", %{conn: conn, user: user, activity: activity} do
assert %{"id" => ^id_str, "pinned" => true} =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses/#{activity.id}/pin")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert [%{"id" => ^id_str, "pinned" => true}] =
conn
|> get("/api/v1/accounts/#{user.id}/statuses?pinned=true")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
end
test "/pin: returns 400 error when activity is not public", %{conn: conn, user: user} do
- {:ok, dm} = CommonAPI.post(user, %{"status" => "test", "visibility" => "direct"})
+ {:ok, dm} = CommonAPI.post(user, %{status: "test", visibility: "direct"})
- conn = post(conn, "/api/v1/statuses/#{dm.id}/pin")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{dm.id}/pin")
- assert json_response(conn, 400) == %{"error" => "Could not pin"}
+ assert json_response_and_validate_schema(conn, 400) == %{"error" => "Could not pin"}
end
test "unpin status", %{conn: conn, user: user, activity: activity} do
@@ -941,29 +1056,33 @@ test "unpin status", %{conn: conn, user: user, activity: activity} do
conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/unpin")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert [] =
conn
|> get("/api/v1/accounts/#{user.id}/statuses?pinned=true")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
end
test "/unpin: returns 400 error when activity is not exist", %{conn: conn} do
- conn = post(conn, "/api/v1/statuses/1/unpin")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/1/unpin")
- assert json_response(conn, 400) == %{"error" => "Could not unpin"}
+ assert json_response_and_validate_schema(conn, 400) == %{"error" => "Could not unpin"}
end
test "max pinned statuses", %{conn: conn, user: user, activity: activity_one} do
- {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ {:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
id_str_one = to_string(activity_one.id)
assert %{"id" => ^id_str_one, "pinned" => true} =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses/#{id_str_one}/pin")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
user = refresh_record(user)
@@ -971,7 +1090,7 @@ test "max pinned statuses", %{conn: conn, user: user, activity: activity_one} do
conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity_two.id}/pin")
- |> json_response(400)
+ |> json_response_and_validate_schema(400)
end
end
@@ -985,7 +1104,7 @@ test "max pinned statuses", %{conn: conn, user: user, activity: activity_one} do
test "returns rich-media card", %{conn: conn, user: user} do
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "https://example.com/ogp"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp"})
card_data = %{
"image" => "http://ia.media-imdb.com/images/rock.jpg",
@@ -1011,18 +1130,18 @@ test "returns rich-media card", %{conn: conn, user: user} do
response =
conn
|> get("/api/v1/statuses/#{activity.id}/card")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert response == card_data
# works with private posts
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "https://example.com/ogp", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "https://example.com/ogp", visibility: "direct"})
response_two =
conn
|> get("/api/v1/statuses/#{activity.id}/card")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert response_two == card_data
end
@@ -1030,13 +1149,12 @@ test "returns rich-media card", %{conn: conn, user: user} do
test "replaces missing description with an empty string", %{conn: conn, user: user} do
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "https://example.com/ogp-missing-data"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "https://example.com/ogp-missing-data"})
response =
conn
|> get("/api/v1/statuses/#{activity.id}/card")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert response == %{
"type" => "link",
@@ -1063,36 +1181,42 @@ test "bookmarks" do
%{conn: conn} = oauth_access(["write:bookmarks", "read:bookmarks"])
author = insert(:user)
- {:ok, activity1} =
- CommonAPI.post(author, %{
- "status" => "heweoo?"
- })
+ {:ok, activity1} = CommonAPI.post(author, %{status: "heweoo?"})
+ {:ok, activity2} = CommonAPI.post(author, %{status: "heweoo!"})
- {:ok, activity2} =
- CommonAPI.post(author, %{
- "status" => "heweoo!"
- })
+ response1 =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity1.id}/bookmark")
- response1 = post(conn, "/api/v1/statuses/#{activity1.id}/bookmark")
+ assert json_response_and_validate_schema(response1, 200)["bookmarked"] == true
- assert json_response(response1, 200)["bookmarked"] == true
+ response2 =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity2.id}/bookmark")
- response2 = post(conn, "/api/v1/statuses/#{activity2.id}/bookmark")
-
- assert json_response(response2, 200)["bookmarked"] == true
+ assert json_response_and_validate_schema(response2, 200)["bookmarked"] == true
bookmarks = get(conn, bookmarks_uri)
- assert [json_response(response2, 200), json_response(response1, 200)] ==
- json_response(bookmarks, 200)
+ assert [
+ json_response_and_validate_schema(response2, 200),
+ json_response_and_validate_schema(response1, 200)
+ ] ==
+ json_response_and_validate_schema(bookmarks, 200)
- response1 = post(conn, "/api/v1/statuses/#{activity1.id}/unbookmark")
+ response1 =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity1.id}/unbookmark")
- assert json_response(response1, 200)["bookmarked"] == false
+ assert json_response_and_validate_schema(response1, 200)["bookmarked"] == false
bookmarks = get(conn, bookmarks_uri)
- assert [json_response(response2, 200)] == json_response(bookmarks, 200)
+ assert [json_response_and_validate_schema(response2, 200)] ==
+ json_response_and_validate_schema(bookmarks, 200)
end
describe "conversation muting" do
@@ -1100,7 +1224,7 @@ test "bookmarks" do
setup do
post_user = insert(:user)
- {:ok, activity} = CommonAPI.post(post_user, %{"status" => "HIE"})
+ {:ok, activity} = CommonAPI.post(post_user, %{status: "HIE"})
%{activity: activity}
end
@@ -1109,16 +1233,22 @@ test "mute conversation", %{conn: conn, activity: activity} do
assert %{"id" => ^id_str, "muted" => true} =
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses/#{activity.id}/mute")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
end
test "cannot mute already muted conversation", %{conn: conn, user: user, activity: activity} do
{:ok, _} = CommonAPI.add_mute(user, activity)
- conn = post(conn, "/api/v1/statuses/#{activity.id}/mute")
+ conn =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses/#{activity.id}/mute")
- assert json_response(conn, 400) == %{"error" => "conversation is already muted"}
+ assert json_response_and_validate_schema(conn, 400) == %{
+ "error" => "conversation is already muted"
+ }
end
test "unmute conversation", %{conn: conn, user: user, activity: activity} do
@@ -1130,7 +1260,7 @@ test "unmute conversation", %{conn: conn, user: user, activity: activity} do
conn
# |> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/unmute")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
end
end
@@ -1139,16 +1269,17 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
user2 = insert(:user)
user3 = insert(:user)
- {:ok, replied_to} = CommonAPI.post(user1, %{"status" => "cofe"})
+ {:ok, replied_to} = CommonAPI.post(user1, %{status: "cofe"})
# Reply to status from another user
conn1 =
conn
|> assign(:user, user2)
|> assign(:token, insert(:oauth_token, user: user2, scopes: ["write:statuses"]))
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => replied_to.id})
- assert %{"content" => "xD", "id" => id} = json_response(conn1, 200)
+ assert %{"content" => "xD", "id" => id} = json_response_and_validate_schema(conn1, 200)
activity = Activity.get_by_id_with_object(id)
@@ -1160,10 +1291,11 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
conn
|> assign(:user, user3)
|> assign(:token, insert(:oauth_token, user: user3, scopes: ["write:statuses"]))
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/statuses/#{activity.id}/reblog")
assert %{"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1}} =
- json_response(conn2, 200)
+ json_response_and_validate_schema(conn2, 200)
assert to_string(activity.id) == id
@@ -1186,7 +1318,7 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
setup do: oauth_access(["read:accounts"])
setup %{user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test"})
%{activity: activity}
end
@@ -1198,7 +1330,7 @@ test "returns users who have favorited the status", %{conn: conn, activity: acti
response =
conn
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
[%{"id" => id}] = response
@@ -1212,7 +1344,7 @@ test "returns empty array when status has not been favorited yet", %{
response =
conn
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -1229,7 +1361,7 @@ test "does not return users who have favorited the status but are blocked", %{
response =
conn
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -1241,7 +1373,7 @@ test "does not fail on an unauthenticated request", %{activity: activity} do
response =
build_conn()
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
[%{"id" => id}] = response
assert id == other_user.id
@@ -1252,8 +1384,8 @@ test "requires authentication for private posts", %{user: user} do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "@#{other_user.nickname} wanna get some #cofe together?",
- "visibility" => "direct"
+ status: "@#{other_user.nickname} wanna get some #cofe together?",
+ visibility: "direct"
})
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
@@ -1262,7 +1394,7 @@ test "requires authentication for private posts", %{user: user} do
build_conn()
|> get(favourited_by_url)
- |> json_response(404)
+ |> json_response_and_validate_schema(404)
conn =
build_conn()
@@ -1272,12 +1404,12 @@ test "requires authentication for private posts", %{user: user} do
conn
|> assign(:token, nil)
|> get(favourited_by_url)
- |> json_response(404)
+ |> json_response_and_validate_schema(404)
response =
conn
|> get(favourited_by_url)
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
[%{"id" => id}] = response
assert id == other_user.id
@@ -1288,7 +1420,7 @@ test "requires authentication for private posts", %{user: user} do
setup do: oauth_access(["read:accounts"])
setup %{user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "test"})
%{activity: activity}
end
@@ -1300,7 +1432,7 @@ test "returns users who have reblogged the status", %{conn: conn, activity: acti
response =
conn
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
[%{"id" => id}] = response
@@ -1314,7 +1446,7 @@ test "returns empty array when status has not been reblogged yet", %{
response =
conn
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -1331,7 +1463,7 @@ test "does not return users who have reblogged the status but are blocked", %{
response =
conn
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -1342,12 +1474,12 @@ test "does not return users who have reblogged the status privately", %{
} do
other_user = insert(:user)
- {:ok, _, _} = CommonAPI.repeat(activity.id, other_user, %{"visibility" => "private"})
+ {:ok, _, _} = CommonAPI.repeat(activity.id, other_user, %{visibility: "private"})
response =
conn
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -1359,7 +1491,7 @@ test "does not fail on an unauthenticated request", %{activity: activity} do
response =
build_conn()
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
[%{"id" => id}] = response
assert id == other_user.id
@@ -1370,20 +1502,20 @@ test "requires authentication for private posts", %{user: user} do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "@#{other_user.nickname} wanna get some #cofe together?",
- "visibility" => "direct"
+ status: "@#{other_user.nickname} wanna get some #cofe together?",
+ visibility: "direct"
})
build_conn()
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(404)
+ |> json_response_and_validate_schema(404)
response =
build_conn()
|> assign(:user, other_user)
|> assign(:token, insert(:oauth_token, user: other_user, scopes: ["read:accounts"]))
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert [] == response
end
@@ -1392,16 +1524,16 @@ test "requires authentication for private posts", %{user: user} do
test "context" do
user = insert(:user)
- {:ok, %{id: id1}} = CommonAPI.post(user, %{"status" => "1"})
- {:ok, %{id: id2}} = CommonAPI.post(user, %{"status" => "2", "in_reply_to_status_id" => id1})
- {:ok, %{id: id3}} = CommonAPI.post(user, %{"status" => "3", "in_reply_to_status_id" => id2})
- {:ok, %{id: id4}} = CommonAPI.post(user, %{"status" => "4", "in_reply_to_status_id" => id3})
- {:ok, %{id: id5}} = CommonAPI.post(user, %{"status" => "5", "in_reply_to_status_id" => id4})
+ {:ok, %{id: id1}} = CommonAPI.post(user, %{status: "1"})
+ {:ok, %{id: id2}} = CommonAPI.post(user, %{status: "2", in_reply_to_status_id: id1})
+ {:ok, %{id: id3}} = CommonAPI.post(user, %{status: "3", in_reply_to_status_id: id2})
+ {:ok, %{id: id4}} = CommonAPI.post(user, %{status: "4", in_reply_to_status_id: id3})
+ {:ok, %{id: id5}} = CommonAPI.post(user, %{status: "5", in_reply_to_status_id: id4})
response =
build_conn()
|> get("/api/v1/statuses/#{id3}/context")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert %{
"ancestors" => [%{"id" => ^id1}, %{"id" => ^id2}],
@@ -1413,14 +1545,14 @@ test "returns the favorites of a user" do
%{user: user, conn: conn} = oauth_access(["read:favourites"])
other_user = insert(:user)
- {:ok, _} = CommonAPI.post(other_user, %{"status" => "bla"})
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "traps are happy"})
+ {:ok, _} = CommonAPI.post(other_user, %{status: "bla"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "traps are happy"})
{:ok, _} = CommonAPI.favorite(user, activity.id)
first_conn = get(conn, "/api/v1/favourites")
- assert [status] = json_response(first_conn, 200)
+ assert [status] = json_response_and_validate_schema(first_conn, 200)
assert status["id"] == to_string(activity.id)
assert [{"link", _link_header}] =
@@ -1429,8 +1561,7 @@ test "returns the favorites of a user" do
# Honours query params
{:ok, second_activity} =
CommonAPI.post(other_user, %{
- "status" =>
- "Trees Are Never Sad Look At Them Every Once In Awhile They're Quite Beautiful."
+ status: "Trees Are Never Sad Look At Them Every Once In Awhile They're Quite Beautiful."
})
{:ok, _} = CommonAPI.favorite(user, second_activity.id)
@@ -1439,17 +1570,17 @@ test "returns the favorites of a user" do
second_conn = get(conn, "/api/v1/favourites?since_id=#{last_like}")
- assert [second_status] = json_response(second_conn, 200)
+ assert [second_status] = json_response_and_validate_schema(second_conn, 200)
assert second_status["id"] == to_string(second_activity.id)
third_conn = get(conn, "/api/v1/favourites?limit=0")
- assert [] = json_response(third_conn, 200)
+ assert [] = json_response_and_validate_schema(third_conn, 200)
end
test "expires_at is nil for another user" do
%{conn: conn, user: user} = oauth_access(["read:statuses"])
- {:ok, activity} = CommonAPI.post(user, %{"status" => "foobar", "expires_in" => 1_000_000})
+ {:ok, activity} = CommonAPI.post(user, %{status: "foobar", expires_in: 1_000_000})
expires_at =
activity.id
@@ -1458,11 +1589,15 @@ test "expires_at is nil for another user" do
|> NaiveDateTime.to_iso8601()
assert %{"pleroma" => %{"expires_at" => ^expires_at}} =
- conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok)
+ conn
+ |> get("/api/v1/statuses/#{activity.id}")
+ |> json_response_and_validate_schema(:ok)
%{conn: conn} = oauth_access(["read:statuses"])
assert %{"pleroma" => %{"expires_at" => nil}} =
- conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok)
+ conn
+ |> get("/api/v1/statuses/#{activity.id}")
+ |> json_response_and_validate_schema(:ok)
end
end
diff --git a/test/web/mastodon_api/controllers/suggestion_controller_test.exs b/test/web/mastodon_api/controllers/suggestion_controller_test.exs
index f120bd0cd..7f08e187c 100644
--- a/test/web/mastodon_api/controllers/suggestion_controller_test.exs
+++ b/test/web/mastodon_api/controllers/suggestion_controller_test.exs
@@ -11,7 +11,7 @@ test "returns empty result", %{conn: conn} do
res =
conn
|> get("/api/v1/suggestions")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert res == []
end
diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs
index 06efdc901..f8b9289f3 100644
--- a/test/web/mastodon_api/controllers/timeline_controller_test.exs
+++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs
@@ -28,13 +28,13 @@ test "does NOT render account/pleroma/relationship if this is disabled by defaul
other_user = insert(:user)
- {:ok, _} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, _} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
response =
conn
|> assign(:user, user)
|> get("/api/v1/timelines/home")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert Enum.all?(response, fn n ->
get_in(n, ["account", "pleroma", "relationship"]) == %{}
@@ -42,18 +42,18 @@ test "does NOT render account/pleroma/relationship if this is disabled by defaul
end
test "the home timeline", %{user: user, conn: conn} do
- uri = "/api/v1/timelines/home?with_relationships=true"
+ uri = "/api/v1/timelines/home?with_relationships=1"
following = insert(:user, nickname: "followed")
third_user = insert(:user, nickname: "repeated")
- {:ok, _activity} = CommonAPI.post(following, %{"status" => "post"})
- {:ok, activity} = CommonAPI.post(third_user, %{"status" => "repeated post"})
+ {:ok, _activity} = CommonAPI.post(following, %{status: "post"})
+ {:ok, activity} = CommonAPI.post(third_user, %{status: "repeated post"})
{:ok, _, _} = CommonAPI.repeat(activity.id, following)
ret_conn = get(conn, uri)
- assert Enum.empty?(json_response(ret_conn, :ok))
+ assert Enum.empty?(json_response_and_validate_schema(ret_conn, :ok))
{:ok, _user} = User.follow(user, following)
@@ -78,7 +78,7 @@ test "the home timeline", %{user: user, conn: conn} do
"pleroma" => %{"relationship" => %{"following" => true}}
}
}
- ] = json_response(ret_conn, :ok)
+ ] = json_response_and_validate_schema(ret_conn, :ok)
{:ok, _user} = User.follow(third_user, user)
@@ -104,22 +104,20 @@ test "the home timeline", %{user: user, conn: conn} do
"pleroma" => %{"relationship" => %{"following" => true}}
}
}
- ] = json_response(ret_conn, :ok)
+ ] = json_response_and_validate_schema(ret_conn, :ok)
end
test "the home timeline when the direct messages are excluded", %{user: user, conn: conn} do
- {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
- {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+ {:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
+ {:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
- {:ok, unlisted_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
+ {:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
- {:ok, private_activity} =
- CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+ {:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
- conn = get(conn, "/api/v1/timelines/home", %{"exclude_visibilities" => ["direct"]})
+ conn = get(conn, "/api/v1/timelines/home?exclude_visibilities[]=direct")
- assert status_ids = json_response(conn, :ok) |> Enum.map(& &1["id"])
+ assert status_ids = json_response_and_validate_schema(conn, :ok) |> Enum.map(& &1["id"])
assert public_activity.id in status_ids
assert unlisted_activity.id in status_ids
assert private_activity.id in status_ids
@@ -132,33 +130,33 @@ test "the home timeline when the direct messages are excluded", %{user: user, co
test "the public timeline", %{conn: conn} do
following = insert(:user)
- {:ok, _activity} = CommonAPI.post(following, %{"status" => "test"})
+ {:ok, _activity} = CommonAPI.post(following, %{status: "test"})
_activity = insert(:note_activity, local: false)
- conn = get(conn, "/api/v1/timelines/public", %{"local" => "False"})
+ conn = get(conn, "/api/v1/timelines/public?local=False")
- assert length(json_response(conn, :ok)) == 2
+ assert length(json_response_and_validate_schema(conn, :ok)) == 2
- conn = get(build_conn(), "/api/v1/timelines/public", %{"local" => "True"})
+ conn = get(build_conn(), "/api/v1/timelines/public?local=True")
- assert [%{"content" => "test"}] = json_response(conn, :ok)
+ assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
- conn = get(build_conn(), "/api/v1/timelines/public", %{"local" => "1"})
+ conn = get(build_conn(), "/api/v1/timelines/public?local=1")
- assert [%{"content" => "test"}] = json_response(conn, :ok)
+ assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
end
test "the public timeline includes only public statuses for an authenticated user" do
%{user: user, conn: conn} = oauth_access(["read:statuses"])
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "test"})
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "private"})
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "unlisted"})
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "direct"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "test"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "private"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "unlisted"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "direct"})
res_conn = get(conn, "/api/v1/timelines/public")
- assert length(json_response(res_conn, 200)) == 1
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 1
end
end
@@ -176,15 +174,15 @@ defp local_and_remote_activities do
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
test "if user is unauthenticated", %{conn: conn} do
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
- assert json_response(res_conn, :unauthorized) == %{
+ assert json_response_and_validate_schema(res_conn, :unauthorized) == %{
"error" => "authorization required for timeline view"
}
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
- assert json_response(res_conn, :unauthorized) == %{
+ assert json_response_and_validate_schema(res_conn, :unauthorized) == %{
"error" => "authorization required for timeline view"
}
end
@@ -192,11 +190,11 @@ test "if user is unauthenticated", %{conn: conn} do
test "if user is authenticated" do
%{conn: conn} = oauth_access(["read:statuses"])
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
- assert length(json_response(res_conn, 200)) == 1
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 1
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
- assert length(json_response(res_conn, 200)) == 2
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -206,24 +204,24 @@ test "if user is authenticated" do
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
test "if user is unauthenticated", %{conn: conn} do
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
- assert json_response(res_conn, :unauthorized) == %{
+ assert json_response_and_validate_schema(res_conn, :unauthorized) == %{
"error" => "authorization required for timeline view"
}
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
- assert length(json_response(res_conn, 200)) == 2
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
test "if user is authenticated", %{conn: _conn} do
%{conn: conn} = oauth_access(["read:statuses"])
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
- assert length(json_response(res_conn, 200)) == 1
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 1
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
- assert length(json_response(res_conn, 200)) == 2
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -233,12 +231,12 @@ test "if user is authenticated", %{conn: _conn} do
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
test "if user is unauthenticated", %{conn: conn} do
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
- assert length(json_response(res_conn, 200)) == 1
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 1
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
- assert json_response(res_conn, :unauthorized) == %{
+ assert json_response_and_validate_schema(res_conn, :unauthorized) == %{
"error" => "authorization required for timeline view"
}
end
@@ -246,11 +244,11 @@ test "if user is unauthenticated", %{conn: conn} do
test "if user is authenticated", %{conn: _conn} do
%{conn: conn} = oauth_access(["read:statuses"])
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
- assert length(json_response(res_conn, 200)) == 1
+ res_conn = get(conn, "/api/v1/timelines/public?local=true")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 1
- res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "false"})
- assert length(json_response(res_conn, 200)) == 2
+ res_conn = get(conn, "/api/v1/timelines/public?local=false")
+ assert length(json_response_and_validate_schema(res_conn, 200)) == 2
end
end
@@ -263,14 +261,14 @@ test "direct timeline", %{conn: conn} do
{:ok, direct} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "direct"
})
{:ok, _follower_only} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "private"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "private"
})
conn_user_two =
@@ -281,7 +279,7 @@ test "direct timeline", %{conn: conn} do
# Only direct should be visible here
res_conn = get(conn_user_two, "api/v1/timelines/direct")
- [status] = json_response(res_conn, :ok)
+ assert [status] = json_response_and_validate_schema(res_conn, :ok)
assert %{"visibility" => "direct"} = status
assert status["url"] != direct.data["id"]
@@ -293,33 +291,34 @@ test "direct timeline", %{conn: conn} do
|> assign(:token, insert(:oauth_token, user: user_one, scopes: ["read:statuses"]))
|> get("api/v1/timelines/direct")
- [status] = json_response(res_conn, :ok)
+ [status] = json_response_and_validate_schema(res_conn, :ok)
assert %{"visibility" => "direct"} = status
# Both should be visible here
res_conn = get(conn_user_two, "api/v1/timelines/home")
- [_s1, _s2] = json_response(res_conn, :ok)
+ [_s1, _s2] = json_response_and_validate_schema(res_conn, :ok)
# Test pagination
Enum.each(1..20, fn _ ->
{:ok, _} =
CommonAPI.post(user_one, %{
- "status" => "Hi @#{user_two.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user_two.nickname}!",
+ visibility: "direct"
})
end)
res_conn = get(conn_user_two, "api/v1/timelines/direct")
- statuses = json_response(res_conn, :ok)
+ statuses = json_response_and_validate_schema(res_conn, :ok)
assert length(statuses) == 20
- res_conn =
- get(conn_user_two, "api/v1/timelines/direct", %{max_id: List.last(statuses)["id"]})
+ max_id = List.last(statuses)["id"]
- [status] = json_response(res_conn, :ok)
+ res_conn = get(conn_user_two, "api/v1/timelines/direct?max_id=#{max_id}")
+
+ assert [status] = json_response_and_validate_schema(res_conn, :ok)
assert status["url"] != direct.data["id"]
end
@@ -332,19 +331,19 @@ test "doesn't include DMs from blocked users" do
{:ok, _blocked_direct} =
CommonAPI.post(blocked, %{
- "status" => "Hi @#{blocker.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}!",
+ visibility: "direct"
})
{:ok, direct} =
CommonAPI.post(other_user, %{
- "status" => "Hi @#{blocker.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{blocker.nickname}!",
+ visibility: "direct"
})
res_conn = get(conn, "api/v1/timelines/direct")
- [status] = json_response(res_conn, :ok)
+ [status] = json_response_and_validate_schema(res_conn, :ok)
assert status["id"] == direct.id
end
end
@@ -354,14 +353,14 @@ test "doesn't include DMs from blocked users" do
test "list timeline", %{user: user, conn: conn} do
other_user = insert(:user)
- {:ok, _activity_one} = CommonAPI.post(user, %{"status" => "Marisa is cute."})
- {:ok, activity_two} = CommonAPI.post(other_user, %{"status" => "Marisa is cute."})
+ {:ok, _activity_one} = CommonAPI.post(user, %{status: "Marisa is cute."})
+ {:ok, activity_two} = CommonAPI.post(other_user, %{status: "Marisa is cute."})
{:ok, list} = Pleroma.List.create("name", user)
{:ok, list} = Pleroma.List.follow(list, other_user)
conn = get(conn, "/api/v1/timelines/list/#{list.id}")
- assert [%{"id" => id}] = json_response(conn, :ok)
+ assert [%{"id" => id}] = json_response_and_validate_schema(conn, :ok)
assert id == to_string(activity_two.id)
end
@@ -371,12 +370,12 @@ test "list timeline does not leak non-public statuses for unfollowed users", %{
conn: conn
} do
other_user = insert(:user)
- {:ok, activity_one} = CommonAPI.post(other_user, %{"status" => "Marisa is cute."})
+ {:ok, activity_one} = CommonAPI.post(other_user, %{status: "Marisa is cute."})
{:ok, _activity_two} =
CommonAPI.post(other_user, %{
- "status" => "Marisa is cute.",
- "visibility" => "private"
+ status: "Marisa is cute.",
+ visibility: "private"
})
{:ok, list} = Pleroma.List.create("name", user)
@@ -384,7 +383,7 @@ test "list timeline does not leak non-public statuses for unfollowed users", %{
conn = get(conn, "/api/v1/timelines/list/#{list.id}")
- assert [%{"id" => id}] = json_response(conn, :ok)
+ assert [%{"id" => id}] = json_response_and_validate_schema(conn, :ok)
assert id == to_string(activity_one.id)
end
@@ -397,18 +396,18 @@ test "list timeline does not leak non-public statuses for unfollowed users", %{
test "hashtag timeline", %{conn: conn} do
following = insert(:user)
- {:ok, activity} = CommonAPI.post(following, %{"status" => "test #2hu"})
+ {:ok, activity} = CommonAPI.post(following, %{status: "test #2hu"})
nconn = get(conn, "/api/v1/timelines/tag/2hu")
- assert [%{"id" => id}] = json_response(nconn, :ok)
+ assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok)
assert id == to_string(activity.id)
# works for different capitalization too
nconn = get(conn, "/api/v1/timelines/tag/2HU")
- assert [%{"id" => id}] = json_response(nconn, :ok)
+ assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok)
assert id == to_string(activity.id)
end
@@ -416,26 +415,25 @@ test "hashtag timeline", %{conn: conn} do
test "multi-hashtag timeline", %{conn: conn} do
user = insert(:user)
- {:ok, activity_test} = CommonAPI.post(user, %{"status" => "#test"})
- {:ok, activity_test1} = CommonAPI.post(user, %{"status" => "#test #test1"})
- {:ok, activity_none} = CommonAPI.post(user, %{"status" => "#test #none"})
+ {:ok, activity_test} = CommonAPI.post(user, %{status: "#test"})
+ {:ok, activity_test1} = CommonAPI.post(user, %{status: "#test #test1"})
+ {:ok, activity_none} = CommonAPI.post(user, %{status: "#test #none"})
- any_test = get(conn, "/api/v1/timelines/tag/test", %{"any" => ["test1"]})
+ any_test = get(conn, "/api/v1/timelines/tag/test?any[]=test1")
- [status_none, status_test1, status_test] = json_response(any_test, :ok)
+ [status_none, status_test1, status_test] = json_response_and_validate_schema(any_test, :ok)
assert to_string(activity_test.id) == status_test["id"]
assert to_string(activity_test1.id) == status_test1["id"]
assert to_string(activity_none.id) == status_none["id"]
- restricted_test =
- get(conn, "/api/v1/timelines/tag/test", %{"all" => ["test1"], "none" => ["none"]})
+ restricted_test = get(conn, "/api/v1/timelines/tag/test?all[]=test1&none[]=none")
- assert [status_test1] == json_response(restricted_test, :ok)
+ assert [status_test1] == json_response_and_validate_schema(restricted_test, :ok)
- all_test = get(conn, "/api/v1/timelines/tag/test", %{"all" => ["none"]})
+ all_test = get(conn, "/api/v1/timelines/tag/test?all[]=none")
- assert [status_none] == json_response(all_test, :ok)
+ assert [status_none] == json_response_and_validate_schema(all_test, :ok)
end
end
end
diff --git a/test/web/mastodon_api/mastodon_api_test.exs b/test/web/mastodon_api/mastodon_api_test.exs
index cb971806a..a7f9c5205 100644
--- a/test/web/mastodon_api/mastodon_api_test.exs
+++ b/test/web/mastodon_api/mastodon_api_test.exs
@@ -75,9 +75,9 @@ test "returns notifications for user" do
User.subscribe(subscriber, user)
- {:ok, status} = CommonAPI.post(user, %{"status" => "Akariiiin"})
+ {:ok, status} = CommonAPI.post(user, %{status: "Akariiiin"})
- {:ok, status1} = CommonAPI.post(user, %{"status" => "Magi"})
+ {:ok, status1} = CommonAPI.post(user, %{status: "Magi"})
{:ok, [notification]} = Notification.create_notifications(status)
{:ok, [notification1]} = Notification.create_notifications(status1)
res = MastodonAPI.get_notifications(subscriber)
diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs
index 5fb162141..69ddbb5d4 100644
--- a/test/web/mastodon_api/views/account_view_test.exs
+++ b/test/web/mastodon_api/views/account_view_test.exs
@@ -31,7 +31,7 @@ test "Represent a user account" do
nickname: "shp@shitposter.club",
name: ":karjalanpiirakka: shp",
bio:
- "valid html. a
b
c
d
f",
+ "valid html. a
b
c
d
f '&<>\"",
inserted_at: ~N[2017-08-15 15:47:06.597036],
emoji: %{"karjalanpiirakka" => "/file.png"}
})
@@ -46,7 +46,7 @@ test "Represent a user account" do
followers_count: 3,
following_count: 0,
statuses_count: 5,
- note: "valid html. a
b
c
d
f",
+ note: "valid html. a
b
c
d
f '&<>"",
url: user.ap_id,
avatar: "http://localhost:4001/images/avi.png",
avatar_static: "http://localhost:4001/images/avi.png",
@@ -63,7 +63,7 @@ test "Represent a user account" do
fields: [],
bot: false,
source: %{
- note: "valid html. a\nb\nc\nd\nf",
+ note: "valid html. a\nb\nc\nd\nf '&<>\"",
sensitive: false,
pleroma: %{
actor_type: "Person",
@@ -93,7 +93,14 @@ test "Represent a user account" do
test "Represent the user account for the account owner" do
user = insert(:user)
- notification_settings = %Pleroma.User.NotificationSetting{}
+ notification_settings = %{
+ followers: true,
+ follows: true,
+ non_followers: true,
+ non_follows: true,
+ privacy_option: false
+ }
+
privacy = user.default_scope
assert %{
@@ -452,8 +459,8 @@ test "shows unread_conversation_count only to the account owner" do
{:ok, _activity} =
CommonAPI.post(other_user, %{
- "status" => "Hey @#{user.nickname}.",
- "visibility" => "direct"
+ status: "Hey @#{user.nickname}.",
+ visibility: "direct"
})
user = User.get_cached_by_ap_id(user.ap_id)
diff --git a/test/web/mastodon_api/views/conversation_view_test.exs b/test/web/mastodon_api/views/conversation_view_test.exs
index dbf3c51e2..6f84366f8 100644
--- a/test/web/mastodon_api/views/conversation_view_test.exs
+++ b/test/web/mastodon_api/views/conversation_view_test.exs
@@ -16,7 +16,7 @@ test "represents a Mastodon Conversation entity" do
other_user = insert(:user)
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "hey @#{other_user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "hey @#{other_user.nickname}", visibility: "direct"})
[participation] = Participation.for_user_with_last_activity_id(user)
diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs
index 0806269a2..04a774d17 100644
--- a/test/web/mastodon_api/views/notification_view_test.exs
+++ b/test/web/mastodon_api/views/notification_view_test.exs
@@ -34,7 +34,7 @@ defp test_notifications_rendering(notifications, user, expected_result) do
test "Mention notification" do
user = insert(:user)
mentioned_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{mentioned_user.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey @#{mentioned_user.nickname}"})
{:ok, [notification]} = Notification.create_notifications(activity)
user = User.get_cached_by_id(user.id)
@@ -53,7 +53,7 @@ test "Mention notification" do
test "Favourite notification" do
user = insert(:user)
another_user = insert(:user)
- {:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, favorite_activity} = CommonAPI.favorite(another_user, create_activity.id)
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
create_activity = Activity.get_by_id(create_activity.id)
@@ -73,7 +73,7 @@ test "Favourite notification" do
test "Reblog notification" do
user = insert(:user)
another_user = insert(:user)
- {:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
+ {:ok, create_activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, reblog_activity, _object} = CommonAPI.repeat(create_activity.id, another_user)
{:ok, [notification]} = Notification.create_notifications(reblog_activity)
reblog_activity = Activity.get_by_id(create_activity.id)
@@ -155,7 +155,7 @@ test "EmojiReact notification" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
{:ok, _activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
activity = Repo.get(Activity, activity.id)
diff --git a/test/web/mastodon_api/views/poll_view_test.exs b/test/web/mastodon_api/views/poll_view_test.exs
index 63b204387..76672f36c 100644
--- a/test/web/mastodon_api/views/poll_view_test.exs
+++ b/test/web/mastodon_api/views/poll_view_test.exs
@@ -22,10 +22,10 @@ test "renders a poll" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Is Tenshi eating a corndog cute?",
- "poll" => %{
- "options" => ["absolutely!", "sure", "yes", "why are you even asking?"],
- "expires_in" => 20
+ status: "Is Tenshi eating a corndog cute?",
+ poll: %{
+ options: ["absolutely!", "sure", "yes", "why are you even asking?"],
+ expires_in: 20
}
})
@@ -62,11 +62,11 @@ test "detects if it is multiple choice" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Which Mastodon developer is your favourite?",
- "poll" => %{
- "options" => ["Gargron", "Eugen"],
- "expires_in" => 20,
- "multiple" => true
+ status: "Which Mastodon developer is your favourite?",
+ poll: %{
+ options: ["Gargron", "Eugen"],
+ expires_in: 20,
+ multiple: true
}
})
@@ -91,10 +91,10 @@ test "detects emoji" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "What's with the smug face?",
- "poll" => %{
- "options" => [":blank: sip", ":blank::blank: sip", ":blank::blank::blank: sip"],
- "expires_in" => 20
+ status: "What's with the smug face?",
+ poll: %{
+ options: [":blank: sip", ":blank::blank: sip", ":blank::blank::blank: sip"],
+ expires_in: 20
}
})
@@ -109,11 +109,11 @@ test "detects vote status" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "Which input devices do you use?",
- "poll" => %{
- "options" => ["mouse", "trackball", "trackpoint"],
- "multiple" => true,
- "expires_in" => 20
+ status: "Which input devices do you use?",
+ poll: %{
+ options: ["mouse", "trackball", "trackpoint"],
+ multiple: true,
+ expires_in: 20
}
})
diff --git a/test/web/mastodon_api/views/scheduled_activity_view_test.exs b/test/web/mastodon_api/views/scheduled_activity_view_test.exs
index 0c0987593..fbfd873ef 100644
--- a/test/web/mastodon_api/views/scheduled_activity_view_test.exs
+++ b/test/web/mastodon_api/views/scheduled_activity_view_test.exs
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
test "A scheduled activity with a media attachment" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hi"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hi"})
scheduled_at =
NaiveDateTime.utc_now()
@@ -47,7 +47,7 @@ test "A scheduled activity with a media attachment" do
expected = %{
id: to_string(scheduled_activity.id),
media_attachments:
- %{"media_ids" => [upload.id]}
+ %{media_ids: [upload.id]}
|> Utils.attachments_from_ids()
|> Enum.map(&StatusView.render("attachment.json", %{attachment: &1})),
params: %{
diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs
index b5e7dc317..ffad65b01 100644
--- a/test/web/mastodon_api/views/status_view_test.exs
+++ b/test/web/mastodon_api/views/status_view_test.exs
@@ -20,6 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
import Pleroma.Factory
import Tesla.Mock
+ import OpenApiSpex.TestAssertions
setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
@@ -30,7 +31,7 @@ test "has an emoji reaction list" do
user = insert(:user)
other_user = insert(:user)
third_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "dae cofe??"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"})
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "☕")
{:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
@@ -38,6 +39,8 @@ test "has an emoji reaction list" do
activity = Repo.get(Activity, activity.id)
status = StatusView.render("show.json", activity: activity)
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
+
assert status[:pleroma][:emoji_reactions] == [
%{name: "☕", count: 2, me: false},
%{name: "🍵", count: 1, me: false}
@@ -45,6 +48,8 @@ test "has an emoji reaction list" do
status = StatusView.render("show.json", activity: activity, for: user)
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
+
assert status[:pleroma][:emoji_reactions] == [
%{name: "☕", count: 2, me: true},
%{name: "🍵", count: 1, me: false}
@@ -54,7 +59,7 @@ test "has an emoji reaction list" do
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
[participation] = Participation.for_user(user)
status =
@@ -68,12 +73,13 @@ test "loads and returns the direct conversation id when given the `with_direct_c
status = StatusView.render("show.json", activity: activity, for: user)
assert status[:pleroma][:direct_conversation_id] == nil
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "returns the direct conversation id when given the `direct_conversation_id` option" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
[participation] = Participation.for_user(user)
status =
@@ -84,12 +90,13 @@ test "returns the direct conversation id when given the `direct_conversation_id`
)
assert status[:pleroma][:direct_conversation_id] == participation.id
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "returns a temporary ap_id based user for activities missing db users" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
Repo.delete(user)
Cachex.clear(:user_cache)
@@ -119,7 +126,7 @@ test "returns a temporary ap_id based user for activities missing db users" do
test "tries to get a user by nickname if fetching by ap_id doesn't work" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
{:ok, user} =
user
@@ -131,6 +138,7 @@ test "tries to get a user by nickname if fetching by ap_id doesn't work" do
result = StatusView.render("show.json", activity: activity)
assert result[:account][:id] == to_string(user.id)
+ assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
end
test "a note with null content" do
@@ -149,6 +157,7 @@ test "a note with null content" do
status = StatusView.render("show.json", %{activity: note})
assert status.content == ""
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "a note activity" do
@@ -222,6 +231,7 @@ test "a note activity" do
}
assert status == expected
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "tells if the message is muted for some reason" do
@@ -230,13 +240,14 @@ test "tells if the message is muted for some reason" do
{:ok, _user_relationships} = User.mute(user, other_user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
relationships_opt = UserRelationship.view_relationships_option(user, [other_user])
opts = %{activity: activity}
status = StatusView.render("show.json", opts)
assert status.muted == false
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
status = StatusView.render("show.json", Map.put(opts, :relationships, relationships_opt))
assert status.muted == false
@@ -247,6 +258,7 @@ test "tells if the message is muted for some reason" do
status = StatusView.render("show.json", Map.put(for_opts, :relationships, relationships_opt))
assert status.muted == true
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "tells if the message is thread muted" do
@@ -255,7 +267,7 @@ test "tells if the message is thread muted" do
{:ok, _user_relationships} = User.mute(user, other_user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
status = StatusView.render("show.json", %{activity: activity, for: user})
assert status.pleroma.thread_muted == false
@@ -270,7 +282,7 @@ test "tells if the message is thread muted" do
test "tells if the status is bookmarked" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Cute girls doing cute things"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Cute girls doing cute things"})
status = StatusView.render("show.json", %{activity: activity})
assert status.bookmarked == false
@@ -292,8 +304,7 @@ test "a reply" do
note = insert(:note_activity)
user = insert(:user)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "he", "in_reply_to_status_id" => note.id})
+ {:ok, activity} = CommonAPI.post(user, %{status: "he", in_reply_to_status_id: note.id})
status = StatusView.render("show.json", %{activity: activity})
@@ -308,12 +319,14 @@ test "contains mentions" do
user = insert(:user)
mentioned = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hi @#{mentioned.nickname}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "hi @#{mentioned.nickname}"})
status = StatusView.render("show.json", %{activity: activity})
assert status.mentions ==
Enum.map([mentioned], fn u -> AccountView.render("mention.json", %{user: u}) end)
+
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
test "create mentions from the 'to' field" do
@@ -405,14 +418,14 @@ test "attachments" do
api_spec = Pleroma.Web.ApiSpec.spec()
assert expected == StatusView.render("attachment.json", %{attachment: object})
- OpenApiSpex.TestAssertions.assert_schema(expected, "Attachment", api_spec)
+ assert_schema(expected, "Attachment", api_spec)
# If theres a "id", use that instead of the generated one
object = Map.put(object, "id", 2)
result = StatusView.render("attachment.json", %{attachment: object})
assert %{id: "2"} = result
- OpenApiSpex.TestAssertions.assert_schema(result, "Attachment", api_spec)
+ assert_schema(result, "Attachment", api_spec)
end
test "put the url advertised in the Activity in to the url attribute" do
@@ -436,6 +449,7 @@ test "a reblog" do
assert represented[:id] == to_string(reblog.id)
assert represented[:reblog][:id] == to_string(activity.id)
assert represented[:emojis] == []
+ assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
end
test "a peertube video" do
@@ -452,6 +466,7 @@ test "a peertube video" do
assert represented[:id] == to_string(activity.id)
assert length(represented[:media_attachments]) == 1
+ assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
end
test "funkwhale audio" do
@@ -567,13 +582,15 @@ test "embeds a relationship in the account" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "drink more water"
+ status: "drink more water"
})
result = StatusView.render("show.json", %{activity: activity, for: other_user})
assert result[:account][:pleroma][:relationship] ==
AccountView.render("relationship.json", %{user: other_user, target: user})
+
+ assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
end
test "embeds a relationship in the account in reposts" do
@@ -582,7 +599,7 @@ test "embeds a relationship in the account in reposts" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "˙˙ɐʎns"
+ status: "˙˙ɐʎns"
})
{:ok, activity, _object} = CommonAPI.repeat(activity.id, other_user)
@@ -594,6 +611,8 @@ test "embeds a relationship in the account in reposts" do
assert result[:reblog][:account][:pleroma][:relationship] ==
AccountView.render("relationship.json", %{user: user, target: user})
+
+ assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
end
test "visibility/list" do
@@ -601,8 +620,7 @@ test "visibility/list" do
{:ok, list} = Pleroma.List.create("foo", user)
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
status = StatusView.render("show.json", activity: activity)
@@ -616,5 +634,6 @@ test "successfully renders a Listen activity (pleroma extension)" do
assert status.length == listen_activity.data["object"]["length"]
assert status.title == listen_activity.data["object"]["title"]
+ assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
end
end
diff --git a/test/web/metadata/twitter_card_test.exs b/test/web/metadata/twitter_card_test.exs
index 9e9c6853a..10931b5ba 100644
--- a/test/web/metadata/twitter_card_test.exs
+++ b/test/web/metadata/twitter_card_test.exs
@@ -30,7 +30,7 @@ test "it renders twitter card for user info" do
test "it uses summary twittercard if post has no attachment" do
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI"})
note =
insert(:note, %{
@@ -56,7 +56,7 @@ test "it uses summary twittercard if post has no attachment" do
test "it renders avatar not attachment if post is nsfw and unfurl_nsfw is disabled" do
Pleroma.Config.put([Pleroma.Web.Metadata, :unfurl_nsfw], false)
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI"})
note =
insert(:note, %{
@@ -100,7 +100,7 @@ test "it renders avatar not attachment if post is nsfw and unfurl_nsfw is disabl
test "it renders supported types of attachments and skips unknown types" do
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "HI"})
note =
insert(:note, %{
diff --git a/test/web/mongooseim/mongoose_im_controller_test.exs b/test/web/mongooseim/mongoose_im_controller_test.exs
index 1ac2f2c27..5176cde84 100644
--- a/test/web/mongooseim/mongoose_im_controller_test.exs
+++ b/test/web/mongooseim/mongoose_im_controller_test.exs
@@ -41,13 +41,13 @@ test "/user_exists", %{conn: conn} do
end
test "/check_password", %{conn: conn} do
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("cool"))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt("cool"))
_deactivated_user =
insert(:user,
nickname: "konata",
deactivated: true,
- password_hash: Comeonin.Pbkdf2.hashpwsalt("cool")
+ password_hash: Pbkdf2.hash_pwd_salt("cool")
)
res =
diff --git a/test/web/oauth/ldap_authorization_test.exs b/test/web/oauth/ldap_authorization_test.exs
index a8fe8a841..011642c08 100644
--- a/test/web/oauth/ldap_authorization_test.exs
+++ b/test/web/oauth/ldap_authorization_test.exs
@@ -19,7 +19,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
@tag @skip
test "authorizes the existing user using LDAP credentials" do
password = "testpassword"
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password))
app = insert(:oauth_app, scopes: ["read", "write"])
host = Pleroma.Config.get([:ldap, :host]) |> to_charlist
@@ -104,7 +104,7 @@ test "creates a new user after successful LDAP authorization" do
@tag @skip
test "falls back to the default authorization when LDAP is unavailable" do
password = "testpassword"
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password))
app = insert(:oauth_app, scopes: ["read", "write"])
host = Pleroma.Config.get([:ldap, :host]) |> to_charlist
@@ -148,7 +148,7 @@ test "falls back to the default authorization when LDAP is unavailable" do
@tag @skip
test "disallow authorization for wrong LDAP credentials" do
password = "testpassword"
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password))
app = insert(:oauth_app, scopes: ["read", "write"])
host = Pleroma.Config.get([:ldap, :host]) |> to_charlist
diff --git a/test/web/oauth/mfa_controller_test.exs b/test/web/oauth/mfa_controller_test.exs
index ce4a07320..3c341facd 100644
--- a/test/web/oauth/mfa_controller_test.exs
+++ b/test/web/oauth/mfa_controller_test.exs
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.OAuth.MFAControllerTest do
insert(:user,
multi_factor_authentication_settings: %MFA.Settings{
enabled: true,
- backup_codes: [Comeonin.Pbkdf2.hashpwsalt("test-code")],
+ backup_codes: [Pbkdf2.hash_pwd_salt("test-code")],
totp: %MFA.Settings.TOTP{secret: otp_secret, confirmed: true}
}
)
@@ -247,7 +247,7 @@ test "returns access token with valid code", %{conn: conn, app: app} do
hashed_codes =
backup_codes
- |> Enum.map(&Comeonin.Pbkdf2.hashpwsalt(&1))
+ |> Enum.map(&Pbkdf2.hash_pwd_salt(&1))
user =
insert(:user,
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs
index 7a107584d..d389e4ce0 100644
--- a/test/web/oauth/oauth_controller_test.exs
+++ b/test/web/oauth/oauth_controller_test.exs
@@ -311,7 +311,7 @@ test "with valid params, POST /oauth/register?op=connect redirects to `redirect_
app: app,
conn: conn
} do
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt("testpassword"))
registration = insert(:registration, user: nil)
redirect_uri = OAuthController.default_redirect_uri(app)
@@ -342,7 +342,7 @@ test "with unlisted `redirect_uri`, POST /oauth/register?op=connect results in H
app: app,
conn: conn
} do
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt("testpassword"))
registration = insert(:registration, user: nil)
unlisted_redirect_uri = "http://cross-site-request.com"
@@ -750,7 +750,7 @@ test "issues a token for an all-body request" do
test "issues a token for `password` grant_type with valid credentials, with full permissions by default" do
password = "testpassword"
- user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password))
app = insert(:oauth_app, scopes: ["read", "write"])
@@ -778,7 +778,7 @@ test "issues a mfa token for `password` grant_type, when MFA enabled" do
user =
insert(:user,
- password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
+ password_hash: Pbkdf2.hash_pwd_salt(password),
multi_factor_authentication_settings: %MFA.Settings{
enabled: true,
totp: %MFA.Settings.TOTP{secret: otp_secret, confirmed: true}
@@ -887,7 +887,7 @@ test "rejects token exchange for valid credentials belonging to unconfirmed user
password = "testpassword"
{:ok, user} =
- insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
+ insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password))
|> User.confirmation_changeset(need_confirmation: true)
|> User.update_and_set_cache()
@@ -915,7 +915,7 @@ test "rejects token exchange for valid credentials belonging to deactivated user
user =
insert(:user,
- password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
+ password_hash: Pbkdf2.hash_pwd_salt(password),
deactivated: true
)
@@ -943,7 +943,7 @@ test "rejects token exchange for user with password_reset_pending set to true" d
user =
insert(:user,
- password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
+ password_hash: Pbkdf2.hash_pwd_salt(password),
password_reset_pending: true
)
@@ -972,7 +972,7 @@ test "rejects token exchange for user with confirmation_pending set to true" do
user =
insert(:user,
- password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
+ password_hash: Pbkdf2.hash_pwd_salt(password),
confirmation_pending: true
)
diff --git a/test/web/pleroma_api/controllers/account_controller_test.exs b/test/web/pleroma_api/controllers/account_controller_test.exs
index 6b671a667..103997c31 100644
--- a/test/web/pleroma_api/controllers/account_controller_test.exs
+++ b/test/web/pleroma_api/controllers/account_controller_test.exs
@@ -31,8 +31,28 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
test "resend account confirmation email", %{conn: conn, user: user} do
conn
+ |> put_req_header("content-type", "application/json")
|> post("/api/v1/pleroma/accounts/confirmation_resend?email=#{user.email}")
- |> json_response(:no_content)
+ |> json_response_and_validate_schema(:no_content)
+
+ ObanHelpers.perform_all()
+
+ email = Pleroma.Emails.UserEmail.account_confirmation_email(user)
+ notify_email = Config.get([:instance, :notify_email])
+ instance_name = Config.get([:instance, :name])
+
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: email.html_body
+ )
+ end
+
+ test "resend account confirmation email (with nickname)", %{conn: conn, user: user} do
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/pleroma/accounts/confirmation_resend?nickname=#{user.nickname}")
+ |> json_response_and_validate_schema(:no_content)
ObanHelpers.perform_all()
@@ -54,7 +74,10 @@ test "resend account confirmation email", %{conn: conn, user: user} do
test "user avatar can be set", %{user: user, conn: conn} do
avatar_image = File.read!("test/fixtures/avatar_data_uri")
- conn = patch(conn, "/api/v1/pleroma/accounts/update_avatar", %{img: avatar_image})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_avatar", %{img: avatar_image})
user = refresh_record(user)
@@ -70,17 +93,20 @@ test "user avatar can be set", %{user: user, conn: conn} do
]
} = user.avatar
- assert %{"url" => _} = json_response(conn, 200)
+ assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
end
test "user avatar can be reset", %{user: user, conn: conn} do
- conn = patch(conn, "/api/v1/pleroma/accounts/update_avatar", %{img: ""})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_avatar", %{img: ""})
user = User.get_cached_by_id(user.id)
assert user.avatar == nil
- assert %{"url" => nil} = json_response(conn, 200)
+ assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
end
end
@@ -88,21 +114,27 @@ test "user avatar can be reset", %{user: user, conn: conn} do
setup do: oauth_access(["write:accounts"])
test "can set profile banner", %{user: user, conn: conn} do
- conn = patch(conn, "/api/v1/pleroma/accounts/update_banner", %{"banner" => @image})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => @image})
user = refresh_record(user)
assert user.banner["type"] == "Image"
- assert %{"url" => _} = json_response(conn, 200)
+ assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
end
test "can reset profile banner", %{user: user, conn: conn} do
- conn = patch(conn, "/api/v1/pleroma/accounts/update_banner", %{"banner" => ""})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_banner", %{"banner" => ""})
user = refresh_record(user)
assert user.banner == %{}
- assert %{"url" => nil} = json_response(conn, 200)
+ assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
end
end
@@ -110,19 +142,26 @@ test "can reset profile banner", %{user: user, conn: conn} do
setup do: oauth_access(["write:accounts"])
test "background image can be set", %{user: user, conn: conn} do
- conn = patch(conn, "/api/v1/pleroma/accounts/update_background", %{"img" => @image})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_background", %{"img" => @image})
user = refresh_record(user)
assert user.background["type"] == "Image"
- assert %{"url" => _} = json_response(conn, 200)
+ # assert %{"url" => _} = json_response(conn, 200)
+ assert %{"url" => _} = json_response_and_validate_schema(conn, 200)
end
test "background image can be reset", %{user: user, conn: conn} do
- conn = patch(conn, "/api/v1/pleroma/accounts/update_background", %{"img" => ""})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> patch("/api/v1/pleroma/accounts/update_background", %{"img" => ""})
user = refresh_record(user)
assert user.background == %{}
- assert %{"url" => nil} = json_response(conn, 200)
+ assert %{"url" => nil} = json_response_and_validate_schema(conn, 200)
end
end
@@ -143,7 +182,7 @@ test "returns list of statuses favorited by specified user", %{
response =
conn
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
[like] = response
@@ -160,7 +199,7 @@ test "returns favorites for specified user_id when requester is not logged in",
response =
build_conn()
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert length(response) == 1
end
@@ -171,8 +210,8 @@ test "returns favorited DM only when user is logged in and he is one of recipien
} do
{:ok, direct} =
CommonAPI.post(current_user, %{
- "status" => "Hi @#{user.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user.nickname}!",
+ visibility: "direct"
})
CommonAPI.favorite(user, direct.id)
@@ -183,7 +222,7 @@ test "returns favorited DM only when user is logged in and he is one of recipien
|> assign(:user, u)
|> assign(:token, insert(:oauth_token, user: u, scopes: ["read:favourites"]))
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert length(response) == 1
end
@@ -191,7 +230,7 @@ test "returns favorited DM only when user is logged in and he is one of recipien
response =
build_conn()
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(200)
+ |> json_response_and_validate_schema(200)
assert length(response) == 0
end
@@ -204,8 +243,8 @@ test "does not return others' favorited DM when user is not one of recipients",
{:ok, direct} =
CommonAPI.post(user_two, %{
- "status" => "Hi @#{user.nickname}!",
- "visibility" => "direct"
+ status: "Hi @#{user.nickname}!",
+ visibility: "direct"
})
CommonAPI.favorite(user, direct.id)
@@ -213,7 +252,7 @@ test "does not return others' favorited DM when user is not one of recipients",
response =
conn
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -233,11 +272,12 @@ test "paginates favorites using since_id and max_id", %{
response =
conn
- |> get("/api/v1/pleroma/accounts/#{user.id}/favourites", %{
- since_id: third_activity.id,
- max_id: seventh_activity.id
- })
- |> json_response(:ok)
+ |> get(
+ "/api/v1/pleroma/accounts/#{user.id}/favourites?since_id=#{third_activity.id}&max_id=#{
+ seventh_activity.id
+ }"
+ )
+ |> json_response_and_validate_schema(:ok)
assert length(response) == 3
refute third_activity in response
@@ -256,8 +296,8 @@ test "limits favorites using limit parameter", %{
response =
conn
- |> get("/api/v1/pleroma/accounts/#{user.id}/favourites", %{limit: "3"})
- |> json_response(:ok)
+ |> get("/api/v1/pleroma/accounts/#{user.id}/favourites?limit=3")
+ |> json_response_and_validate_schema(:ok)
assert length(response) == 3
end
@@ -269,7 +309,7 @@ test "returns empty response when user does not have any favorited statuses", %{
response =
conn
|> get("/api/v1/pleroma/accounts/#{user.id}/favourites")
- |> json_response(:ok)
+ |> json_response_and_validate_schema(:ok)
assert Enum.empty?(response)
end
@@ -277,7 +317,7 @@ test "returns empty response when user does not have any favorited statuses", %{
test "returns 404 error when specified user is not exist", %{conn: conn} do
conn = get(conn, "/api/v1/pleroma/accounts/test/favourites")
- assert json_response(conn, 404) == %{"error" => "Record not found"}
+ assert json_response_and_validate_schema(conn, 404) == %{"error" => "Record not found"}
end
test "returns 403 error when user has hidden own favorites", %{conn: conn} do
@@ -287,7 +327,7 @@ test "returns 403 error when user has hidden own favorites", %{conn: conn} do
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites")
- assert json_response(conn, 403) == %{"error" => "Can't get favorites"}
+ assert json_response_and_validate_schema(conn, 403) == %{"error" => "Can't get favorites"}
end
test "hides favorites for new users by default", %{conn: conn} do
@@ -298,7 +338,7 @@ test "hides favorites for new users by default", %{conn: conn} do
assert user.hide_favorites
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/favourites")
- assert json_response(conn, 403) == %{"error" => "Can't get favorites"}
+ assert json_response_and_validate_schema(conn, 403) == %{"error" => "Can't get favorites"}
end
end
@@ -312,11 +352,12 @@ test "subscribing / unsubscribing to a user" do
|> assign(:user, user)
|> post("/api/v1/pleroma/accounts/#{subscription_target.id}/subscribe")
- assert %{"id" => _id, "subscribing" => true} = json_response(ret_conn, 200)
+ assert %{"id" => _id, "subscribing" => true} =
+ json_response_and_validate_schema(ret_conn, 200)
conn = post(conn, "/api/v1/pleroma/accounts/#{subscription_target.id}/unsubscribe")
- assert %{"id" => _id, "subscribing" => false} = json_response(conn, 200)
+ assert %{"id" => _id, "subscribing" => false} = json_response_and_validate_schema(conn, 200)
end
end
@@ -326,7 +367,7 @@ test "returns 404 when subscription_target not found" do
conn = post(conn, "/api/v1/pleroma/accounts/target_id/subscribe")
- assert %{"error" => "Record not found"} = json_response(conn, 404)
+ assert %{"error" => "Record not found"} = json_response_and_validate_schema(conn, 404)
end
end
@@ -336,7 +377,7 @@ test "returns 404 when subscription_target not found" do
conn = post(conn, "/api/v1/pleroma/accounts/target_id/unsubscribe")
- assert %{"error" => "Record not found"} = json_response(conn, 404)
+ assert %{"error" => "Record not found"} = json_response_and_validate_schema(conn, 404)
end
end
end
diff --git a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
index 43f1b154d..cfd1dbd24 100644
--- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
+++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs
@@ -20,7 +20,7 @@ test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
result =
conn
@@ -42,7 +42,7 @@ test "DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
{:ok, _reaction_activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
ObanHelpers.perform_all()
@@ -68,7 +68,7 @@ test "GET /api/v1/pleroma/statuses/:id/reactions", %{conn: conn} do
other_user = insert(:user)
doomed_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
result =
conn
@@ -106,7 +106,7 @@ test "GET /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
result =
conn
@@ -133,7 +133,7 @@ test "/api/v1/pleroma/conversations/:id" do
%{user: other_user, conn: conn} = oauth_access(["read:statuses"])
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}!", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}!", visibility: "direct"})
[participation] = Participation.for_user(other_user)
@@ -151,18 +151,18 @@ test "/api/v1/pleroma/conversations/:id/statuses" do
third_user = insert(:user)
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "Hi @#{third_user.nickname}!", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hi @#{third_user.nickname}!", visibility: "direct"})
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}!", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}!", visibility: "direct"})
[participation] = Participation.for_user(other_user)
{:ok, activity_two} =
CommonAPI.post(other_user, %{
- "status" => "Hi!",
- "in_reply_to_status_id" => activity.id,
- "in_reply_to_conversation_id" => participation.id
+ status: "Hi!",
+ in_reply_to_status_id: activity.id,
+ in_reply_to_conversation_id: participation.id
})
result =
@@ -178,9 +178,9 @@ test "/api/v1/pleroma/conversations/:id/statuses" do
{:ok, %{id: id_three}} =
CommonAPI.post(other_user, %{
- "status" => "Bye!",
- "in_reply_to_status_id" => activity.id,
- "in_reply_to_conversation_id" => participation.id
+ status: "Bye!",
+ in_reply_to_status_id: activity.id,
+ in_reply_to_conversation_id: participation.id
})
assert [%{"id" => ^id_two}, %{"id" => ^id_three}] =
@@ -198,7 +198,7 @@ test "PATCH /api/v1/pleroma/conversations/:id" do
%{user: user, conn: conn} = oauth_access(["write:conversations"])
other_user = insert(:user)
- {:ok, _activity} = CommonAPI.post(user, %{"status" => "Hi", "visibility" => "direct"})
+ {:ok, _activity} = CommonAPI.post(user, %{status: "Hi", visibility: "direct"})
[participation] = Participation.for_user(user)
@@ -229,10 +229,10 @@ test "POST /api/v1/pleroma/conversations/read" do
%{user: other_user, conn: conn} = oauth_access(["write:conversations"])
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}", visibility: "direct"})
{:ok, _activity} =
- CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
+ CommonAPI.post(user, %{status: "Hi @#{other_user.nickname}", visibility: "direct"})
[participation2, participation1] = Participation.for_user(other_user)
assert Participation.get(participation2.id).read == false
@@ -255,8 +255,8 @@ test "POST /api/v1/pleroma/conversations/read" do
test "it marks a single notification as read", %{user: user1, conn: conn} do
user2 = insert(:user)
- {:ok, activity1} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
- {:ok, activity2} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
+ {:ok, activity1} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
+ {:ok, activity2} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
{:ok, [notification1]} = Notification.create_notifications(activity1)
{:ok, [notification2]} = Notification.create_notifications(activity2)
@@ -272,9 +272,9 @@ test "it marks a single notification as read", %{user: user1, conn: conn} do
test "it marks multiple notifications as read", %{user: user1, conn: conn} do
user2 = insert(:user)
- {:ok, _activity1} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
- {:ok, _activity2} = CommonAPI.post(user2, %{"status" => "hi @#{user1.nickname}"})
- {:ok, _activity3} = CommonAPI.post(user2, %{"status" => "HIE @#{user1.nickname}"})
+ {:ok, _activity1} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
+ {:ok, _activity2} = CommonAPI.post(user2, %{status: "hi @#{user1.nickname}"})
+ {:ok, _activity3} = CommonAPI.post(user2, %{status: "HIE @#{user1.nickname}"})
[notification3, notification2, notification1] = Notification.for_user(user1, %{limit: 3})
diff --git a/test/web/push/impl_test.exs b/test/web/push/impl_test.exs
index b855d72ba..2acd0939f 100644
--- a/test/web/push/impl_test.exs
+++ b/test/web/push/impl_test.exs
@@ -13,8 +13,8 @@ defmodule Pleroma.Web.Push.ImplTest do
import Pleroma.Factory
- setup_all do
- Tesla.Mock.mock_global(fn
+ setup do
+ Tesla.Mock.mock(fn
%{method: :post, url: "https://example.com/example/1234"} ->
%Tesla.Env{status: 200}
@@ -55,7 +55,7 @@ test "performs sending notifications" do
data: %{alerts: %{"follow" => true, "mention" => false}}
)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -147,7 +147,7 @@ test "renders title and body for announce activity" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -166,7 +166,7 @@ test "renders title and body for like activity" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" =>
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -184,8 +184,8 @@ test "renders title for create activity with direct visibility" do
{:ok, activity} =
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => "This is just between you and me, pal"
+ visibility: "direct",
+ status: "This is just between you and me, pal"
})
assert Impl.format_title(%{activity: activity}) ==
@@ -199,8 +199,8 @@ test "hides details for notifications when privacy option enabled" do
{:ok, activity} =
CommonAPI.post(user, %{
- "visibility" => "direct",
- "status" => " "public",
- "status" => " "direct",
- "status" =>
+ visibility: "direct",
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
@@ -263,8 +263,8 @@ test "returns regular content for notifications with privacy option disabled" do
{:ok, activity} =
CommonAPI.post(user, %{
- "visibility" => "public",
- "status" =>
+ visibility: "public",
+ status:
"Lorem ipsum dolor sit amet, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
})
diff --git a/test/web/rel_me_test.exs b/test/web/rel_me_test.exs
index e05a8863d..65255916d 100644
--- a/test/web/rel_me_test.exs
+++ b/test/web/rel_me_test.exs
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RelMeTest do
- use ExUnit.Case, async: true
+ use ExUnit.Case
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
diff --git a/test/web/rich_media/helpers_test.exs b/test/web/rich_media/helpers_test.exs
index aa0c5c830..8264a9c41 100644
--- a/test/web/rich_media/helpers_test.exs
+++ b/test/web/rich_media/helpers_test.exs
@@ -26,8 +26,8 @@ test "refuses to crawl incomplete URLs" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "[test](example.com/ogp)",
- "content_type" => "text/markdown"
+ status: "[test](example.com/ogp)",
+ content_type: "text/markdown"
})
Config.put([:rich_media, :enabled], true)
@@ -40,8 +40,8 @@ test "refuses to crawl malformed URLs" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "[test](example.com[]/ogp)",
- "content_type" => "text/markdown"
+ status: "[test](example.com[]/ogp)",
+ content_type: "text/markdown"
})
Config.put([:rich_media, :enabled], true)
@@ -54,8 +54,8 @@ test "crawls valid, complete URLs" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "[test](https://example.com/ogp)",
- "content_type" => "text/markdown"
+ status: "[test](https://example.com/ogp)",
+ content_type: "text/markdown"
})
Config.put([:rich_media, :enabled], true)
@@ -69,8 +69,8 @@ test "refuses to crawl URLs from posts marked sensitive" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "http://example.com/ogp",
- "sensitive" => true
+ status: "http://example.com/ogp",
+ sensitive: true
})
%Object{} = object = Object.normalize(activity)
@@ -87,7 +87,7 @@ test "refuses to crawl URLs from posts tagged NSFW" do
{:ok, activity} =
CommonAPI.post(user, %{
- "status" => "http://example.com/ogp #nsfw"
+ status: "http://example.com/ogp #nsfw"
})
%Object{} = object = Object.normalize(activity)
@@ -103,12 +103,12 @@ test "refuses to crawl URLs of private network from posts" do
user = insert(:user)
{:ok, activity} =
- CommonAPI.post(user, %{"status" => "http://127.0.0.1:4000/notice/9kCP7VNyPJXFOXDrgO"})
+ CommonAPI.post(user, %{status: "http://127.0.0.1:4000/notice/9kCP7VNyPJXFOXDrgO"})
- {:ok, activity2} = CommonAPI.post(user, %{"status" => "https://10.111.10.1/notice/9kCP7V"})
- {:ok, activity3} = CommonAPI.post(user, %{"status" => "https://172.16.32.40/notice/9kCP7V"})
- {:ok, activity4} = CommonAPI.post(user, %{"status" => "https://192.168.10.40/notice/9kCP7V"})
- {:ok, activity5} = CommonAPI.post(user, %{"status" => "https://pleroma.local/notice/9kCP7V"})
+ {:ok, activity2} = CommonAPI.post(user, %{status: "https://10.111.10.1/notice/9kCP7V"})
+ {:ok, activity3} = CommonAPI.post(user, %{status: "https://172.16.32.40/notice/9kCP7V"})
+ {:ok, activity4} = CommonAPI.post(user, %{status: "https://192.168.10.40/notice/9kCP7V"})
+ {:ok, activity5} = CommonAPI.post(user, %{status: "https://pleroma.local/notice/9kCP7V"})
Config.put([:rich_media, :enabled], true)
diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs
index 430683ea0..a49ab002f 100644
--- a/test/web/static_fe/static_fe_controller_test.exs
+++ b/test/web/static_fe/static_fe_controller_test.exs
@@ -32,8 +32,8 @@ test "404 when user not found", %{conn: conn} do
end
test "profile does not include private messages", %{conn: conn, user: user} do
- CommonAPI.post(user, %{"status" => "public"})
- CommonAPI.post(user, %{"status" => "private", "visibility" => "private"})
+ CommonAPI.post(user, %{status: "public"})
+ CommonAPI.post(user, %{status: "private", visibility: "private"})
conn = get(conn, "/users/#{user.nickname}")
@@ -44,7 +44,7 @@ test "profile does not include private messages", %{conn: conn, user: user} do
end
test "pagination", %{conn: conn, user: user} do
- Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
+ Enum.map(1..30, fn i -> CommonAPI.post(user, %{status: "test#{i}"}) end)
conn = get(conn, "/users/#{user.nickname}")
@@ -57,7 +57,7 @@ test "pagination", %{conn: conn, user: user} do
end
test "pagination, page 2", %{conn: conn, user: user} do
- activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end)
+ activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{status: "test#{i}"}) end)
{:ok, a11} = Enum.at(activities, 11)
conn = get(conn, "/users/#{user.nickname}?max_id=#{a11.id}")
@@ -77,7 +77,7 @@ test "it requires authentication if instance is NOT federating", %{conn: conn, u
describe "notice html" do
test "single notice page", %{conn: conn, user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "testing a thing!"})
conn = get(conn, "/notice/#{activity.id}")
@@ -89,7 +89,7 @@ test "single notice page", %{conn: conn, user: user} do
test "filters HTML tags", %{conn: conn} do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ""})
+ {:ok, activity} = CommonAPI.post(user, %{status: ""})
conn =
conn
@@ -101,11 +101,11 @@ test "filters HTML tags", %{conn: conn} do
end
test "shows the whole thread", %{conn: conn, user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "space: the final frontier"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "space: the final frontier"})
CommonAPI.post(user, %{
- "status" => "these are the voyages or something",
- "in_reply_to_status_id" => activity.id
+ status: "these are the voyages or something",
+ in_reply_to_status_id: activity.id
})
conn = get(conn, "/notice/#{activity.id}")
@@ -117,7 +117,7 @@ test "shows the whole thread", %{conn: conn, user: user} do
test "redirect by AP object ID", %{conn: conn, user: user} do
{:ok, %Activity{data: %{"object" => object_url}}} =
- CommonAPI.post(user, %{"status" => "beam me up"})
+ CommonAPI.post(user, %{status: "beam me up"})
conn = get(conn, URI.parse(object_url).path)
@@ -126,7 +126,7 @@ test "redirect by AP object ID", %{conn: conn, user: user} do
test "redirect by activity ID", %{conn: conn, user: user} do
{:ok, %Activity{data: %{"id" => id}}} =
- CommonAPI.post(user, %{"status" => "I'm a doctor, not a devops!"})
+ CommonAPI.post(user, %{status: "I'm a doctor, not a devops!"})
conn = get(conn, URI.parse(id).path)
@@ -140,8 +140,7 @@ test "404 when notice not found", %{conn: conn} do
end
test "404 for private status", %{conn: conn, user: user} do
- {:ok, activity} =
- CommonAPI.post(user, %{"status" => "don't show me!", "visibility" => "private"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "don't show me!", visibility: "private"})
conn = get(conn, "/notice/#{activity.id}")
@@ -171,7 +170,7 @@ test "302 for remote cached status", %{conn: conn, user: user} do
end
test "it requires authentication if instance is NOT federating", %{conn: conn, user: user} do
- {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "testing a thing!"})
ensure_federating_or_authenticated(conn, "/notice/#{activity.id}", user)
end
diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs
index ee530f4e9..95b7d1420 100644
--- a/test/web/streamer/streamer_test.exs
+++ b/test/web/streamer/streamer_test.exs
@@ -17,6 +17,76 @@ defmodule Pleroma.Web.StreamerTest do
setup do: clear_config([:instance, :skip_thread_containment])
+ describe "get_topic without an user" do
+ test "allows public" do
+ assert {:ok, "public"} = Streamer.get_topic("public", nil)
+ assert {:ok, "public:local"} = Streamer.get_topic("public:local", nil)
+ assert {:ok, "public:media"} = Streamer.get_topic("public:media", nil)
+ assert {:ok, "public:local:media"} = Streamer.get_topic("public:local:media", nil)
+ end
+
+ test "allows hashtag streams" do
+ assert {:ok, "hashtag:cofe"} = Streamer.get_topic("hashtag", nil, %{"tag" => "cofe"})
+ end
+
+ test "disallows user streams" do
+ assert {:error, _} = Streamer.get_topic("user", nil)
+ assert {:error, _} = Streamer.get_topic("user:notification", nil)
+ assert {:error, _} = Streamer.get_topic("direct", nil)
+ end
+
+ test "disallows list streams" do
+ assert {:error, _} = Streamer.get_topic("list", nil, %{"list" => 42})
+ end
+ end
+
+ describe "get_topic with an user" do
+ setup do
+ user = insert(:user)
+ {:ok, %{user: user}}
+ end
+
+ test "allows public streams", %{user: user} do
+ assert {:ok, "public"} = Streamer.get_topic("public", user)
+ assert {:ok, "public:local"} = Streamer.get_topic("public:local", user)
+ assert {:ok, "public:media"} = Streamer.get_topic("public:media", user)
+ assert {:ok, "public:local:media"} = Streamer.get_topic("public:local:media", user)
+ end
+
+ test "allows user streams", %{user: user} do
+ expected_user_topic = "user:#{user.id}"
+ expected_notif_topic = "user:notification:#{user.id}"
+ expected_direct_topic = "direct:#{user.id}"
+ assert {:ok, ^expected_user_topic} = Streamer.get_topic("user", user)
+ assert {:ok, ^expected_notif_topic} = Streamer.get_topic("user:notification", user)
+ assert {:ok, ^expected_direct_topic} = Streamer.get_topic("direct", user)
+ end
+
+ test "allows hashtag streams", %{user: user} do
+ assert {:ok, "hashtag:cofe"} = Streamer.get_topic("hashtag", user, %{"tag" => "cofe"})
+ end
+
+ test "disallows registering to an user stream", %{user: user} do
+ another_user = insert(:user)
+ assert {:error, _} = Streamer.get_topic("user:#{another_user.id}", user)
+ assert {:error, _} = Streamer.get_topic("user:notification:#{another_user.id}", user)
+ assert {:error, _} = Streamer.get_topic("direct:#{another_user.id}", user)
+ end
+
+ test "allows list stream that are owned by the user", %{user: user} do
+ {:ok, list} = List.create("Test", user)
+ assert {:error, _} = Streamer.get_topic("list:#{list.id}", user)
+ assert {:ok, _} = Streamer.get_topic("list", user, %{"list" => list.id})
+ end
+
+ test "disallows list stream that are not owned by the user", %{user: user} do
+ another_user = insert(:user)
+ {:ok, list} = List.create("Test", another_user)
+ assert {:error, _} = Streamer.get_topic("list:#{list.id}", user)
+ assert {:error, _} = Streamer.get_topic("list", user, %{"list" => list.id})
+ end
+ end
+
describe "user streams" do
setup do
user = insert(:user)
@@ -25,17 +95,17 @@ defmodule Pleroma.Web.StreamerTest do
end
test "it streams the user's post in the 'user' stream", %{user: user} do
- Streamer.add_socket("user", user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+ Streamer.get_topic_and_add_socket("user", user)
+ {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
assert_receive {:render_with_user, _, _, ^activity}
refute Streamer.filtered_by_user?(user, activity)
end
test "it streams boosts of the user in the 'user' stream", %{user: user} do
- Streamer.add_socket("user", user)
+ Streamer.get_topic_and_add_socket("user", user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "hey"})
{:ok, announce, _} = CommonAPI.repeat(activity.id, user)
assert_receive {:render_with_user, Pleroma.Web.StreamerView, "update.json", ^announce}
@@ -43,14 +113,14 @@ test "it streams boosts of the user in the 'user' stream", %{user: user} do
end
test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
- Streamer.add_socket("user", user)
+ Streamer.get_topic_and_add_socket("user", user)
Streamer.stream("user", notify)
assert_receive {:render_with_user, _, _, ^notify}
refute Streamer.filtered_by_user?(user, notify)
end
test "it sends notify to in the 'user:notification' stream", %{user: user, notify: notify} do
- Streamer.add_socket("user:notification", user)
+ Streamer.get_topic_and_add_socket("user:notification", user)
Streamer.stream("user:notification", notify)
assert_receive {:render_with_user, _, _, ^notify}
refute Streamer.filtered_by_user?(user, notify)
@@ -62,9 +132,9 @@ test "it doesn't send notify to the 'user:notification' stream when a user is bl
blocked = insert(:user)
{:ok, _user_relationship} = User.block(user, blocked)
- Streamer.add_socket("user:notification", user)
+ Streamer.get_topic_and_add_socket("user:notification", user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => ":("})
+ {:ok, activity} = CommonAPI.post(user, %{status: ":("})
{:ok, _} = CommonAPI.favorite(blocked, activity.id)
refute_receive _
@@ -75,10 +145,10 @@ test "it doesn't send notify to the 'user:notification' stream when a thread is
} do
user2 = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
{:ok, _} = CommonAPI.add_mute(user, activity)
- Streamer.add_socket("user:notification", user)
+ Streamer.get_topic_and_add_socket("user:notification", user)
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
@@ -91,8 +161,8 @@ test "it sends favorite to 'user:notification' stream'", %{
} do
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
- {:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
- Streamer.add_socket("user:notification", user)
+ {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
+ Streamer.get_topic_and_add_socket("user:notification", user)
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
assert_receive {:render_with_user, _, "notification.json", notif}
@@ -106,8 +176,8 @@ test "it doesn't send the 'user:notification' stream' when a domain is blocked",
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
{:ok, user} = User.block_domain(user, "hecking-lewd-place.com")
- {:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
- Streamer.add_socket("user:notification", user)
+ {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
+ Streamer.get_topic_and_add_socket("user:notification", user)
{:ok, favorite_activity} = CommonAPI.favorite(user2, activity.id)
refute_receive _
@@ -130,7 +200,7 @@ test "it sends follow activities to the 'user:notification' stream", %{
%Tesla.Env{status: 200, body: body}
end)
- Streamer.add_socket("user:notification", user)
+ Streamer.get_topic_and_add_socket("user:notification", user)
{:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user2, user)
assert_receive {:render_with_user, _, "notification.json", notif}
@@ -143,9 +213,9 @@ test "it sends to public authenticated" do
user = insert(:user)
other_user = insert(:user)
- Streamer.add_socket("public", other_user)
+ Streamer.get_topic_and_add_socket("public", other_user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Test"})
assert_receive {:render_with_user, _, _, ^activity}
refute Streamer.filtered_by_user?(user, activity)
end
@@ -153,9 +223,9 @@ test "it sends to public authenticated" do
test "works for deletions" do
user = insert(:user)
other_user = insert(:user)
- {:ok, activity} = CommonAPI.post(other_user, %{"status" => "Test"})
+ {:ok, activity} = CommonAPI.post(other_user, %{status: "Test"})
- Streamer.add_socket("public", user)
+ Streamer.get_topic_and_add_socket("public", user)
{:ok, _} = CommonAPI.delete(activity.id, other_user)
activity_id = activity.id
@@ -166,9 +236,9 @@ test "works for deletions" do
test "it sends to public unauthenticated" do
user = insert(:user)
- Streamer.add_socket("public", nil)
+ Streamer.get_topic_and_add_socket("public", nil)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Test"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "Test"})
activity_id = activity.id
assert_receive {:text, event}
assert %{"event" => "update", "payload" => payload} = Jason.decode!(event)
@@ -195,7 +265,7 @@ test "it filters to user if recipients invalid and thread containment is enabled
)
)
- Streamer.add_socket("public", user)
+ Streamer.get_topic_and_add_socket("public", user)
Streamer.stream("public", activity)
assert_receive {:render_with_user, _, _, ^activity}
assert Streamer.filtered_by_user?(user, activity)
@@ -216,7 +286,7 @@ test "it sends message if recipients invalid and thread containment is disabled"
)
)
- Streamer.add_socket("public", user)
+ Streamer.get_topic_and_add_socket("public", user)
Streamer.stream("public", activity)
assert_receive {:render_with_user, _, _, ^activity}
@@ -238,7 +308,7 @@ test "it sends message if recipients invalid and thread containment is enabled b
)
)
- Streamer.add_socket("public", user)
+ Streamer.get_topic_and_add_socket("public", user)
Streamer.stream("public", activity)
assert_receive {:render_with_user, _, _, ^activity}
@@ -252,8 +322,8 @@ test "it filters messages involving blocked users" do
blocked_user = insert(:user)
{:ok, _user_relationship} = User.block(user, blocked_user)
- Streamer.add_socket("public", user)
- {:ok, activity} = CommonAPI.post(blocked_user, %{"status" => "Test"})
+ Streamer.get_topic_and_add_socket("public", user)
+ {:ok, activity} = CommonAPI.post(blocked_user, %{status: "Test"})
assert_receive {:render_with_user, _, _, ^activity}
assert Streamer.filtered_by_user?(user, activity)
end
@@ -263,21 +333,21 @@ test "it filters messages transitively involving blocked users" do
blockee = insert(:user)
friend = insert(:user)
- Streamer.add_socket("public", blocker)
+ Streamer.get_topic_and_add_socket("public", blocker)
{:ok, _user_relationship} = User.block(blocker, blockee)
- {:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
+ {:ok, activity_one} = CommonAPI.post(friend, %{status: "hey! @#{blockee.nickname}"})
assert_receive {:render_with_user, _, _, ^activity_one}
assert Streamer.filtered_by_user?(blocker, activity_one)
- {:ok, activity_two} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
+ {:ok, activity_two} = CommonAPI.post(blockee, %{status: "hey! @#{friend.nickname}"})
assert_receive {:render_with_user, _, _, ^activity_two}
assert Streamer.filtered_by_user?(blocker, activity_two)
- {:ok, activity_three} = CommonAPI.post(blockee, %{"status" => "hey! @#{blocker.nickname}"})
+ {:ok, activity_three} = CommonAPI.post(blockee, %{status: "hey! @#{blocker.nickname}"})
assert_receive {:render_with_user, _, _, ^activity_three}
assert Streamer.filtered_by_user?(blocker, activity_three)
@@ -295,12 +365,12 @@ test "it doesn't send unwanted DMs to list" do
{:ok, list} = List.create("Test", user_a)
{:ok, list} = List.follow(list, user_b)
- Streamer.add_socket("list:#{list.id}", user_a)
+ Streamer.get_topic_and_add_socket("list", user_a, %{"list" => list.id})
{:ok, _activity} =
CommonAPI.post(user_b, %{
- "status" => "@#{user_c.nickname} Test",
- "visibility" => "direct"
+ status: "@#{user_c.nickname} Test",
+ visibility: "direct"
})
refute_receive _
@@ -313,12 +383,12 @@ test "it doesn't send unwanted private posts to list" do
{:ok, list} = List.create("Test", user_a)
{:ok, list} = List.follow(list, user_b)
- Streamer.add_socket("list:#{list.id}", user_a)
+ Streamer.get_topic_and_add_socket("list", user_a, %{"list" => list.id})
{:ok, _activity} =
CommonAPI.post(user_b, %{
- "status" => "Test",
- "visibility" => "private"
+ status: "Test",
+ visibility: "private"
})
refute_receive _
@@ -333,12 +403,12 @@ test "it sends wanted private posts to list" do
{:ok, list} = List.create("Test", user_a)
{:ok, list} = List.follow(list, user_b)
- Streamer.add_socket("list:#{list.id}", user_a)
+ Streamer.get_topic_and_add_socket("list", user_a, %{"list" => list.id})
{:ok, activity} =
CommonAPI.post(user_b, %{
- "status" => "Test",
- "visibility" => "private"
+ status: "Test",
+ visibility: "private"
})
assert_receive {:render_with_user, _, _, ^activity}
@@ -354,9 +424,9 @@ test "it filters muted reblogs" do
CommonAPI.follow(user1, user2)
CommonAPI.hide_reblogs(user1, user2)
- {:ok, create_activity} = CommonAPI.post(user3, %{"status" => "I'm kawen"})
+ {:ok, create_activity} = CommonAPI.post(user3, %{status: "I'm kawen"})
- Streamer.add_socket("user", user1)
+ Streamer.get_topic_and_add_socket("user", user1)
{:ok, announce_activity, _} = CommonAPI.repeat(create_activity.id, user2)
assert_receive {:render_with_user, _, _, ^announce_activity}
assert Streamer.filtered_by_user?(user1, announce_activity)
@@ -368,8 +438,8 @@ test "it filters reblog notification for reblog-muted actors" do
CommonAPI.follow(user1, user2)
CommonAPI.hide_reblogs(user1, user2)
- {:ok, create_activity} = CommonAPI.post(user1, %{"status" => "I'm kawen"})
- Streamer.add_socket("user", user1)
+ {:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
+ Streamer.get_topic_and_add_socket("user", user1)
{:ok, _favorite_activity, _} = CommonAPI.repeat(create_activity.id, user2)
assert_receive {:render_with_user, _, "notification.json", notif}
@@ -382,8 +452,8 @@ test "it send non-reblog notification for reblog-muted actors" do
CommonAPI.follow(user1, user2)
CommonAPI.hide_reblogs(user1, user2)
- {:ok, create_activity} = CommonAPI.post(user1, %{"status" => "I'm kawen"})
- Streamer.add_socket("user", user1)
+ {:ok, create_activity} = CommonAPI.post(user1, %{status: "I'm kawen"})
+ Streamer.get_topic_and_add_socket("user", user1)
{:ok, _favorite_activity} = CommonAPI.favorite(user2, create_activity.id)
assert_receive {:render_with_user, _, "notification.json", notif}
@@ -394,9 +464,9 @@ test "it send non-reblog notification for reblog-muted actors" do
test "it filters posts from muted threads" do
user = insert(:user)
user2 = insert(:user)
- Streamer.add_socket("user", user2)
+ Streamer.get_topic_and_add_socket("user", user2)
{:ok, user2, user, _activity} = CommonAPI.follow(user2, user)
- {:ok, activity} = CommonAPI.post(user, %{"status" => "super hot take"})
+ {:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
{:ok, _} = CommonAPI.add_mute(user2, activity)
assert_receive {:render_with_user, _, _, ^activity}
assert Streamer.filtered_by_user?(user2, activity)
@@ -411,12 +481,12 @@ test "it sends conversation update to the 'direct' stream", %{} do
user = insert(:user)
another_user = insert(:user)
- Streamer.add_socket("direct", user)
+ Streamer.get_topic_and_add_socket("direct", user)
{:ok, _create_activity} =
CommonAPI.post(another_user, %{
- "status" => "hey @#{user.nickname}",
- "visibility" => "direct"
+ status: "hey @#{user.nickname}",
+ visibility: "direct"
})
assert_receive {:text, received_event}
@@ -433,12 +503,12 @@ test "it doesn't send conversation update to the 'direct' stream when the last m
user = insert(:user)
another_user = insert(:user)
- Streamer.add_socket("direct", user)
+ Streamer.get_topic_and_add_socket("direct", user)
{:ok, create_activity} =
CommonAPI.post(another_user, %{
- "status" => "hi @#{user.nickname}",
- "visibility" => "direct"
+ status: "hi @#{user.nickname}",
+ visibility: "direct"
})
create_activity_id = create_activity.id
@@ -459,19 +529,19 @@ test "it doesn't send conversation update to the 'direct' stream when the last m
test "it sends conversation update to the 'direct' stream when a message is deleted" do
user = insert(:user)
another_user = insert(:user)
- Streamer.add_socket("direct", user)
+ Streamer.get_topic_and_add_socket("direct", user)
{:ok, create_activity} =
CommonAPI.post(another_user, %{
- "status" => "hi @#{user.nickname}",
- "visibility" => "direct"
+ status: "hi @#{user.nickname}",
+ visibility: "direct"
})
{:ok, create_activity2} =
CommonAPI.post(another_user, %{
- "status" => "hi @#{user.nickname} 2",
- "in_reply_to_status_id" => create_activity.id,
- "visibility" => "direct"
+ status: "hi @#{user.nickname} 2",
+ in_reply_to_status_id: create_activity.id,
+ visibility: "direct"
})
assert_receive {:render_with_user, _, _, ^create_activity}
diff --git a/test/web/twitter_api/password_controller_test.exs b/test/web/twitter_api/password_controller_test.exs
index 0a24860d3..231a46c67 100644
--- a/test/web/twitter_api/password_controller_test.exs
+++ b/test/web/twitter_api/password_controller_test.exs
@@ -54,7 +54,7 @@ test "it returns HTTP 200", %{conn: conn} do
assert response =~ "Password changed!
"
user = refresh_record(user)
- assert Comeonin.Pbkdf2.checkpw("test", user.password_hash)
+ assert Pbkdf2.verify_pass("test", user.password_hash)
assert Enum.empty?(Token.get_user_tokens(user))
end
diff --git a/test/web/twitter_api/util_controller_test.exs b/test/web/twitter_api/util_controller_test.exs
index b701239a0..ad919d341 100644
--- a/test/web/twitter_api/util_controller_test.exs
+++ b/test/web/twitter_api/util_controller_test.exs
@@ -688,7 +688,7 @@ test "with proper permissions, valid password and matching new password and conf
assert json_response(conn, 200) == %{"status" => "success"}
fetched_user = User.get_cached_by_id(user.id)
- assert Comeonin.Pbkdf2.checkpw("newpass", fetched_user.password_hash) == true
+ assert Pbkdf2.verify_pass("newpass", fetched_user.password_hash) == true
end
end
diff --git a/test/workers/cron/digest_emails_worker_test.exs b/test/workers/cron/digest_emails_worker_test.exs
index 0a63bf4e0..f9bc50db5 100644
--- a/test/workers/cron/digest_emails_worker_test.exs
+++ b/test/workers/cron/digest_emails_worker_test.exs
@@ -29,7 +29,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do
user2 = insert(:user, last_digest_emailed_at: date)
{:ok, _} = User.switch_email_notifications(user2, "digest", true)
- CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"})
+ CommonAPI.post(user, %{status: "hey @#{user2.nickname}!"})
{:ok, user2: user2}
end
diff --git a/test/workers/cron/new_users_digest_worker_test.exs b/test/workers/cron/new_users_digest_worker_test.exs
index e6d050ecc..54cf0ca46 100644
--- a/test/workers/cron/new_users_digest_worker_test.exs
+++ b/test/workers/cron/new_users_digest_worker_test.exs
@@ -15,7 +15,7 @@ test "it sends new users digest emails" do
admin = insert(:user, %{is_admin: true})
user = insert(:user, %{inserted_at: yesterday})
user2 = insert(:user, %{inserted_at: yesterday})
- CommonAPI.post(user, %{"status" => "cofe"})
+ CommonAPI.post(user, %{status: "cofe"})
NewUsersDigestWorker.perform(nil, nil)
ObanHelpers.perform_all()
@@ -36,7 +36,7 @@ test "it doesn't fail when admin has no email" do
insert(:user, %{inserted_at: yesterday})
user = insert(:user, %{inserted_at: yesterday})
- CommonAPI.post(user, %{"status" => "cofe"})
+ CommonAPI.post(user, %{status: "cofe"})
NewUsersDigestWorker.perform(nil, nil)
ObanHelpers.perform_all()