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
ec34de0c
Commit
ec34de0c
authored
6 years ago
by
Maksim
Browse files
Options
Downloads
Patches
Plain Diff
WebSub fix test
parent
3ce16e5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/test.exs
+0
-1
0 additions, 1 deletion
config/test.exs
lib/pleroma/http/connection.ex
+2
-1
2 additions, 1 deletion
lib/pleroma/http/connection.ex
test/web/websub/websub_test.exs
+20
-11
20 additions, 11 deletions
test/web/websub/websub_test.exs
with
22 additions
and
13 deletions
config/test.exs
+
0
−
1
View file @
ec34de0c
...
...
@@ -25,7 +25,6 @@ config :pbkdf2_elixir, rounds: 1
config
:pleroma
,
:websub
,
Pleroma
.
Web
.
WebsubMock
config
:pleroma
,
:ostatus
,
Pleroma
.
Web
.
OStatusMock
config
:pleroma
,
:httpoison
,
HTTPoisonMock
config
:tesla
,
adapter:
Tesla
.
Mock
try
do
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/http/connection.ex
+
2
−
1
View file @
ec34de0c
defmodule
Pleroma
.
HTTP
.
Connection
do
@hackney_options
[
pool:
:default
]
@adapter
Application
.
get_env
(
:tesla
,
:adapter
)
@doc
"""
Configure a client connection
...
...
@@ -10,7 +11,7 @@ defmodule Pleroma.HTTP.Connection do
"""
@spec
new
(
Keyword
.
t
())
::
Tesla
.
Env
.
client
()
def
new
(
opts
\\
[])
do
Tesla
.
client
([],
{
Tesla
.
Adapter
.
Hackney
,
hackney_options
(
opts
)})
Tesla
.
client
([],
{
@adapter
,
hackney_options
(
opts
)})
end
# fetch Hackney options
...
...
This diff is collapsed.
Click to expand it.
test/web/websub/websub_test.exs
+
20
−
11
View file @
ec34de0c
...
...
@@ -10,6 +10,18 @@ defmodule Pleroma.Web.WebsubTest do
alias
Pleroma
.
Web
.
Websub
.
{
WebsubServerSubscription
,
WebsubClientSubscription
}
import
Pleroma
.
Factory
alias
Pleroma
.
Web
.
Router
.
Helpers
import
Tesla
.
Mock
setup
do
mock
fn
%{
method:
:get
,
url:
"https://mastodon.social/users/lambadalambda.atom"
}
->
%
Tesla
.
Env
{
status:
200
,
body:
File
.
read!
(
"test/fixtures/lambadalambda.atom"
)}
%{
method:
:post
,
url:
"http://example.org/needs_refresh"
}
->
%
Tesla
.
Env
{
status:
200
,
body:
""
}
end
:ok
end
test
"a verification of a request that is accepted"
do
sub
=
insert
(
:websub_subscription
)
...
...
@@ -26,8 +38,8 @@ defmodule Pleroma.Web.WebsubTest do
assert
String
.
to_integer
(
seconds
)
>
0
{
:ok
,
%
HTTPoison
.
Response
{
status
_code
:
200
,
%
Tesla
.
Env
{
status:
200
,
body:
challenge
}}
end
...
...
@@ -41,8 +53,8 @@ defmodule Pleroma.Web.WebsubTest do
getter
=
fn
_path
,
_headers
,
_options
->
{
:ok
,
%
HTTPoison
.
Response
{
status
_code
:
500
,
%
Tesla
.
Env
{
status:
500
,
body:
""
}}
end
...
...
@@ -113,12 +125,7 @@ defmodule Pleroma.Web.WebsubTest do
test
"discovers the hub and canonical url"
do
topic
=
"https://mastodon.social/users/lambadalambda.atom"
getter
=
fn
^
topic
->
doc
=
File
.
read!
(
"test/fixtures/lambadalambda.atom"
)
{
:ok
,
%{
status_code:
200
,
body:
doc
}}
end
{
:ok
,
discovered
}
=
Websub
.
gather_feed_data
(
topic
,
getter
)
{
:ok
,
discovered
}
=
Websub
.
gather_feed_data
(
topic
)
expected
=
%{
"hub"
=>
"https://mastodon.social/api/push"
,
...
...
@@ -158,7 +165,7 @@ defmodule Pleroma.Web.WebsubTest do
websub
.
id
)
{
:ok
,
%{
status
_code
:
202
}}
{
:ok
,
%{
status:
202
}}
end
task
=
Task
.
async
(
fn
->
Websub
.
request_subscription
(
websub
,
poster
)
end
)
...
...
@@ -209,6 +216,7 @@ defmodule Pleroma.Web.WebsubTest do
insert
(
:websub_client_subscription
,
%{
valid_until:
NaiveDateTime
.
add
(
now
,
2
*
day
),
topic:
"http://example.org/still_good"
,
hub:
"http://example.org/still_good"
,
state:
"accepted"
})
...
...
@@ -216,6 +224,7 @@ defmodule Pleroma.Web.WebsubTest do
insert
(
:websub_client_subscription
,
%{
valid_until:
NaiveDateTime
.
add
(
now
,
day
-
100
),
topic:
"http://example.org/needs_refresh"
,
hub:
"http://example.org/needs_refresh"
,
state:
"accepted"
})
...
...
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