Hello community,

here is the log from the commit of package yast2-users for openSUSE:Factory 
checked in at 2016-12-03 18:24:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-users (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-users.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-users"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-users/yast2-users.changes  2016-10-18 
13:25:41.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-users.new/yast2-users.changes     
2016-12-03 18:24:44.000000000 +0100
@@ -1,0 +2,14 @@
+Fri Dec  2 12:58:58 UTC 2016 - jreidin...@suse.com
+
+- Set the focus to the first password field to keep the same
+  behavior as before the last change. (for FATE#321754)
+- 3.2.6
+
+-------------------------------------------------------------------
+Thu Dec  1 09:41:59 UTC 2016 - jreidin...@suse.com
+
+- prepare reusable widget for setting root password
+  (needed for FATE#321754)
+- 3.2.5
+
+-------------------------------------------------------------------

Old:
----
  yast2-users-3.2.4.tar.bz2

New:
----
  yast2-users-3.2.6.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-users.spec ++++++
--- /var/tmp/diff_new_pack.FVejGD/_old  2016-12-03 18:24:45.000000000 +0100
+++ /var/tmp/diff_new_pack.FVejGD/_new  2016-12-03 18:24:45.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-users
-Version:        3.2.4
+Version:        3.2.6
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-users-3.2.4.tar.bz2 -> yast2-users-3.2.6.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/package/yast2-users.changes 
new/yast2-users-3.2.6/package/yast2-users.changes
--- old/yast2-users-3.2.4/package/yast2-users.changes   2016-10-11 
18:07:07.000000000 +0200
+++ new/yast2-users-3.2.6/package/yast2-users.changes   2016-12-02 
15:17:22.000000000 +0100
@@ -1,4 +1,18 @@
 -------------------------------------------------------------------
+Fri Dec  2 12:58:58 UTC 2016 - jreidin...@suse.com
+
+- Set the focus to the first password field to keep the same
+  behavior as before the last change. (for FATE#321754)
+- 3.2.6
+
+-------------------------------------------------------------------
+Thu Dec  1 09:41:59 UTC 2016 - jreidin...@suse.com
+
+- prepare reusable widget for setting root password
+  (needed for FATE#321754)
+- 3.2.5
+
+-------------------------------------------------------------------
 Tue Oct 11 15:10:21 UTC 2016 - h...@suse.com
 
 - Fix the invocation of authentication configuration instance
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/package/yast2-users.spec 
new/yast2-users-3.2.6/package/yast2-users.spec
--- old/yast2-users-3.2.4/package/yast2-users.spec      2016-10-11 
18:07:07.000000000 +0200
+++ new/yast2-users-3.2.6/package/yast2-users.spec      2016-12-02 
15:17:22.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-users
-Version:        3.2.4
+Version:        3.2.6
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/src/Makefile.am 
new/yast2-users-3.2.6/src/Makefile.am
--- old/yast2-users-3.2.4/src/Makefile.am       2016-10-11 18:07:07.000000000 
+0200
+++ new/yast2-users-3.2.6/src/Makefile.am       2016-12-02 15:17:22.000000000 
+0100
@@ -67,7 +67,8 @@
   lib/users/encryption_proposal.rb \
   lib/users/ssh_authorized_keys_file.rb \
   lib/users/ssh_authorized_keyring.rb \
-  lib/users/users_database.rb
+  lib/users/users_database.rb \
+  lib/users/widgets.rb
 
 scrconf_DATA = \
   scrconf/uid.scr \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-users-3.2.4/src/lib/users/dialogs/inst_root_first.rb 
new/yast2-users-3.2.6/src/lib/users/dialogs/inst_root_first.rb
--- old/yast2-users-3.2.4/src/lib/users/dialogs/inst_root_first.rb      
2016-10-11 18:07:07.000000000 +0200
+++ new/yast2-users-3.2.6/src/lib/users/dialogs/inst_root_first.rb      
2016-12-02 15:17:22.000000000 +0100
@@ -18,9 +18,12 @@
 # To contact Novell about this file by physical or electronic mail, you may 
find
 # current contact information at www.novell.com.
 # 
------------------------------------------------------------------------------
+
+require "users/widgets"
 require "users/ca_password_validator"
 require "users/local_password"
 
+
 module Yast
   # This library provides a simple dialog for setting new password for the
   # system adminitrator (root) including checking quality of the password
@@ -33,12 +36,9 @@
 
     def run
       Yast.import "UI"
-      Yast.import "GetInstArgs"
       Yast.import "Mode"
-      Yast.import "Popup"
-      Yast.import "Report"
       Yast.import "UsersSimple"
-      Yast.import "Wizard"
+      Yast.import "CWM"
 
       textdomain "users"
 
@@ -48,8 +48,13 @@
       # helpful when testing all manually on a running system
       Wizard.CreateDialog if separate_wizard_needed?
 
-      create_ui
-      ret = handle_ui
+      Wizard.SetTitleIcon("yast-users")
+
+      ret = CWM.show(
+        content,
+        # Title for root-password dialogue
+        caption: _("Password for the System Administrator \"root\""),
+      )
 
       Wizard.CloseDialog if separate_wizard_needed?
 
@@ -59,163 +64,16 @@
   private
 
     # Returns a UI widget-set for the dialog
-    def root_password_ui
-      current_password = UsersSimple.GetRootPassword || ""
-
+    def content
       VBox(
         VStretch(),
         HSquash(
-          VBox(
-            # advise users to remember their new password
-            Left(Label(_("Do not forget what you enter here."))),
-            VSpacing(0.8),
-            Password(
-              Id(:pw1),
-              Opt(:hstretch),
-              # Label: get password for user root
-              _("&Password for root User"),
-              current_password
-            ),
-            VSpacing(0.8),
-            Password(
-              Id(:pw2),
-              Opt(:hstretch),
-              # Label: get same password again for verification
-              _("Con&firm Password"),
-              current_password
-            ),
-            VSpacing(2.4),
-            # text entry label
-            InputField(Opt(:hstretch), _("&Test Keyboard Layout"))
-          )
+          ::Users::PasswordWidget.new
         ),
         VStretch()
       )
     end
 
-    # Returns help for the dialog
-    def root_password_help
-      # help text ( explain what the user "root" is and does ) 1
-      helptext = _(
-        "<p>\n" \
-        "Unlike normal users of the system, who write texts, create\n" \
-        "graphics, or browse the Internet, the user \"root\" exists on\n" \
-        "every system and is called into action whenever\n" \
-        "administrative tasks need to be performed. Only log in as root\n" \
-        "when you need to be the system administrator.\n" \
-        "</p>\n"
-      ).dup <<
-
-      # help text, continued 2
-      _(
-        "<p>\n" \
-        "Because the root user is equipped with extensive permissions, the 
password\n" \
-        "for \"root\" should be chosen carefully. A combination of letters and 
numbers\n" \
-        "is recommended. To ensure that the password was entered correctly,\n" 
\
-        "reenter it in a second field.\n" \
-        "</p>\n"
-      ) <<
-
-      # help text, continued 3
-      _(
-        "<p>\n" \
-        "All the rules for user passwords apply to the \"root\" password:\n" \
-        "Distinguish between uppercase and lowercase. A password should have 
at\n" \
-        "least 5 characters and, as a rule, not contain any accented letters 
or umlauts.\n" \
-        "</p>\n"
-      )
-
-      helptext = helptext + UsersSimple.ValidPasswordHelptext
-
-      # help text, continued 4
-      helptext << _(
-        "<p>\n" \
-        "Do not forget this \"root\" password.\n" \
-        "</p>"
-      )
-
-      helptext << ::Users::CAPasswordValidator.new.help_text
-
-      helptext
-    end
-
-    # Sets the wizard dialog contents
-    def create_ui
-      Wizard.SetTitleIcon("yast-users")
-
-      Wizard.SetContents(
-        # Title for root-password dialogue
-        _("Password for the System Administrator \"root\""),
-        root_password_ui,
-        root_password_help,
-        GetInstArgs.enable_back || Mode.normal,
-        GetInstArgs.enable_next || Mode.normal
-      )
-    end
-
-    # Handles user's input and returns symbol what to do next
-    # @return [Symbol] :next, :back or :abort
-    def handle_ui
-      begin
-        UI.SetFocus(Id(:pw1))
-        ret = Wizard.UserInput
-
-        if ret == :abort || ret == :cancel
-          if Popup.ConfirmAbort(:incomplete)
-            ret = :abort
-          else
-            ret = :try_again
-            next
-          end
-        end
-
-        ret = :next if ret == :accept # from proposal
-
-        if ret == :next
-          password_1 = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value))
-          password_2 = Convert.to_string(UI.QueryWidget(Id(:pw2), :Value))
-
-          if validate_password(password_1, password_2)
-            UsersSimple.SetRootPassword(password_1)
-          else
-            ret = :try_again
-          end
-        end
-      end until ret == :next || ret == :back || ret == :abort
-
-      ret
-    end
-
-    # Validates whether password1 and password2 match and are valid
-    def validate_password(password_1, password_2)
-      if password_1 != password_2
-        # report misspellings of the password
-        Popup.Message(_("The passwords do not match.\nTry again."))
-        return false
-      end
-
-      if password_1.empty?
-        Popup.Error(_("No password entered.\nTry again."))
-        return false
-      end
-
-      error = UsersSimple.CheckPassword(password_1, "local")
-
-      if error != ""
-        Report.Error(error)
-        return false
-      end
-
-      passwd = ::Users::LocalPassword.new(username: "root", plain: password_1)
-      # User can confirm using "invalid" password confirming all the errors
-      if !passwd.valid?
-        errors = passwd.errors + [_("Really use this password?")]
-        return false unless Popup.YesNo(errors.join("\n\n"))
-      end
-
-      return true
-    end
-
     # Returns whether we need/ed to create new UI Wizard
     def separate_wizard_needed?
       Mode.normal
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/src/lib/users/widgets.rb 
new/yast2-users-3.2.6/src/lib/users/widgets.rb
--- old/yast2-users-3.2.4/src/lib/users/widgets.rb      1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-users-3.2.6/src/lib/users/widgets.rb      2016-12-02 
15:17:22.000000000 +0100
@@ -0,0 +1,156 @@
+# encoding: utf-8
+
+# 
------------------------------------------------------------------------------
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+#
+#
+# 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 "cwm/widget"
+
+require "users/ca_password_validator"
+require "users/local_password"
+
+Yast.import "Popup"
+Yast.import "Report"
+Yast.import "UsersSimple"
+
+module Users
+  class PasswordWidget < CWM::CustomWidget
+    def initialize
+      textdomain "users"
+    end
+
+    def contents
+      VBox(
+        # advise users to remember their new password
+        Left(Label(_("Do not forget what you enter here."))),
+        VSpacing(0.8),
+        Password(
+          Id(:pw1),
+          Opt(:hstretch),
+          # Label: get password for user root
+          _("&Password for root User")
+        ),
+        VSpacing(0.8),
+        Password(
+          Id(:pw2),
+          Opt(:hstretch),
+          # Label: get same password again for verification
+          _("Con&firm Password")
+        ),
+        VSpacing(2.4),
+        # text entry label
+        InputField(Opt(:hstretch), _("&Test Keyboard Layout"))
+      )
+    end
+
+    def init
+      # focus on first password, so user can immediately write. Also does not
+      # break openQA current test
+      Yast::UI.SetFocus(Id(:pw1))
+      current_password = Yast::UsersSimple.GetRootPassword
+      return if !current_password || current_password.empty?
+
+      Yast::UI.ChangeWidget(Id(:pw1), :Value, current_password)
+      Yast::UI.ChangeWidget(Id(:pw2), :Value, current_password)
+    end
+
+    def validate
+      password1 = Yast::UI.QueryWidget(Id(:pw1), :Value)
+      password2 = Yast::UI.QueryWidget(Id(:pw2), :Value)
+      if password1 != password2
+        # report misspellings of the password
+        Yast::Popup.Message(_("The passwords do not match.\nTry again."))
+        Yast::UI.SetFocus(Id(:pw2))
+        return false
+      end
+
+      if password1.empty?
+        Yast::Popup.Error(_("No password entered.\nTry again."))
+        Yast::UI.SetFocus(Id(:pw1))
+        return false
+      end
+
+      error = Yast::UsersSimple.CheckPassword(password1, "local")
+
+      if error != ""
+        Yast::Report.Error(error)
+        Yast::UI.SetFocus(Id(:pw1))
+        return false
+      end
+
+      passwd = ::Users::LocalPassword.new(username: "root", plain: password1)
+      # User can confirm using "invalid" password confirming all the errors
+      if !passwd.valid?
+        errors = passwd.errors + [_("Really use this password?")]
+        Yast::UI.SetFocus(Id(:pw1))
+        return false unless Yast::Popup.YesNo(errors.join("\n\n"))
+      end
+
+      return true
+    end
+
+    def store
+      password1 = Yast::UI.QueryWidget(Id(:pw1), :Value)
+      Yast::UsersSimple.SetRootPassword(password1)
+    end
+
+    def help
+      # help text ( explain what the user "root" is and does ) 1
+      helptext = _(
+        "<p>\n" \
+        "Unlike normal users of the system, who write texts, create\n" \
+        "graphics, or browse the Internet, the user \"root\" exists on\n" \
+        "every system and is called into action whenever\n" \
+        "administrative tasks need to be performed. Only log in as root\n" \
+        "when you need to be the system administrator.\n" \
+        "</p>\n"
+      ).dup <<
+
+      # help text, continued 2
+      _(
+        "<p>\n" \
+        "Because the root user is equipped with extensive permissions, the 
password\n" \
+        "for \"root\" should be chosen carefully. A combination of letters and 
numbers\n" \
+        "is recommended. To ensure that the password was entered correctly,\n" 
\
+        "reenter it in a second field.\n" \
+        "</p>\n"
+      ) <<
+
+      # help text, continued 3
+      _(
+        "<p>\n" \
+        "All the rules for user passwords apply to the \"root\" password:\n" \
+        "Distinguish between uppercase and lowercase. A password should have 
at\n" \
+        "least 5 characters and, as a rule, not contain any accented letters 
or umlauts.\n" \
+        "</p>\n"
+      )
+
+      helptext << Yast::UsersSimple.ValidPasswordHelptext
+
+      # help text, continued 4
+      helptext << _(
+        "<p>\n" \
+        "Do not forget this \"root\" password.\n" \
+        "</p>"
+      )
+
+      helptext << ::Users::CAPasswordValidator.new.help_text
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/test/Makefile.am 
new/yast2-users-3.2.6/test/Makefile.am
--- old/yast2-users-3.2.4/test/Makefile.am      2016-10-11 18:07:07.000000000 
+0200
+++ new/yast2-users-3.2.6/test/Makefile.am      2016-12-02 15:17:22.000000000 
+0100
@@ -4,7 +4,8 @@
   lib/users/ca_password_validator_test.rb \
   lib/users/encryption_method_test.rb \
   lib/users/ssh_authorized_keys_file_test.rb \
-  lib/users/users_database_test.rb
+  lib/users/users_database_test.rb \
+  widgets_test.rb
 
 TEST_EXTENSIONS = .rb
 RB_LOG_COMPILER = rspec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-3.2.4/test/widgets_test.rb 
new/yast2-users-3.2.6/test/widgets_test.rb
--- old/yast2-users-3.2.4/test/widgets_test.rb  1970-01-01 01:00:00.000000000 
+0100
+++ new/yast2-users-3.2.6/test/widgets_test.rb  2016-12-02 15:17:22.000000000 
+0100
@@ -0,0 +1,92 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+require "users/widgets"
+
+def stub_widget_value(id, value)
+  allow(Yast::UI).to receive(:QueryWidget).with(Id(id), 
:Value).and_return(value)
+end
+
+describe Users::PasswordWidget do
+  it "has help text" do
+    expect(subject.help).to_not be_empty
+  end
+
+  it "has valid content" do
+    expect(subject.contents).to be_a(Yast::Term)
+  end
+
+  it "initializes password to current value" do
+    pwd = "paranoic"
+    allow(Yast::UsersSimple).to receive(:GetRootPassword).and_return(pwd)
+    expect(Yast::UI).to receive(:ChangeWidget).with(Id(:pw1), :Value, pwd)
+    expect(Yast::UI).to receive(:ChangeWidget).with(Id(:pw2), :Value, pwd)
+
+    subject.init
+  end
+
+  context "validation" do
+    it "reports error if password is empty" do
+      stub_widget_value(:pw1, "")
+      stub_widget_value(:pw2, "")
+
+      expect(Yast::Popup).to receive(:Error)
+      expect(Yast::UI).to receive(:SetFocus).with(Id(:pw1))
+
+      expect(subject.validate).to eq false
+    end
+
+    it "reports error if passwords do not match" do
+      stub_widget_value(:pw1, "a")
+      stub_widget_value(:pw2, "b")
+
+      expect(Yast::Popup).to receive(:Message)
+      expect(Yast::UI).to receive(:SetFocus).with(Id(:pw2))
+
+      expect(subject.validate).to eq false
+    end
+
+    it "reports error if password contain forbidden characters" do
+      stub_widget_value(:pw1, "mimic_forbidden")
+      stub_widget_value(:pw2, "mimic_forbidden")
+
+      expect(Yast::UsersSimple).to 
receive(:CheckPassword).with("mimic_forbidden", "local").
+        and_return("Invalid password")
+      expect(Yast::Report).to receive(:Error)
+      expect(Yast::UI).to receive(:SetFocus).with(Id(:pw1))
+
+      expect(subject.validate).to eq false
+    end
+
+    it "asks for confirmation if password is not strong enough" do
+      stub_widget_value(:pw1, "a")
+      stub_widget_value(:pw2, "a")
+
+      allow(Yast::UsersSimple).to receive(:CheckPassword).and_return("")
+      allow(Users::LocalPassword).to receive(:new).and_return(double(valid?: 
false, errors: ["E"]))
+
+      expect(Yast::UI).to receive(:SetFocus).with(Id(:pw1))
+      expect(Yast::Popup).to receive(:YesNo).and_return(false)
+
+      expect(subject.validate).to eq false
+    end
+
+    it "is valid otherwise" do
+      stub_widget_value(:pw1, "a")
+      stub_widget_value(:pw2, "a")
+
+      allow(Yast::UsersSimple).to receive(:CheckPassword).and_return("")
+      allow(Users::LocalPassword).to receive(:new).and_return(double(valid?: 
true))
+
+      expect(subject.validate).to eq true
+    end
+  end
+
+  it "stores its value" do
+    stub_widget_value(:pw1, "new cool password")
+
+    expect(Yast::UsersSimple).to receive(:SetRootPassword).with("new cool 
password")
+
+    subject.store
+  end
+end


Reply via email to