Hello community,
here is the log from the commit of package yast2-registration for
openSUSE:Factory checked in at 2018-06-18 13:48:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old)
and /work/SRC/openSUSE:Factory/.yast2-registration.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-registration"
Mon Jun 18 13:48:55 2018 rev:19 rq:616724 version:4.0.40
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes
2018-05-17 19:31:58.322215131 +0200
+++
/work/SRC/openSUSE:Factory/.yast2-registration.new/yast2-registration.changes
2018-06-18 13:49:04.755919768 +0200
@@ -1,0 +2,33 @@
+Wed Jun 13 14:00:30 UTC 2018 - [email protected]
+
+- Prefer the SCC credentials at upgrade when both NCC and SCC
+ credentials are present in the system (bsc#1096813)
+- 4.0.40
+
+-------------------------------------------------------------------
+Wed Jun 6 07:33:07 UTC 2018 - [email protected]
+
+- Fixed also the another places detecting the installed product
+ (bsc#1095702)
+- 4.0.39
+
+-------------------------------------------------------------------
+Tue Jun 5 10:12:07 UTC 2018 - [email protected]
+
+- Fixed evaluating the installed product (the installed upgraded
+ products are marked as "removed") (bsc#1095702)
+- 4.0.38
+
+-------------------------------------------------------------------
+Wed May 30 12:26:23 UTC 2018 - [email protected]
+
+- Fixes for upgrade via SMT (bsc#1094865):
+ - Set the new "target_distro" for libzypp also after reloading
+ the target otherwise libzypp might reject the new repositories
+ - Copy also the SMT credentials into the installation system,
+ not only the SCC ones
+ - Copy the SMT (and also the RMT) SSL certificate into the
+ installation system (for HTTPS communication)
+- 4.0.37
+
+-------------------------------------------------------------------
Old:
----
yast2-registration-4.0.36.tar.bz2
New:
----
yast2-registration-4.0.40.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-registration.spec ++++++
--- /var/tmp/diff_new_pack.jhjvSN/_old 2018-06-18 13:49:05.951875562 +0200
+++ /var/tmp/diff_new_pack.jhjvSN/_new 2018-06-18 13:49:05.955875415 +0200
@@ -17,7 +17,7 @@
Name: yast2-registration
-Version: 4.0.36
+Version: 4.0.40
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ yast2-registration-4.0.36.tar.bz2 -> yast2-registration-4.0.40.tar.bz2
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/package/yast2-registration.changes
new/yast2-registration-4.0.40/package/yast2-registration.changes
--- old/yast2-registration-4.0.36/package/yast2-registration.changes
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/package/yast2-registration.changes
2018-06-14 09:29:44.000000000 +0200
@@ -1,4 +1,37 @@
-------------------------------------------------------------------
+Wed Jun 13 14:00:30 UTC 2018 - [email protected]
+
+- Prefer the SCC credentials at upgrade when both NCC and SCC
+ credentials are present in the system (bsc#1096813)
+- 4.0.40
+
+-------------------------------------------------------------------
+Wed Jun 6 07:33:07 UTC 2018 - [email protected]
+
+- Fixed also the another places detecting the installed product
+ (bsc#1095702)
+- 4.0.39
+
+-------------------------------------------------------------------
+Tue Jun 5 10:12:07 UTC 2018 - [email protected]
+
+- Fixed evaluating the installed product (the installed upgraded
+ products are marked as "removed") (bsc#1095702)
+- 4.0.38
+
+-------------------------------------------------------------------
+Wed May 30 12:26:23 UTC 2018 - [email protected]
+
+- Fixes for upgrade via SMT (bsc#1094865):
+ - Set the new "target_distro" for libzypp also after reloading
+ the target otherwise libzypp might reject the new repositories
+ - Copy also the SMT credentials into the installation system,
+ not only the SCC ones
+ - Copy the SMT (and also the RMT) SSL certificate into the
+ installation system (for HTTPS communication)
+- 4.0.37
+
+-------------------------------------------------------------------
Tue May 8 17:27:36 CEST 2018 - [email protected]
- Fixed: Offline migration against RMT sends some requests to
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/package/yast2-registration.spec
new/yast2-registration-4.0.40/package/yast2-registration.spec
--- old/yast2-registration-4.0.36/package/yast2-registration.spec
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/package/yast2-registration.spec
2018-06-14 09:29:44.000000000 +0200
@@ -17,7 +17,7 @@
Name: yast2-registration
-Version: 4.0.36
+Version: 4.0.40
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/src/lib/registration/clients/inst_migration_repos.rb
new/yast2-registration-4.0.40/src/lib/registration/clients/inst_migration_repos.rb
---
old/yast2-registration-4.0.36/src/lib/registration/clients/inst_migration_repos.rb
2018-05-15 09:42:03.000000000 +0200
+++
new/yast2-registration-4.0.40/src/lib/registration/clients/inst_migration_repos.rb
2018-06-14 09:29:44.000000000 +0200
@@ -46,27 +46,24 @@
SwMgmt.copy_old_credentials(destdir)
# import the SMT certificate to inst-sys
- import_ssl_certificate
+ import_ssl_certificates
end
- # Import the old SSL certificate if present. Tries both SLE12 nad SLE11
- # file locations.
- def import_ssl_certificate
- # SLE12 certificate path
- cert_file = File.join(Yast::Installation.destdir,
SUSE::Connect::YaST::SERVER_CERT_FILE)
+ # Import the old SSL certificate if present. Tries all known locations.
+ def import_ssl_certificates
+ prefix = Yast::Installation.destdir
- if !File.exist?(cert_file)
- # try the the SLE11 certificate path as well
- cert_file = File.join(Yast::Installation.destdir,
- SslCertificate::SLE11_SERVER_CERT_FILE)
-
- return unless File.exist?(cert_file)
+ SslCertificate::PATHS.each do |file|
+ cert_file = File.join(prefix, file)
+ if File.exist?(cert_file)
+ log.info("Importing the SSL certificate from the old system:
(#{prefix})#{file} ...")
+ cert = SslCertificate.load_file(cert_file)
+ target_path = File.join(SslCertificate::INSTSYS_CERT_DIR,
File.basename(cert_file))
+ cert.import_to_instsys(target_path)
+ else
+ log.debug("SSL certificate (#{prefix})#{file} not found in the
system")
+ end
end
-
- log.info("Importing the SSL certificate from the old system
(#{cert_file})...")
- cert = SslCertificate.load_file(cert_file)
- # in Stage.initial this imports to the inst-sys
- cert.import
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/src/lib/registration/ssl_certificate.rb
new/yast2-registration-4.0.40/src/lib/registration/ssl_certificate.rb
--- old/yast2-registration-4.0.36/src/lib/registration/ssl_certificate.rb
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/src/lib/registration/ssl_certificate.rb
2018-06-14 09:29:44.000000000 +0200
@@ -12,13 +12,29 @@
Yast.import "Stage"
# Path to the registration certificate in the instsys
- INSTSYS_SERVER_CERT_FILE =
"/etc/pki/trust/anchors/registration_server.pem".freeze
- # the SLE11 certificate path, see
- #
https://github.com/yast/yast-registration/blob/Code-11-SP3/src/modules/Register.ycp#L296-L297
- SLE11_SERVER_CERT_FILE = "/etc/ssl/certs/registration-server.pem".freeze
+ INSTSYS_CERT_DIR = "/etc/pki/trust/anchors".freeze
+ INSTSYS_SERVER_CERT_FILE = File.join(INSTSYS_CERT_DIR,
"registration_server.pem").freeze
# Path to system CA certificates
CA_CERTS_DIR = "/var/lib/ca-certificates".freeze
+ # all used certificate paths, this is used during upgrade to import
+ # the old certificate into the inst-sys, put the older paths at the end
+ # so the newer paths are checked first
+ PATHS = [
+ # the YaST (SUSEConnect) current default path
+ # /usr/share/pki/trust/anchors/registration_server.pem
+ SUSE::Connect::YaST::SERVER_CERT_FILE,
+ # RMT certificate
+ #
https://github.com/SUSE/rmt/blob/b240ce577bd1637cfb57548f2741a1925cf3e4ee/public/tools/rmt-client-setup#L214
+ "/etc/pki/trust/anchors/rmt-server.pem",
+ # SMT certificate
+ # https://github.com/SUSE/smt/blob/SMT12/script/clientSetup4SMT.sh#L245
+ "/etc/pki/trust/anchors/registration-server.pem",
+ # the SLE11 path (for both YaST and the clientSetup4SMT.sh script)
+ #
https://github.com/yast/yast-registration/blob/Code-11-SP3/src/modules/Register.ycp#L296-L297
+ "/etc/ssl/certs/registration-server.pem"
+ ].freeze
+
attr_reader :x509_cert
# Path to store the certificate of the registration server
@@ -175,12 +191,15 @@
# to installation system is slightly different to the one followed
# to import certificates to a installed system.
#
+ # @param target_path [String] where the imported certificate will be saved,
+ # the path should contain the INSTSYS_CERT_DIR prefix otherwise it might
+ # not work correctly.
# @return [Boolean] true if import was successful; false otherwise.
#
# @see update_instsys_ca
- def import_to_instsys
+ def import_to_instsys(target_path = self.class.default_certificate_path)
# Copy certificate
- File.write(self.class.default_certificate_path, x509_cert.to_pem)
+ File.write(target_path, x509_cert.to_pem)
# Update database
self.class.update_instsys_ca
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/src/lib/registration/sw_mgmt.rb
new/yast2-registration-4.0.40/src/lib/registration/sw_mgmt.rb
--- old/yast2-registration-4.0.36/src/lib/registration/sw_mgmt.rb
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/src/lib/registration/sw_mgmt.rb
2018-06-14 09:29:44.000000000 +0200
@@ -46,6 +46,7 @@
Yast.import "Installation"
Yast.import "PackageCallbacks"
Yast.import "Popup"
+ Yast.import "Product"
class SwMgmt
include Yast
@@ -72,7 +73,7 @@
# display progress when refreshing repositories
PackageCallbacks.InitPackageCallbacks
- raise_pkg_exception unless Pkg.TargetInitialize(Installation.destdir)
+ raise_pkg_exception unless init_target(Installation.destdir)
raise_pkg_exception unless Pkg.TargetLoad
raise_pkg_exception(SourceRestoreError) unless Pkg.SourceRestore
@@ -199,8 +200,9 @@
elsif Stage.initial
# during upgrade it depends on whether target is already initialized,
# use the product from the medium for the self-update step
+ # (during upgrade the installed product might me already selected for
removal)
if installed
- p["status"] == :installed && p["type"] == "base"
+ (p["status"] == :installed || p["status"] == :removed) && p["type"]
== "base"
elsif selected
p["status"] == :selected
else
@@ -208,7 +210,7 @@
end
else
# in installed system or at upgrade the base product has valid type
- p["status"] == :installed && p["type"] == "base"
+ (p["status"] == :installed || p["status"] == :removed) && p["type"] ==
"base"
end
end
@@ -223,15 +225,21 @@
# Any product installed? (e.g. during upgrade)
# @return [Boolean] true if at least one product is installed
def self.product_installed?
- Pkg.ResolvableProperties("", :product, "").any? { |p| p["status"] ==
:installed }
+ Pkg.ResolvableProperties("", :product, "").any? do |p|
+ p["status"] == :installed || p["status"] == :removed
+ end
end
def self.installed_products
# just for testing/debugging
return [FAKE_BASE_PRODUCT] if ENV["FAKE_BASE_PRODUCT"]
- products = Pkg.ResolvableProperties("", :product, "").select do |p|
- p["status"] == :installed
+ all_products = Pkg.ResolvableProperties("", :product, "")
+ log.info("Evaluating products: #{all_products}")
+
+ products = all_products.select do |p|
+ # installed or installed marked for removal (at upgrade)
+ p["status"] == :installed || p["status"] == :removed
end
log.info "Found installed products: #{products.map { |p| p["name"] }}"
@@ -443,18 +451,27 @@
::FileUtils.mkdir_p(dir)
end
- # check for NCC credentials
- ncc_file = File.join(source_dir, dir, "NCCcredentials")
- copy_old_credentials_file(ncc_file)
+ # if the system contains both NCC and SCC credentials then the SCC ones
+ # should be preferred (bsc#1096813)
+ # take advantage that "NCCcredentials" is alphabetically before
+ # "SCCcredentials" so it is enough to just sort the files and then the
+ # SCC credentials will simply overwrite the NCC credentials
+ Dir[File.join(source_dir, dir, "*")].sort.each do |path|
+ # skip non-files
+ next unless File.file?(path)
+
+ # check for the NCC credentials, we need to save them as the SCC
credentials
+ new_path = if File.basename(path) == "NCCcredentials"
+ SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE
+ else
+ File.join(dir, File.basename(path))
+ end
- scc_file = File.join(source_dir,
SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
- copy_old_credentials_file(scc_file)
+ copy_old_credentials_file(path, new_path)
+ end
end
- def self.copy_old_credentials_file(file)
- return unless File.exist?(file)
-
- new_file = SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE
+ private_class_method def self.copy_old_credentials_file(file, new_file)
log.info "Copying the old credentials from previous installation"
log.info "Copying #{file} to #{new_file}"
@@ -465,17 +482,18 @@
credentials = SUSE::Connect::YaST.credentials(new_file)
log.info "Using previous credentials (username): #{credentials.username}"
+ rescue SUSE::Connect::MalformedSccCredentialsFile => e
+ log.warn "Cannot parse the credentials file: #{e.inspect}"
end
- private_class_method :copy_old_credentials_file
-
def self.find_addon_updates(addons)
log.info "Available addons: #{addons.map(&:identifier)}"
products = Pkg.ResolvableProperties("", :product, "")
installed_addons = products.select do |product|
- product["status"] == :installed && product["type"] != "base"
+ (product["status"] == :installed || product["status"] == :removed) &&
+ product["type"] != "base"
end
product_names = installed_addons.map { |a|
"#{a["name"]}-#{a["version"]}-#{a["release"]}" }
@@ -501,7 +519,7 @@
# a helper method for iterating over repositories
# @param repo_aliases [Array<String>] list of repository aliases
# @param block block evaluated for each found repository
- def self.each_repo(repo_aliases, &block)
+ private_class_method def self.each_repo(repo_aliases, &block)
all_repos = Pkg.SourceGetCurrent(false)
repo_aliases.each do |repo_alias|
@@ -611,6 +629,35 @@
raise klass, Pkg.LastError
end
- private_class_method :each_repo
+ # initialize the libzypp target
+ # @param destdir [String] the target directory
+ # @return [Boolean] true on sucess, false otherwise
+ def self.init_target(destdir)
+ if Stage.initial && Mode.update
+ # at upgrade we need to override the target_distro otherwise libzypp
+ # will use the old value from the upgraded system which might not
+ # match the new target_distro from the media and might result in
ignoring
+ # service repositories (bsc#1094865)
+ options = { "target_distro" => target_distribution }
+ Pkg.TargetInitializeOptions(destdir, options)
+ else
+ Pkg.TargetInitialize(destdir)
+ end
+ end
+
+ # get the target distribution for the new base product
+ # @return [String] target distribution name or empty string if not found
+ def self.target_distribution
+ base_products = Product.FindBaseProducts
+
+ # empty target distribution disables service compatibility check in case
+ # the base product cannot be found
+ target_distro = base_products ? base_products.first["register_target"] :
""
+ log.info "Base product target distribution: #{target_distro.inspect}"
+
+ target_distro
+ end
+
+ private_class_method :init_target, :target_distribution
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/src/lib/registration/ui/offline_migration_workflow.rb
new/yast2-registration-4.0.40/src/lib/registration/ui/offline_migration_workflow.rb
---
old/yast2-registration-4.0.36/src/lib/registration/ui/offline_migration_workflow.rb
2018-05-15 09:42:03.000000000 +0200
+++
new/yast2-registration-4.0.40/src/lib/registration/ui/offline_migration_workflow.rb
2018-06-14 09:29:44.000000000 +0200
@@ -125,8 +125,9 @@
end
end
- log.info("Removing #{SslCertificate::INSTSYS_SERVER_CERT_FILE}")
- File.delete(SslCertificate::INSTSYS_SERVER_CERT_FILE)
+ files = Dir[File.join(SslCertificate::INSTSYS_CERT_DIR, "*.pem")]
+ log.info("Removing files: #{files.inspect}")
+ File.delete(*files)
# Cleanup
FileUtils.rm_rf(SslCertificate::TMP_CA_CERTS_DIR)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/test/inst_migration_repos_spec.rb
new/yast2-registration-4.0.40/test/inst_migration_repos_spec.rb
--- old/yast2-registration-4.0.36/test/inst_migration_repos_spec.rb
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/test/inst_migration_repos_spec.rb
2018-06-14 09:29:44.000000000 +0200
@@ -7,7 +7,7 @@
describe Registration::Clients::InstMigrationRepos do
let(:destdir) { "/mnt" }
let(:sle12_cert) { File.join(destdir, SUSE::Connect::YaST::SERVER_CERT_FILE)
}
- let(:sle11_cert) { File.join(destdir,
Registration::SslCertificate::SLE11_SERVER_CERT_FILE) }
+ let(:sle11_cert) { File.join(destdir,
"/etc/ssl/certs/registration-server.pem") }
before do
allow(Yast::WFM).to receive(:call)
@@ -32,7 +32,7 @@
expect(File).to receive(:read).with(sle12_cert).and_return(
File.read(fixtures_file("test.pem"))
)
- expect_any_instance_of(Registration::SslCertificate).to receive(:import)
+ expect_any_instance_of(Registration::SslCertificate).to
receive(:import_to_instsys)
subject.main
end
@@ -42,7 +42,7 @@
expect(File).to receive(:read).with(sle11_cert).and_return(
File.read(fixtures_file("test.pem"))
)
- expect_any_instance_of(Registration::SslCertificate).to receive(:import)
+ expect_any_instance_of(Registration::SslCertificate).to
receive(:import_to_instsys)
subject.main
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-registration-4.0.36/test/offline_migration_workflow_test.rb
new/yast2-registration-4.0.40/test/offline_migration_workflow_test.rb
--- old/yast2-registration-4.0.36/test/offline_migration_workflow_test.rb
2018-05-15 09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/test/offline_migration_workflow_test.rb
2018-06-14 09:29:44.000000000 +0200
@@ -26,6 +26,9 @@
expect(Dir).to receive(:[])
.with(File.join(Registration::SslCertificate::TMP_CA_CERTS_DIR, "*"))
.and_return([File.join(Registration::SslCertificate::TMP_CA_CERTS_DIR,
"smt.pem")])
+ expect(Dir).to receive(:[])
+ .with("/etc/pki/trust/anchors/*.pem")
+ .and_return(["/etc/pki/trust/anchors/registration_server.pem"])
var_lib_cert = File.join(Registration::SslCertificate::CA_CERTS_DIR,
"/openssl/smt.pem")
expect(File).to receive(:exist?).with(var_lib_cert).and_return(true)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-registration-4.0.36/test/sw_mgmt_spec.rb
new/yast2-registration-4.0.40/test/sw_mgmt_spec.rb
--- old/yast2-registration-4.0.36/test/sw_mgmt_spec.rb 2018-05-15
09:42:03.000000000 +0200
+++ new/yast2-registration-4.0.40/test/sw_mgmt_spec.rb 2018-06-14
09:29:44.000000000 +0200
@@ -206,17 +206,18 @@
describe ".copy_old_credentials" do
let(:root_dir) { "/mnt" }
let(:target_dir) { SUSE::Connect::YaST::DEFAULT_CREDENTIALS_DIR }
+ let(:ncc_credentials) { File.join(root_dir, target_dir, "NCCcredentials") }
+ let(:scc_credentials) { File.join(root_dir, target_dir, "SCCcredentials") }
before do
expect(File).to receive(:exist?).with(target_dir).and_return(false)
+ allow(File).to receive(:file?).and_return(true)
expect(FileUtils).to receive(:mkdir_p).with(target_dir)
end
it "does not fail when the old credentials are missing" do
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"NCCcredentials"))
- .and_return(false)
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"SCCcredentials"))
- .and_return(false)
+ expect(Dir).to receive(:[]).with(File.join(root_dir, target_dir, "*"))
+ .and_return([])
# no copy
expect(FileUtils).to receive(:cp).never
@@ -225,29 +226,53 @@
end
it "copies old NCC credentials at upgrade" do
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"NCCcredentials"))
- .and_return(true)
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"SCCcredentials"))
- .and_return(false)
+ expect(Dir).to receive(:[]).with(File.join(root_dir, target_dir, "*"))
+ .and_return([ncc_credentials])
- expect(subject).to receive(:`).with("cp -a " + File.join(root_dir,
target_dir,
- "NCCcredentials") + " " + File.join(target_dir, "SCCcredentials"))
+ expect(subject).to receive(:`).with("cp -a " + ncc_credentials + " " +
+ File.join(target_dir, "SCCcredentials"))
expect(SUSE::Connect::YaST).to
receive(:credentials).and_return(OpenStruct.new)
- expect { subject.copy_old_credentials(root_dir) }.to_not raise_error
+ subject.copy_old_credentials(root_dir)
+ end
+
+ it "prefers the SCC credentials if both NCC and SCC credentials are
present" do
+ # deliberately return the SCC credentials first here
+ expect(Dir).to receive(:[]).with(File.join(root_dir, target_dir, "*"))
+ .and_return([scc_credentials, ncc_credentials])
+
+ # copy the credentials in the NCC, SCC order (bsc#1096813)
+ expect(subject).to receive(:`).with("cp -a " + ncc_credentials + " " +
+ File.join(target_dir, "SCCcredentials")).ordered
+ expect(subject).to receive(:`).with("cp -a " + scc_credentials + " " +
+ File.join(target_dir, "SCCcredentials")).ordered
+
+ allow(SUSE::Connect::YaST).to
receive(:credentials).and_return(OpenStruct.new)
+
+ subject.copy_old_credentials(root_dir)
end
it "copies old SCC credentials at upgrade" do
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"NCCcredentials"))
- .and_return(false)
- expect(File).to receive(:exist?).with(File.join(root_dir, target_dir,
"SCCcredentials"))
- .and_return(true)
+ expect(Dir).to receive(:[]).with(File.join(root_dir, target_dir, "*"))
+ .and_return([scc_credentials])
- expect(subject).to receive(:`).with("cp -a " + File.join(root_dir,
target_dir,
- "SCCcredentials") + " " + File.join(target_dir, "SCCcredentials"))
+ expect(subject).to receive(:`).with("cp -a " + scc_credentials + " " +
+ File.join(target_dir, "SCCcredentials"))
expect(SUSE::Connect::YaST).to
receive(:credentials).and_return(OpenStruct.new)
- expect { subject.copy_old_credentials(root_dir) }.to_not raise_error
+ subject.copy_old_credentials(root_dir)
+ end
+
+ it "copies old SMT credentials at upgrade" do
+ smt_credentials = File.join(root_dir, target_dir,
"SMT-http_smt_example_com")
+ expect(Dir).to receive(:[]).with(File.join(root_dir, target_dir, "*"))
+ .and_return([smt_credentials])
+
+ expect(subject).to receive(:`).with("cp -a " + smt_credentials + " " +
+ File.join(target_dir, "SMT-http_smt_example_com"))
+ expect(SUSE::Connect::YaST).to
receive(:credentials).and_return(OpenStruct.new)
+
+ subject.copy_old_credentials(root_dir)
end
end