Merge remote-tracking branch 'upstream/develop' into block-behavior

This commit is contained in:
Alex Gleason 2021-04-29 11:14:32 -05:00
commit 762be6ce10
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
1191 changed files with 14893 additions and 5986 deletions

1
test/config/emoji.txt Normal file
View file

@ -0,0 +1 @@
external_emoji, https://example.com/emoji.png

View file

@ -1,7 +1,7 @@
# Pleroma: A lightweight social networking server
# Originally taken from
# https://github.com/VeryBigThings/elixir_common/blob/master/lib/vbt/credo/check/consistency/file_location.ex
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Credo.Check.Consistency.FileLocation do

80
test/fixtures/bridgy/actor.json vendored Normal file
View file

@ -0,0 +1,80 @@
{
"id": "https://fed.brid.gy/jk.nipponalba.scot",
"url": "https://fed.brid.gy/r/https://jk.nipponalba.scot",
"urls": [
{
"value": "https://jk.nipponalba.scot"
},
{
"value": "https://social.nipponalba.scot/jk"
},
{
"value": "https://px.nipponalba.scot/jk"
}
],
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Person",
"name": "J K 🇯🇵🏴󠁧󠁢󠁳󠁣󠁴󠁿",
"image": [
{
"url": "https://jk.nipponalba.scot/images/profile.jpg",
"type": "Image",
"name": "profile picture"
}
],
"tag": [
{
"type": "Tag",
"name": "Craft Beer"
},
{
"type": "Tag",
"name": "Single Malt Whisky"
},
{
"type": "Tag",
"name": "Homebrewing"
},
{
"type": "Tag",
"name": "Scottish Politics"
},
{
"type": "Tag",
"name": "Scottish History"
},
{
"type": "Tag",
"name": "Japanese History"
},
{
"type": "Tag",
"name": "Tech"
},
{
"type": "Tag",
"name": "Veganism"
},
{
"type": "Tag",
"name": "Cooking"
}
],
"icon": [
{
"url": "https://jk.nipponalba.scot/images/profile.jpg",
"type": "Image",
"name": "profile picture"
}
],
"preferredUsername": "jk.nipponalba.scot",
"summary": "",
"publicKey": {
"id": "jk.nipponalba.scot",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdarxwzxnNbJ2hneWOYHkYJowk\npyigQtxlUd0VjgSQHwxU9kWqfbrHBVADyTtcqi/4dAzQd3UnCI1TPNnn4LPZY9PW\noiWd3Zl1/EfLFxO7LU9GS7fcSLQkyj5JNhSlN3I8QPudZbybrgRDVZYooDe1D+52\n5KLGqC2ajrIVOiDRTQIDAQAB\n-----END PUBLIC KEY-----"
},
"inbox": "https://fed.brid.gy/jk.nipponalba.scot/inbox",
"outbox": "https://fed.brid.gy/jk.nipponalba.scot/outbox",
"following": "https://fed.brid.gy/jk.nipponalba.scot/following",
"followers": "https://fed.brid.gy/jk.nipponalba.scot/followers"
}

View file

@ -0,0 +1,5 @@
use Mix.Config
config :pleroma, exported_config_merged: true
config :pleroma, :first_setting, key: "new value"

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
use Mix.Config

26
test/fixtures/guppe-actor.json vendored Normal file
View file

@ -0,0 +1,26 @@
{
"@context" : [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1"
],
"followers" : "https://gup.pe/u/bernie2020/followers",
"following" : "https://gup.pe/u/bernie2020/following",
"icon" : {
"mediaType" : "image/jpeg",
"type" : "Image",
"url" : "https://gup.pe/f/guppe.png"
},
"id" : "https://gup.pe/u/bernie2020",
"inbox" : "https://gup.pe/u/bernie2020/inbox",
"liked" : "https://gup.pe/u/bernie2020/liked",
"name" : "Bernie2020 group",
"outbox" : "https://gup.pe/u/bernie2020/outbox",
"preferredUsername" : "Bernie2020",
"publicKey" : {
"id" : "https://gup.pe/u/bernie2020#main-key",
"owner" : "https://gup.pe/u/bernie2020",
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw4J8nSrdWWxFaipgWDhR\nbTFzHUGoFy7Gjdc6gg9ZWGWDm9ZU5Ct0C/4o72dXSWdyLbQGYMbWVHLI1LHWKSiC\nVtwIYoccQBaxfi5bCxsahWhhSNPfK8tVlySHvBy73ir8KUZm93eAYh1iE9x+Dk63\nInmi7wzjsqHSlu1KxPGYcnyxs+xxhlTUSd5LsPfO1b9sHMW+X4rEky7OC90veCdD\nsoHU+nCmf+2zJSlOrU7DAzqB4Axc9oS9Q5RlT3yARJQMeu6JyjJJP9CMbpGFbUNT\n5Gsw0km1Rc1rR4tUoz8pLUYtliEUK+/0EmHi2EHAT1ueEfMoGGbCaX/mCoMmAwYJ\nwIGYXmKn2/ARIJpw2XPmrKWXqa2AndOQdb3l44Sl3ej2rC/JQmimGCn7tbfKEZyC\n6mMkOYTIeBtyW/wXFc1+GzJxtvA3C9HjilE+O/7gLHfCLP6FRIxg/9kOLhEj64Ed\n5HZ3sylvifXXubS/lLZr6sZW6d9ICoYLZpFw9AoF2zaYWpvJqBrWinnCJzvbMCYj\nfq/RAkcQYSxkDOHquiGgbRZHGAMKLnz5fMKJIzBtdQojYCUmB14OArW+ITUE9i2a\nPAJaXEGZ+BHYp/0ScFaXwp5LIgT1S+sPKxWJU//77wQfs25i7NZHSN/jtXVmsFS6\nLFVw49LcWAz3J2Im+A+uSd8CAwEAAQ==\n-----END PUBLIC KEY-----\n"
},
"summary" : "I'm a group about Bernie2020. Follow me to get all the group posts. Tag me to share with the group. Create other groups by searching for or tagging @yourGroupName@gup.pe",
"type" : "Group"
}

View file

@ -0,0 +1,39 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://{{domain}}/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"id": "https://{{domain}}/users/{{nickname}}/collections/featured",
"orderedItems": [
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://{{domain}}/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"actor": "https://{{domain}}/users/{{nickname}}",
"attachment": [],
"attributedTo": "https://{{domain}}/users/{{nickname}}",
"cc": [
"https://{{domain}}/users/{{nickname}}/followers"
],
"content": "",
"id": "https://{{domain}}/objects/{{object_id}}",
"published": "2021-02-12T15:13:43.915429Z",
"sensitive": false,
"source": "",
"summary": "",
"tag": [],
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Note"
}
],
"type": "OrderedCollection"
}

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Fixtures.Modules.RuntimeModule do

121
test/fixtures/peertube/actor-person.json vendored Normal file
View file

@ -0,0 +1,121 @@
{
"type": "Person",
"id": "https://peertube.stream/accounts/createurs",
"following": "https://peertube.stream/accounts/createurs/following",
"followers": "https://peertube.stream/accounts/createurs/followers",
"playlists": "https://peertube.stream/accounts/createurs/playlists",
"inbox": "https://peertube.stream/accounts/createurs/inbox",
"outbox": "https://peertube.stream/accounts/createurs/outbox",
"preferredUsername": "createurs",
"url": "https://peertube.stream/accounts/createurs",
"name": "Créateurs",
"endpoints": {
"sharedInbox": "https://peertube.stream/inbox"
},
"publicKey": {
"id": "https://peertube.stream/accounts/createurs#main-key",
"owner": "https://peertube.stream/accounts/createurs",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxqkQhbRYbA81+WTYjorR\n2lEMad3kYCnzDjGTLr4I92eanzFHxyELGnjzP6TpEvjOiB9NrCRrqU/iFPLdgrq2\nwIFcXPWdCq6Gcg7QLlaeMM0JoJmr0KTEhzg0XKCo96UsyTzaF4DISxqi8RyoyWeU\nEkgiOzlkdYTlouq3MlQH+p1PBAsNUQfIEUsU+l6k1vzbm8JRwlT+D1bNde4I/Lqs\n4uB5ru3zzInwZ2hz9+heiriNoGEBv74rZHYn966tZVX8iMGx2+m6okozEdEQbqCl\n0ekqDcd8P6CoFqqeeu8coh82OUtuFI/XsbetdWA55YQmSHyMiTsIwVbeoogIETbI\n4QIDAQAB\n-----END PUBLIC KEY-----"
},
"icon": {
"type": "Image",
"mediaType": "image/png",
"url": "https://peertube.stream/lazy-static/avatars/c27b672d-ad8f-498a-adbe-553af8da56f9.png"
},
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
},
{
"pt": "https://joinpeertube.org/ns#",
"sc": "http://schema.org#",
"Hashtag": "as:Hashtag",
"uuid": "sc:identifier",
"category": "sc:category",
"licence": "sc:license",
"subtitleLanguage": "sc:subtitleLanguage",
"sensitive": "as:sensitive",
"language": "sc:inLanguage",
"isLiveBroadcast": "sc:isLiveBroadcast",
"liveSaveReplay": {
"@type": "sc:Boolean",
"@id": "pt:liveSaveReplay"
},
"permanentLive": {
"@type": "sc:Boolean",
"@id": "pt:permanentLive"
},
"Infohash": "pt:Infohash",
"Playlist": "pt:Playlist",
"PlaylistElement": "pt:PlaylistElement",
"originallyPublishedAt": "sc:datePublished",
"views": {
"@type": "sc:Number",
"@id": "pt:views"
},
"state": {
"@type": "sc:Number",
"@id": "pt:state"
},
"size": {
"@type": "sc:Number",
"@id": "pt:size"
},
"fps": {
"@type": "sc:Number",
"@id": "pt:fps"
},
"startTimestamp": {
"@type": "sc:Number",
"@id": "pt:startTimestamp"
},
"stopTimestamp": {
"@type": "sc:Number",
"@id": "pt:stopTimestamp"
},
"position": {
"@type": "sc:Number",
"@id": "pt:position"
},
"commentsEnabled": {
"@type": "sc:Boolean",
"@id": "pt:commentsEnabled"
},
"downloadEnabled": {
"@type": "sc:Boolean",
"@id": "pt:downloadEnabled"
},
"waitTranscoding": {
"@type": "sc:Boolean",
"@id": "pt:waitTranscoding"
},
"support": {
"@type": "sc:Text",
"@id": "pt:support"
},
"likes": {
"@id": "as:likes",
"@type": "@id"
},
"dislikes": {
"@id": "as:dislikes",
"@type": "@id"
},
"playlists": {
"@id": "pt:playlists",
"@type": "@id"
},
"shares": {
"@id": "as:shares",
"@type": "@id"
},
"comments": {
"@id": "as:comments",
"@type": "@id"
}
}
],
"summary": null
}

