Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2ea35022
Commit
2ea35022
authored
Feb 03, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix opensearch for anonymous users
parent
92a06b97
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
208 additions
and
199 deletions
+208
-199
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-1
changelogs/unreleased/fix-opensearch.yml
changelogs/unreleased/fix-opensearch.yml
+5
-0
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+202
-198
No files found.
app/controllers/search_controller.rb
View file @
2ea35022
...
...
@@ -9,7 +9,7 @@ class SearchController < ApplicationController
around_action
:allow_gitaly_ref_name_caching
before_action
:block_anonymous_global_searches
before_action
:block_anonymous_global_searches
,
except: :opensearch
skip_before_action
:authenticate_user!
requires_cross_project_access
if:
->
do
search_term_present
=
params
[
:search
].
present?
||
params
[
:term
].
present?
...
...
changelogs/unreleased/fix-opensearch.yml
0 → 100644
View file @
2ea35022
---
title
:
Fix opensearch for anonymous users
merge_request
:
53056
author
:
type
:
fixed
spec/controllers/search_controller_spec.rb
View file @
2ea35022
...
...
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec
.
describe
SearchController
do
include
ExternalAuthorizationServiceHelpers
context
'authorized user'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
@@ -258,20 +259,6 @@ RSpec.describe SearchController do
it_behaves_like
'with external authorization service enabled'
,
:autocomplete
,
{
term:
'hello'
}
end
describe
'GET #opensearch'
do
render_views
it
'renders xml'
do
get
:opensearch
,
format: :xml
doc
=
Nokogiri
::
XML
.
parse
(
response
.
body
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
doc
.
css
(
'OpenSearchDescription ShortName'
).
text
).
to
eq
(
'GitLab'
)
expect
(
doc
.
css
(
'OpenSearchDescription *'
).
map
(
&
:name
)).
to
eq
(
%w[ShortName Description InputEncoding Image Url SearchForm]
)
end
end
describe
'#append_info_to_payload'
do
it
'appends search metadata for logging'
do
last_payload
=
nil
...
...
@@ -293,4 +280,21 @@ RSpec.describe SearchController do
expect
(
last_payload
[
:metadata
][
'meta.search.filters.state'
]).
to
eq
(
'true'
)
end
end
end
context
'unauthorized user'
do
describe
'GET #opensearch'
do
render_views
it
'renders xml'
do
get
:opensearch
,
format: :xml
doc
=
Nokogiri
::
XML
.
parse
(
response
.
body
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
doc
.
css
(
'OpenSearchDescription ShortName'
).
text
).
to
eq
(
'GitLab'
)
expect
(
doc
.
css
(
'OpenSearchDescription *'
).
map
(
&
:name
)).
to
eq
(
%w[ShortName Description InputEncoding Image Url SearchForm]
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment