Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
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-shell
Commits
1ff35618
Commit
1ff35618
authored
Aug 20, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitlabAccessStatus needs HTTP response status code
parent
ca93c218
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
13 deletions
+20
-13
lib/gitlab_access_status.rb
lib/gitlab_access_status.rb
+4
-2
spec/gitlab_access_spec.rb
spec/gitlab_access_spec.rb
+2
-0
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+14
-11
No files found.
lib/gitlab_access_status.rb
View file @
1ff35618
...
...
@@ -3,8 +3,9 @@ require 'json'
class
GitAccessStatus
attr_reader
:message
,
:gl_repository
,
:gl_id
,
:gl_username
,
:gitaly
,
:git_protocol
,
:git_config_options
def
initialize
(
status
,
message
,
gl_repository:
nil
,
gl_id:
nil
,
gl_username:
nil
,
gitaly:
nil
,
git_protocol:
nil
,
git_config_options:
nil
)
def
initialize
(
status
,
status_code
,
message
,
gl_repository:
nil
,
gl_id:
nil
,
gl_username:
nil
,
gitaly:
nil
,
git_protocol:
nil
,
git_config_options:
nil
)
@status
=
status
@status_code
=
status_code
@message
=
message
@gl_repository
=
gl_repository
@gl_id
=
gl_id
...
...
@@ -14,9 +15,10 @@ class GitAccessStatus
@git_protocol
=
git_protocol
end
def
self
.
create_from_json
(
json
)
def
self
.
create_from_json
(
json
,
status_code
)
values
=
JSON
.
parse
(
json
)
new
(
values
[
"status"
],
status_code
,
values
[
"message"
],
gl_repository:
values
[
"gl_repository"
],
gl_id:
values
[
"gl_id"
],
...
...
spec/gitlab_access_spec.rb
View file @
1ff35618
...
...
@@ -8,6 +8,7 @@ describe GitlabAccess do
let
(
:api
)
do
double
(
GitlabNet
).
tap
do
|
api
|
allow
(
api
).
to
receive
(
:check_access
).
and_return
(
GitAccessStatus
.
new
(
true
,
HTTPCodes
::
HTTP_SUCCESS
,
'ok'
,
gl_repository:
'project-1'
,
gl_id:
'user-123'
,
...
...
@@ -45,6 +46,7 @@ describe GitlabAccess do
before
do
allow
(
api
).
to
receive
(
:check_access
).
and_return
(
GitAccessStatus
.
new
(
false
,
HTTPCodes
::
HTTP_UNAUTHORIZED
,
'denied'
,
gl_repository:
nil
,
gl_id:
nil
,
...
...
spec/gitlab_shell_spec.rb
View file @
1ff35618
...
...
@@ -22,23 +22,26 @@ describe GitlabShell do
let
(
:git_config_options
)
{
[
'receive.MaxInputSize=10000'
]
}
let
(
:gitaly_check_access
)
{
GitAccessStatus
.
new
(
true
,
'ok'
,
gl_repository:
gl_repository
,
gl_id:
gl_id
,
gl_username:
gl_username
,
git_config_options:
git_config_options
,
gitaly:
{
'repository'
=>
{
'relative_path'
=>
repo_name
,
'storage_name'
=>
'default'
}
,
'address'
=>
'unix:gitaly.socket'
},
git_protocol:
git_protocol
)
}
let
(
:gitaly_check_access
)
do
GitAccessStatus
.
new
(
true
,
HTTPCodes
::
HTTP_SUCCESS
,
'ok'
,
gl_repository:
gl_repository
,
gl_id:
gl_id
,
gl_username:
gl_username
,
git_config_options:
git_config_options
,
gitaly:
{
'repository'
=>
{
'relative_path'
=>
repo_name
,
'storage_name'
=>
'default'
}
,
'address'
=>
'unix:gitaly.socket'
},
git_protocol:
git_protocol
)
end
let
(
:api
)
do
double
(
GitlabNet
).
tap
do
|
api
|
allow
(
api
).
to
receive
(
:discover
).
and_return
({
'name'
=>
'John Doe'
,
'username'
=>
'testuser'
})
allow
(
api
).
to
receive
(
:check_access
).
and_return
(
GitAccessStatus
.
new
(
true
,
HTTPCodes
::
HTTP_SUCCESS
,
'ok'
,
gl_repository:
gl_repository
,
gl_id:
gl_id
,
...
...
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