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
9d2aac82
Commit
9d2aac82
authored
Jun 24, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix and refactor spec
parent
58c1c493
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
spec/models/remote_mirror_spec.rb
spec/models/remote_mirror_spec.rb
+14
-15
No files found.
spec/models/remote_mirror_spec.rb
View file @
9d2aac82
...
...
@@ -23,19 +23,19 @@ describe RemoteMirror do
describe
'encrypting credentials'
do
context
'when setting URL for a first time'
do
it
'should store the URL without credentials'
do
mirror
=
create_mirror
_with_url
(
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://foo:bar@test.com'
)
expect
(
mirror
.
read_attribute
(
:url
)).
to
eq
(
'http://test.com'
)
end
it
'should store the credentials on a separate field'
do
mirror
=
create_mirror
_with_url
(
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://foo:bar@test.com'
)
expect
(
mirror
.
credentials
).
to
eq
({
user:
'foo'
,
password:
'bar'
})
end
it
'should handle credentials with large content'
do
mirror
=
create_mirror
_with_url
(
'http://bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif:9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75@test.com'
)
mirror
=
create_mirror
(
url:
'http://bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif:9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75@test.com'
)
expect
(
mirror
.
credentials
).
to
eq
({
user:
'bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif'
,
...
...
@@ -46,7 +46,7 @@ describe RemoteMirror do
context
'when updating the URL'
do
it
'should allow a new URL without credentials'
do
mirror
=
create_mirror
_with_url
(
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://foo:bar@test.com'
)
mirror
.
update_attribute
(
:url
,
'http://test.com'
)
...
...
@@ -55,7 +55,7 @@ describe RemoteMirror do
end
it
'should allow a new URL with credentials'
do
mirror
=
create_mirror
_with_url
(
'http://test.com'
)
mirror
=
create_mirror
(
url:
'http://test.com'
)
mirror
.
update_attribute
(
:url
,
'http://foo:bar@test.com'
)
...
...
@@ -64,7 +64,7 @@ describe RemoteMirror do
end
it
'should update the remote config if credentials changed'
do
mirror
=
create_mirror
_with_url
(
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://foo:bar@test.com'
)
repo
=
mirror
.
project
.
repository
mirror
.
update_attribute
(
:url
,
'http://foo:baz@test.com'
)
...
...
@@ -73,11 +73,10 @@ describe RemoteMirror do
end
it
'should still be picked up by the worker if is stuck'
do
mirror
=
create_mirror_with_url
(
'http://test.com'
)
mirror
.
update_attribute
(
:update_status
,
'started'
)
# this will reset some of the updated_at fields
mirror
.
update_attribute
(
:url
,
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://cantbeblank'
,
update_status:
'started'
,
last_update_at:
nil
,
updated_at:
25
.
hours
.
ago
)
expect
(
RemoteMirror
.
stuck
.
last
).
to
eq
(
mirror
)
end
...
...
@@ -87,7 +86,7 @@ describe RemoteMirror do
describe
'#safe_url'
do
context
'when URL contains credentials'
do
it
'should mask the credentials'
do
mirror
=
create_mirror
_with_url
(
'http://foo:bar@test.com'
)
mirror
=
create_mirror
(
url:
'http://foo:bar@test.com'
)
expect
(
mirror
.
safe_url
).
to
eq
(
'http://*****:*****@test.com'
)
end
...
...
@@ -95,15 +94,15 @@ describe RemoteMirror do
context
'when URL does not contain credentials'
do
it
'should show the full URL'
do
mirror
=
create_mirror
_with_url
(
'http://test.com'
)
mirror
=
create_mirror
(
url:
'http://test.com'
)
expect
(
mirror
.
safe_url
).
to
eq
(
'http://test.com'
)
end
end
end
def
create_mirror
_with_url
(
url
)
def
create_mirror
(
params
)
project
=
FactoryGirl
.
create
(
:project
)
project
.
remote_mirrors
.
create!
(
url:
url
)
project
.
remote_mirrors
.
create!
(
params
)
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