Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SLE-12-SP3' into frozen_string_f…
Browse files Browse the repository at this point in the history
…ix_sp4

Fixed "frozen String" crash
  • Loading branch information
lslezak committed Feb 19, 2019
2 parents 1554941 + c26c19b commit f674ee9
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 13 deletions.
14 changes: 13 additions & 1 deletion package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
-------------------------------------------------------------------
Mon Feb 18 13:11:12 UTC 2019 - lslezak@suse.cz

- Fixed "can't modify frozen String" crash (bsc#1125006)
- 3.2.18

-------------------------------------------------------------------
Thu Oct 11 14:55:15 UTC 2018 - lslezak@suse.cz

- CRLF control characters cannot be included in the registration
code, added validation check (bsc#1111419)
- 3.2.17

-------------------------------------------------------------------
Fri Oct 19 10:52:05 UTC 2018 - knut.anderssen@suse.com

- RegistrationCode widget: Use always the custom url instead of the
cached one (bsc#1100199)

- 3.2.16
-------------------------------------------------------------------
Fri Aug 31 10:12:16 UTC 2018 - lslezak@suse.cz

- Better check the not installed addon products, some specific
repositories do not provide any product
- Fixes online migration on PPC (bsc#1103412)
- 3.2.16

-------------------------------------------------------------------
Thu Jul 26 09:25:16 UTC 2018 - lslezak@suse.cz
Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.2.17
Version: 3.2.18
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
17 changes: 10 additions & 7 deletions src/lib/registration/ui/not_installed_products_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ class NotInstalledProductsDialog

REGISTRATION_CHECK_MSG = N_("Checking registration status")

attr_accessor :registration, :registration_ui

def self.run
dialog = NotInstalledProductsDialog.new
dialog.run
end

def initialize
textdomain "registration"

self.registration = Registration.new(UrlHelpers.registration_url)
self.registration_ui = RegistrationUI.new(registration)
end

def run
Expand All @@ -74,6 +69,14 @@ def run

private

def registration
@registration ||= Registration.new(UrlHelpers.registration_url)
end

def registration_ui
@registration_ui ||= RegistrationUI.new(registration)
end

def content
VBox(
MinWidth(80,
Expand Down Expand Up @@ -152,11 +155,11 @@ def not_installed_addons_summary
# not installed. (1/2)
summary = _("<p>The addons listed below are registered but not installed: </p>")

summary << "<ul>#{not_installed_addon_names.map { |a| "<li>#{a}</li>" }.join("")}</ul>"
summary += "<ul>#{not_installed_addon_names.map { |a| "<li>#{a}</li>" }.join("")}</ul>"

# TRANSLATORS: A RichText warning about all the products registered but
# not installed. (2/2)
summary << _("<p>It's preferable to <b>deactivate</b> your products at your " \
summary += _("<p>It's preferable to <b>deactivate</b> your products at your " \
"registration server if you don't plan to use them anymore.</p>")

summary
Expand Down
5 changes: 1 addition & 4 deletions src/lib/registration/widgets/registration_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ def valid_url?
# run the system and the base product registration
# @return [Boolean] true on success
def register_system_and_base_product
url = UrlHelpers.registration_url
return false if UrlHelpers.registration_url == :cancel

registration = Registration.new(url)
registration = Registration.new(options.custom_url)
registration_ui = RegistrationUI.new(registration)

success, product_service = registration_ui.register_system_and_base_product
Expand Down
54 changes: 54 additions & 0 deletions test/registration/ui/not_installed_products_dialog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env rspec
# ------------------------------------------------------------------------------
# Copyright (c) 2018 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.
# ------------------------------------------------------------------------------

require_relative "../../spec_helper"
require "registration/ui/not_installed_products_dialog"

describe Registration::UI::NotInstalledProductsDialog do
describe "#run" do
before do
allow(Yast::UI).to receive(:OpenDialog)
allow(Yast::UI).to receive(:CloseDialog)
allow(Yast::UI).to receive(:SetFocus)

allow(Yast::Popup).to receive(:Feedback).and_yield
allow(subject).to receive(:handle_dialog)

# the translated strings are frozen
allow(subject).to receive(:_), &:freeze
end

context "when there is a registered but not installed product" do
before do
allow(Registration::Addon).to receive(:registered_not_installed).and_return(
[
double(name: "not_installed_product")
]
)
end

it "displays a product summary popup" do
expect(Yast::UI).to receive(:OpenDialog) do |_opts, content|
# find the RichText widget in the content
term = content.nested_find do |t|
t.respond_to?(:value) && t.value == :RichText
end

expect(term.params[1]).to match(/registered but not installed: .*not_installed_product/)
end

subject.run
end
end
end
end

0 comments on commit f674ee9

Please sign in to comment.