Commit fb383dc6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fj-11886-fix-port-validation' into 'master'

Fix port validation in .gitlab-webide.yml

Closes #11886

See merge request gitlab-org/gitlab-ee!13846
parents 91bf5b85 f65402f9
---
title: Fix port validation in .gitlab-webide.yml
merge_request: 13846
author:
type: fixed
......@@ -45,6 +45,21 @@ describe Gitlab::WebIde::Config::Entry::Terminal do
end
end
end
context 'when unknown port keys detected' do
let(:config) do
{
image: { name: "ruby", ports: [80] },
services: [{ name: "mysql", alias: "service2", ports: [{ number: 81, invalid_key: 'foobar' }] }]
}
end
it 'is not valid' do
expect(entry).not_to be_valid
expect(entry.errors.first)
.to match /port config contains unknown keys: invalid_key/
end
end
end
context 'when entry value is not correct' do
......
......@@ -24,7 +24,7 @@ module Gitlab
end
entry :ports, Entry::Ports,
description: 'Ports used expose the image'
description: 'Ports used to expose the image'
attributes :ports
......
......@@ -24,6 +24,9 @@ module Gitlab
validates :alias, type: String, presence: true, unless: ->(record) { record.ports.blank? }
end
entry :ports, Entry::Ports,
description: 'Ports used to expose the service'
def alias
value[:alias]
end
......
......@@ -112,6 +112,16 @@ describe Gitlab::Ci::Config::Entry::Service do
it 'is valid' do
expect(entry).to be_valid
end
context 'when unknown port keys detected' do
let(:ports) { [{ number: 80, invalid_key: 'foo' }] }
it 'is not valid' do
expect(entry).not_to be_valid
expect(entry.errors.first)
.to match /port config contains unknown keys: invalid_key/
end
end
end
describe '#ports' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment