Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix Ruby SDK
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Olofsson
Matrix Ruby SDK
Commits
6a2c2bc6
Verified
Commit
6a2c2bc6
authored
4 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
api: More fixes for discovery
parent
968b56e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
lib/matrix_sdk/api.rb
+8
-8
8 additions, 8 deletions
lib/matrix_sdk/api.rb
test/api_creation_test.rb
+21
-4
21 additions, 4 deletions
test/api_creation_test.rb
test/client_test.rb
+4
-1
4 additions, 1 deletion
test/client_test.rb
with
35 additions
and
13 deletions
CHANGELOG.md
+
2
−
0
View file @
6a2c2bc6
## 2.1.2 - **Unreleased**
-
Adds method for reading complete member lists for rooms, improves the CS spec adherence
-
Adds test for state events
-
Fixes state event handler for rooms not actually passing events
-
Fixes Api#new_for_domain using a faulty URI in certain cases
## 2.1.1 - 2020-08-21
...
...
This diff is collapsed.
Click to expand it.
lib/matrix_sdk/api.rb
+
8
−
8
View file @
6a2c2bc6
...
...
@@ -115,10 +115,10 @@ module MatrixSdk
if
target_uri
.
nil?
# Attempt .well-known discovery for server-to-server
well_known
=
begin
uri
=
URI
(
"https://
#{
domain
}
/.well-known/matrix/server"
)
logger
.
debug
"Trying
#{
uri
}
..."
data
=
Net
::
HTTP
.
start
(
uri
.
host
,
uri
.
port
,
use_ssl:
true
,
open_timeout:
5
,
read_timeout:
5
,
write_timeout:
5
)
do
|
http
|
http
.
get
(
uri
.
path
).
body
wk_
uri
=
URI
(
"https://
#{
domain
}
/.well-known/matrix/server"
)
logger
.
debug
"Trying
#{
wk_
uri
}
..."
data
=
Net
::
HTTP
.
start
(
wk_
uri
.
host
,
wk_
uri
.
port
,
use_ssl:
true
,
open_timeout:
5
,
read_timeout:
5
,
write_timeout:
5
)
do
|
http
|
http
.
get
(
wk_
uri
.
path
).
body
end
JSON
.
parse
(
data
)
rescue
StandardError
=>
e
...
...
@@ -133,10 +133,10 @@ module MatrixSdk
elsif
%i[client identity]
.
include?
target
# Attempt .well-known discovery
well_known
=
begin
uri
=
URI
(
"https://
#{
domain
}
/.well-known/matrix/client"
)
logger
.
debug
"Trying
#{
uri
}
..."
data
=
Net
::
HTTP
.
start
(
uri
.
host
,
uri
.
port
,
use_ssl:
true
,
open_timeout:
5
,
read_timeout:
5
,
write_timeout:
5
)
do
|
http
|
http
.
get
(
uri
.
path
).
body
wk_
uri
=
URI
(
"https://
#{
domain
}
/.well-known/matrix/client"
)
logger
.
debug
"Trying
#{
wk_
uri
}
..."
data
=
Net
::
HTTP
.
start
(
wk_
uri
.
host
,
wk_
uri
.
port
,
use_ssl:
true
,
open_timeout:
5
,
read_timeout:
5
,
write_timeout:
5
)
do
|
http
|
http
.
get
(
wk_
uri
.
path
).
body
end
data
=
JSON
.
parse
(
data
)
rescue
StandardError
=>
e
...
...
This diff is collapsed.
Click to expand it.
test/api_creation_test.rb
+
21
−
4
View file @
6a2c2bc6
...
...
@@ -66,9 +66,10 @@ class ApiTest < Test::Unit::TestCase
.
never
::
Net
::
HTTP
.
any_instance
.
expects
(
:get
)
.
with
(
'
https://example.com
/.well-known/matrix/client'
)
.
returns
(
'{"m.homeserver":{"base_url":"https://matrix.example.com"}}'
)
.
with
(
'/.well-known/matrix/client'
)
.
returns
(
OpenStruct
.
new
(
body:
'{"m.homeserver":{"base_url":"https://matrix.example.com"}}'
)
)
MatrixSdk
::
Api
.
expects
(
:new
)
...
...
@@ -83,6 +84,11 @@ class ApiTest < Test::Unit::TestCase
.
expects
(
:getresource
)
.
returns
(
Resolv
::
DNS
::
Resource
::
IN
::
SRV
.
new
(
10
,
1
,
443
,
'matrix.example.com'
))
::
Net
::
HTTP
.
any_instance
.
expects
(
:get
)
.
never
MatrixSdk
::
Api
.
expects
(
:new
)
.
with
(
URI
(
'https://example.com'
),
address:
'matrix.example.com'
,
port:
443
)
...
...
@@ -96,6 +102,13 @@ class ApiTest < Test::Unit::TestCase
.
expects
(
:getresource
)
.
raises
(
::
Resolv
::
ResolvError
)
::
Net
::
HTTP
.
any_instance
.
expects
(
:get
)
.
with
(
'/.well-known/matrix/server'
)
.
once
.
raises
(
StandardError
)
MatrixSdk
::
Api
.
expects
(
:new
)
.
with
(
URI
(
'https://example.com'
),
address:
'example.com'
,
port:
8448
)
...
...
@@ -118,12 +131,16 @@ class ApiTest < Test::Unit::TestCase
.
raises
(
::
Resolv
::
ResolvError
)
::
Net
::
HTTP
.
any_instance
.
expects
(
:get
)
.
with
(
'https://example.com/.well-known/matrix/server'
)
.
with
(
'/.well-known/matrix/server'
)
.
once
.
raises
(
StandardError
)
::
Net
::
HTTP
.
any_instance
.
expects
(
:get
)
.
with
(
'https://example.com/.well-known/matrix/client'
)
.
with
(
'/.well-known/matrix/client'
)
.
once
.
raises
(
StandardError
)
api
=
MatrixSdk
::
Api
.
new_for_domain
(
'example.com'
,
target: :server
)
...
...
This diff is collapsed.
Click to expand it.
test/client_test.rb
+
4
−
1
View file @
6a2c2bc6
...
...
@@ -61,13 +61,16 @@ class ClientTest < Test::Unit::TestCase
def
test_events
cl
=
MatrixSdk
::
Client
.
new
'https://example.com'
room
=
cl
.
ensure_room
'!726s6s6q:example.com'
cl
.
instance_variable_get
(
:@on_presence_event
).
expects
(
:fire
).
once
cl
.
instance_variable_get
(
:@on_invite_event
).
expects
(
:fire
).
once
cl
.
instance_variable_get
(
:@on_leave_event
).
expects
(
:fire
).
once
cl
.
instance_variable_get
(
:@on_event
).
expects
(
:fire
).
twice
cl
.
instance_variable_get
(
:@on_ephemeral_event
).
expects
(
:fire
).
once
room
.
instance_variable_get
(
:@on_state_event
).
expects
(
:fire
).
twice
room
.
instance_variable_get
(
:@on_event
).
expects
(
:fire
).
twice
room
.
instance_variable_get
(
:@on_ephemeral_event
).
expects
(
:fire
).
once
response
=
JSON
.
parse
(
open
(
'test/fixtures/sync_response.json'
).
read
,
symbolize_names:
true
)
...
...
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