Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33101394
remote_fetcher_worker_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
remote_fetcher_worker_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Workers.RemoteFetcherWorkerTest
do
use
Pleroma.DataCase
use
Oban.Testing
,
repo
:
Pleroma.Repo
alias
Pleroma.Workers.RemoteFetcherWorker
@deleted_object_one
"https://deleted-404.example.com/"
@deleted_object_two
"https://deleted-410.example.com/"
@unauthorized_object
"https://unauthorized.example.com/"
@depth_object
"https://depth.example.com/"
@content_type_object
"https://bad_content_type.example.com/"
describe
"RemoteFetcherWorker"
do
setup
do
Tesla.Mock
.
mock
(
fn
%{
method
:
:get
,
url
:
@deleted_object_one
}
->
%
Tesla.Env
{
status
:
404
}
%{
method
:
:get
,
url
:
@deleted_object_two
}
->
%
Tesla.Env
{
status
:
410
}
%{
method
:
:get
,
url
:
@unauthorized_object
}
->
%
Tesla.Env
{
status
:
403
}
%{
method
:
:get
,
url
:
@depth_object
}
->
%
Tesla.Env
{
status
:
200
}
%{
method
:
:get
,
url
:
@content_type_object
}
->
%
Tesla.Env
{
status
:
200
,
headers
:
[{
"content-type"
,
"application/json"
}],
body
:
File
.
read!
(
"test/fixtures/spoofed-object.json"
)
}
end
)
end
test
"does not retry jobs for a deleted object"
do
[
%{
"op"
=>
"fetch_remote"
,
"id"
=>
@deleted_object_one
},
%{
"op"
=>
"fetch_remote"
,
"id"
=>
@deleted_object_two
}
]
|>
Enum
.
each
(
fn
job
->
assert
{
:cancel
,
_
}
=
perform_job
(
RemoteFetcherWorker
,
job
)
end
)
end
test
"does not retry jobs for an unauthorized object"
do
assert
{
:cancel
,
_
}
=
perform_job
(
RemoteFetcherWorker
,
%{
"op"
=>
"fetch_remote"
,
"id"
=>
@unauthorized_object
})
end
test
"does not retry jobs for an an object that exceeded depth"
do
clear_config
([
:instance
,
:federation_incoming_replies_max_depth
],
0
)
assert
{
:cancel
,
_
}
=
perform_job
(
RemoteFetcherWorker
,
%{
"op"
=>
"fetch_remote"
,
"id"
=>
@depth_object
,
"depth"
=>
1
})
end
test
"does not retry jobs for when object returns wrong content type"
do
assert
{
:cancel
,
_
}
=
perform_job
(
RemoteFetcherWorker
,
%{
"op"
=>
"fetch_remote"
,
"id"
=>
@content_type_object
})
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 12:24 PM (1 d, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
972353
Default Alt Text
remote_fetcher_worker_test.exs (2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment