BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bf4cc9e1
Unverified
Commit
bf4cc9e1
authored
May 30, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't allow to pass a user to ProjectWiki#http_url_to_repo
This partially reverts
be25bbc4
. Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
fd376b3e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
33 deletions
+9
-33
project_wiki.rb
app/models/project_wiki.rb
+2
-5
url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+0
-6
user_git_access_wiki_page_spec.rb
.../features/projects/wiki/user_git_access_wiki_page_spec.rb
+1
-1
url_sanitizer_spec.rb
spec/lib/gitlab/url_sanitizer_spec.rb
+2
-7
project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+4
-14
No files found.
app/models/project_wiki.rb
View file @
bf4cc9e1
...
...
@@ -42,11 +42,8 @@ class ProjectWiki
url_to_repo
end
def
http_url_to_repo
(
user
=
nil
)
url
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
path_with_namespace
}
.git"
credentials
=
Gitlab
::
UrlSanitizer
.
http_credentials_for_user
(
user
)
Gitlab
::
UrlSanitizer
.
new
(
url
,
credentials:
credentials
).
full_url
def
http_url_to_repo
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
path_with_namespace
}
.git"
end
def
wiki_base_path
...
...
lib/gitlab/url_sanitizer.rb
View file @
bf4cc9e1
...
...
@@ -18,12 +18,6 @@ module Gitlab
false
end
def
self
.
http_credentials_for_user
(
user
)
return
{}
unless
user
.
respond_to?
(
:username
)
{
user:
user
.
username
}
end
def
initialize
(
url
,
credentials:
nil
)
@url
=
Addressable
::
URI
.
parse
(
url
.
strip
)
@credentials
=
credentials
...
...
spec/features/projects/wiki/user_git_access_wiki_page_spec.rb
View file @
bf4cc9e1
...
...
@@ -21,6 +21,6 @@ describe 'Projects > Wiki > User views Git access wiki page', :feature do
click_link
'Clone repository'
expect
(
page
).
to
have_text
(
"Clone repository
#{
project
.
wiki
.
path_with_namespace
}
"
)
expect
(
page
).
to
have_text
(
project
.
wiki
.
http_url_to_repo
(
user
)
)
expect
(
page
).
to
have_text
(
project
.
wiki
.
http_url_to_repo
)
end
end
spec/lib/gitlab/url_sanitizer_spec.rb
View file @
bf4cc9e1
...
...
@@ -62,11 +62,6 @@ describe Gitlab::UrlSanitizer, lib: true do
end
end
describe
'.http_credentials_for_user'
do
it
{
expect
(
described_class
.
http_credentials_for_user
(
user
)).
to
eq
({
user:
'john.doe'
})
}
it
{
expect
(
described_class
.
http_credentials_for_user
(
'foo'
)).
to
eq
({})
}
end
describe
'#sanitized_url'
do
it
{
expect
(
url_sanitizer
.
sanitized_url
).
to
eq
(
"https://github.com/me/project.git"
)
}
end
...
...
@@ -76,7 +71,7 @@ describe Gitlab::UrlSanitizer, lib: true do
context
'when user is given to #initialize'
do
let
(
:url_sanitizer
)
do
described_class
.
new
(
"https://github.com/me/project.git"
,
credentials:
described_class
.
http_credentials_for_user
(
user
)
)
described_class
.
new
(
"https://github.com/me/project.git"
,
credentials:
{
user:
user
.
username
}
)
end
it
{
expect
(
url_sanitizer
.
credentials
).
to
eq
({
user:
'john.doe'
})
}
...
...
@@ -94,7 +89,7 @@ describe Gitlab::UrlSanitizer, lib: true do
context
'when user is given to #initialize'
do
let
(
:url_sanitizer
)
do
described_class
.
new
(
"https://github.com/me/project.git"
,
credentials:
described_class
.
http_credentials_for_user
(
user
)
)
described_class
.
new
(
"https://github.com/me/project.git"
,
credentials:
{
user:
user
.
username
}
)
end
it
{
expect
(
url_sanitizer
.
full_url
).
to
eq
(
"https://john.doe@github.com/me/project.git"
)
}
...
...
spec/models/project_wiki_spec.rb
View file @
bf4cc9e1
...
...
@@ -37,21 +37,11 @@ describe ProjectWiki, models: true do
describe
"#http_url_to_repo"
do
let
(
:project
)
{
create
:empty_project
}
context
'when no user is given'
do
it
'returns the url to the repo without a username'
do
expected_url
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
subject
.
path_with_namespace
}
.git"
it
'returns the full http url to the repo'
do
expected_url
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
subject
.
path_with_namespace
}
.git"
expect
(
project_wiki
.
http_url_to_repo
).
to
eq
(
expected_url
)
expect
(
project_wiki
.
http_url_to_repo
).
not_to
include
(
'@'
)
end
end
context
'when user is given'
do
it
'returns the url to the repo with the username'
do
user
=
build_stubbed
(
:user
)
expect
(
project_wiki
.
http_url_to_repo
(
user
)).
to
start_with
(
"http://
#{
user
.
username
}
@"
)
end
expect
(
project_wiki
.
http_url_to_repo
).
to
eq
(
expected_url
)
expect
(
project_wiki
.
http_url_to_repo
).
not_to
include
(
'@'
)
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