Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21968801
timeline_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
timeline_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.Preload.Providers.TimelineTest
do
use
Pleroma.DataCase
import
Pleroma.Factory
alias
Pleroma.Web.CommonAPI
alias
Pleroma.Web.Preload.Providers.Timelines
@public_url
"/api/v1/timelines/public"
describe
"unauthenticated timeliness when restricted"
do
setup
do
:
clear_config
([
:restrict_unauthenticated
,
:timelines
,
:local
],
true
)
setup
do
:
clear_config
([
:restrict_unauthenticated
,
:timelines
,
:federated
],
true
)
test
"return nothing"
do
tl_data
=
Timelines
.
generate_terms
(%{})
refute
Map
.
has_key?
(
tl_data
,
"/api/v1/timelines/public"
)
end
end
describe
"unauthenticated timeliness when unrestricted"
do
setup
do
:
clear_config
([
:restrict_unauthenticated
,
:timelines
,
:local
],
false
)
setup
do
:
clear_config
([
:restrict_unauthenticated
,
:timelines
,
:federated
],
false
)
setup
do
:
{
:ok
,
user
:
insert
(
:user
)}
test
"returns the timeline when not restricted"
do
assert
Timelines
.
generate_terms
(%{})
|>
Map
.
has_key?
(
@public_url
)
end
test
"returns public items"
,
%{
user
:
user
}
do
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 1!"
})
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 2!"
})
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 3!"
})
assert
Timelines
.
generate_terms
(%{})
|>
Map
.
fetch!
(
@public_url
)
|>
Enum
.
count
()
==
3
end
test
"does not return non-public items"
,
%{
user
:
user
}
do
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 1!"
,
visibility
:
"unlisted"
})
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 2!"
,
visibility
:
"direct"
})
{
:ok
,
_
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's post 3!"
})
assert
Timelines
.
generate_terms
(%{})
|>
Map
.
fetch!
(
@public_url
)
|>
Enum
.
count
()
==
1
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 28, 3:25 AM (2 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
816200
Default Alt Text
timeline_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment