diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/import_export | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/import_export')
-rw-r--r-- | spec/lib/gitlab/import_export/all_models.yml | 13 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/attributes_permitter_spec.rb | 69 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/safe_model_attributes.yml | 2 |
3 files changed, 84 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 2b7138a7a10..614aa55c3c5 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -58,6 +58,7 @@ issues: - test_reports - requirement - incident_management_issuable_escalation_status +- pending_escalations work_item_type: - issues events: @@ -223,6 +224,7 @@ ci_pipelines: - builds - bridges - processables +- generic_commit_statuses - trigger_requests - variables - auto_canceled_by @@ -318,6 +320,7 @@ integrations: - project - service_hook - jira_tracker_data +- zentao_tracker_data - issue_tracker_data - open_project_tracker_data hooks: @@ -354,6 +357,8 @@ project: - taggings - base_tags - topic_taggings +- topics_acts_as_taggable +- project_topics - topics - chat_services - cluster @@ -365,6 +370,7 @@ project: - value_streams - group - namespace +- project_namespace - management_clusters - boards - last_event @@ -395,6 +401,7 @@ project: - teamcity_integration - pushover_integration - jira_integration +- zentao_integration - redmine_integration - youtrack_integration - custom_issue_tracker_integration @@ -583,6 +590,9 @@ project: - timelogs - error_tracking_errors - error_tracking_client_keys +- pending_builds +- security_scans +- ci_feature_usages award_emoji: - awardable - user @@ -673,6 +683,7 @@ boards: - destroyable_lists - milestone - iteration +- iteration_cadence - board_labels - board_assignee - assignee @@ -762,3 +773,5 @@ push_rule: - group bulk_import_export: - group +service_desk_setting: + - file_template_project diff --git a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb index 0c1b1cd74bf..36a831a785c 100644 --- a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb +++ b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb @@ -74,4 +74,73 @@ RSpec.describe Gitlab::ImportExport::AttributesPermitter do expect(subject.permitted_attributes_for(:labels)).to contain_exactly(:title, :description, :type, :priorities) end end + + describe '#permitted_attributes_defined?' do + using RSpec::Parameterized::TableSyntax + + let(:attributes_permitter) { described_class.new } + + where(:relation_name, :permitted_attributes_defined) do + :user | false + :author | false + :ci_cd_settings | false + :issuable_sla | false + :push_rule | false + :metrics_setting | true + :project_badges | true + :pipeline_schedules | true + :error_tracking_setting | true + :auto_devops | true + end + + with_them do + it { expect(attributes_permitter.permitted_attributes_defined?(relation_name)).to eq(permitted_attributes_defined) } + end + end + + describe 'included_attributes for Project' do + let(:prohibited_attributes) { %i[remote_url my_attributes my_ids token my_id test] } + + subject { described_class.new } + + Gitlab::ImportExport::Config.new.to_h[:included_attributes].each do |relation_sym, permitted_attributes| + context "for #{relation_sym}" do + let(:import_export_config) { Gitlab::ImportExport::Config.new.to_h } + let(:project_relation_factory) { Gitlab::ImportExport::Project::RelationFactory } + + let(:relation_hash) { (permitted_attributes + prohibited_attributes).map(&:to_s).zip([]).to_h } + let(:relation_name) { project_relation_factory.overrides[relation_sym]&.to_sym || relation_sym } + let(:relation_class) { project_relation_factory.relation_class(relation_name) } + let(:excluded_keys) { import_export_config.dig(:excluded_keys, relation_sym) || [] } + + let(:cleaned_hash) do + Gitlab::ImportExport::AttributeCleaner.new( + relation_hash: relation_hash, + relation_class: relation_class, + excluded_keys: excluded_keys + ).clean + end + + let(:permitted_hash) { subject.permit(relation_sym, relation_hash) } + + if described_class.new.permitted_attributes_defined?(relation_sym) + it 'contains only attributes that are defined as permitted in the import/export config' do + expect(permitted_hash.keys).to contain_exactly(*permitted_attributes.map(&:to_s)) + end + + it 'does not contain attributes that would be cleaned with AttributeCleaner' do + expect(cleaned_hash.keys).to include(*permitted_hash.keys) + end + + it 'does not contain prohibited attributes that are not related to given relation' do + expect(permitted_hash.keys).not_to include(*prohibited_attributes.map(&:to_s)) + end + else + it 'is disabled' do + expect(subject).not_to be_permitted_attributes_defined(relation_sym) + end + end + end + end + end end diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 77d126e012e..a9efa32f986 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -167,6 +167,7 @@ ProjectMember: - expires_at - ldap - override +- invite_email_success User: - id - username @@ -761,6 +762,7 @@ Board: - group_id - milestone_id - iteration_id +- iteration_cadence_id - weight - name - hide_backlog_list |