Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
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
Maunium
synapse
Commits
852816be
Commit
852816be
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix presence tests
parent
e25e0f4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/handlers/test_presence.py
+28
-15
28 additions, 15 deletions
tests/handlers/test_presence.py
with
28 additions
and
15 deletions
tests/handlers/test_presence.py
+
28
−
15
View file @
852816be
...
@@ -389,14 +389,18 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -389,14 +389,18 @@ class PresenceInvitesTestCase(PresenceTestCase):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
test_invite_remote
(
self
):
def
test_invite_remote
(
self
):
# Use a different destination, otherwise retry logic might fail the
# request
u_rocket
=
UserID
.
from_string
(
"
@rocket:there
"
)
put_json
=
self
.
mock_http_client
.
put_json
put_json
=
self
.
mock_http_client
.
put_json
put_json
.
expect_call_and_return
(
put_json
.
expect_call_and_return
(
call
(
"
elsew
here
"
,
call
(
"
t
here
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
data
=
_expect_edu
(
"
elsew
here
"
,
"
m.presence_invite
"
,
data
=
_expect_edu
(
"
t
here
"
,
"
m.presence_invite
"
,
content
=
{
content
=
{
"
observer_user
"
:
"
@apple:test
"
,
"
observer_user
"
:
"
@apple:test
"
,
"
observed_user
"
:
"
@
cabbage:elsew
here
"
,
"
observed_user
"
:
"
@
rocket:t
here
"
,
}
}
),
),
json_data_callback
=
ANY
,
json_data_callback
=
ANY
,
...
@@ -405,10 +409,10 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -405,10 +409,10 @@ class PresenceInvitesTestCase(PresenceTestCase):
)
)
yield
self
.
handler
.
send_invite
(
yield
self
.
handler
.
send_invite
(
observer_user
=
self
.
u_apple
,
observed_user
=
self
.
u_cabbage
)
observer_user
=
self
.
u_apple
,
observed_user
=
u_rocket
)
self
.
assertEquals
(
self
.
assertEquals
(
[{
"
observed_user_id
"
:
"
@
cabbage:elsew
here
"
,
"
accepted
"
:
0
}],
[{
"
observed_user_id
"
:
"
@
rocket:t
here
"
,
"
accepted
"
:
0
}],
(
yield
self
.
datastore
.
get_presence_list
(
self
.
u_apple
.
localpart
))
(
yield
self
.
datastore
.
get_presence_list
(
self
.
u_apple
.
localpart
))
)
)
...
@@ -418,13 +422,18 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -418,13 +422,18 @@ class PresenceInvitesTestCase(PresenceTestCase):
def
test_accept_remote
(
self
):
def
test_accept_remote
(
self
):
# TODO(paul): This test will likely break if/when real auth permissions
# TODO(paul): This test will likely break if/when real auth permissions
# are added; for now the HS will always accept any invite
# are added; for now the HS will always accept any invite
# Use a different destination, otherwise retry logic might fail the
# request
u_rocket
=
UserID
.
from_string
(
"
@rocket:moon
"
)
put_json
=
self
.
mock_http_client
.
put_json
put_json
=
self
.
mock_http_client
.
put_json
put_json
.
expect_call_and_return
(
put_json
.
expect_call_and_return
(
call
(
"
elsewhere
"
,
call
(
"
moon
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
data
=
_expect_edu
(
"
elsewhere
"
,
"
m.presence_accept
"
,
data
=
_expect_edu
(
"
moon
"
,
"
m.presence_accept
"
,
content
=
{
content
=
{
"
observer_user
"
:
"
@
cabbage:elsewhere
"
,
"
observer_user
"
:
"
@
rocket:moon
"
,
"
observed_user
"
:
"
@apple:test
"
,
"
observed_user
"
:
"
@apple:test
"
,
}
}
),
),
...
@@ -437,7 +446,7 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -437,7 +446,7 @@ class PresenceInvitesTestCase(PresenceTestCase):
"
/_matrix/federation/v1/send/1000000/
"
,
"
/_matrix/federation/v1/send/1000000/
"
,
_make_edu_json
(
"
elsewhere
"
,
"
m.presence_invite
"
,
_make_edu_json
(
"
elsewhere
"
,
"
m.presence_invite
"
,
content
=
{
content
=
{
"
observer_user
"
:
"
@
cabbage:elsewhere
"
,
"
observer_user
"
:
"
@
rocket:moon
"
,
"
observed_user
"
:
"
@apple:test
"
,
"
observed_user
"
:
"
@apple:test
"
,
}
}
)
)
...
@@ -446,7 +455,7 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -446,7 +455,7 @@ class PresenceInvitesTestCase(PresenceTestCase):
self
.
assertTrue
(
self
.
assertTrue
(
(
yield
self
.
datastore
.
is_presence_visible
(
(
yield
self
.
datastore
.
is_presence_visible
(
observed_localpart
=
self
.
u_apple
.
localpart
,
observed_localpart
=
self
.
u_apple
.
localpart
,
observer_userid
=
self
.
u_cabbage
.
to_string
(),
observer_userid
=
u_rocket
.
to_string
(),
))
))
)
)
...
@@ -454,13 +463,17 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -454,13 +463,17 @@ class PresenceInvitesTestCase(PresenceTestCase):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
test_invited_remote_nonexistant
(
self
):
def
test_invited_remote_nonexistant
(
self
):
# Use a different destination, otherwise retry logic might fail the
# request
u_rocket
=
UserID
.
from_string
(
"
@rocket:sun
"
)
put_json
=
self
.
mock_http_client
.
put_json
put_json
=
self
.
mock_http_client
.
put_json
put_json
.
expect_call_and_return
(
put_json
.
expect_call_and_return
(
call
(
"
elsewhere
"
,
call
(
"
sun
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
path
=
"
/_matrix/federation/v1/send/1000000/
"
,
data
=
_expect_edu
(
"
elsewhere
"
,
"
m.presence_deny
"
,
data
=
_expect_edu
(
"
sun
"
,
"
m.presence_deny
"
,
content
=
{
content
=
{
"
observer_user
"
:
"
@
cabbage:elsewhere
"
,
"
observer_user
"
:
"
@
rocket:sun
"
,
"
observed_user
"
:
"
@durian:test
"
,
"
observed_user
"
:
"
@durian:test
"
,
}
}
),
),
...
@@ -471,9 +484,9 @@ class PresenceInvitesTestCase(PresenceTestCase):
...
@@ -471,9 +484,9 @@ class PresenceInvitesTestCase(PresenceTestCase):
yield
self
.
mock_federation_resource
.
trigger
(
"
PUT
"
,
yield
self
.
mock_federation_resource
.
trigger
(
"
PUT
"
,
"
/_matrix/federation/v1/send/1000000/
"
,
"
/_matrix/federation/v1/send/1000000/
"
,
_make_edu_json
(
"
elsewhere
"
,
"
m.presence_invite
"
,
_make_edu_json
(
"
sun
"
,
"
m.presence_invite
"
,
content
=
{
content
=
{
"
observer_user
"
:
"
@
cabbage:elsewhere
"
,
"
observer_user
"
:
"
@
rocket:sun
"
,
"
observed_user
"
:
"
@durian:test
"
,
"
observed_user
"
:
"
@durian:test
"
,
}
}
)
)
...
...
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