From 02d4b75f42f64fcba6e3e3e34869f86bbb5f5eff Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Tue, 13 Apr 2021 21:16:57 +0100 Subject: [PATCH 1/3] Use empty string instead of 'default' as the 'Default' id --- .../installation/clients/security_proposal.rb | 2 +- src/lib/installation/security_settings.rb | 2 +- .../widgets/polkit_default_priv.rb | 6 ++-- test/lib/clients/security_proposal_test.rb | 34 +++++++++++++++++++ test/lib/widgets/polkit_default_priv_test.rb | 27 ++++++++++++++- 5 files changed, 65 insertions(+), 6 deletions(-) mode change 100644 => 100755 test/lib/widgets/polkit_default_priv_test.rb diff --git a/src/lib/installation/clients/security_proposal.rb b/src/lib/installation/clients/security_proposal.rb index 333274358..9193eb1b7 100644 --- a/src/lib/installation/clients/security_proposal.rb +++ b/src/lib/installation/clients/security_proposal.rb @@ -232,7 +232,7 @@ def sshd_proposal end def polkit_default_priv_proposal - value = @settings.polkit_default_privileges || "default" + value = @settings.polkit_default_privileges.to_s human_value = @settings.human_polkit_privileges[value] format(_("PolicyKit Default Privileges: %s"), human_value) diff --git a/src/lib/installation/security_settings.rb b/src/lib/installation/security_settings.rb index 6ba8a88b1..aa08a0c6a 100644 --- a/src/lib/installation/security_settings.rb +++ b/src/lib/installation/security_settings.rb @@ -146,7 +146,7 @@ def access_problem? def human_polkit_privileges { - "default" => _("Default"), + "" => _("Default"), # TRANSLATORS: restrictive in sense the most restrictive policy "restrictive" => _("Restrictive"), "standard" => _("Standard"), diff --git a/src/lib/installation/widgets/polkit_default_priv.rb b/src/lib/installation/widgets/polkit_default_priv.rb index 85891b1dc..899ac4d0a 100644 --- a/src/lib/installation/widgets/polkit_default_priv.rb +++ b/src/lib/installation/widgets/polkit_default_priv.rb @@ -18,6 +18,7 @@ # ------------------------------------------------------------------------------ require "cwm/common_widgets" +require "installation/security_settings" module Installation module Widgets @@ -59,12 +60,11 @@ def help end def init - self.value = @settings.polkit_default_privileges || "default" + self.value = @settings.polkit_default_privileges.to_s end def store - res = value == "default" ? nil : value - @settings.polkit_default_privileges = res + @settings.polkit_default_privileges = value.empty? ? nil : value end end end diff --git a/test/lib/clients/security_proposal_test.rb b/test/lib/clients/security_proposal_test.rb index 7a8a62afd..7b1c69697 100755 --- a/test/lib/clients/security_proposal_test.rb +++ b/test/lib/clients/security_proposal_test.rb @@ -184,5 +184,39 @@ end end end + + context "when showing the PolicyKit Default privileges selected" do + let(:selected) { "" } + + before do + allow(proposal_settings).to receive(:polkit_default_privileges).and_return(selected) + end + + context "and it is not set" do + let(:selected) { nil } + + it "shows it as 'Default'" do + proposal = client.make_proposal({}) + expect(proposal["preformatted_proposal"]).to include("Privileges: Default") + end + end + + context "and it is empty" do + let(:selected) { nil } + + it "shows it as 'Default'" do + proposal = client.make_proposal({}) + expect(proposal["preformatted_proposal"]).to include("Privileges: Default") + end + end + context "and it is restrictive" do + let(:selected) { "restrictive" } + + it "shows it as 'Restrictive'" do + proposal = client.make_proposal({}) + expect(proposal["preformatted_proposal"]).to include("Privileges: Restrictive") + end + end + end end end diff --git a/test/lib/widgets/polkit_default_priv_test.rb b/test/lib/widgets/polkit_default_priv_test.rb old mode 100644 new mode 100755 index 99fda5575..b2170b94c --- a/test/lib/widgets/polkit_default_priv_test.rb +++ b/test/lib/widgets/polkit_default_priv_test.rb @@ -5,7 +5,32 @@ require "cwm/rspec" describe Installation::Widgets::PolkitDefaultPriv do - subject { described_class.new(Installation::SecuritySettings.create_instance) } + let(:settings) { Installation::SecuritySettings.create_instance } + subject { described_class.new(settings) } include_examples "CWM::ComboBox" + + describe ".store" do + let(:selected) { "" } + + before do + allow(subject).to receive(:value).and_return(selected) + end + + context "when the value selected is the 'Default'" do + it "sets the settings polkit_default_privileges to nil" do + expect(settings).to receive(:polkit_default_privileges=).with(nil) + subject.store + end + end + + context "when the value selected is other" do + let(:selected) { "restrictive" } + + it "sets the settings with the selected value" do + expect(settings).to receive(:polkit_default_privileges=).with("restrictive") + subject.store + end + end + end end From 89fa2043804b444eccf3a86040ef3accc4c87d08 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Wed, 14 Apr 2021 12:11:42 +0100 Subject: [PATCH 2/3] Bump version & changelog --- package/yast2-installation.changes | 8 ++++++++ package/yast2-installation.spec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package/yast2-installation.changes b/package/yast2-installation.changes index 5a1096f0e..f0aa116b3 100644 --- a/package/yast2-installation.changes +++ b/package/yast2-installation.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Apr 14 11:08:52 UTC 2021 - Knut Anderssen + +- Show 'Default' in the proposal summary as the PolicyKit Default + Privileges to be used when it is not specified or specified as + empty in the control file (bsc#1184277) +- 4.3.37 + ------------------------------------------------------------------- Mon Mar 29 16:25:00 UTC 2021 - Ladislav Slezák diff --git a/package/yast2-installation.spec b/package/yast2-installation.spec index d4ede4440..cf574ab3d 100644 --- a/package/yast2-installation.spec +++ b/package/yast2-installation.spec @@ -16,7 +16,7 @@ # Name: yast2-installation -Version: 4.3.36 +Version: 4.3.37 Release: 0 Group: System/YaST License: GPL-2.0-only From a982d6c3698775db0a316360d16faf0e6e891d51 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Wed, 14 Apr 2021 14:42:54 +0100 Subject: [PATCH 3/3] Added missing space --- src/lib/installation/widgets/polkit_default_priv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/installation/widgets/polkit_default_priv.rb b/src/lib/installation/widgets/polkit_default_priv.rb index 899ac4d0a..34560e1c9 100644 --- a/src/lib/installation/widgets/polkit_default_priv.rb +++ b/src/lib/installation/widgets/polkit_default_priv.rb @@ -54,7 +54,7 @@ def help "to allow a more seamless user experience without" \ " interruptions in the workflow due to password " \ "prompts.
" \ - "The \"default\" is to keep value empty and it will be" \ + "The \"default\" is to keep value empty and it will be " \ "assigned automatically.

" ) end