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
195ff2aa
Commit
195ff2aa
authored
Mar 05, 2020
by
Aleksei Lipniagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add controller specs
parent
fe682ae6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
spec/controllers/import/gitlab_projects_controller_spec.rb
spec/controllers/import/gitlab_projects_controller_spec.rb
+58
-0
No files found.
spec/controllers/import/gitlab_projects_controller_spec.rb
View file @
195ff2aa
...
...
@@ -39,4 +39,62 @@ describe Import::GitlabProjectsController do
it_behaves_like
'project import rate limiter'
end
describe
'POST authorize'
do
let
(
:workhorse_token
)
{
JWT
.
encode
({
'iss'
=>
'gitlab-workhorse'
},
Gitlab
::
Workhorse
.
secret
,
'HS256'
)
}
before
do
request
.
headers
[
'GitLab-Workhorse'
]
=
'1.0'
request
.
headers
[
Gitlab
::
Workhorse
::
INTERNAL_API_REQUEST_HEADER
]
=
workhorse_token
end
it
'authorizes importing project with workhorse header'
do
post
:authorize
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
content_type
.
to_s
).
to
eq
(
Gitlab
::
Workhorse
::
INTERNAL_API_CONTENT_TYPE
)
end
it
'rejects requests that bypassed gitlab-workhorse or have invalid header'
do
request
.
headers
[
Gitlab
::
Workhorse
::
INTERNAL_API_REQUEST_HEADER
]
=
'INVALID_HEADER'
expect
{
post
:authorize
,
format: :json
}.
to
raise_error
(
JWT
::
DecodeError
)
end
context
'when using remote storage'
do
context
'when direct upload is enabled'
do
before
do
stub_uploads_object_storage
(
ImportExportUploader
,
enabled:
true
,
direct_upload:
true
)
end
it
'responds with status 200, location of file remote store and object details'
do
post
:authorize
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
content_type
.
to_s
).
to
eq
(
Gitlab
::
Workhorse
::
INTERNAL_API_CONTENT_TYPE
)
expect
(
json_response
).
not_to
have_key
(
'TempPath'
)
expect
(
json_response
[
'RemoteObject'
]).
to
have_key
(
'ID'
)
expect
(
json_response
[
'RemoteObject'
]).
to
have_key
(
'GetURL'
)
expect
(
json_response
[
'RemoteObject'
]).
to
have_key
(
'StoreURL'
)
expect
(
json_response
[
'RemoteObject'
]).
to
have_key
(
'DeleteURL'
)
expect
(
json_response
[
'RemoteObject'
]).
to
have_key
(
'MultipartUpload'
)
end
end
context
'when direct upload is disabled'
do
before
do
stub_uploads_object_storage
(
ImportExportUploader
,
enabled:
true
,
direct_upload:
false
)
end
it
'handles as a local file'
do
post
:authorize
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
content_type
.
to_s
).
to
eq
(
Gitlab
::
Workhorse
::
INTERNAL_API_CONTENT_TYPE
)
expect
(
json_response
[
'TempPath'
]).
to
eq
(
ImportExportUploader
.
workhorse_local_upload_path
)
expect
(
json_response
[
'RemoteObject'
]).
to
be_nil
end
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