Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pierre Boudes
mastodon
Commits
defe4f9b
Commit
defe4f9b
authored
7 years ago
by
Akihiko Odaki (@fn_aki@pawoo.net)
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Cover WebfingerResource more (#3560)
parent
943775fd
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
spec/lib/webfinger_resource_spec.rb
+37
-4
37 additions, 4 deletions
spec/lib/webfinger_resource_spec.rb
with
37 additions
and
4 deletions
spec/lib/webfinger_resource_spec.rb
+
37
−
4
View file @
defe4f9b
...
...
@@ -2,14 +2,16 @@ require 'rails_helper'
describe
WebfingerResource
do
around
do
|
example
|
before
=
Rails
.
configuration
.
x
.
local_domain
before_local
=
Rails
.
configuration
.
x
.
local_domain
before_web
=
Rails
.
configuration
.
x
.
web_domain
example
.
run
Rails
.
configuration
.
x
.
local_domain
=
before
Rails
.
configuration
.
x
.
local_domain
=
before_local
Rails
.
configuration
.
x
.
webdomain
=
before_web
end
describe
'#username'
do
describe
'with a URL value'
do
it
'raises with a
n unrecognized route
'
do
it
'raises with a
route whose controller is not AccountsController
'
do
resource
=
'https://example.com/users/alice/other'
expect
{
...
...
@@ -17,6 +19,21 @@ describe WebfingerResource do
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'raises with a route whose action is not show'
do
resource
=
'https://example.com/users/alice'
recognized
=
Rails
.
application
.
routes
.
recognize_path
(
resource
)
allow
(
recognized
).
to
receive
(
:[]
).
with
(
:controller
).
and_return
(
'accounts'
)
allow
(
recognized
).
to
receive
(
:[]
).
with
(
:username
).
and_return
(
'alice'
)
expect
(
recognized
).
to
receive
(
:[]
).
with
(
:action
).
and_return
(
'create'
)
expect
(
Rails
.
application
.
routes
).
to
receive
(
:recognize_path
).
with
(
resource
).
and_return
(
recognized
).
at_least
(
:once
)
expect
{
WebfingerResource
.
new
(
resource
).
username
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'raises with a string that doesnt start with URL'
do
resource
=
'website for http://example.com/users/alice/other'
...
...
@@ -63,6 +80,14 @@ describe WebfingerResource do
result
=
WebfingerResource
.
new
(
resource
).
username
expect
(
result
).
to
eq
'alice'
end
it
'finds username for a web domain'
do
Rails
.
configuration
.
x
.
web_domain
=
'example.com'
resource
=
'alice@example.com'
result
=
WebfingerResource
.
new
(
resource
).
username
expect
(
result
).
to
eq
'alice'
end
end
describe
'with an acct value'
do
...
...
@@ -82,13 +107,21 @@ describe WebfingerResource do
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'finds the username for a local account'
do
it
'finds the username for a local account
if the domain is the local one
'
do
Rails
.
configuration
.
x
.
local_domain
=
'example.com'
resource
=
'acct:alice@example.com'
result
=
WebfingerResource
.
new
(
resource
).
username
expect
(
result
).
to
eq
'alice'
end
it
'finds the username for a local account if the domain is the Web one'
do
Rails
.
configuration
.
x
.
web_domain
=
'example.com'
resource
=
'acct:alice@example.com'
result
=
WebfingerResource
.
new
(
resource
).
username
expect
(
result
).
to
eq
'alice'
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