Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jeff
pleroma
Commits
8086c7ae
Commit
8086c7ae
authored
5 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
tests: add tests for banner and avatar removal
parent
baf72d6c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/web/activity_pub/mrf/simple_policy_test.exs
+72
-1
72 additions, 1 deletion
test/web/activity_pub/mrf/simple_policy_test.exs
with
72 additions
and
1 deletion
test/web/activity_pub/mrf/simple_policy_test.exs
+
72
−
1
View file @
8086c7ae
...
...
@@ -17,7 +17,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
federated_timeline_removal:
[],
report_removal:
[],
reject:
[],
accept:
[]
accept:
[],
avatar_removal:
[],
banner_removal:
[]
)
on_exit
(
fn
->
...
...
@@ -206,6 +208,60 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
end
describe
"when :avatar_removal"
do
test
"is empty"
do
Config
.
put
([
:mrf_simple
,
:avatar_removal
],
[])
remote_user
=
build_remote_user
()
assert
SimplePolicy
.
filter
(
remote_user
)
==
{
:ok
,
remote_user
}
end
test
"is not empty but it doesn't have a matching host"
do
Config
.
put
([
:mrf_simple
,
:avatar_removal
],
[
"non.matching.remote"
])
remote_user
=
build_remote_user
()
assert
SimplePolicy
.
filter
(
remote_user
)
==
{
:ok
,
remote_user
}
end
test
"has a matching host"
do
Config
.
put
([
:mrf_simple
,
:avatar_removal
],
[
"remote.instance"
])
remote_user
=
build_remote_user
()
{
:ok
,
filtered
}
=
SimplePolicy
.
filter
(
remote_user
)
refute
filtered
[
"icon"
]
end
end
describe
"when :banner_removal"
do
test
"is empty"
do
Config
.
put
([
:mrf_simple
,
:banner_removal
],
[])
remote_user
=
build_remote_user
()
assert
SimplePolicy
.
filter
(
remote_user
)
==
{
:ok
,
remote_user
}
end
test
"is not empty but it doesn't have a matching host"
do
Config
.
put
([
:mrf_simple
,
:banner_removal
],
[
"non.matching.remote"
])
remote_user
=
build_remote_user
()
assert
SimplePolicy
.
filter
(
remote_user
)
==
{
:ok
,
remote_user
}
end
test
"has a matching host"
do
Config
.
put
([
:mrf_simple
,
:banner_removal
],
[
"remote.instance"
])
remote_user
=
build_remote_user
()
{
:ok
,
filtered
}
=
SimplePolicy
.
filter
(
remote_user
)
refute
filtered
[
"image"
]
end
end
defp
build_local_message
do
%{
"actor"
=>
"
#{
Pleroma
.
Web
.
base_url
()
}
/users/alice"
,
...
...
@@ -217,4 +273,19 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
defp
build_remote_message
do
%{
"actor"
=>
"https://remote.instance/users/bob"
}
end
defp
build_remote_user
do
%{
"id"
=>
"https://remote.instance/users/bob"
,
"icon"
=>
%{
"url"
=>
"http://example.com/image.jpg"
,
"type"
=>
"Image"
},
"image"
=>
%{
"url"
=>
"http://example.com/image.jpg"
,
"type"
=>
"Image"
},
"type"
=>
"Person"
}
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment