-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
035f4f0
commit bdd1c1a
Showing
2 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
service/test/agama/dbus/storage/proposal_settings_conversion/to_dbus_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2023] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../../../test_helper" | ||
require "y2storage/encryption_method" | ||
require "y2storage/pbkd_function" | ||
require "agama/dbus/storage/proposal_settings_conversion/to_dbus" | ||
require "agama/storage/proposal_settings" | ||
require "agama/storage/volume" | ||
|
||
describe Agama::DBus::Storage::ProposalSettingsConversion::ToDBus do | ||
let(:default_settings) { Agama::Storage::ProposalSettings.new } | ||
|
||
let(:custom_settings) do | ||
Agama::Storage::ProposalSettings.new.tap do |settings| | ||
settings.boot_device = "/dev/sda" | ||
settings.lvm.enabled = true | ||
settings.lvm.system_vg_devices = ["/dev/sda", "/dev/sdb"] | ||
settings.encryption.password = "notsecret" | ||
settings.encryption.method = Y2Storage::EncryptionMethod::LUKS2 | ||
settings.encryption.pbkd_function = Y2Storage::PbkdFunction::ARGON2ID | ||
settings.space.policy = :custom | ||
settings.space.actions = { "/dev/sda" => :force_delete } | ||
settings.volumes = [Agama::Storage::Volume.new("/test")] | ||
end | ||
end | ||
|
||
describe "#convert" do | ||
it "converts the settings to a D-Bus hash" do | ||
expect(described_class.new(default_settings).convert).to eq( | ||
"BootDevice" => "", | ||
"LVM" => false, | ||
"SystemVGDevices" => [], | ||
"EncryptionPassword" => "", | ||
"EncryptionMethod" => "luks1", | ||
"EncryptionPBKDFunction" => "", | ||
"SpacePolicy" => "keep", | ||
"SpaceActions" => {}, | ||
"Volumes" => [] | ||
) | ||
|
||
expect(described_class.new(custom_settings).convert).to eq( | ||
"BootDevice" => "/dev/sda", | ||
"LVM" => true, | ||
"SystemVGDevices" => ["/dev/sda", "/dev/sdb"], | ||
"EncryptionPassword" => "notsecret", | ||
"EncryptionMethod" => "luks2", | ||
"EncryptionPBKDFunction" => "argon2id", | ||
"SpacePolicy" => "custom", | ||
"SpaceActions" => { "/dev/sda" => :force_delete }, | ||
"Volumes" => [ | ||
{ | ||
"MountPath" => "/test", | ||
"MountOptions" => [], | ||
"TargetDevice" => "", | ||
"TargetVG" => "", | ||
"FsType" => "", | ||
"MinSize" => 0, | ||
"MaxSize" => 0, | ||
"AutoSize" => false, | ||
"Snapshots" => false, | ||
"Outline" => { | ||
"Required" => false, | ||
"FsTypes" => [], | ||
"SupportAutoSize" => false, | ||
"SnapshotsConfigurable" => true, | ||
"SnapshotsAffectSizes" => false, | ||
"SizeRelevantVolumes" => [] | ||
} | ||
} | ||
] | ||
) | ||
end | ||
end | ||
end |
99 changes: 99 additions & 0 deletions
99
service/test/agama/dbus/storage/volume_conversion/to_dbus_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2023] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../../../test_helper" | ||
require "y2storage/filesystems/type" | ||
require "y2storage/disk_size" | ||
require "agama/dbus/storage/volume_conversion/to_dbus" | ||
require "agama/storage/volume" | ||
|
||
describe Agama::DBus::Storage::VolumeConversion::ToDBus do | ||
let(:default_volume) { Agama::Storage::Volume.new("/test") } | ||
|
||
let(:custom_volume) do | ||
outline = Agama::Storage::VolumeOutline.new.tap do |outline| | ||
outline.required = true | ||
outline.filesystems = [Y2Storage::Filesystems::Type::EXT3, Y2Storage::Filesystems::Type::EXT4] | ||
outline.adjust_by_ram = true | ||
outline.min_size_fallback_for = ["/", "/home"] | ||
outline.max_size_fallback_for = ["swap"] | ||
outline.snapshots_configurable = true | ||
outline.snapshots_size = Y2Storage::DiskSize.new(1000) | ||
outline.snapshots_percentage = 10 | ||
end | ||
|
||
Agama::Storage::Volume.new("/test").tap do |volume| | ||
volume.outline = outline | ||
volume.fs_type = Y2Storage::Filesystems::Type::EXT4 | ||
volume.btrfs.snapshots = true | ||
volume.mount_options = ["rw", "default"] | ||
volume.device = "/dev/sda" | ||
volume.separate_vg_name = "/dev/system" | ||
volume.min_size = Y2Storage::DiskSize.new(1024) | ||
volume.max_size = Y2Storage::DiskSize.new(2048) | ||
volume.auto_size = true | ||
end | ||
end | ||
|
||
describe "#convert" do | ||
it "converts the volume to a D-Bus hash" do | ||
expect(described_class.new(default_volume).convert).to eq( | ||
"MountPath" => "/test", | ||
"MountOptions" => [], | ||
"TargetDevice" => "", | ||
"TargetVG" => "", | ||
"FsType" => "", | ||
"MinSize" => 0, | ||
"MaxSize" => 0, | ||
"AutoSize" => false, | ||
"Snapshots" => false, | ||
"Outline" => { | ||
"Required" => false, | ||
"FsTypes" => [], | ||
"SupportAutoSize" => false, | ||
"SnapshotsConfigurable" => true, | ||
"SnapshotsAffectSizes" => false, | ||
"SizeRelevantVolumes" => [] | ||
} | ||
) | ||
|
||
expect(described_class.new(custom_volume).convert).to eq( | ||
"MountPath" => "/test", | ||
"MountOptions" => ["rw", "default"], | ||
"TargetDevice" => "/dev/sda", | ||
"TargetVG" => "/dev/system", | ||
"FsType" => "Ext4", | ||
"MinSize" => 1024, | ||
"MaxSize" => 2048, | ||
"AutoSize" => true, | ||
"Snapshots" => true, | ||
"Outline" => { | ||
"Required" => true, | ||
"FsTypes" => ["Ext3", "Ext4"], | ||
"SupportAutoSize" => true, | ||
"SnapshotsConfigurable" => true, | ||
"SnapshotsAffectSizes" => true, | ||
"SizeRelevantVolumes" => ["/", "/home", "swap"] | ||
} | ||
) | ||
end | ||
end | ||
end |