Script 'mail_helper' called by ro Hello packager, This is just FYI. Your package was checked in in distribution "sle12" by autobuild-member: ro. Here comes the log... ---------------------------%<------------------------------ Hi, here is the log from ci_new_pac /mounts/work_src_done/SLE12/yast2-registration -> sle12 Changes: -------- --- /work/SRC/SUSE:SLE-12:GA/yast2-registration/yast2-registration.changes 2014-04-22 12:35:42.000000000 +0200 +++ /mounts/work_src_done/SLE12/yast2-registration/yast2-registration.changes 2014-04-23 13:23:18.000000000 +0200 @@ -1,0 +2,7 @@ +Wed Apr 23 07:29:37 UTC 2014 - lslezak@suse.cz + +- use "suse-connect" gem as the backend (to share the code with + the command line registration tool) +- 3.1.38 + +------------------------------------------------------------------- calling whatdependson for sle12-i586 Packages directly triggered for rebuild: - yast2-registration ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/SUSE:SLE-12:GA/yast2-registration (Old) and /mounts/work_src_done/SLE12/yast2-registration (BS:build ID:36662 MAIL:yast-commit@opensuse.org) (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-registration", Maintainer is "yast-commit@opensuse.org" Old: ---- yast2-registration-3.1.37.tar.bz2 New: ---- yast2-registration-3.1.38.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-registration.spec ++++++ --- /var/tmp/diff_new_pack.oVjgGg/_old 2014-04-24 11:35:18.000000000 +0200 +++ /var/tmp/diff_new_pack.oVjgGg/_new 2014-04-24 11:35:18.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 3.1.37 +Version: 3.1.38 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -31,15 +31,14 @@ Requires: yast2-pkg-bindings >= 2.17.20 # N_() method Requires: yast2-ruby-bindings >= 3.1.12 -# SCC API library -Requires: rubygem-scc_api >= 0.2.9 +Requires: rubygem-suse-connect Requires: yast2-slp >= 3.1.2 BuildRequires: yast2 >= 3.1.26 BuildRequires: update-desktop-files BuildRequires: yast2-devtools >= 3.1.6 BuildRequires: rubygem-rspec -BuildRequires: rubygem-scc_api >= 0.2.9 +BuildRequires: rubygem-suse-connect BuildRequires: yast2-slp >= 3.1.2 BuildArch: noarch @@ -74,7 +73,7 @@ %{yast_schemadir}/autoyast/rnc/*.rnc %{yast_libdir}/registration %{yast_libdir}/yast -%{yast_libdir}/yast/scc_api.rb +%{yast_libdir}/yast/suse_connect.rb %doc %{yast_docdir} %changelog ++++++ yast2-registration-3.1.37.tar.bz2 -> yast2-registration-3.1.38.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/Gemfile new/yast2-registration-3.1.38/Gemfile --- old/yast2-registration-3.1.37/Gemfile 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/Gemfile 2014-04-23 13:21:07.000000000 +0200 @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "scc_api", :github => "yast/rubygem-scc_api" +gem "suse-connect", :github => "SUSE/connect" group :test do gem "rake" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/package/yast2-registration.changes new/yast2-registration-3.1.38/package/yast2-registration.changes --- old/yast2-registration-3.1.37/package/yast2-registration.changes 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/package/yast2-registration.changes 2014-04-23 13:21:07.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Wed Apr 23 07:29:37 UTC 2014 - lslezak@suse.cz + +- use "suse-connect" gem as the backend (to share the code with + the command line registration tool) +- 3.1.38 + +------------------------------------------------------------------- Tue Apr 22 07:04:33 UTC 2014 - lslezak@suse.cz - use "registration code" term everywhere to be consistent with diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/package/yast2-registration.spec new/yast2-registration-3.1.38/package/yast2-registration.spec --- old/yast2-registration-3.1.37/package/yast2-registration.spec 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/package/yast2-registration.spec 2014-04-23 13:21:07.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 3.1.37 +Version: 3.1.38 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -31,15 +31,14 @@ Requires: yast2-pkg-bindings >= 2.17.20 # N_() method Requires: yast2-ruby-bindings >= 3.1.12 -# SCC API library -Requires: rubygem-scc_api >= 0.2.9 +Requires: rubygem-suse-connect Requires: yast2-slp >= 3.1.2 BuildRequires: yast2 >= 3.1.26 BuildRequires: update-desktop-files BuildRequires: yast2-devtools >= 3.1.6 BuildRequires: rubygem-rspec -BuildRequires: rubygem-scc_api >= 0.2.9 +BuildRequires: rubygem-suse-connect BuildRequires: yast2-slp >= 3.1.2 BuildArch: noarch @@ -74,7 +73,7 @@ %{yast_schemadir}/autoyast/rnc/*.rnc %{yast_libdir}/registration %{yast_libdir}/yast -%{yast_libdir}/yast/scc_api.rb +%{yast_libdir}/yast/suse_connect.rb %doc %{yast_docdir} %changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/Makefile.am new/yast2-registration-3.1.38/src/Makefile.am --- old/yast2-registration-3.1.37/src/Makefile.am 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/src/Makefile.am 2014-04-23 13:21:07.000000000 +0200 @@ -17,11 +17,11 @@ lib/registration/storage.rb \ lib/registration/registration.rb \ lib/registration/helpers.rb \ - lib/registration/scc_helpers.rb + lib/registration/connect_helpers.rb ylibyastdir = @ylibdir@/yast ylibyast_DATA = \ - lib/yast/scc_api.rb + lib/yast/suse_connect.rb schemafilesdir = $(schemadir)/autoyast/rnc schemafiles_DATA = \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/clients/inst_scc.rb new/yast2-registration-3.1.38/src/clients/inst_scc.rb --- old/yast2-registration-3.1.37/src/clients/inst_scc.rb 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/src/clients/inst_scc.rb 2014-04-23 13:21:07.000000000 +0200 @@ -23,13 +23,13 @@ # # use external rubygem for SCC communication -require "yast/scc_api" +require "yast/suse_connect" require "cgi" require "registration/exceptions" require "registration/helpers" -require "registration/scc_helpers" +require "registration/connect_helpers" require "registration/sw_mgmt" require "registration/storage" require "registration/registration" @@ -77,17 +77,7 @@ return end - if !Mode.normal - # read registration codes from USB media - log.info "Reading codes from USB media..." - # TODO FIXME: placeholder for FATE#316796 (https://fate.suse.com/316796) - # read the codes here, return Hash with mapping product_name => reg_code - @known_reg_codes = {} - log.info "Found #{@known_reg_codes.size} codes" - else - log.info "Initializing empty known reg codes" - @known_reg_codes = {} - end + @known_reg_codes = {} # cache the values ::Registration::Storage::RegCodes.instance.reg_codes = @known_reg_codes @@ -129,28 +119,32 @@ @registration = ::Registration::Registration.new(url) ::Registration::SccHelpers.catch_registration_errors do + distro_target = ::Registration::SwMgmt.find_base_product["register_target"] if !::Registration::Registration.is_registered? + log.info "Registering system, distro_target: #{distro_target}" + Popup.Feedback(_("Registering the System..."), _("Contacting the SUSE Customer Center server")) do - @registration.register(email, reg_code) + @registration.register(email, reg_code, distro_target) end end if !options.base_registered # then register the product(s) - base_product = ::Registration::SwMgmt.base_product_to_register product_services = Popup.Feedback( _("Registering Product..."), _("Contacting the SUSE Customer Center server")) do + base_product = ::Registration::SwMgmt.base_product_to_register + base_product["reg_code"] = reg_code @registration.register_products([base_product]) - end - # remember the base products for later (to get the respective addons) - ::Registration::Storage::BaseProduct.instance.product = base_product - options.base_registered = true + # remember the base products for later (to get the respective addons) + ::Registration::Storage::BaseProduct.instance.product = base_product + options.base_registered = true + end # select repositories to use in installation (e.g. enable/disable Updates) select_repositories(product_services) if Mode.installation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/clients/scc_auto.rb new/yast2-registration-3.1.38/src/clients/scc_auto.rb --- old/yast2-registration-3.1.37/src/clients/scc_auto.rb 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/src/clients/scc_auto.rb 2014-04-23 13:21:07.000000000 +0200 @@ -26,13 +26,13 @@ # # -require "yast/scc_api" +require "yast/suse_connect" require "erb" require "registration/storage" require "registration/registration" require "registration/helpers" -require "registration/scc_helpers" +require "registration/connect_helpers" module Yast class SccAutoClient < Client diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/registration/connect_helpers.rb new/yast2-registration-3.1.38/src/lib/registration/connect_helpers.rb --- old/yast2-registration-3.1.37/src/lib/registration/connect_helpers.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-3.1.38/src/lib/registration/connect_helpers.rb 2014-04-23 13:21:07.000000000 +0200 @@ -0,0 +1,106 @@ +# encoding: utf-8 + +# ------------------------------------------------------------------------------ +# Copyright (c) 2014 Novell, Inc. 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. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, you may find +# current contact information at www.novell.com. +# ------------------------------------------------------------------------------ +# +# + +require "yast" +require "suse/connect" + +require "registration/helpers" +require "registration/exceptions" + +module Registration + + class SccHelpers + include Yast::Logger + extend Yast::I18n + + textdomain "registration" + + Yast.import "Mode" + Yast.import "Popup" + Yast.import "Report" + + def self.catch_registration_errors(&block) + begin + yield + true + rescue SocketError + # Error popup + if Yast::Mode.installation + if Yast::Popup.YesNo( + _("Network is not configured, the registration server cannot be reached.\n" + + "Do you want to configure the network now?")) + + ::Registration::Helpers::run_network_configuration + end + else + Yast::Report.Error(_("Network error, check the network configuration.")) + end + false + rescue Timeout::Error + # Error popup + Yast::Report.Error(_("Connection time out.")) + false + rescue SUSE::Connect::ApiError => e + log.error "Received error: #{e.code}: #{e.body}" + case e.response + when Net::HTTPUnauthorized, Net::HTTPUnprocessableEntity + # Error popup + report_error(_("The email address is not known or\nthe registration code is not valid."), e) + when Net::HTTPClientError + report_error(_("Registration client error."), e) + when Net::HTTPServerError + report_error(_("Registration server error.\nRetry registration later."), e) + else + report_error(_("Registration failed."), e) + end + false + rescue ::Registration::ServiceError => e + log.error("Service error: #{e.message % e.service}") + Yast::Report.Error(_(e.message) % e.service) + false + rescue ::Registration::PkgError => e + log.error("Pkg error: #{e.message}") + Yast::Report.Error(_(e.message)) + false + rescue Exception => e + log.error("SCC registration failed: #{e}, #{e.backtrace}") + Yast::Report.Error(_("Registration failed.")) + false + end + end + + private + + def self.report_error(msg, api_error) + localized_error = api_error.body["localized_error"] || "" + + if !localized_error.empty? + # %s are error details + localized_error = ("\n\n" + _("Details: %s") % localized_error) + end + + Yast::Report.Error(msg + localized_error) + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/registration/registration.rb new/yast2-registration-3.1.38/src/lib/registration/registration.rb --- old/yast2-registration-3.1.37/src/lib/registration/registration.rb 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/src/lib/registration/registration.rb 2014-04-23 13:21:07.000000000 +0200 @@ -19,8 +19,8 @@ # ------------------------------------------------------------------------------ # -require "scc_api" require "yast" +require "suse/connect" require "registration/helpers" require "registration/sw_mgmt" @@ -30,7 +30,7 @@ class Registration include Yast::Logger - SCC_CREDENTIALS = SccApi::Credentials::DEFAULT_CREDENTIALS_DIR + "/SCCCredentials" + SCC_CREDENTIALS = SUSE::Connect::Credentials::GLOBAL_CREDENTIALS_FILE attr_accessor :url @@ -38,67 +38,83 @@ @url = url end - def register(email, reg_code) - @scc = SccApi::Connection.new(email, reg_code) + def register(email, reg_code, distro_target) + settings = connect_params( + :token => reg_code, + :distro_target => distro_target, + :email => email + ) - # set the current language to receive translated error messages - @scc.language = ::Registration::Helpers.language + login, password = SUSE::Connect::YaST.announce_system(settings) + credentials = SUSE::Connect::Credentials.new(login, password, SCC_CREDENTIALS) - if @url - log.info "Using custom registration URL: #{@url.inspect}" - @scc.url = @url - end - - # announce (register the system) first - @credentials = @scc.announce + log.info "Global SCC credentials: #{credentials}" # ensure the zypp config directories are writable in inst-sys ::Registration::SwMgmt.zypp_config_writable! # write the global credentials - @credentials.write + credentials.write end def register_products(products) product_services = products.map do |product| - log.info("Registering product: #{product["name"]}") - begin - orig_reg_code = @scc.reg_code - # use product specific reg. code (e.g. for addons) - @scc.reg_code = product["reg_code"] if product["reg_code"] - - ret = @scc.register(product) - ensure - # restore the original base product code - @scc.reg_code = orig_reg_code - end + product_ident = { + :arch => product["arch"], + :name => product["name"], + :version => product["version"], + :release_type => product["release_type"] + } + log.info "Registering product: #{product_ident}" + + params = connect_params(:product_ident => product_ident) - ret + # use product specific reg. code (e.g. for addons) + params[:token] = product["reg_code"] if product["reg_code"] + + SUSE::Connect::YaST.activate_product(params) end log.info "registered product_services: #{product_services.inspect}" if !product_services.empty? - add_product_services(product_services) + credentials = SUSE::Connect::Credentials.read(SCC_CREDENTIALS) + ::Registration::SwMgmt.add_services(product_services, credentials) end product_services end - def add_product_services(product_services) - ::Registration::SwMgmt.add_services(product_services, @credentials) - end - def get_addon_list # extensions for base product base_product = ::Registration::Storage::BaseProduct.instance.product - @scc.extensions_for(base_product["name"]).extensions + params = connect_params(:product_ident => {:name => base_product["name"]}) + + log.info "Reading available addons for product: #{base_product["name"]}" + SUSE::Connect::YaST.list_products(params) end def self.is_registered? - File.exist?(SCC_CREDENTIALS) + SUSE::Connect::System.registered? + end + + private + + def connect_params(params) + default_params = { + :language => ::Registration::Helpers.language, + :debug => ENV["SCCDEBUG"], + :verbose => ENV["Y2DEBUG"] == "1" + } + + if @url + log.info "Using custom registration URL: #{@url.inspect}" + default_params[:url] = @url + end + + default_params.merge(params) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/registration/scc_helpers.rb new/yast2-registration-3.1.38/src/lib/registration/scc_helpers.rb --- old/yast2-registration-3.1.37/src/lib/registration/scc_helpers.rb 2014-04-22 09:28:26.000000000 +0200 +++ new/yast2-registration-3.1.38/src/lib/registration/scc_helpers.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,93 +0,0 @@ -# encoding: utf-8 - -# ------------------------------------------------------------------------------ -# Copyright (c) 2014 Novell, Inc. 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. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, contact Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, you may find -# current contact information at www.novell.com. -# ------------------------------------------------------------------------------ -# -# - -require "yast" -require "scc_api" - -require "registration/helpers" -require "registration/exceptions" - -module Registration - - class SccHelpers - include Yast::Logger - extend Yast::I18n - - textdomain "registration" - - Yast.import "Mode" - Yast.import "Popup" - Yast.import "Report" - - def self.catch_registration_errors(&block) - begin - yield - true - rescue SccApi::NoNetworkError - # Error popup - if Yast::Mode.installation && Yast::Popup.YesNo( - _("Network is not configured, the registration server cannot be reached.\n" + - "Do you want to configure the network now?") ) - ::Registration::Helpers::run_network_configuration - end - false - rescue SccApi::NotAuthorized - # Error popup - Yast::Report.Error(_("The email address is not known or\nthe registration code is not valid.")) - false - rescue Timeout::Error - # Error popup - Yast::Report.Error(_("Connection time out.")) - false - rescue SccApi::ErrorResponse => e - # error popup, a generic message when no details are available - message = JSON.parse(e.message)["localized_error"] || _("Unknown error") - Yast::Report.Error(message) - false - rescue SccApi::HttpError => e - case e.response - when Net::HTTPClientError - Yast::Report.Error(_("Registration client error.")) - when Net::HTTPServerError - Yast::Report.Error(_("Registration server error.\n\nRetry registration later.")) - else - Yast::Report.Error(_("Registration failed.")) - end - false - rescue ::Registration::ServiceError => e - log.error("Service error: #{e.message % e.service}") - Yast::Report.Error(_(e.message) % e.service) - false - rescue ::Registration::PkgError => e - log.error("Pkg error: #{e.message}") - Yast::Report.Error(_(e.message)) - false - rescue Exception => e - log.error("SCC registration failed: #{e}, #{e.backtrace}") - Yast::Report.Error(_("Registration failed.")) - false - end - end - - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/registration/sw_mgmt.rb new/yast2-registration-3.1.38/src/lib/registration/sw_mgmt.rb --- old/yast2-registration-3.1.37/src/lib/registration/sw_mgmt.rb 2014-04-22 09:28:27.000000000 +0200 +++ new/yast2-registration-3.1.38/src/lib/registration/sw_mgmt.rb 2014-04-23 13:21:07.000000000 +0200 @@ -108,9 +108,9 @@ # filter out not needed data product_info = { - "name" => base_product["name"], - "arch" => base_product["arch"], - "version" => ::Registration::Helpers.base_version(base_product["version"]), + "name" => base_product["name"], + "arch" => base_product["arch"], + "version" => ::Registration::Helpers.base_version(base_product["version"]), "release_type" => base_product["flavor"] } @@ -130,49 +130,50 @@ end # services for registered products - product_services.map(&:services).flatten.each do |service| - log.info "Adding service #{service.name.inspect} (#{service.url})" + product_services.map(&:sources).flatten.each do |source| + log.info "Adding service #{source.name.inspect} (#{source.url})" - credentials_file = ::Registration::Helpers.credentials_from_url(service.url) + credentials_file = Helpers.credentials_from_url(source.url) if credentials_file # TODO FIXME: SCC currenly does not return credentials for the service, # just reuse the global credentials and save to a different file - credentials.file = credentials_file - credentials.write + service_credentials = credentials.dup + service_credentials.file = credentials_file + service_credentials.write end # add a new service or update the existing service - if Pkg.ServiceAliases.include?(service.name) - log.info "Updating existing service: #{service.name}" - if !Pkg.ServiceSet(service.name, { - "alias" => service.name, - "name" => service.name, - "url" => service.url.to_s, + if Pkg.ServiceAliases.include?(source.name) + log.info "Updating existing service: #{source.name}" + if !Pkg.ServiceSet(source.name, { + "alias" => source.name, + "name" => source.name, + "url" => source.url.to_s, "enabled" => true, "autorefresh" => true, }) ## error message - raise ::Registration::ServiceError.new(N_("Updating service '%s' failed."), service.name) + raise ::Registration::ServiceError.new(N_("Updating service '%s' failed."), source.name) end else - log.info "Adding new service: #{service.name}" - if !Pkg.ServiceAdd(service.name, service.url.to_s) + log.info "Adding new service: #{source.name}" + if !Pkg.ServiceAdd(source.name, source.url.to_s) # error message - raise ::Registration::ServiceError.new(N_("Adding service '%s' failed."), service.name) + raise ::Registration::ServiceError.new(N_("Adding service '%s' failed."), source.name) end end # refresh works only for saved services - if !Pkg.ServiceSave(service.name) + if !Pkg.ServiceSave(source.name) # error message - raise ::Registration::ServiceError.new(N_("Saving service '%s' failed."), service.name) + raise ::Registration::ServiceError.new(N_("Saving service '%s' failed."), source.name) end - if !Pkg.ServiceRefresh(service.name) + if !Pkg.ServiceRefresh(source.name) # error message - raise ::Registration::ServiceError.new(N_("Refreshing service '%s' failed."), service.name) + raise ::Registration::ServiceError.new(N_("Refreshing service '%s' failed."), source.name) end end ensure @@ -180,7 +181,7 @@ end # get list of repositories belonging to registered services - # @param product_services [ArraySccApi::ProductServices] added services + # @param product_services [ArraySUSE::Connect::Service] added services # @param only_updates [Boolean] return only update repositories # @return [Array<Hash>] list of repositories def self.service_repos(product_services, only_updates: false) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/yast/scc_api.rb new/yast2-registration-3.1.38/src/lib/yast/scc_api.rb --- old/yast2-registration-3.1.37/src/lib/yast/scc_api.rb 2014-04-22 09:28:27.000000000 +0200 +++ new/yast2-registration-3.1.38/src/lib/yast/scc_api.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,31 +0,0 @@ -# encoding: utf-8 - -# *************************************************************************** -# -# Copyright (c) 2014 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, contact Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, -# you may find current contact information at www.novell.com -# -# *************************************************************************** -# -# Summary: SCC API initialization -# - -require "scc_api" -require "yast/logger" - -SccApi::GlobalLogger.instance.log = Yast::Y2Logger.instance diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/src/lib/yast/suse_connect.rb new/yast2-registration-3.1.38/src/lib/yast/suse_connect.rb --- old/yast2-registration-3.1.37/src/lib/yast/suse_connect.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-3.1.38/src/lib/yast/suse_connect.rb 2014-04-23 13:21:07.000000000 +0200 @@ -0,0 +1,31 @@ +# encoding: utf-8 + +# *************************************************************************** +# +# Copyright (c) 2014 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +# *************************************************************************** +# +# Summary: SUSE Connect API initialization +# + +require "suse/connect" +require "yast/y2logger" + +SUSE::Connect::GlobalLogger.instance.log = Yast::Y2Logger.instance diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/test/Makefile.am new/yast2-registration-3.1.38/test/Makefile.am --- old/yast2-registration-3.1.37/test/Makefile.am 2014-04-22 09:28:27.000000000 +0200 +++ new/yast2-registration-3.1.38/test/Makefile.am 2014-04-23 13:21:07.000000000 +0200 @@ -2,8 +2,9 @@ addon_spec.rb \ discover_registration_services_test.rb \ helpers_spec.rb \ - scc_test.rb \ inst_scc_test.rb \ + registration_spec.rb \ + scc_test.rb \ sw_mgmt_spec.rb TEST_EXTENSIONS = .rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/test/registration_spec.rb new/yast2-registration-3.1.38/test/registration_spec.rb --- old/yast2-registration-3.1.37/test/registration_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-3.1.38/test/registration_spec.rb 2014-04-23 13:21:07.000000000 +0200 @@ -0,0 +1,66 @@ +#! /usr/bin/env rspec + +require_relative "spec_helper" +require_relative "yast_stubs" + +describe "Registration::Registration" do + let(:yast_wfm) { double("Yast::Wfm") } + + before do + stub_yast_require + require "registration/registration" + + stub_const("Yast::WFM", yast_wfm) + yast_wfm.stub(:GetLanguage).and_return("en") + end + + describe ".register" do + it "registers the system using the provided registration code" do + username = "user" + password = "password" + reg_code = "reg_code" + + expect(Registration::SwMgmt).to receive(:zypp_config_writable!) + SUSE::Connect::Credentials.any_instance.should_receive(:write) + expect(SUSE::Connect::YaST).to(receive(:announce_system) + .with(hash_including(:token => reg_code)) + .and_return([username, password]) + ) + + Registration::Registration.new.register("email", reg_code, "sles-12-x86_64") + end + end + + describe ".register_products" do + it "registers the selected product and returns added zypp services" do + product = { + "arch" => "x86_64", + "name" => "SLES", + "version" => "12", + "release_type" => "DVD" + } + + source = SUSE::Connect::Source.new("service", "https://example.com") + service = SUSE::Connect::Service.new([source], [], []) + + expect(SUSE::Connect::YaST).to(receive(:activate_product) + .with(hash_including( + :product_ident => { + :name => product["name"], + :version => product["version"], + :arch => product["arch"], + :release_type => product["release_type"] + } + )) + .and_return(service) + ) + expect(Registration::SwMgmt).to receive(:add_services) + expect(SUSE::Connect::Credentials).to receive(:read) + .with(SUSE::Connect::Credentials::GLOBAL_CREDENTIALS_FILE) + + service_list = Registration::Registration.new.register_products([product]) + expect(service_list).to eq([service]) + end + end + +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-3.1.37/test/sw_mgmt_spec.rb new/yast2-registration-3.1.38/test/sw_mgmt_spec.rb --- old/yast2-registration-3.1.37/test/sw_mgmt_spec.rb 2014-04-22 09:28:27.000000000 +0200 +++ new/yast2-registration-3.1.38/test/sw_mgmt_spec.rb 2014-04-23 13:21:07.000000000 +0200 @@ -3,7 +3,7 @@ require_relative "spec_helper" require_relative "yast_stubs" -require "scc_api" +require "suse/connect" describe "Registration::SwMgmt" do let(:yast_pkg) { double("Yast::Pkg") } @@ -91,17 +91,16 @@ describe ".add_services" do let(:service_url) { "https://example.com/foo/bar?credentials=TEST_credentials" } - let(:credentials) { SccApi::Credentials.new("user", "password", "file") } + let(:credentials) { SUSE::Connect::Credentials.new("user", "password", "file") } let(:product_services) do - service = SccApi::Service.new("test", service_url) - SccApi::ProductServices.new([service], [], []) + SUSE::Connect::Service.new({"test" => service_url}, [], []) end before do expect(yast_pkg).to receive(:SourceSaveAll).and_return(true).twice expect(yast_pkg).to receive(:ServiceRefresh).with("test").and_return(true) expect(yast_pkg).to receive(:ServiceSave).with("test").and_return(true) - expect(credentials).to receive(:write) + SUSE::Connect::Credentials.any_instance.should_receive(:write) end it "it creates a new service if the service does not exist yet" do continue with "q"... Checked in at Thu Apr 24 11:35:50 CEST 2014 by ro Remember to have fun... -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org