Commit 3b72786b authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch '216912-jira-proxy-settings' into 'master'

Add Jira proxy settings columns

See merge request gitlab-org/gitlab!52119
parents b3e21ec0 9f39e9d3
......@@ -30,7 +30,8 @@ class JiraService < IssueTrackerService
# TODO: we can probably just delegate as part of
# https://gitlab.com/gitlab-org/gitlab/issues/29404
data_field :username, :password, :url, :api_url, :jira_issue_transition_id, :project_key, :issues_enabled, :vulnerabilities_enabled, :vulnerabilities_issuetype
data_field :username, :password, :url, :api_url, :jira_issue_transition_id, :project_key, :issues_enabled,
:vulnerabilities_enabled, :vulnerabilities_issuetype, :proxy_address, :proxy_port, :proxy_username, :proxy_password
before_update :reset_password
after_commit :update_deployment_type, on: [:create, :update], if: :update_deployment_type?
......
......@@ -7,6 +7,15 @@ class JiraTrackerData < ApplicationRecord
attr_encrypted :api_url, encryption_options
attr_encrypted :username, encryption_options
attr_encrypted :password, encryption_options
attr_encrypted :proxy_address, encryption_options
attr_encrypted :proxy_port, encryption_options
attr_encrypted :proxy_username, encryption_options
attr_encrypted :proxy_password, encryption_options
validates :proxy_address, length: { maximum: 2048 }
validates :proxy_port, length: { maximum: 5 }
validates :proxy_username, length: { maximum: 255 }
validates :proxy_password, length: { maximum: 255 }
enum deployment_type: { unknown: 0, server: 1, cloud: 2 }, _prefix: :deployment
end
---
title: Add Jira proxy settings columns
merge_request: 52119
author:
type: added
# frozen_string_literal: true
class AddProxySettingsToJiraTrackerData < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :jira_tracker_data, :encrypted_proxy_address, :text
add_column :jira_tracker_data, :encrypted_proxy_address_iv, :text
add_column :jira_tracker_data, :encrypted_proxy_port, :text
add_column :jira_tracker_data, :encrypted_proxy_port_iv, :text
add_column :jira_tracker_data, :encrypted_proxy_username, :text
add_column :jira_tracker_data, :encrypted_proxy_username_iv, :text
add_column :jira_tracker_data, :encrypted_proxy_password, :text
add_column :jira_tracker_data, :encrypted_proxy_password_iv, :text
end
end
c8b5485f158fdec0ab6813e4014713786dfa231b901e77ea610a873d03f8f0f0
\ No newline at end of file
......@@ -13602,6 +13602,14 @@ CREATE TABLE jira_tracker_data (
deployment_type smallint DEFAULT 0 NOT NULL,
vulnerabilities_issuetype text,
vulnerabilities_enabled boolean DEFAULT false NOT NULL,
encrypted_proxy_address text,
encrypted_proxy_address_iv text,
encrypted_proxy_port text,
encrypted_proxy_port_iv text,
encrypted_proxy_username text,
encrypted_proxy_username_iv text,
encrypted_proxy_password text,
encrypted_proxy_password_iv text,
CONSTRAINT check_0bf84b76e9 CHECK ((char_length(vulnerabilities_issuetype) <= 255)),
CONSTRAINT check_214cf6a48b CHECK ((char_length(project_key) <= 255))
);
......
# frozen_string_literal: true
# these factories should never be called directly, they are used when creating services
# These factories should not be called directly unless we are testing a _tracker_data model.
# The factories are used when creating integrations.
FactoryBot.define do
factory :jira_tracker_data do
service
......
......@@ -3,13 +3,28 @@
require 'spec_helper'
RSpec.describe JiraTrackerData do
let(:service) { build(:jira_service) }
describe 'Associations' do
describe 'associations' do
it { is_expected.to belong_to(:service) }
end
describe 'deployment_type' do
it { is_expected.to define_enum_for(:deployment_type).with_values([:unknown, :server, :cloud]).with_prefix(:deployment) }
end
describe 'proxy settings' do
it { is_expected.to validate_length_of(:proxy_address).is_at_most(2048) }
it { is_expected.to validate_length_of(:proxy_port).is_at_most(5) }
it { is_expected.to validate_length_of(:proxy_username).is_at_most(255) }
it { is_expected.to validate_length_of(:proxy_password).is_at_most(255) }
end
describe 'encrypted attributes' do
subject { described_class.encrypted_attributes.keys }
it {
is_expected.to contain_exactly(
:api_url, :password, :proxy_address, :proxy_password, :proxy_port, :proxy_username, :url, :username
)
}
end
end
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