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
c5338da3
Verified
Commit
c5338da3
authored
6 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
api: Fix tests and finish discovery code
parent
78c32900
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#2557
passed
6 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/matrix_sdk/api.rb
+2
-2
2 additions, 2 deletions
lib/matrix_sdk/api.rb
test/api_creation_test.rb
+11
-9
11 additions, 9 deletions
test/api_creation_test.rb
with
13 additions
and
11 deletions
lib/matrix_sdk/api.rb
+
2
−
2
View file @
c5338da3
...
@@ -74,7 +74,7 @@ module MatrixSdk
...
@@ -74,7 +74,7 @@ module MatrixSdk
uri
=
URI
(
"http
#{
ssl
?
's'
:
''
}
://
#{
domain
}
"
)
uri
=
URI
(
"http
#{
ssl
?
's'
:
''
}
://
#{
domain
}
"
)
target_uri
=
nil
target_uri
=
nil
if
!
port
.
empty?
if
!
port
.
nil?
&&
!
port
.
empty?
target_uri
=
URI
(
"https://
#{
domain
}
:
#{
port
}
"
)
target_uri
=
URI
(
"https://
#{
domain
}
:
#{
port
}
"
)
elsif
target
==
:server
elsif
target
==
:server
# Attempt SRV record discovery
# Attempt SRV record discovery
...
@@ -96,7 +96,7 @@ module MatrixSdk
...
@@ -96,7 +96,7 @@ module MatrixSdk
target_uri
=
well_known
[
'm.server'
]
if
well_known
&&
well_known
.
key?
(
'm.server'
)
target_uri
=
well_known
[
'm.server'
]
if
well_known
&&
well_known
.
key?
(
'm.server'
)
else
else
target_uri
=
URI
(
"https://
#{
target_uri
.
target
}
:
#{
target
.
port
}
"
)
target_uri
=
URI
(
"https://
#{
target_uri
.
target
}
:
#{
target
_uri
.
port
}
"
)
end
end
elsif
%i[client identity]
.
include?
target_uri
elsif
%i[client identity]
.
include?
target_uri
# Attempt .well-known discovery
# Attempt .well-known discovery
...
...
This diff is collapsed.
Click to expand it.
test/api_creation_test.rb
+
11
−
9
View file @
c5338da3
...
@@ -21,35 +21,37 @@ class ApiTest < Test::Unit::TestCase
...
@@ -21,35 +21,37 @@ class ApiTest < Test::Unit::TestCase
assert_equal
URI
(
'https://matrix.example.com'
),
api
.
homeserver
assert_equal
URI
(
'https://matrix.example.com'
),
api
.
homeserver
end
end
def
test_creation_for_domain
def
test_
server_
creation_for_domain
::
Resolv
::
DNS
::
Resolv
::
DNS
.
any_instance
.
any_instance
.
expects
(
:getresource
)
.
expects
(
:getresource
)
.
returns
(
Resolv
::
DNS
::
Resource
::
IN
::
SRV
.
new
(
10
,
1
,
443
,
'matrix.example.com'
))
.
returns
(
Resolv
::
DNS
::
Resource
::
IN
::
SRV
.
new
(
10
,
1
,
443
,
'matrix.example.com'
))
MatrixSdk
::
Api
MatrixSdk
::
Api
.
expects
(
:new
)
.
expects
(
:new
)
.
with
(
'https://example.com'
,
address:
'matrix.example.com'
,
port:
443
)
.
with
(
URI
(
'https://example.com'
)
,
address:
'matrix.example.com'
,
port:
443
)
MatrixSdk
::
Api
.
new_for_domain
'example.com'
MatrixSdk
::
Api
.
new_for_domain
'example.com'
,
target: :server
end
end
def
test_creation_for_missing_domain
def
test_
server_
creation_for_missing_domain
::
Resolv
::
DNS
::
Resolv
::
DNS
.
any_instance
.
any_instance
.
expects
(
:getresource
)
.
expects
(
:getresource
)
.
raises
(
::
Resolv
::
ResolvError
)
.
raises
(
::
Resolv
::
ResolvError
)
MatrixSdk
::
Api
MatrixSdk
::
Api
.
expects
(
:new
)
.
expects
(
:new
)
.
with
(
'https://example.com'
,
address:
'example.com'
,
port:
8448
)
.
with
(
URI
(
'https://example.com'
)
,
address:
'example.com'
,
port:
8448
)
MatrixSdk
::
Api
.
new_for_domain
'example.com'
MatrixSdk
::
Api
.
new_for_domain
'example.com'
,
target: :server
end
end
def
test_creation_for_domain_and_port
def
test_
server_
creation_for_domain_and_port
MatrixSdk
::
Api
MatrixSdk
::
Api
.
expects
(
:new
)
.
expects
(
:new
)
.
with
(
'https://example.com'
,
address:
'example.com'
,
port:
8448
)
.
with
(
URI
(
'https://example.com'
)
,
address:
'example.com'
,
port:
8448
)
MatrixSdk
::
Api
.
new_for_domain
'example.com:8448'
MatrixSdk
::
Api
.
new_for_domain
'example.com:8448'
,
target: :server
end
end
end
end
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