View file

@ -0,0 +1,413 @@
{
"type": "Create",
"id": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/activity",
"actor": "https://peertube.stream/accounts/createurs",
"object": {
"type": "Video",
"id": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6",
"name": "Vu du 20/02/21 : \"Planète Mars 2050\"",
"duration": "PT385S",
"uuid": "abece3c3-b9c6-47f4-8040-f3eed8c602e6",
"tag": [
{
"type": "Hashtag",
"name": "France3"
},
{
"type": "Hashtag",
"name": "lezapping"
}
],
"category": {
"identifier": "11",
"name": "News & Politics"
},
"language": {
"identifier": "fr",
"name": "French"
},
"views": 5,
"sensitive": false,
"waitTranscoding": false,
"isLiveBroadcast": false,
"liveSaveReplay": null,
"permanentLive": null,
"state": 1,
"commentsEnabled": true,
"downloadEnabled": false,
"published": "2021-02-20T17:04:54.278Z",
"originallyPublishedAt": "2021-02-19T23:00:00.000Z",
"updated": "2021-02-21T20:01:11.189Z",
"mediaType": "text/markdown",
"content": "Un regard impertinent et libre, orchestré par Patrick Menais et son équipe, sur le monde de limage.\r\n\r\nEn avant-première du lundi au samedi à 17h00 sur Facebook, Twitter et YouTube.\r\n\r\nDu lundi au samedi à 20h00 sur France 3.\r\n\r\nhttps://www.facebook.com/vufrancetv\r\nhttps://twitter.com/VuFrancetv",
"support": "Suivre VU :\r\n- Twitter : https://twitter.com/vufrancetv\r\n- Facebook :https://www.facebook.com/vufrancetv/\r\n- Site : https://www.france.tv/france-3/vu/",
"subtitleLanguage": [],
"icon": [
{
"type": "Image",
"url": "https://peertube.stream/static/thumbnails/abece3c3-b9c6-47f4-8040-f3eed8c602e6.jpg",
"mediaType": "image/jpeg",
"width": 223,
"height": 122
},
{
"type": "Image",
"url": "https://peertube.stream/lazy-static/previews/abece3c3-b9c6-47f4-8040-f3eed8c602e6.jpg",
"mediaType": "image/jpeg",
"width": 850,
"height": 480
}
],
"url": [
{
"type": "Link",
"mediaType": "text/html",
"href": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6"
},
{
"type": "Link",
"mediaType": "application/x-mpegURL",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/master.m3u8",
"tag": [
{
"type": "Infohash",
"name": "00bfce9595e1655d8696b60e19ca25c34be5fa63"
},
{
"type": "Infohash",
"name": "256c21b65d5e0f944b4b79d8e0cbc55c9d906807"
},
{
"type": "Infohash",
"name": "fcd981098c484d0e328927c8fb21ecf986880b7e"
},
{
"type": "Infohash",
"name": "f7e01ac566e9fef91cd22514e6c3c256af7a9f5f"
},
{
"type": "Infohash",
"name": "42b421fc44d0dceb45ac3f6f6419b07fd570a232"
},
{
"type": "Infohash",
"name": "f876c6d6d49ce618a880ca223df54cb29f4b4bfd"
},
{
"type": "Link",
"name": "sha256",
"mediaType": "application/json",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/segments-sha256.json"
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
"height": 1080,
"size": 57888169,
"fps": 25
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570040",
"height": 1080,
"fps": 25
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-hls.torrent",
"height": 1080
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-hls.torrent&xt=urn:btih:68af82ebcd9df8335e407b755f38f5fd39c8a6a4&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
"height": 1080
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-720-fragmented.mp4",
"height": 720,
"size": 45165123,
"fps": 25
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570056",
"height": 720,
"fps": 25
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-720-hls.torrent",
"height": 720
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-720-hls.torrent&xt=urn:btih:8450928a4ffb2a4c5f927a163487c48c05f6e700&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-720-fragmented.mp4",
"height": 720
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-480-fragmented.mp4",
"height": 480,
"size": 29618534,
"fps": 25
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570042",
"height": 480,
"fps": 25
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-480-hls.torrent",
"height": 480
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-480-hls.torrent&xt=urn:btih:39e11181db5f376aa78c94bffcb9ccf2f4bca715&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-480-fragmented.mp4",
"height": 480
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-360-fragmented.mp4",
"height": 360,
"size": 21771466,
"fps": 25
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570043",
"height": 360,
"fps": 25
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-360-hls.torrent",
"height": 360
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-360-hls.torrent&xt=urn:btih:c33aa52822528e29ffd1a615ebe40450e4c61452&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-360-fragmented.mp4",
"height": 360
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-240-fragmented.mp4",
"height": 240,
"size": 14856165,
"fps": 25
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570057",
"height": 240,
"fps": 25
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-240-hls.torrent",
"height": 240
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-240-hls.torrent&xt=urn:btih:157e4cc3e9f15c06e995d6c3388539fdda312771&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-240-fragmented.mp4",
"height": 240
},
{
"type": "Link",
"mediaType": "video/mp4",
"href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-0-fragmented.mp4",
"height": 0,
"size": 6248765,
"fps": 0
},
{
"type": "Link",
"rel": [
"metadata",
"video/mp4"
],
"mediaType": "application/json",
"href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570041",
"height": 0,
"fps": 0
},
{
"type": "Link",
"mediaType": "application/x-bittorrent",
"href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-0-hls.torrent",
"height": 0
},
{
"type": "Link",
"mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
"href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-0-hls.torrent&xt=urn:btih:abc8dc58903d18cf7ec0c0cef92cc5ffe5cb0b5c&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-0-fragmented.mp4",
"height": 0
}
]
}
],
"likes": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/likes",
"dislikes": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/dislikes",
"shares": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/announces",
"comments": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/comments",
"attributedTo": [
{
"type": "Person",
"id": "https://peertube.stream/accounts/createurs"
},
{
"type": "Group",
"id": "https://peertube.stream/video-channels/vu"
}
],
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://peertube.stream/accounts/createurs/followers"
]
},
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://peertube.stream/accounts/createurs/followers"
],
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
},
{
"pt": "https://joinpeertube.org/ns#",
"sc": "http://schema.org#",
"Hashtag": "as:Hashtag",
"uuid": "sc:identifier",
"category": "sc:category",
"licence": "sc:license",
"subtitleLanguage": "sc:subtitleLanguage",
"sensitive": "as:sensitive",
"language": "sc:inLanguage",
"isLiveBroadcast": "sc:isLiveBroadcast",
"liveSaveReplay": {
"@type": "sc:Boolean",
"@id": "pt:liveSaveReplay"
},
"permanentLive": {
"@type": "sc:Boolean",
"@id": "pt:permanentLive"
},
"Infohash": "pt:Infohash",
"Playlist": "pt:Playlist",
"PlaylistElement": "pt:PlaylistElement",
"originallyPublishedAt": "sc:datePublished",
"views": {
"@type": "sc:Number",
"@id": "pt:views"
},
"state": {
"@type": "sc:Number",
"@id": "pt:state"
},
"size": {
"@type": "sc:Number",
"@id": "pt:size"
},
"fps": {
"@type": "sc:Number",
"@id": "pt:fps"
},
"startTimestamp": {
"@type": "sc:Number",
"@id": "pt:startTimestamp"
},
"stopTimestamp": {
"@type": "sc:Number",
"@id": "pt:stopTimestamp"
},
"position": {
"@type": "sc:Number",
"@id": "pt:position"
},
"commentsEnabled": {
"@type": "sc:Boolean",
"@id": "pt:commentsEnabled"
},
"downloadEnabled": {
"@type": "sc:Boolean",
"@id": "pt:downloadEnabled"
},
"waitTranscoding": {
"@type": "sc:Boolean",
"@id": "pt:waitTranscoding"
},
"support": {
"@type": "sc:Text",
"@id": "pt:support"
},
"likes": {
"@id": "as:likes",
"@type": "@id"
},
"dislikes": {
"@id": "as:dislikes",
"@type": "@id"
},
"playlists": {
"@id": "pt:playlists",
"@type": "@id"
},
"shares": {
"@id": "as:shares",
"@type": "@id"
},
"comments": {
"@id": "as:comments",
"@type": "@id"
}
}
]
}

47
test/fixtures/statuses/masto-note.json vendored Normal file
View file

