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
a64f174d
Commit
a64f174d
authored
Aug 29, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored JSON header generation to its own class and added tests for it
parent
dbf374e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
10 deletions
+45
-10
lib/gitlab_lfs_authentication.rb
lib/gitlab_lfs_authentication.rb
+22
-0
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+2
-10
spec/gitlab_lfs_authentication_spec.rb
spec/gitlab_lfs_authentication_spec.rb
+21
-0
No files found.
lib/gitlab_lfs_authentication.rb
0 → 100644
View file @
a64f174d
require
'base64'
require
'json'
class
GitlabLfsAuthentication
attr_accessor
:user
,
:repository_http_path
def
initialize
(
user
,
repository_http_path
)
@user
=
user
@repository_http_path
=
repository_http_path
end
def
authenticate!
authorization
=
{
header:
{
Authorization
:
"Basic
#{
Base64
.
strict_encode64
(
"
#{
user
[
'username'
]
}
:
#{
user
[
'lfs_token'
]
}
"
)
}
"
},
href:
"
#{
repository_http_path
}
/info/lfs/"
}
JSON
.
generate
(
authorization
)
end
end
lib/gitlab_shell.rb
View file @
a64f174d
require
'shellwords'
require
'shellwords'
require
'base64'
require
'json'
require_relative
'gitlab_net'
require_relative
'gitlab_net'
require_relative
'gitlab_lfs_authentication'
class
GitlabShell
class
GitlabShell
class
AccessDeniedError
<
StandardError
;
end
class
AccessDeniedError
<
StandardError
;
end
...
@@ -195,14 +194,7 @@ class GitlabShell
...
@@ -195,14 +194,7 @@ class GitlabShell
def
lfs_authenticate
def
lfs_authenticate
return
unless
user
return
unless
user
authorization
=
{
puts
GitlabLfsAuthentication
.
new
(
user
,
repository_http_path
).
authenticate!
header:
{
Authorization
:
"Basic
#{
Base64
.
strict_encode64
(
"
#{
user
[
'username'
]
}
:
#{
user
[
'lfs_token'
]
}
"
)
}
"
},
href:
"
#{
repository_http_path
}
/info/lfs/"
}
puts
JSON
.
generate
(
authorization
)
end
end
private
private
...
...
spec/gitlab_lfs_authentication_spec.rb
0 → 100644
View file @
a64f174d
require
'spec_helper'
require
'gitlab_lfs_authentication'
describe
GitlabLfsAuthentication
do
let
(
:user
)
{
{
'username'
=>
'dzaporozhets'
,
'lfs_token'
=>
'wsnys8Zm8Jn7zyhHTAAK'
}
}
subject
do
GitlabLfsAuthentication
.
new
(
user
,
'http://gitlab.dev/repo'
)
end
describe
'#initialize'
do
it
{
subject
.
user
.
should
==
user
}
it
{
subject
.
repository_http_path
.
should
==
'http://gitlab.dev/repo'
}
end
describe
'#authenticate!'
do
result
=
"{
\"
header
\"
:{
\"
Authorization
\"
:
\"
Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL
\"
},
\"
href
\"
:
\"
http://gitlab.dev/repo/info/lfs/
\"
}"
it
{
subject
.
authenticate!
.
should
==
result
}
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