Skip to content

Commit

Permalink
Merge pull request #456 from yast/feature/bsc-1114018-sle15sp1
Browse files Browse the repository at this point in the history
[SLE-15-SP1] Allow to use "refuse" as a cancel action
  • Loading branch information
dgdavid committed Jul 1, 2019
2 parents b9f99e5 + fda9196 commit 6e3bb38
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 23 deletions.
8 changes: 8 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jun 20 14:11:46 UTC 2019 - David Diaz <dgonzalez@suse.com>

- Better handling of license agreement dialog, allowing to
distinguish when the user is declining a license or aborting
the installation (bsc#1114018)
- 4.1.47

-------------------------------------------------------------------
Mon Jun 17 17:15:29 CEST 2019 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.1.46
Version: 4.1.47
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
4 changes: 1 addition & 3 deletions src/include/packager/repositories_include.rb
Expand Up @@ -186,12 +186,10 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
try_again(url, scheme) ? :again : :cancel
else
Progress.NextStage
license_accepted = true
Builtins.foreach(newSources) do |id|
if !LicenseAccepted(id)
log.info("License NOT accepted, removing the source")
Pkg.SourceDelete(id)
license_accepted = false
else
src_data = Pkg.SourceGeneralData(id)
log.info("Addded repository: #{src_data}")
Expand All @@ -207,7 +205,7 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
end
end

license_accepted ? :ok : :abort
:ok
end
ensure
# relese (unmount) the medium
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AddOnProduct.rb
Expand Up @@ -559,7 +559,7 @@ def AcceptedLicenseAndInfoFile(src_id)
ret = ProductLicense.AskAddOnLicenseAgreement(src_id)
return nil if ret.nil?

if ret == :abort || ret == :back
if [:refused, :abort, :back].include?(ret)
Builtins.y2milestone("License confirmation failed")
return false
end
Expand Down
4 changes: 3 additions & 1 deletion src/modules/ProductLicense.rb
Expand Up @@ -416,7 +416,7 @@ def AskAddOnLicenseAgreement(src_id)
src_id,
"",
@license_patterns,
"abort",
"refuse",
# back button is disabled
false,
false,
Expand Down Expand Up @@ -635,6 +635,8 @@ def HandleLicenseDialogRet(licenses, base_product, action)
log.info "License has been declined."

case action
when "refuse"
ret = :refused
when "abort"
ret = :abort
when "halt"
Expand Down
56 changes: 42 additions & 14 deletions test/product_license_test.rb
Expand Up @@ -146,25 +146,53 @@
end

context "while some license(s) have not been accepted" do
it "returns symbol :abort, :accepted, :halt according to the third function parameter" do
let(:base_prod) { false }

before do
expect(Yast::ProductLicense).to receive(:AllLicensesAccepted).and_return(false)
.at_least(:once)
# :halt case
allow(Yast::ProductLicense).to receive(:TimedOKCancel).and_return(true)
end

base_prod = false
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "abort"))
.to eq(:abort)
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "continue"))
.to eq(:accepted)
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "halt"))
.to eq(:halt)
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "unknown"))
.to eq(:abort)
context "when cancel action is 'continue'" do
it "returns :accepted" do
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "continue"))
.to eq(:accepted)
end
end

context "when cancel action is 'refuse'" do
it "returns :refused" do
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "refuse"))
.to eq(:refused)
end
end

context "when cancel action is 'abort'" do
it "returns :abort" do
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "abort"))
.to eq(:abort)
end
end

context "when cancel action is 'halt'" do
it "returns :halt" do
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "halt"))
.to eq(:halt)
end
end

context "when cancel action is unknown" do
it "returns :abort" do
expect(Yast::ProductLicense
.send(:HandleLicenseDialogRet, licenses_ref, base_prod, "whaterver"))
.to eq(:abort)
end
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions test/repositories_include_test.rb
Expand Up @@ -111,13 +111,12 @@ def main
expect(ret).to eq(:ok)
end

it "returns :abort and removes the repository if license is rejected" do
it "removes the repository if license is rejected" do
expect(Yast::AddOnProduct).to receive(:AcceptedLicenseAndInfoFile)
.with(repo_id).and_return(false)
expect(Yast::Pkg).to receive(:SourceDelete).with(repo_id)

ret = RepositoryIncludeTester.createSource(url, plaindir, download, preffered_name)
expect(ret).to eq(:abort)
RepositoryIncludeTester.createSource(url, plaindir, download, preffered_name)
end

context "more products available on the medium" do
Expand Down

0 comments on commit 6e3bb38

Please sign in to comment.