@ -0,0 +1,47 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
{
"ostatus": "http://ostatus.org#",
"atomUri": "ostatus:atomUri",
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
"conversation": "ostatus:conversation",
"sensitive": "as:sensitive",
"toot": "http://joinmastodon.org/ns#",
"votersCount": "toot:votersCount"
}
],
"id": "https://example.com/users/{{nickname}}/statuses/{{status_id}}",
"type": "Note",
"summary": null,
"inReplyTo": null,
"published": "2021-02-24T12:40:49Z",
"url": "https://example.com/@{{nickname}}/{{status_id}}",
"attributedTo": "https://example.com/users/{{nickname}}",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://example.com/users/{{nickname}}/followers"
],
"sensitive": false,
"atomUri": "https://example.com/users/{{nickname}}/statuses/{{status_id}}",
"inReplyToAtomUri": null,
"conversation": "tag:example.com,2021-02-24:objectId=15:objectType=Conversation",
"content": "<p></p>",
"contentMap": {
"en": "<p></p>"
},
"attachment": [],
"tag": [],
"replies": {
"id": "https://example.com/users/{{nickname}}/statuses/{{status_id}}/replies",
"type": "Collection",
"first": {
"type": "CollectionPage",
"next": "https://example.com/users/{{nickname}}/statuses/{{status_id}}/replies?only_other_accounts=true&page=true",
"partOf": "https://example.com/users/{{nickname}}/statuses/{{status_id}}/replies",
"items": []
}
}
}

27
test/fixtures/statuses/note.json vendored Normal file
View file

@ -0,0 +1,27 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://example.com/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"actor": "https://example.com/users/{{nickname}}",
"attachment": [],
"attributedTo": "https://example.com/users/{{nickname}}",
"cc": [
"https://example.com/users/{{nickname}}/followers"
],
"content": "Content",
"context": "https://example.com/contexts/e4b180e1-7403-477f-aeb4-de57e7a3fe7f",
"conversation": "https://example.com/contexts/e4b180e1-7403-477f-aeb4-de57e7a3fe7f",
"id": "https://example.com/objects/{{object_id}}",
"published": "2019-12-15T22:00:05.279583Z",
"sensitive": false,
"summary": "",
"tag": [],
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Note"
}

View file

@ -0,0 +1,49 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://patch.cx/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"actor": "https://patch.cx/users/rin",
"attachment": [],
"attributedTo": "https://patch.cx/users/rin",
"cc": [
"https://patch.cx/users/rin/followers"
],
"content": ":joker_disapprove: <br><br>just grabbing a test fixture, nevermind me",
"context": "https://patch.cx/contexts/2c3ce4b4-18b1-4b1a-8965-3932027b5326",
"conversation": "https://patch.cx/contexts/2c3ce4b4-18b1-4b1a-8965-3932027b5326",
"id": "https://patch.cx/objects/a399c28e-c821-4820-bc3e-4afeb044c16f",
"published": "2021-03-22T16:54:46.461939Z",
"sensitive": null,
"source": ":joker_disapprove: \r\n\r\njust grabbing a test fixture, nevermind me",
"summary": ":joker_smile: ",
"tag": [
{
"icon": {
"type": "Image",
"url": "https://patch.cx/emoji/custom/joker_disapprove.png"
},
"id": "https://patch.cx/emoji/custom/joker_disapprove.png",
"name": ":joker_disapprove:",
"type": "Emoji",
"updated": "1970-01-01T00:00:00Z"
},
{
"icon": {
"type": "Image",
"url": "https://patch.cx/emoji/custom/joker_smile.png"
},
"id": "https://patch.cx/emoji/custom/joker_smile.png",
"name": ":joker_smile:",
"type": "Emoji",
"updated": "1970-01-01T00:00:00Z"
}
],
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Note"
}

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource={uri}" type="application/xrd+xml" />
</XRD>

View file

@ -1,41 +0,0 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"http://localhost:4001/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"attachment": [],
"endpoints": {
"oauthAuthorizationEndpoint": "http://localhost:4001/oauth/authorize",
"oauthRegistrationEndpoint": "http://localhost:4001/api/v1/apps",
"oauthTokenEndpoint": "http://localhost:4001/oauth/token",
"sharedInbox": "http://localhost:4001/inbox"
},
"followers": "http://localhost:4001/users/{{nickname}}/followers",
"following": "http://localhost:4001/users/{{nickname}}/following",
"icon": {
"type": "Image",
"url": "http://localhost:4001/media/4e914f5b84e4a259a3f6c2d2edc9ab642f2ab05f3e3d9c52c81fc2d984b3d51e.jpg"
},
"id": "http://localhost:4001/users/{{nickname}}",
"image": {
"type": "Image",
"url": "http://localhost:4001/media/f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg?name=f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg"
},
"inbox": "http://localhost:4001/users/{{nickname}}/inbox",
"manuallyApprovesFollowers": false,
"name": "{{nickname}}",
"outbox": "http://localhost:4001/users/{{nickname}}/outbox",
"preferredUsername": "{{nickname}}",
"publicKey": {
"id": "http://localhost:4001/users/{{nickname}}#main-key",
"owner": "http://localhost:4001/users/{{nickname}}",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5DLtwGXNZElJyxFGfcVc\nXANhaMadj/iYYQwZjOJTV9QsbtiNBeIK54PJrYuU0/0YIdrvS1iqheX5IwXRhcwa\nhm3ZyLz7XeN9st7FBni4BmZMBtMpxAuYuu5p/jbWy13qAiYOhPreCx0wrWgm/lBD\n9mkgaxIxPooBE0S4ZWEJIDIV1Vft3AWcRUyWW1vIBK0uZzs6GYshbQZB952S0yo4\nFzI1hABGHncH8UvuFauh4EZ8tY7/X5I0pGRnDOcRN1dAht5w5yTA+6r5kebiFQjP\nIzN/eCO/a9Flrj9YGW7HDNtjSOH0A31PLRGlJtJO3yK57dnf5ppyCZGfL4emShQo\ncQIDAQAB\n-----END PUBLIC KEY-----\n\n"
},
"summary": "your friendly neighborhood pleroma developer<br>I like cute things and distributed systems, and really hate delete and redrafts",
"tag": [],
"type": "Person",
"url": "http://localhost:4001/users/{{nickname}}"
}

View file

@ -0,0 +1,18 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
{
"ostatus": "http://ostatus.org#",
"atomUri": "ostatus:atomUri",
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
"conversation": "ostatus:conversation",
"sensitive": "as:sensitive",
"toot": "http://joinmastodon.org/ns#",
"votersCount": "toot:votersCount"
}
],
"id": "https://{{domain}}/users/{{nickname}}/collections/featured",
"type": "OrderedCollection",
"totalItems": 0,
"orderedItems": []
}

42
test/fixtures/users_mock/user.json vendored Normal file
View file

