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
0a4f44de
Commit
0a4f44de
authored
Apr 09, 2019
by
Wolphin
Committed by
Kamil Trzciński
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add environment url validation
parent
1fce09ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
lib/gitlab/ci/config/entry/environment.rb
lib/gitlab/ci/config/entry/environment.rb
+2
-0
spec/lib/gitlab/ci/config/entry/environment_spec.rb
spec/lib/gitlab/ci/config/entry/environment_spec.rb
+40
-0
No files found.
lib/gitlab/ci/config/entry/environment.rb
View file @
0a4f44de
...
...
@@ -36,10 +36,12 @@ module Gitlab
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:url
,
type:
String
,
length:
{
maximum:
255
},
allow_nil:
true
validates
:action
,
type:
String
,
inclusion:
{
in:
%w[start stop]
,
message:
'should be start or stop'
},
allow_nil:
true
...
...
spec/lib/gitlab/ci/config/entry/environment_spec.rb
View file @
0a4f44de
...
...
@@ -100,6 +100,26 @@ describe Gitlab::Ci::Config::Entry::Environment do
end
end
context
'when wrong action type is used'
do
let
(
:config
)
do
{
name:
'production'
,
action:
[
'stop'
]
}
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
describe
'#errors'
do
it
'contains error about wrong action type'
do
expect
(
entry
.
errors
)
.
to
include
'environment action should be a string'
end
end
end
context
'when invalid action is used'
do
let
(
:config
)
do
{
name:
'production'
,
...
...
@@ -151,6 +171,26 @@ describe Gitlab::Ci::Config::Entry::Environment do
end
end
context
'when wrong url type is used'
do
let
(
:config
)
do
{
name:
'production'
,
url:
[
'https://meow.meow'
]
}
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
describe
'#errors'
do
it
'contains error about wrong url type'
do
expect
(
entry
.
errors
)
.
to
include
'environment url should be a string'
end
end
end
context
'when variables are used for environment'
do
let
(
:config
)
do
{
name:
'review/$CI_COMMIT_REF_NAME'
,
...
...
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