Skip to content
代码片段 群组 项目
未验证 提交 3e50f794 编辑于 作者: Artur Fedorov's avatar Artur Fedorov
浏览文件

This MR adds new field for update service

New encrypted field shared secret was added to a model
API services were updated accordingly

Changelog: changed
EE: true
上级 0cddd01d
No related branches found
No related tags found
无相关合并请求
...@@ -80,6 +80,7 @@ PUT /projects/:id/external_status_checks/:check_id ...@@ -80,6 +80,7 @@ PUT /projects/:id/external_status_checks/:check_id
| `check_id` | integer | yes | ID of an external status check service | | `check_id` | integer | yes | ID of an external status check service |
| `name` | string | no | Display name of external status check service | | `name` | string | no | Display name of external status check service |
| `external_url` | string | no | URL of external status check service | | `external_url` | string | no | URL of external status check service |
| `shared_secret` | string | no | HMAC secret for external status check |
| `protected_branch_ids` | `array<Integer>` | no | IDs of protected branches to scope the rule by | | `protected_branch_ids` | `array<Integer>` | no | IDs of protected branches to scope the rule by |
## Delete external status check service ## Delete external status check service
......
...@@ -42,7 +42,7 @@ def execute_on_all_protected_branches_rule ...@@ -42,7 +42,7 @@ def execute_on_all_protected_branches_rule
end end
def permitted_params def permitted_params
%i[check_id name external_url] %i[check_id name external_url shared_secret]
end end
end end
end end
......
...@@ -27,7 +27,7 @@ def can_update_external_status_check? ...@@ -27,7 +27,7 @@ def can_update_external_status_check?
end end
def resource_params def resource_params
params.slice(:name, :external_url, :protected_branch_ids) params.slice(:name, :shared_secret, :external_url, :protected_branch_ids)
end end
def external_status_check def external_status_check
......
...@@ -70,6 +70,7 @@ def check_feature_enabled! ...@@ -70,6 +70,7 @@ def check_feature_enabled!
desc: 'ID of an external status check', desc: 'ID of an external status check',
documentation: { example: 1 } documentation: { example: 1 }
optional :name, type: String, desc: 'Display name of external status check', documentation: { example: 'QA' } optional :name, type: String, desc: 'Display name of external status check', documentation: { example: 'QA' }
optional :shared_secret, type: String, desc: 'HMAC shared secret', documentation: { example: 'hmac-sha256' }
optional :external_url, optional :external_url,
type: String, type: String,
desc: 'URL of external status check resource', desc: 'URL of external status check resource',
......
...@@ -481,7 +481,7 @@ ...@@ -481,7 +481,7 @@
let_it_be(:protected_branch) { create(:protected_branch, project: project) } let_it_be(:protected_branch) { create(:protected_branch, project: project) }
let(:params) do let(:params) do
{ name: 'New rule', external_url: 'https://gitlab.com/test/example.json', protected_branch_ids: protected_branch.id } { name: 'New rule', external_url: 'https://gitlab.com/test/example.json', protected_branch_ids: protected_branch.id, shared_secret: 'shared_secret' }
end end
subject do subject do
...@@ -503,7 +503,7 @@ ...@@ -503,7 +503,7 @@
expect(json_response['id']).not_to be_nil expect(json_response['id']).not_to be_nil
expect(json_response['name']).to eq('New rule') expect(json_response['name']).to eq('New rule')
expect(json_response['hmac']).to eq(false) expect(json_response['hmac']).to eq(true)
expect(json_response['external_url']).to eq('https://gitlab.com/test/example.json') expect(json_response['external_url']).to eq('https://gitlab.com/test/example.json')
expect(json_response['protected_branches'].size).to eq(1) expect(json_response['protected_branches'].size).to eq(1)
end end
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
create(:external_status_check, project: project, protected_branches: [protected_branch]) create(:external_status_check, project: project, protected_branches: [protected_branch])
end end
let(:params) { { check_id: external_status_check.id, name: 'Updated name', external_url: 'https://external_url_updated.com' } } let(:shared_secret) { 'shared secret' }
let(:params) { { check_id: external_status_check.id, name: 'Updated name', external_url: 'https://external_url_updated.com', shared_secret: shared_secret } }
subject(:execute) { described_class.new(branch_rule, user, params).execute } subject(:execute) { described_class.new(branch_rule, user, params).execute }
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
external_status_check.reload external_status_check.reload
expect(external_status_check.name).to eq('Updated name') expect(external_status_check.name).to eq('Updated name')
expect(external_status_check.external_url).to eq('https://external_url_updated.com') expect(external_status_check.external_url).to eq('https://external_url_updated.com')
expect(external_status_check.shared_secret).to eq(shared_secret)
end end
it 'includes the updated external_status_check record in payload' do it 'includes the updated external_status_check record in payload' do
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
expect(external_status_check.project).to eq(project) expect(external_status_check.project).to eq(project)
expect(external_status_check.name).to eq('Updated name') expect(external_status_check.name).to eq('Updated name')
expect(external_status_check.external_url).to eq('https://external_url_updated.com') expect(external_status_check.external_url).to eq('https://external_url_updated.com')
expect(external_status_check.shared_secret).to eq(shared_secret)
expect(external_status_check.protected_branches).to contain_exactly(protected_branch) expect(external_status_check.protected_branches).to contain_exactly(protected_branch)
end end
end end
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
let_it_be(:protected_branch) { create(:protected_branch, project: project) } let_it_be(:protected_branch) { create(:protected_branch, project: project) }
let(:current_user) { project.first_owner } let(:current_user) { project.first_owner }
let(:params) { { id: project.id, check_id: check.id, external_url: 'http://newvalue.com', name: 'new name', protected_branch_ids: [protected_branch.id] } } let(:params) { { id: project.id, check_id: check.id, external_url: 'http://newvalue.com', name: 'new name', protected_branch_ids: [protected_branch.id], shared_secret: 'shared_secret' } }
subject(:execute) { described_class.new(container: project, current_user: current_user, params: params).execute } subject(:execute) { described_class.new(container: project, current_user: current_user, params: params).execute }
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
expect(check.external_url).to eq('http://newvalue.com') expect(check.external_url).to eq('http://newvalue.com')
expect(check.name).to eq('new name') expect(check.name).to eq('new name')
expect(check.protected_branches).to contain_exactly(protected_branch) expect(check.protected_branches).to contain_exactly(protected_branch)
expect(check.shared_secret).to eq('shared_secret')
end end
it 'is successful' do it 'is successful' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册