@ -0,0 +1,42 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://example.com/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"attachment": [],
"endpoints": {
"oauthAuthorizationEndpoint": "https://example.com/oauth/authorize",
"oauthRegistrationEndpoint": "https://example.com/api/v1/apps",
"oauthTokenEndpoint": "https://example.com/oauth/token",
"sharedInbox": "https://example.com/inbox"
},
"followers": "https://example.com/users/{{nickname}}/followers",
"following": "https://example.com/users/{{nickname}}/following",
"icon": {
"type": "Image",
"url": "https://example.com/media/4e914f5b84e4a259a3f6c2d2edc9ab642f2ab05f3e3d9c52c81fc2d984b3d51e.jpg"
},
"id": "https://example.com/users/{{nickname}}",
"image": {
"type": "Image",
"url": "https://example.com/media/f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg?name=f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg"
},
"inbox": "https://example.com/users/{{nickname}}/inbox",
"manuallyApprovesFollowers": false,
"name": "{{nickname}}",
"outbox": "https://example.com/users/{{nickname}}/outbox",
"preferredUsername": "{{nickname}}",
"publicKey": {
"id": "https://example.com/users/{{nickname}}#main-key",
"owner": "https://example.com/users/{{nickname}}",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5DLtwGXNZElJyxFGfcVc\nXANhaMadj/iYYQwZjOJTV9QsbtiNBeIK54PJrYuU0/0YIdrvS1iqheX5IwXRhcwa\nhm3ZyLz7XeN9st7FBni4BmZMBtMpxAuYuu5p/jbWy13qAiYOhPreCx0wrWgm/lBD\n9mkgaxIxPooBE0S4ZWEJIDIV1Vft3AWcRUyWW1vIBK0uZzs6GYshbQZB952S0yo4\nFzI1hABGHncH8UvuFauh4EZ8tY7/X5I0pGRnDOcRN1dAht5w5yTA+6r5kebiFQjP\nIzN/eCO/a9Flrj9YGW7HDNtjSOH0A31PLRGlJtJO3yK57dnf5ppyCZGfL4emShQo\ncQIDAQAB\n-----END PUBLIC KEY-----\n\n"
},
"featured": "https://example.com/users/{{nickname}}/collections/featured",
"summary": "your friendly neighborhood pleroma developer<br>I like cute things and distributed systems, and really hate delete and redrafts",
"tag": [],
"type": "Person",
"url": "https://example.com/users/{{nickname}}"
}

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.PleromaTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.AppTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.ConfigTest do
@ -200,6 +200,44 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
end
end
describe "migrate_from_db/1" do
setup do: clear_config(:configurable_from_database, true)
setup do
insert_config_record(:pleroma, :setting_first, key: "value", key2: ["Activity"])
insert_config_record(:pleroma, :setting_second, key: "value2", key2: [Repo])
insert_config_record(:quack, :level, :info)
path = "test/instance_static"
file_path = Path.join(path, "temp.exported_from_db.secret.exs")
on_exit(fn -> File.rm!(file_path) end)
[file_path: file_path]
end
test "with path parameter", %{file_path: file_path} do
MixTask.run(["migrate_from_db", "--env", "temp", "--path", Path.dirname(file_path)])
file = File.read!(file_path)
assert file =~ "config :pleroma, :setting_first,"
assert file =~ "config :pleroma, :setting_second,"
assert file =~ "config :quack, :level, :info"
end
test "release", %{file_path: file_path} do
clear_config(:release, true)
clear_config(:config_path, file_path)
MixTask.run(["migrate_from_db", "--env", "temp"])
file = File.read!(file_path)
assert file =~ "config :pleroma, :setting_first,"
assert file =~ "config :pleroma, :setting_second,"
assert file =~ "config :quack, :level, :info"
end
end
describe "operations on database config" do
setup do: clear_config(:configurable_from_database, true)

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.CountStatusesTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.DatabaseTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.DigestTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-onl
defmodule Mix.Tasks.Pleroma.Ecto.MigrateTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.Ecto.RollbackTest do
@ -12,7 +12,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.RollbackTest do
Logger.configure(level: :warn)
assert capture_log(fn ->
Mix.Tasks.Pleroma.Ecto.Rollback.run()
Mix.Tasks.Pleroma.Ecto.Rollback.run(["--env", "test"])
end) =~ "[info] Rollback succesfully"
Logger.configure(level: level)

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.EctoTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.EmailTest do
@ -61,18 +61,18 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
test "Sends confirmation emails" do
local_user1 =
insert(:user, %{
confirmation_pending: true,
is_confirmed: false,
confirmation_token: "mytoken",
deactivated: false,
is_active: true,
email: "local1@pleroma.com",
local: true
})
local_user2 =
insert(:user, %{
confirmation_pending: true,
is_confirmed: false,
confirmation_token: "mytoken",
deactivated: false,
is_active: true,
email: "local2@pleroma.com",
local: true
})
@ -88,30 +88,30 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
test "Does not send confirmation email to inappropriate users" do
# confirmed user
insert(:user, %{
confirmation_pending: false,
is_confirmed: true,
confirmation_token: "mytoken",
deactivated: false,
is_active: true,
email: "confirmed@pleroma.com",
local: true
})
# remote user
insert(:user, %{
deactivated: false,
is_active: true,
email: "remote@not-pleroma.com",
local: false
})
# deactivated user =
insert(:user, %{
deactivated: true,
is_active: false,
email: "deactivated@pleroma.com",
local: false
})
# invisible user
insert(:user, %{
deactivated: false,
is_active: true,
email: "invisible@pleroma.com",
local: true,
invisible: true

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.EmojiTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.FrontendTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.InstanceTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.RefreshCounterCacheTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.RelayTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
@ -12,7 +12,7 @@ defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
test "creates new dir" do
path = "test/fixtures/new_dir/"
file_path = path <> "robots.txt"
Pleroma.Config.put([:instance, :static_dir], path)
clear_config([:instance, :static_dir], path)
on_exit(fn ->
{:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path)
@ -29,7 +29,7 @@ defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
test "to existance folder" do
path = "test/fixtures/"
file_path = path <> "robots.txt"
Pleroma.Config.put([:instance, :static_dir], path)
clear_config([:instance, :static_dir], path)
on_exit(fn ->
:ok = File.rm(file_path)

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UploadsTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UserTest do
@ -102,7 +102,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert_received {:mix_shell, :info, [message]}
assert message =~ " deleted"
assert %{deactivated: true} = User.get_by_nickname(user.nickname)
assert %{is_active: false} = User.get_by_nickname(user.nickname)
assert called(Pleroma.Web.Federator.publish(:_))
end
@ -114,7 +114,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
{:ok, post} = CommonAPI.post(user, %{status: "uguu"})
{:ok, post2} = CommonAPI.post(user2, %{status: "test"})
obj = Object.normalize(post2)
obj = Object.normalize(post2, fetch: false)
{:ok, like_object, meta} = Pleroma.Web.ActivityPub.Builder.like(user, obj)
@ -130,7 +130,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
clear_config([:instance, :federating], true)
object = Object.normalize(post)
object = Object.normalize(post, fetch: false)
Object.prune(object)
with_mock Pleroma.Web.Federator,
@ -140,7 +140,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert_received {:mix_shell, :info, [message]}
assert message =~ " deleted"
assert %{deactivated: true} = User.get_by_nickname(user.nickname)
assert %{is_active: false} = User.get_by_nickname(user.nickname)
assert called(Pleroma.Web.Federator.publish(:_))
refute Pleroma.Repo.get(Pleroma.Activity, like_activity.id)
@ -157,41 +157,8 @@ defmodule Mix.Tasks.Pleroma.UserTest do
end
end
describe "running toggle_activated" do
test "user is deactivated" do
user = insert(:user)
Mix.Tasks.Pleroma.User.run(["toggle_activated", user.nickname])
assert_received {:mix_shell, :info, [message]}
assert message =~ " deactivated"
user = User.get_cached_by_nickname(user.nickname)
assert user.deactivated
end
test "user is activated" do
user = insert(:user, deactivated: true)
Mix.Tasks.Pleroma.User.run(["toggle_activated", user.nickname])
assert_received {:mix_shell, :info, [message]}
assert message =~ " activated"
user = User.get_cached_by_nickname(user.nickname)
refute user.deactivated
end
test "no user to toggle" do
Mix.Tasks.Pleroma.User.run(["toggle_activated", "nonexistent"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "No user"
end
end
describe "running deactivate" do
test "user is unsubscribed" do
test "active user is deactivated and unsubscribed" do
followed = insert(:user)
remote_followed = insert(:user, local: false)
user = insert(:user)
@ -201,16 +168,26 @@ defmodule Mix.Tasks.Pleroma.UserTest do
Mix.Tasks.Pleroma.User.run(["deactivate", user.nickname])
assert_received {:mix_shell, :info, [message]}
assert message =~ "Deactivating"
# Note that the task has delay :timer.sleep(500)
assert_received {:mix_shell, :info, [message]}
assert message =~ "Successfully unsubscribed"
assert message ==
"Successfully deactivated #{user.nickname} and unsubscribed all local followers"
user = User.get_cached_by_nickname(user.nickname)
assert Enum.empty?(Enum.filter(User.get_friends(user), & &1.local))
assert user.deactivated
refute user.is_active
end
test "user is deactivated" do
%{id: id, nickname: nickname} = insert(:user, is_active: false)
assert :ok = Mix.Tasks.Pleroma.User.run(["deactivate", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "User #{nickname} already deactivated"
user = Repo.get(User, id)
refute user.is_active
end
test "no user to deactivate" do
@ -238,7 +215,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert message =~ ~r/Admin status .* true/
assert_received {:mix_shell, :info, [message]}
assert message =~ ~r/Confirmation pending .* false/
assert message =~ ~r/Confirmation status.* true/
assert_received {:mix_shell, :info, [message]}
assert message =~ ~r/Locked status .* true/
@ -250,7 +227,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert user.is_moderator
assert user.is_locked
assert user.is_admin
refute user.confirmation_pending
assert user.is_confirmed
end
test "All statuses unset" do
@ -259,7 +236,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
is_locked: true,
is_moderator: true,
is_admin: true,
confirmation_pending: true
is_confirmed: false
)
Mix.Tasks.Pleroma.User.run([
@ -275,7 +252,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert message =~ ~r/Admin status .* false/
assert_received {:mix_shell, :info, [message]}
assert message =~ ~r/Confirmation pending .* true/
assert message =~ ~r/Confirmation status.* false/
assert_received {:mix_shell, :info, [message]}
assert message =~ ~r/Locked status .* false/
@ -287,7 +264,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
refute user.is_moderator
refute user.is_locked
refute user.is_admin
assert user.confirmation_pending
refute user.is_confirmed
end
test "no user to set status" do
@ -436,13 +413,6 @@ defmodule Mix.Tasks.Pleroma.UserTest do
assert_received {:mix_shell, :info, [message]}
assert message =~ "Invite for token #{invite.token} was revoked."
end
test "it prints an error message when invite is not exist" do
Mix.Tasks.Pleroma.User.run(["revoke_invite", "foo"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "No invite found"
end
end
describe "running delete_activities" do
@ -464,27 +434,27 @@ defmodule Mix.Tasks.Pleroma.UserTest do
describe "running confirm" do
test "user is confirmed" do
%{id: id, nickname: nickname} = insert(:user, confirmation_pending: false)
%{id: id, nickname: nickname} = insert(:user, is_confirmed: true)
assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "#{nickname} doesn't need confirmation."
user = Repo.get(User, id)
refute user.confirmation_pending
assert user.is_confirmed
refute user.confirmation_token
end
test "user is not confirmed" do
%{id: id, nickname: nickname} =
insert(:user, confirmation_pending: true, confirmation_token: "some token")
insert(:user, is_confirmed: false, confirmation_token: "some token")
assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "#{nickname} doesn't need confirmation."
user = Repo.get(User, id)
refute user.confirmation_pending
assert user.is_confirmed
refute user.confirmation_token
end
@ -496,6 +466,37 @@ defmodule Mix.Tasks.Pleroma.UserTest do
end
end
describe "running activate" do
test "user is activated" do
%{id: id, nickname: nickname} = insert(:user, is_active: true)
assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "User #{nickname} already activated"
user = Repo.get(User, id)
assert user.is_active
end
test "user is not activated" do
%{id: id, nickname: nickname} = insert(:user, is_active: false)
assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "Successfully activated #{nickname}"
user = Repo.get(User, id)
assert user.is_active
end
test "no user to activate" do
Mix.Tasks.Pleroma.User.run(["activate", "foo"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "No user"
end
end
describe "search" do
test "it returns users matching" do
user = insert(:user)
@ -579,29 +580,29 @@ defmodule Mix.Tasks.Pleroma.UserTest do
describe "bulk confirm and unconfirm" do
test "confirm all" do
user1 = insert(:user, confirmation_pending: true)
user2 = insert(:user, confirmation_pending: true)
user1 = insert(:user, is_confirmed: false)
user2 = insert(:user, is_confirmed: false)
assert user1.confirmation_pending
assert user2.confirmation_pending
refute user1.is_confirmed
refute user2.is_confirmed
Mix.Tasks.Pleroma.User.run(["confirm_all"])
user1 = User.get_cached_by_nickname(user1.nickname)
user2 = User.get_cached_by_nickname(user2.nickname)
refute user1.confirmation_pending
refute user2.confirmation_pending
assert user1.is_confirmed
assert user2.is_confirmed
end
test "unconfirm all" do
user1 = insert(:user, confirmation_pending: false)
user2 = insert(:user, confirmation_pending: false)
admin = insert(:user, is_admin: true, confirmation_pending: false)
mod = insert(:user, is_moderator: true, confirmation_pending: false)
user1 = insert(:user, is_confirmed: true)
user2 = insert(:user, is_confirmed: true)
admin = insert(:user, is_admin: true, is_confirmed: true)
mod = insert(:user, is_moderator: true, is_confirmed: true)
refute user1.confirmation_pending
refute user2.confirmation_pending
assert user1.is_confirmed
assert user2.is_confirmed
Mix.Tasks.Pleroma.User.run(["unconfirm_all"])
@ -610,10 +611,10 @@ defmodule Mix.Tasks.Pleroma.UserTest do
admin = User.get_cached_by_nickname(admin.nickname)
mod = User.get_cached_by_nickname(mod.nickname)
assert user1.confirmation_pending
assert user2.confirmation_pending
refute admin.confirmation_pending
refute mod.confirmation_pending
refute user1.is_confirmed
refute user2.is_confirmed
assert admin.is_confirmed
assert mod.is_confirmed
end
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity.Ir.TopicsTest do
@ -11,6 +11,8 @@ defmodule Pleroma.Activity.Ir.TopicsTest do
require Pleroma.Constants
import Mock
describe "poll answer" do
test "produce no topics" do
activity = %Activity{object: %Object{data: %{"type" => "Answer"}}}
@ -77,14 +79,13 @@ defmodule Pleroma.Activity.Ir.TopicsTest do
refute Enum.member?(topics, "public:local:media")
end
test "converts tags to hash tags", %{activity: %{object: %{data: data} = object} = activity} do
tagged_data = Map.put(data, "tag", ["foo", "bar"])
activity = %{activity | object: %{object | data: tagged_data}}
test "converts tags to hash tags", %{activity: activity} do
with_mock(Object, [:passthrough], hashtags: fn _ -> ["foo", "bar"] end) do
topics = Topics.get_activity_topics(activity)
topics = Topics.get_activity_topics(activity)
assert Enum.member?(topics, "hashtag:foo")
assert Enum.member?(topics, "hashtag:bar")
assert Enum.member?(topics, "hashtag:foo")
assert Enum.member?(topics, "hashtag:bar")
end
end
test "only converts strings to hash tags", %{

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity.SearchTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ActivityTest do
@ -25,7 +25,7 @@ defmodule Pleroma.ActivityTest do
test "returns activities by it's objects AP ids" do
activity = insert(:note_activity)
object_data = Object.normalize(activity).data
object_data = Object.normalize(activity, fetch: false).data
[found_activity] = Activity.get_all_create_by_object_ap_id(object_data["id"])
@ -34,7 +34,7 @@ defmodule Pleroma.ActivityTest do
test "returns the activity that created an object" do
activity = insert(:note_activity)
object_data = Object.normalize(activity).data
object_data = Object.normalize(activity, fetch: false).data
found_activity = Activity.get_create_by_object_ap_id(object_data["id"])
@ -168,7 +168,7 @@ defmodule Pleroma.ActivityTest do
test "find only local statuses for unauthenticated users when `limit_to_local_content` is `:all`",
%{local_activity: local_activity} do
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
clear_config([:instance, :limit_to_local_content], :all)
assert [^local_activity] = Activity.search(nil, "find me")
end
@ -177,7 +177,7 @@ defmodule Pleroma.ActivityTest do
local_activity: local_activity,
remote_activity: remote_activity
} do
Pleroma.Config.put([:instance, :limit_to_local_content], false)
clear_config([:instance, :limit_to_local_content], false)
activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
@ -254,4 +254,26 @@ defmodule Pleroma.ActivityTest do
assert %{id: ^id} = Activity.get_by_object_ap_id_with_object(obj_id)
end
test "add_by_params_query/3" do
user = insert(:user)
note = insert(:note_activity, user: user)
insert(:add_activity, user: user, note: note)
insert(:add_activity, user: user, note: note)
insert(:add_activity, user: user)
assert Repo.aggregate(Activity, :count, :id) == 4
add_query =
Activity.add_by_params_query(note.data["object"], user.ap_id, user.featured_address)
assert Repo.aggregate(add_query, :count, :id) == 2
Repo.delete_all(add_query)
assert Repo.aggregate(add_query, :count, :id) == 0
assert Repo.aggregate(Activity, :count, :id) == 2
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ApplicationRequirementsTest do
@ -9,7 +9,6 @@ defmodule Pleroma.ApplicationRequirementsTest do
import Mock
alias Pleroma.ApplicationRequirements
alias Pleroma.Config
alias Pleroma.Repo
describe "check_repo_pool_size!/1" do
@ -37,8 +36,8 @@ defmodule Pleroma.ApplicationRequirementsTest do
setup do: clear_config([Pleroma.Emails.Mailer])
test "raises if welcome email enabled but mail disabled" do
Pleroma.Config.put([:welcome, :email, :enabled], true)
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
clear_config([:welcome, :email, :enabled], true)
clear_config([Pleroma.Emails.Mailer, :enabled], false)
assert_raise Pleroma.ApplicationRequirements.VerifyError, "The mail disabled.", fn ->
capture_log(&Pleroma.ApplicationRequirements.verify!/0)
@ -59,8 +58,8 @@ defmodule Pleroma.ApplicationRequirementsTest do
setup do: clear_config([:instance, :account_activation_required])
test "raises if account confirmation is required but mailer isn't enable" do
Pleroma.Config.put([:instance, :account_activation_required], true)
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
clear_config([:instance, :account_activation_required], true)
clear_config([Pleroma.Emails.Mailer, :enabled], false)
assert_raise Pleroma.ApplicationRequirements.VerifyError,
"Account activation enabled, but Mailer is disabled. Cannot send confirmation emails.",
@ -70,14 +69,14 @@ defmodule Pleroma.ApplicationRequirementsTest do
end
test "doesn't do anything if account confirmation is disabled" do
Pleroma.Config.put([:instance, :account_activation_required], false)
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
clear_config([:instance, :account_activation_required], false)
clear_config([Pleroma.Emails.Mailer, :enabled], false)
assert Pleroma.ApplicationRequirements.verify!() == :ok
end
test "doesn't do anything if account confirmation is required and mailer is enabled" do
Pleroma.Config.put([:instance, :account_activation_required], true)
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], true)
clear_config([:instance, :account_activation_required], true)
clear_config([Pleroma.Emails.Mailer, :enabled], true)
assert Pleroma.ApplicationRequirements.verify!() == :ok
end
end
@ -93,7 +92,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
setup do: clear_config([:database, :rum_enabled])
test "raises if rum is enabled and detects unapplied rum migrations" do
Config.put([:database, :rum_enabled], true)
clear_config([:database, :rum_enabled], true)
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do
assert_raise ApplicationRequirements.VerifyError,
@ -105,7 +104,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
end
test "raises if rum is disabled and detects rum migrations" do
Config.put([:database, :rum_enabled], false)
clear_config([:database, :rum_enabled], false)
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do
assert_raise ApplicationRequirements.VerifyError,
@ -117,7 +116,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
end
test "doesn't do anything if rum enabled and applied migrations" do
Config.put([:database, :rum_enabled], true)
clear_config([:database, :rum_enabled], true)
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do
assert ApplicationRequirements.verify!() == :ok
@ -125,7 +124,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
end
test "doesn't do anything if rum disabled" do
Config.put([:database, :rum_enabled], false)
clear_config([:database, :rum_enabled], false)
with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do
assert ApplicationRequirements.verify!() == :ok
@ -161,7 +160,7 @@ defmodule Pleroma.ApplicationRequirementsTest do
end
test "doesn't do anything if disabled" do
Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true)
assert :ok == ApplicationRequirements.verify!()
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.BBS.HandlerTest do
@ -54,7 +54,7 @@ defmodule Pleroma.BBS.HandlerTest do
)
assert activity.actor == user.ap_id
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
assert object.data["content"] == "this is a test post"
end
@ -63,7 +63,7 @@ defmodule Pleroma.BBS.HandlerTest do
another_user = insert(:user)
{:ok, activity} = CommonAPI.post(another_user, %{status: "this is a test post"})
activity_object = Object.normalize(activity)
activity_object = Object.normalize(activity, fetch: false)
output =
capture_io(fn ->
@ -82,7 +82,7 @@ defmodule Pleroma.BBS.HandlerTest do
assert reply.actor == user.ap_id
reply_object_data = Object.normalize(reply).data
reply_object_data = Object.normalize(reply, fetch: false).data
assert reply_object_data["content"] == "this is a reply"
assert reply_object_data["inReplyTo"] == activity_object.data["id"]
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.BookmarkTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.CaptchaTest do
@ -69,7 +69,7 @@ defmodule Pleroma.CaptchaTest do
describe "Captcha Wrapper" do
test "validate" do
Pleroma.Config.put([Pleroma.Captcha, :enabled], true)
clear_config([Pleroma.Captcha, :enabled], true)
new = Captcha.new()
@ -83,7 +83,7 @@ defmodule Pleroma.CaptchaTest do
end
test "doesn't validate invalid answer" do
Pleroma.Config.put([Pleroma.Captcha, :enabled], true)
clear_config([Pleroma.Captcha, :enabled], true)
new = Captcha.new()
@ -99,7 +99,7 @@ defmodule Pleroma.CaptchaTest do
end
test "nil answer_data" do
Pleroma.Config.put([Pleroma.Captcha, :enabled], true)
clear_config([Pleroma.Captcha, :enabled], true)
new = Captcha.new()

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Chat.MessageReferenceTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ChatTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.DeprecationWarningsTest do
@ -87,13 +87,22 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
end
test "check_activity_expiration_config/0" do
clear_config(Pleroma.ActivityExpiration, enabled: true)
clear_config([Pleroma.ActivityExpiration], enabled: true)
assert capture_log(fn ->
DeprecationWarnings.check_activity_expiration_config()
end) =~ "Your config is using old namespace for activity expiration configuration."
end
test "check_uploders_s3_public_endpoint/0" do
clear_config([Pleroma.Uploaders.S3], public_endpoint: "https://fake.amazonaws.com/bucket/")
assert capture_log(fn ->
DeprecationWarnings.check_uploders_s3_public_endpoint()
end) =~
"Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket."
end
describe "check_gun_pool_options/0" do
test "await_up_timeout" do
config = Config.get(:connections_pool)

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.HolderTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.LoaderTest do

View file

@ -0,0 +1,45 @@
defmodule Pleroma.Config.ReleaseRuntimeProviderTest do
use ExUnit.Case, async: true
alias Pleroma.Config.ReleaseRuntimeProvider
describe "load/2" do
test "loads release defaults config and warns about non-existent runtime config" do
ExUnit.CaptureIO.capture_io(fn ->
merged = ReleaseRuntimeProvider.load([], [])
assert merged == Pleroma.Config.Holder.release_defaults()
end) =~
"!!! Config path is not declared! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file"
end
test "merged runtime config" do
merged =
ReleaseRuntimeProvider.load([], config_path: "test/fixtures/config/temp.secret.exs")
assert merged[:pleroma][:first_setting] == [key: "value", key2: [Pleroma.Repo]]
assert merged[:pleroma][:second_setting] == [key: "value2", key2: ["Activity"]]
end
test "merged exported config" do
ExUnit.CaptureIO.capture_io(fn ->
merged =
ReleaseRuntimeProvider.load([],
exported_config_path: "test/fixtures/config/temp.exported_from_db.secret.exs"
)
assert merged[:pleroma][:exported_config_merged]
end) =~
"!!! Config path is not declared! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file"
end
test "runtime config is merged with exported config" do
merged =
ReleaseRuntimeProvider.load([],
config_path: "test/fixtures/config/temp.secret.exs",
exported_config_path: "test/fixtures/config/temp.exported_from_db.secret.exs"
)
assert merged[:pleroma][:first_setting] == [key2: [Pleroma.Repo], key: "new value"]
end
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Config.TransferTaskTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConfigDBTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConfigTest do
@ -30,9 +30,9 @@ defmodule Pleroma.ConfigTest do
describe "nil values" do
setup do
Pleroma.Config.put(:lorem, nil)
Pleroma.Config.put(:ipsum, %{dolor: [sit: nil]})
Pleroma.Config.put(:dolor, sit: %{amet: nil})
clear_config(:lorem, nil)
clear_config(:ipsum, %{dolor: [sit: nil]})
clear_config(:dolor, sit: %{amet: nil})
on_exit(fn -> Enum.each(~w(lorem ipsum dolor)a, &Pleroma.Config.delete/1) end)
end
@ -57,9 +57,9 @@ defmodule Pleroma.ConfigTest do
end
test "get/1 when value is false" do
Pleroma.Config.put([:instance, :false_test], false)
Pleroma.Config.put([:instance, :nested], [])
Pleroma.Config.put([:instance, :nested, :false_test], false)
clear_config([:instance, :false_test], false)
clear_config([:instance, :nested], [])
clear_config([:instance, :nested, :false_test], false)
assert Pleroma.Config.get([:instance, :false_test]) == false
assert Pleroma.Config.get([:instance, :nested, :false_test]) == false
@ -81,40 +81,40 @@ defmodule Pleroma.ConfigTest do
end
test "get!/1 when value is false" do
Pleroma.Config.put([:instance, :false_test], false)
Pleroma.Config.put([:instance, :nested], [])
Pleroma.Config.put([:instance, :nested, :false_test], false)
clear_config([:instance, :false_test], false)
clear_config([:instance, :nested], [])
clear_config([:instance, :nested, :false_test], false)
assert Pleroma.Config.get!([:instance, :false_test]) == false
assert Pleroma.Config.get!([:instance, :nested, :false_test]) == false
end
test "put/2 with a key" do
Pleroma.Config.put(:config_test, true)
clear_config(:config_test, true)
assert Pleroma.Config.get(:config_test) == true
end
test "put/2 with a list of keys" do
Pleroma.Config.put([:instance, :config_test], true)
Pleroma.Config.put([:instance, :config_nested_test], [])
Pleroma.Config.put([:instance, :config_nested_test, :x], true)
clear_config([:instance, :config_test], true)
clear_config([:instance, :config_nested_test], [])
clear_config([:instance, :config_nested_test, :x], true)
assert Pleroma.Config.get([:instance, :config_test]) == true
assert Pleroma.Config.get([:instance, :config_nested_test, :x]) == true
end
test "delete/1 with a key" do
Pleroma.Config.put([:delete_me], :delete_me)
clear_config([:delete_me], :delete_me)
Pleroma.Config.delete([:delete_me])
assert Pleroma.Config.get([:delete_me]) == nil
end
test "delete/2 with a list of keys" do
Pleroma.Config.put([:delete_me], hello: "world", world: "Hello")
clear_config([:delete_me], hello: "world", world: "Hello")
Pleroma.Config.delete([:delete_me, :world])
assert Pleroma.Config.get([:delete_me]) == [hello: "world"]
Pleroma.Config.put([:delete_me, :delete_me], hello: "world", world: "Hello")
clear_config([:delete_me, :delete_me], hello: "world", world: "Hello")
Pleroma.Config.delete([:delete_me, :delete_me, :world])
assert Pleroma.Config.get([:delete_me, :delete_me]) == [hello: "world"]
@ -123,8 +123,8 @@ defmodule Pleroma.ConfigTest do
end
test "fetch/1" do
Pleroma.Config.put([:lorem], :ipsum)
Pleroma.Config.put([:ipsum], dolor: :sit)
clear_config([:lorem], :ipsum)
clear_config([:ipsum], dolor: :sit)
assert Pleroma.Config.fetch([:lorem]) == {:ok, :ipsum}
assert Pleroma.Config.fetch(:lorem) == {:ok, :ipsum}

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Conversation.ParticipationTest do
@ -175,8 +175,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
assert [participation_one, participation_two] = Participation.for_user(user)
object2 = Pleroma.Object.normalize(activity_two)
object3 = Pleroma.Object.normalize(activity_three)
object2 = Pleroma.Object.normalize(activity_two, fetch: false)
object3 = Pleroma.Object.normalize(activity_three, fetch: false)
user = Repo.get(Pleroma.User, user.id)
@ -359,4 +359,16 @@ defmodule Pleroma.Conversation.ParticipationTest do
assert Participation.unread_count(blocked) == 1
end
end
test "deletes a conversation" do
user = insert(:user)
other_user = insert(:user)
{:ok, _activity} =
CommonAPI.post(user, %{status: "Hey @#{other_user.nickname}.", visibility: "direct"})
assert [participation] = Participation.for_user(other_user)
assert {:ok, _} = Participation.delete(participation)
assert [] == Participation.for_user(other_user)
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConversationTest do
@ -48,7 +48,7 @@ defmodule Pleroma.ConversationTest do
user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "Hey"})
object = Pleroma.Object.normalize(activity)
object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation = Conversation.get_for_ap_id(context)
@ -64,7 +64,7 @@ defmodule Pleroma.ConversationTest do
{:ok, activity} =
CommonAPI.post(har, %{status: "Hey @#{jafnhar.nickname}", visibility: "direct"})
object = Pleroma.Object.normalize(activity)
object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation =
@ -86,7 +86,7 @@ defmodule Pleroma.ConversationTest do
in_reply_to_status_id: activity.id
})
object = Pleroma.Object.normalize(activity)
object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation_two =
@ -110,7 +110,7 @@ defmodule Pleroma.ConversationTest do
in_reply_to_status_id: activity.id
})
object = Pleroma.Object.normalize(activity)
object = Pleroma.Object.normalize(activity, fetch: false)
context = object.data["context"]
conversation_three =

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Docs.GeneratorTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EarmarkRendererTest do
use Pleroma.DataCase, async: true

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.DateTimeTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectIDTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.RecipientsTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.SafeTextTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.AdminEmailTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.MailerTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.UserEmailTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emoji.FormatterTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emoji.LoaderTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emoji.PackTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.EmojiTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FilterTest do
@ -7,81 +7,120 @@ defmodule Pleroma.FilterTest do
import Pleroma.Factory
alias Oban.Job
alias Pleroma.Filter
alias Pleroma.Repo
setup do
[user: insert(:user)]
end
describe "creating filters" do
test "creating one filter" do
user = insert(:user)
test "creation validation error", %{user: user} do
attrs = %{
user_id: user.id,
expires_in: 60
}
query = %Filter{
{:error, _} = Filter.create(attrs)
assert Repo.all(Job) == []
end
test "use passed expires_at instead expires_in", %{user: user} do
now = NaiveDateTime.utc_now()
attrs = %{
user_id: user.id,
expires_at: now,
phrase: "knights",
context: ["home"],
expires_in: 600
}
{:ok, %Filter{} = filter} = Filter.create(attrs)
result = Filter.get(filter.filter_id, user)
assert result.expires_at == NaiveDateTime.truncate(now, :second)
[job] = Repo.all(Job)
assert DateTime.truncate(job.scheduled_at, :second) ==
now |> NaiveDateTime.truncate(:second) |> DateTime.from_naive!("Etc/UTC")
end
test "creating one filter", %{user: user} do
attrs = %{
user_id: user.id,
filter_id: 42,
phrase: "knights",
context: ["home"]
}
{:ok, %Filter{} = filter} = Filter.create(query)
{:ok, %Filter{} = filter} = Filter.create(attrs)
result = Filter.get(filter.filter_id, user)
assert query.phrase == result.phrase
assert attrs.phrase == result.phrase
end
test "creating one filter without a pre-defined filter_id" do
user = insert(:user)
test "creating with expired_at", %{user: user} do
attrs = %{
user_id: user.id,
filter_id: 42,
phrase: "knights",
context: ["home"],
expires_in: 60
}
query = %Filter{
{:ok, %Filter{} = filter} = Filter.create(attrs)
result = Filter.get(filter.filter_id, user)
assert attrs.phrase == result.phrase
assert [_] = Repo.all(Job)
end
test "creating one filter without a pre-defined filter_id", %{user: user} do
attrs = %{
user_id: user.id,
phrase: "knights",
context: ["home"]
}
{:ok, %Filter{} = filter} = Filter.create(query)
{:ok, %Filter{} = filter} = Filter.create(attrs)
# Should start at 1
assert filter.filter_id == 1
end
test "creating additional filters uses previous highest filter_id + 1" do
user = insert(:user)
test "creating additional filters uses previous highest filter_id + 1", %{user: user} do
filter1 = insert(:filter, user: user)
query_one = %Filter{
user_id: user.id,
filter_id: 42,
phrase: "knights",
context: ["home"]
}
{:ok, %Filter{} = filter_one} = Filter.create(query_one)
query_two = %Filter{
attrs = %{
user_id: user.id,
# No filter_id
phrase: "who",
context: ["home"]
}
{:ok, %Filter{} = filter_two} = Filter.create(query_two)
assert filter_two.filter_id == filter_one.filter_id + 1
{:ok, %Filter{} = filter2} = Filter.create(attrs)
assert filter2.filter_id == filter1.filter_id + 1
end
test "filter_id is unique per user" do
user_one = insert(:user)
test "filter_id is unique per user", %{user: user_one} do
user_two = insert(:user)
query_one = %Filter{
attrs1 = %{
user_id: user_one.id,
phrase: "knights",
context: ["home"]
}
{:ok, %Filter{} = filter_one} = Filter.create(query_one)
{:ok, %Filter{} = filter_one} = Filter.create(attrs1)
query_two = %Filter{
attrs2 = %{
user_id: user_two.id,
phrase: "who",
context: ["home"]
}
{:ok, %Filter{} = filter_two} = Filter.create(query_two)
{:ok, %Filter{} = filter_two} = Filter.create(attrs2)
assert filter_one.filter_id == 1
assert filter_two.filter_id == 1
@ -94,65 +133,61 @@ defmodule Pleroma.FilterTest do
end
end
test "deleting a filter" do
user = insert(:user)
test "deleting a filter", %{user: user} do
filter = insert(:filter, user: user)
query = %Filter{
user_id: user.id,
filter_id: 0,
phrase: "knights",
context: ["home"]
}
{:ok, _filter} = Filter.create(query)
{:ok, filter} = Filter.delete(query)
assert is_nil(Repo.get(Filter, filter.filter_id))
assert Repo.get(Filter, filter.id)
{:ok, filter} = Filter.delete(filter)
refute Repo.get(Filter, filter.id)
end
test "getting all filters by an user" do
user = insert(:user)
query_one = %Filter{
test "deleting a filter with expires_at is removing Oban job too", %{user: user} do
attrs = %{
user_id: user.id,
filter_id: 1,
phrase: "knights",
context: ["home"]
phrase: "cofe",
context: ["home"],
expires_in: 600
}
query_two = %Filter{
user_id: user.id,
filter_id: 2,
phrase: "who",
context: ["home"]
}
{:ok, filter} = Filter.create(attrs)
assert %Job{id: job_id} = Pleroma.Workers.PurgeExpiredFilter.get_expiration(filter.id)
{:ok, _} = Filter.delete(filter)
{:ok, filter_one} = Filter.create(query_one)
{:ok, filter_two} = Filter.create(query_two)
filters = Filter.get_filters(user)
assert filter_one in filters
assert filter_two in filters
assert Repo.get(Job, job_id) == nil
end
test "updating a filter" do
user = insert(:user)
test "getting all filters by an user", %{user: user} do
filter1 = insert(:filter, user: user)
filter2 = insert(:filter, user: user)
query_one = %Filter{
user_id: user.id,
filter_id: 1,
phrase: "knights",
context: ["home"]
}
filter_ids = user |> Filter.get_filters() |> collect_ids()
assert filter1.id in filter_ids
assert filter2.id in filter_ids
end
test "updating a filter", %{user: user} do
filter = insert(:filter, user: user)
changes = %{
phrase: "who",
context: ["home", "timeline"]
}
{:ok, filter_one} = Filter.create(query_one)
{:ok, filter_two} = Filter.update(filter_one, changes)
{:ok, updated_filter} = Filter.update(filter, changes)
assert filter_one != filter_two
assert filter_two.phrase == changes.phrase
assert filter_two.context == changes.context
assert filter != updated_filter
assert updated_filter.phrase == changes.phrase
assert updated_filter.context == changes.context
end
test "updating with error", %{user: user} do
filter = insert(:filter, user: user)
changes = %{
phrase: nil
}
{:error, _} = Filter.update(filter, changes)
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FollowingRelationshipTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FormatterTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FrontendTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Gun.ConnectionPoolTest do
@ -7,7 +7,6 @@ defmodule Pleroma.Gun.ConnectionPoolTest do
import Mox
import ExUnit.CaptureLog
alias Pleroma.Config
alias Pleroma.Gun.ConnectionPool
defp gun_mock(_) do
@ -19,7 +18,6 @@ defmodule Pleroma.Gun.ConnectionPoolTest do
:ok
end
setup :set_mox_from_context
setup :gun_mock
test "gives the same connection to 2 concurrent requests" do
@ -50,7 +48,7 @@ defmodule Pleroma.Gun.ConnectionPoolTest do
test "connection limit is respected with concurrent requests" do
clear_config([:connections_pool, :max_connections]) do
Config.put([:connections_pool, :max_connections], 1)
clear_config([:connections_pool, :max_connections], 1)
# The supervisor needs a reboot to apply the new config setting
Process.exit(Process.whereis(Pleroma.Gun.ConnectionPool.WorkerSupervisor), :kill)

View file

@ -0,0 +1,17 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HashtagTest do
use Pleroma.DataCase
alias Pleroma.Hashtag
describe "changeset validations" do
test "ensure non-blank :name" do
changeset = Hashtag.changeset(%Hashtag{}, %{name: ""})
assert {:name, {"can't be blank", [validation: :required]}} in changeset.errors
end
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HealthcheckTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTMLTest do
@ -175,7 +175,7 @@ defmodule Pleroma.HTMLTest do
"I think I just found the best github repo https://github.com/komeiji-satori/Dress"
})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://github.com/komeiji-satori/Dress"
end
@ -190,7 +190,7 @@ defmodule Pleroma.HTMLTest do
"@#{other_user.nickname} install misskey! https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://github.com/syuilo/misskey/blob/develop/docs/setup.en.md"
@ -206,7 +206,7 @@ defmodule Pleroma.HTMLTest do
status: "#cofe https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
@ -222,7 +222,7 @@ defmodule Pleroma.HTMLTest do
content_type: "text/html"
})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
{:ok, url} = HTML.extract_first_external_url_from_object(object)
assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140"
@ -233,7 +233,7 @@ defmodule Pleroma.HTMLTest do
{:ok, activity} = CommonAPI.post(user, %{status: "\"http://cofe.com/?boomer=ok&foo=bar\""})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
assert {:ok, nil} = HTML.extract_first_external_url_from_object(object)
end
@ -247,7 +247,7 @@ defmodule Pleroma.HTMLTest do
"<a href=\"https://pleroma.gov/media/d24caa3a498e21e0298377a9ca0149a4f4f8b767178aacf837542282e2d94fb1.png?name=image.png\" class=\"attachment\">image.png</a>"
})
object = Object.normalize(activity)
object = Object.normalize(activity, fetch: false)
assert {:ok, nil} = HTML.extract_first_external_url_from_object(object)
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.AdapterHelper.GunTest do
@ -8,7 +8,6 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
import Mox
alias Pleroma.Config
alias Pleroma.HTTP.AdapterHelper.Gun
setup :verify_on_exit!
@ -52,9 +51,7 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
end
test "parses string proxy host & port" do
proxy = Config.get([:http, :proxy_url])
Config.put([:http, :proxy_url], "localhost:8123")
on_exit(fn -> Config.put([:http, :proxy_url], proxy) end)
clear_config([:http, :proxy_url], "localhost:8123")
uri = URI.parse("https://some-domain.com")
opts = Gun.options([receive_conn: false], uri)
@ -62,9 +59,7 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
end
test "parses tuple proxy scheme host and port" do
proxy = Config.get([:http, :proxy_url])
Config.put([:http, :proxy_url], {:socks, 'localhost', 1234})
on_exit(fn -> Config.put([:http, :proxy_url], proxy) end)
clear_config([:http, :proxy_url], {:socks, 'localhost', 1234})
uri = URI.parse("https://some-domain.com")
opts = Gun.options([receive_conn: false], uri)
@ -72,9 +67,7 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
end
test "passed opts have more weight than defaults" do
proxy = Config.get([:http, :proxy_url])
Config.put([:http, :proxy_url], {:socks5, 'localhost', 1234})
on_exit(fn -> Config.put([:http, :proxy_url], proxy) end)
clear_config([:http, :proxy_url], {:socks5, 'localhost', 1234})
uri = URI.parse("https://some-domain.com")
opts = Gun.options([receive_conn: false, proxy: {'example.com', 4321}], uri)

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.AdapterHelperTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.ExAwsTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.RequestBuilderTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.TzdataTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTPTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Instances.InstanceTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.InstancesTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Integration.FederationTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Integration.MastodonWebsocketTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.JobQueueMonitorTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.KeysTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ListTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MarkerTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFA.BackupCodesTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFA.TOTPTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MFATest do
@ -30,8 +30,8 @@ defmodule Pleroma.MFATest 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.verify_pass(code1, hash1)
assert Pbkdf2.verify_pass(code2, hash2)
assert Pleroma.Password.Pbkdf2.verify_pass(code1, hash1)
assert Pleroma.Password.Pbkdf2.verify_pass(code2, hash2)
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.MigrationHelper.NotificationBackfillTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ModerationLogTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.NotificationTest do
@ -45,6 +45,20 @@ defmodule Pleroma.NotificationTest do
assert notification.type == "pleroma:report"
end
test "suppresses notification to reporter if reporter is an admin" do
reporting_admin = insert(:user, is_admin: true)
reported_user = insert(:user)
other_admin = insert(:user, is_admin: true)
{:ok, activity} = CommonAPI.report(reporting_admin, %{account_id: reported_user.id})
{:ok, [notification]} = Notification.create_notifications(activity)
refute notification.user_id == reporting_admin.id
assert notification.user_id == other_admin.id
assert notification.type == "pleroma:report"
end
test "creates a notification for an emoji reaction" do
user = insert(:user)
other_user = insert(:user)
@ -976,7 +990,6 @@ defmodule Pleroma.NotificationTest do
assert Enum.empty?(Notification.for_user(local_user))
end
@tag capture_log: true
test "move activity generates a notification" do
%{ap_id: old_ap_id} = old_user = insert(:user)
%{ap_id: new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
@ -986,18 +999,6 @@ defmodule Pleroma.NotificationTest do
User.follow(follower, old_user)
User.follow(other_follower, old_user)
old_user_url = old_user.ap_id
body =
File.read!("test/fixtures/users_mock/localhost.json")
|> String.replace("{{nickname}}", old_user.nickname)
|> Jason.encode!()
Tesla.Mock.mock(fn
%{method: :get, url: ^old_user_url} ->
%Tesla.Env{status: 200, body: body}
end)
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
ObanHelpers.perform_all()

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Object.ContainmentTest do

View file

@ -1,12 +1,11 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Object.FetcherTest do
use Pleroma.DataCase
alias Pleroma.Activity
alias Pleroma.Config
alias Pleroma.Object
alias Pleroma.Object.Fetcher
@ -87,20 +86,20 @@ defmodule Pleroma.Object.FetcherTest do
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
test "it returns thread depth exceeded error if thread depth is exceeded" do
Config.put([:instance, :federation_incoming_replies_max_depth], 0)
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:error, "Max thread distance exceeded."} =
Fetcher.fetch_object_from_id(@ap_id, depth: 1)
end
test "it fetches object if max thread depth is restricted to 0 and depth is not specified" do
Config.put([:instance, :federation_incoming_replies_max_depth], 0)
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id)
end
test "it fetches object if requested depth does not exceed max thread depth" do
Config.put([:instance, :federation_incoming_replies_max_depth], 10)
clear_config([:instance, :federation_incoming_replies_max_depth], 10)
assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id, depth: 10)
end
@ -245,7 +244,7 @@ defmodule Pleroma.Object.FetcherTest do
Pleroma.Signature,
[:passthrough],
[] do
Config.put([:activitypub, :sign_object_fetches], true)
clear_config([:activitypub, :sign_object_fetches], true)
Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
@ -256,7 +255,7 @@ defmodule Pleroma.Object.FetcherTest do
Pleroma.Signature,
[:passthrough],
[] do
Config.put([:activitypub, :sign_object_fetches], false)
clear_config([:activitypub, :sign_object_fetches], false)
Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")

View file

@ -1,14 +1,17 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ObjectTest do
use Pleroma.DataCase
use Oban.Testing, repo: Pleroma.Repo
import ExUnit.CaptureLog
import Pleroma.Factory
import Tesla.Mock
alias Pleroma.Activity
alias Pleroma.Hashtag
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
@ -78,8 +81,8 @@ defmodule Pleroma.ObjectTest do
setup do: clear_config([:instance, :cleanup_attachments])
test "Disabled via config" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
Pleroma.Config.put([:instance, :cleanup_attachments], false)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([:instance, :cleanup_attachments], false)
file = %Plug.Upload{
content_type: "image/jpeg",
@ -112,8 +115,8 @@ defmodule Pleroma.ObjectTest do
end
test "in subdirectories" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
Pleroma.Config.put([:instance, :cleanup_attachments], true)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([:instance, :cleanup_attachments], true)
file = %Plug.Upload{
content_type: "image/jpeg",
@ -146,9 +149,9 @@ defmodule Pleroma.ObjectTest do
end
test "with dedupe enabled" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
Pleroma.Config.put([Pleroma.Upload, :filters], [Pleroma.Upload.Filter.Dedupe])
Pleroma.Config.put([:instance, :cleanup_attachments], true)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([Pleroma.Upload, :filters], [Pleroma.Upload.Filter.Dedupe])
clear_config([:instance, :cleanup_attachments], true)
uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
@ -184,8 +187,8 @@ defmodule Pleroma.ObjectTest do
end
test "with objects that have legacy data.url attribute" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
Pleroma.Config.put([:instance, :cleanup_attachments], true)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([:instance, :cleanup_attachments], true)
file = %Plug.Upload{
content_type: "image/jpeg",
@ -220,9 +223,9 @@ defmodule Pleroma.ObjectTest do
end
test "With custom base_url" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
Pleroma.Config.put([Pleroma.Upload, :base_url], "https://sub.domain.tld/dir/")
Pleroma.Config.put([:instance, :cleanup_attachments], true)
clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
clear_config([Pleroma.Upload, :base_url], "https://sub.domain.tld/dir/")
clear_config([:instance, :cleanup_attachments], true)
file = %Plug.Upload{
content_type: "image/jpeg",
@ -256,23 +259,22 @@ defmodule Pleroma.ObjectTest do
end
describe "normalizer" do
test "fetches unknown objects by default" do
%Object{} =
object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367")
assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
@url "http://mastodon.example.org/@admin/99541947525187367"
test "does not fetch unknown objects by default" do
assert nil == Object.normalize(@url)
end
test "fetches unknown objects when fetch_remote is explicitly true" do
%Object{} =
object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367", true)
test "fetches unknown objects when fetch is explicitly true" do
%Object{} = object = Object.normalize(@url, fetch: true)
assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367"
assert object.data["url"] == @url
end
test "does not fetch unknown objects when fetch_remote is false" do
test "does not fetch unknown objects when fetch is false" do
assert is_nil(
Object.normalize("http://mastodon.example.org/@admin/99541947525187367", false)
Object.normalize(@url,
fetch: false
)
)
end
end
@ -310,7 +312,10 @@ defmodule Pleroma.ObjectTest do
mock_modified: mock_modified
} do
%Object{} =
object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
object =
Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
fetch: true
)
Object.set_cache(object)
@ -332,7 +337,10 @@ defmodule Pleroma.ObjectTest do
test "returns the old object if refetch fails", %{mock_modified: mock_modified} do
%Object{} =
object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
object =
Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
fetch: true
)
Object.set_cache(object)
@ -355,7 +363,10 @@ defmodule Pleroma.ObjectTest do
mock_modified: mock_modified
} do
%Object{} =
object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
object =
Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
fetch: true
)
Object.set_cache(object)
@ -377,7 +388,10 @@ defmodule Pleroma.ObjectTest do
test "preserves internal fields on refetch", %{mock_modified: mock_modified} do
%Object{} =
object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d")
object =
Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d",
fetch: true
)
Object.set_cache(object)
@ -406,4 +420,28 @@ defmodule Pleroma.ObjectTest do
assert updated_object.data["like_count"] == 1
end
end
describe ":hashtags association" do
test "Hashtag records are created with Object record and updated on its change" do
user = insert(:user)
{:ok, %{object: object}} =
CommonAPI.post(user, %{status: "some text #hashtag1 #hashtag2 ..."})
assert [%Hashtag{name: "hashtag1"}, %Hashtag{name: "hashtag2"}] =
Enum.sort_by(object.hashtags, & &1.name)
{:ok, object} = Object.update_data(object, %{"tag" => []})
assert [] = object.hashtags
object = Object.get_by_id(object.id) |> Repo.preload(:hashtags)
assert [] = object.hashtags
{:ok, object} = Object.update_data(object, %{"tag" => ["abc", "def"]})
assert [%Hashtag{name: "abc"}, %Hashtag{name: "def"}] =
Enum.sort_by(object.hashtags, & &1.name)
end
end
end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.OTPVersionTest do

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.PaginationTest do

Some files were not shown because too many files have changed in this diff Show more