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
a070ae4a
Commit
a070ae4a
authored
Sep 06, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style fixes and better tests.
parent
f53d09e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
10 deletions
+25
-10
lib/gitlab_lfs_authentication.rb
lib/gitlab_lfs_authentication.rb
+2
-2
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+1
-1
spec/gitlab_lfs_authentication_spec.rb
spec/gitlab_lfs_authentication_spec.rb
+21
-6
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+1
-1
No files found.
lib/gitlab_lfs_authentication.rb
View file @
a070ae4a
...
...
@@ -11,11 +11,11 @@ class GitlabLfsAuthentication
end
def
self
.
build_from_json
(
json
)
values
=
JSON
.
parse
(
json
)
values
=
JSON
.
parse
(
json
)
rescue
nil
self
.
new
(
values
[
'username'
],
values
[
'lfs_token'
],
values
[
'repository_http_path'
])
end
def
authenticat
e!
def
authenticat
ion_payload
authorization
=
{
header:
{
Authorization
:
"Basic
#{
Base64
.
strict_encode64
(
"
#{
username
}
:
#{
lfs_token
}
"
)
}
"
...
...
lib/gitlab_shell.rb
View file @
a070ae4a
...
...
@@ -194,7 +194,7 @@ class GitlabShell
return
unless
lfs_access
puts
lfs_access
.
authenticat
e!
puts
lfs_access
.
authenticat
ion_payload
end
private
...
...
spec/gitlab_lfs_authentication_spec.rb
View file @
a070ae4a
require
'spec_helper'
require
'gitlab_lfs_authentication'
require
'json'
describe
GitlabLfsAuthentication
do
let
(
:user
)
{
{
'username'
=>
'dzaporozhets'
,
'lfs_token'
=>
'wsnys8Zm8Jn7zyhHTAAK'
}
}
subject
do
GitlabLfsAuthentication
.
new
(
'dzaporozhets'
,
'wsnys8Zm8Jn7zyhHTAAK'
,
'http://gitlab.dev/repo'
)
GitlabLfsAuthentication
.
build_from_json
(
JSON
.
generate
(
{
username:
'dzaporozhets'
,
lfs_token:
'wsnys8Zm8Jn7zyhHTAAK'
,
repository_http_path:
'http://gitlab.dev/repo'
}
)
)
end
describe
'#
initialize
'
do
describe
'#
build_from_json
'
do
it
{
subject
.
username
.
should
==
'dzaporozhets'
}
it
{
subject
.
lfs_token
.
should
==
'wsnys8Zm8Jn7zyhHTAAK'
}
it
{
subject
.
repository_http_path
.
should
==
'http://gitlab.dev/repo'
}
end
describe
'#authenticat
e!
'
do
describe
'#authenticat
ion_payload
'
do
result
=
"{
\"
header
\"
:{
\"
Authorization
\"
:
\"
Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL
\"
},
\"
href
\"
:
\"
http://gitlab.dev/repo/info/lfs/
\"
}"
it
{
subject
.
authenticate!
.
should
==
result
}
it
{
subject
.
authentication_payload
.
should
eq
(
result
)
}
it
'should be a proper JSON'
do
payload
=
subject
.
authentication_payload
json_payload
=
JSON
.
parse
(
payload
)
json_payload
[
'header'
][
'Authorization'
].
should
eq
(
'Basic ZHphcG9yb3poZXRzOndzbnlzOFptOEpuN3p5aEhUQUFL'
)
json_payload
[
'href'
].
should
eq
(
'http://gitlab.dev/repo/info/lfs/'
)
end
end
end
spec/gitlab_shell_spec.rb
View file @
a070ae4a
...
...
@@ -135,7 +135,7 @@ describe GitlabShell do
end
its
(
:repo_name
)
{
should
==
'dzaporozhets/gitlab.git'
}
its
(
:
git_cm
d
)
{
should
==
'git-lfs-authenticate'
}
its
(
:
comman
d
)
{
should
==
'git-lfs-authenticate'
}
its
(
:git_access
)
{
should
==
'git-upload-pack'
}
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