diff options
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/import_export/group_tree_restorer_spec.rb | 38 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/group_tree_saver_spec.rb | 23 |
2 files changed, 59 insertions, 2 deletions
diff --git a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb index 4d52f1fdda3..9aa9471d155 100644 --- a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb @@ -71,6 +71,44 @@ describe Gitlab::ImportExport::GroupTreeRestorer do end end + context 'excluded attributes' do + let!(:source_user) { create(:user, id: 123) } + let!(:importer_user) { create(:user) } + let(:group) { create(:group) } + let(:shared) { Gitlab::ImportExport::Shared.new(group) } + let(:group_tree_restorer) { described_class.new(user: importer_user, shared: shared, group: group, group_hash: nil) } + let(:group_json) { ActiveSupport::JSON.decode(IO.read(File.join(shared.export_path, 'group.json'))) } + + shared_examples 'excluded attributes' do + excluded_attributes = %w[ + id + name + path + owner_id + parent_id + created_at + updated_at + runners_token + runners_token_encrypted + saml_discovery_token + ] + + before do + group.add_owner(importer_user) + + setup_import_export_config('group_exports/complex') + end + + excluded_attributes.each do |excluded_attribute| + it 'does not allow override of excluded attributes' do + expect(group_json[excluded_attribute]).not_to eq(group.public_send(excluded_attribute)) + end + end + end + + include_examples 'excluded attributes' + end + context 'group.json file access check' do let(:user) { create(:user) } let!(:group) { create(:group, name: 'group2', path: 'group2') } diff --git a/spec/lib/gitlab/import_export/group_tree_saver_spec.rb b/spec/lib/gitlab/import_export/group_tree_saver_spec.rb index 17538db3c68..d6aea8d1e69 100644 --- a/spec/lib/gitlab/import_export/group_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/group_tree_saver_spec.rb @@ -157,9 +157,28 @@ describe Gitlab::ImportExport::GroupTreeSaver do end context 'group attributes' do - it 'does not contain the runners token' do - expect(saved_group_json).not_to include("runners_token" => 'token') + shared_examples 'excluded attributes' do + excluded_attributes = %w[ + id + name + path + owner_id + parent_id + created_at + updated_at + runners_token + runners_token_encrypted + saml_discovery_token + ] + + excluded_attributes.each do |excluded_attribute| + it 'does not contain excluded attribute' do + expect(saved_group_json).not_to include(excluded_attribute => group.public_send(excluded_attribute)) + end + end end + + include_examples 'excluded attributes' end end end |