Skip to content

Commit

Permalink
Merge aec413e into a85a44e
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Aug 24, 2020
2 parents a85a44e + aec413e commit c48f147
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Aug 24 13:44:00 CEST 2020 - schubi@suse.de

- Reporting an error if an corrupted AY configuration file has been
read (bsc#160975).
- 4.3.36

-------------------------------------------------------------------
Thu Aug 13 07:04:06 UTC 2020 - Michal Filka <mfilka@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.3.35
Version: 4.3.36
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
9 changes: 9 additions & 0 deletions src/modules/ProfileLocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ def Process
return false
end
tmp = Convert.to_string(SCR.Read(path(".target.string"), localfile))

unless tmp.valid_encoding?
# TRANSLATORS: %s is the filename
Report.Error(
format(_("AutoYaST file %s\nhas no valid encoding or is corrupted."), filename)
)
return false
end

l = Builtins.splitstring(tmp, "\n")
while !tmp.nil? && Ops.get(l, 0, "") == "-----BEGIN PGP MESSAGE-----"
Builtins.y2milestone("encrypted profile found")
Expand Down
35 changes: 26 additions & 9 deletions test/ProfileLocation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

describe "#Process" do

context "when scheme is \"relurl\"" do
before do
Yast::AutoinstConfig.scheme = "relurl"
Yast::AutoinstConfig.xml_tmpfile = "/tmp/123"
Yast::AutoinstConfig.filepath = "autoinst.xml"
allow(Yast::InstURL).to receive(:installInf2Url).and_return(
"http://download.opensuse.org/distribution/leap/15.1/repo/oss/"
)
end
before do
Yast::AutoinstConfig.scheme = "relurl"
Yast::AutoinstConfig.xml_tmpfile = "/tmp/123"
Yast::AutoinstConfig.filepath = "autoinst.xml"
allow(Yast::InstURL).to receive(:installInf2Url).and_return(
"http://download.opensuse.org/distribution/leap/15.1/repo/oss/"
)
end

context "when scheme is \"relurl\"" do
it "downloads AutoYaST configuration file with absolute path" do
expect(subject).to receive(:Get).with("http",
"download.opensuse.org",
Expand All @@ -28,5 +28,22 @@
subject.Process
end
end

context "when scheme is corrupted" do
before do
allow(subject).to receive(:Get).with("http",
"download.opensuse.org",
"/distribution/leap/15.1/repo/oss/autoinst.xml",
"/tmp/123").and_return("error_string").and_return(true)
allow(Yast::SCR).to receive(:Read).with(Yast.path(".target.string"),
Yast::AutoinstConfig.xml_tmpfile).and_return("error_string")
end

it "reports an error" do
expect_any_instance_of(String).to receive(:valid_encoding?).and_return(false)
expect(Yast::Report).to receive(:Error).with(/has no valid encoding or is corrupted/)
subject.Process
end
end
end
end

0 comments on commit c48f147

Please sign in to comment.