Hello community,

here is the log from the commit of package yast2-http-server for 
openSUSE:Factory checked in at 2019-10-16 09:11:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-http-server (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-http-server.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-http-server"

Wed Oct 16 09:11:29 2019 rev:90 rq:738542 version:4.2.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-http-server/yast2-http-server.changes      
2019-10-09 15:17:38.452779082 +0200
+++ 
/work/SRC/openSUSE:Factory/.yast2-http-server.new.2352/yast2-http-server.changes
    2019-10-16 09:11:30.556051481 +0200
@@ -1,0 +2,6 @@
+Tue Oct 15 07:51:21 UTC 2019 - Martin Vidner <[email protected]>
+
+- Add tests for the previous fix (bsc#1148763, bsc#1145538)
+- 4.2.3
+
+-------------------------------------------------------------------

Old:
----
  yast2-http-server-4.2.2.tar.bz2

New:
----
  yast2-http-server-4.2.3.tar.bz2

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

Other differences:
------------------
++++++ yast2-http-server.spec ++++++
--- /var/tmp/diff_new_pack.jhfl40/_old  2019-10-16 09:11:31.116050038 +0200
+++ /var/tmp/diff_new_pack.jhfl40/_new  2019-10-16 09:11:31.120050027 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-http-server
-Version:        4.2.2
+Version:        4.2.3
 Release:        0
 Summary:        YaST2 - HTTP Server Configuration
 License:        GPL-2.0-only
@@ -39,6 +39,7 @@
 BuildRequires:  yast2-packagemanager-devel
 BuildRequires:  yast2-perl-bindings
 BuildRequires:  yast2-testsuite
+BuildRequires:  rubygem(%rb_default_ruby_abi:rspec)
 
 # Yast2::ServiceWidget
 BuildRequires:  yast2 >= 4.1.0
@@ -68,6 +69,7 @@
 %files
 %{yast_schemadir}
 %{yast_yncludedir}
+%{yast_libdir}
 %{yast_clientdir}
 %{yast_moduledir}
 %{yast_desktopdir}

++++++ yast2-http-server-4.2.2.tar.bz2 -> yast2-http-server-4.2.3.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-http-server-4.2.2/package/yast2-http-server.changes 
new/yast2-http-server-4.2.3/package/yast2-http-server.changes
--- old/yast2-http-server-4.2.2/package/yast2-http-server.changes       
2019-10-04 13:07:05.000000000 +0200
+++ new/yast2-http-server-4.2.3/package/yast2-http-server.changes       
2019-10-15 10:02:45.000000000 +0200
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Oct 15 07:51:21 UTC 2019 - Martin Vidner <[email protected]>
+
+- Add tests for the previous fix (bsc#1148763, bsc#1145538)
+- 4.2.3
+
+-------------------------------------------------------------------
 Fri Oct  4 08:48:05 UTC 2019 - Martin Vidner <[email protected]>
 
 - Really import the missing namespace (bsc#1148763, bsc#1145538)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-http-server-4.2.2/package/yast2-http-server.spec 
new/yast2-http-server-4.2.3/package/yast2-http-server.spec
--- old/yast2-http-server-4.2.2/package/yast2-http-server.spec  2019-10-04 
13:07:05.000000000 +0200
+++ new/yast2-http-server-4.2.3/package/yast2-http-server.spec  2019-10-15 
10:02:45.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-http-server
-Version:        4.2.2
+Version:        4.2.3
 Release:        0
 Summary:        YaST2 - HTTP Server Configuration
 Group:          System/YaST
@@ -38,6 +38,7 @@
 BuildRequires:  yast2-perl-bindings
 BuildRequires:  yast2-testsuite libzio
 BuildRequires:  yast2-devtools >= 4.2.2
+BuildRequires:  rubygem(%rb_default_ruby_abi:rspec)
 
 # Yast2::ServiceWidget
 BuildRequires:  yast2 >= 4.1.0
@@ -68,6 +69,7 @@
 %files
 %{yast_schemadir}
 %{yast_yncludedir}
+%{yast_libdir}
 %{yast_clientdir}
 %{yast_moduledir}
 %{yast_desktopdir}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-http-server-4.2.2/src/Makefile.am 
new/yast2-http-server-4.2.3/src/Makefile.am
--- old/yast2-http-server-4.2.2/src/Makefile.am 2019-10-04 13:07:05.000000000 
+0200
+++ new/yast2-http-server-4.2.3/src/Makefile.am 2019-10-15 10:02:45.000000000 
+0200
@@ -28,6 +28,10 @@
   include/http-server/routines.rb \
   include/http-server/helps.rb
 
+ylibclientdir = @ylibdir@/http-server/clients
+ylibclient_DATA = \
+  lib/http-server/clients/main.rb
+
 scrconf_DATA = \
   scrconf/cfg_http_server.scr
 
@@ -48,6 +52,6 @@
 scalable_DATA = \
   icons/hicolor/scalable/apps/yast-http-server.svg
 
-EXTRA_DIST = $(module_DATA) $(module1_DATA) $(module2_DATA) $(client_DATA) 
$(ynclude_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(schemafiles_DATA) 
$(desktop_DATA) $(symbolic_DATA) $(scalable_DATA)
+EXTRA_DIST = $(module_DATA) $(module1_DATA) $(module2_DATA) $(client_DATA) 
$(ynclude_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(schemafiles_DATA) 
$(desktop_DATA) $(symbolic_DATA) $(scalable_DATA) $(ylibclient_DATA)
 
 include $(top_srcdir)/Makefile.am.common
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-http-server-4.2.2/src/clients/http-server.rb 
new/yast2-http-server-4.2.3/src/clients/http-server.rb
--- old/yast2-http-server-4.2.2/src/clients/http-server.rb      2019-10-04 
13:07:05.000000000 +0200
+++ new/yast2-http-server-4.2.3/src/clients/http-server.rb      2019-10-15 
10:02:45.000000000 +0200
@@ -1,586 +1,3 @@
-# encoding: utf-8
-
-# File:        clients/http-server.ycp
-# Package:     Configuration of http-server
-# Summary:     Main file
-# Authors:     Stanislav Visnovsky <[email protected]>
-#
-# $Id$
-#
-# Main file for http-server configuration. Uses all other files.
-module Yast
-  class HttpServerClient < Client
-    def main
-      Yast.import "UI"
-
-      #**
-      # <h3>Configuration of the http-server</h3>
-
-      textdomain "http-server"
-
-      Yast.import "CommandLine"
-      Yast.import "YaPI::HTTPD"
-      Yast.import "Popup"
-      Yast.import "Report"
-      Yast.import "Message"
-      Yast.import "Hostname"
-      Yast.import "HttpServerWidgets"
-      Yast.import "HttpServer"
-      Yast.import "YaST::HTTPDData"
-
-      Yast.include self, "http-server/wizards.rb"
-
-
-      @cmdline_description = {
-        "id"         => "http-server",
-        # translators: command line help for HTTP server module
-        "help"       => _(
-          "Configuration of HTTP server (Apache2)"
-        ),
-        "guihandler" => fun_ref(method(:HttpServerSequence), "boolean ()"),
-        "initialize" => fun_ref(HttpServer.method(:Read), "boolean ()"),
-        "finish"     => fun_ref(HttpServer.method(:Write), "boolean ()"),
-        "actions"    => {
-          "configure" => {
-            # translators: help text for configure command line action
-            "help"    => _(
-              "Configure host settings"
-            ),
-            "handler" => fun_ref(
-              method(:ConfigureHandler),
-              "boolean (map <string, any>)"
-            )
-          },
-          "modules"   => {
-            # translators: help text for modules command line action
-            "help"    => _(
-              "Configure the Apache2 server modules"
-            ),
-            "handler" => fun_ref(
-              method(:ModulesHandler),
-              "boolean (map <string, string>)"
-            )
-          },
-          "listen"    => {
-            # translators: help text for listen command line action
-            "help"    => _(
-              "Set up the ports and network addresses where the server should 
listen."
-            ),
-            "handler" => fun_ref(
-              method(:ListenHandler),
-              "boolean (map <string, string>)"
-            )
-          },
-          "hosts"     => {
-            "help"    => _("Configure virtual hosts"),
-            "handler" => fun_ref(
-              method(:HostsHandler),
-              "boolean (map <string, string>)"
-            )
-          },
-          "mode"      => {
-            "help"    => _("Enable or disable wizard mode."),
-            "handler" => fun_ref(
-              method(:ModeHandler),
-              "boolean (map <string, string>)"
-            )
-          }
-        },
-        "options"    => {
-          "servername"   => {
-            "type" => "fullhostname",
-            # translators: help text for servername option (configure command 
line action)
-            "help" => _(
-              "Server name, for example, www.example.com"
-            )
-          },
-          "serveradmin"  => {
-            "type" => "string",
-            # translators: help text for serveradmin option (configure command 
line action)
-            "help" => _(
-              "E-mail address of the server administrator"
-            )
-          },
-          "documentroot" => {
-            "type" => "string",
-            # translators: help text for documentroot option (configure 
command line action)
-            "help" => _(
-              "Directory where the documents of the server are stored"
-            )
-          },
-          "host"         => {
-            "type" => "string",
-            # translators: help text for host option (configure command line 
action)
-            "help" => _(
-              "Name of the host to configure."
-            )
-          },
-          "add"          => {
-            "type"     => "regex",
-            "typespec" => 
"([[0-9a-f:]+]:[0-9]+)|([0-9]+)|([0-9]+.[0-9]+.[0-9]+.[0-9]+.[0-9]+)",
-            # translators: help text for add subcommand (listen command line 
action)
-            "help"     => _(
-              "Add a new listen entry ([address:]port)"
-            )
-          },
-          "delete"       => {
-            "type"     => "regex",
-            "typespec" => 
"([[0-9a-f:]+]:[0-9]+)|([0-9]+)|([0-9]+.[0-9]+.[0-9]+.[0-9]+.[0-9]+)",
-            # translators: help text for delete subcommand (listen command 
line action)
-            "help"     => _(
-              "Delete an existing listen entry ([address:]port)"
-            )
-          },
-          "list"         => {
-            # translators: help text for list subcommand (listen command line 
action)
-            "help" => _(
-              "List configured entries"
-            )
-          },
-          "enable"       => {
-            "type"     => "regex",
-            "typespec" => ".+(,.+)*",
-            # translators: help text for enable subcommand (modules command 
line action)
-            "help"     => _(
-              "Comma-separated list of modules to enable"
-            )
-          },
-          "disable"      => {
-            "type"     => "regex",
-            "typespec" => ".+(,.+)*",
-            # translators: help text for disable subcommand (modules command 
line action)
-            "help"     => _(
-              "Comma-separated list of modules to disable"
-            )
-          },
-          "create"       => { "help" => _("Create new virtual host") },
-          "remove"       => {
-            "type" => "string",
-            "help" => _("Delete existing virtual host")
-          },
-          "setdefault"   => {
-            "type" => "string",
-            "help" => _("Set selected virtual host as default host")
-          },
-          "wizard"       => {
-            "type" => "string",
-            "help" => _("Set wizard mode \"on\" or \"off\".")
-          }
-        },
-        "mappings"   => {
-          "configure" => [
-            "host",
-            "servername",
-            "serveradmin",
-            "documentroot",
-            "list"
-          ],
-          "modules"   => ["enable", "disable", "list"],
-          "listen"    => ["add", "delete", "list"],
-          "hosts"     => [
-            "create",
-            "servername",
-            "serveradmin",
-            "documentroot",
-            "remove",
-            "setdefault",
-            "list"
-          ],
-          "mode"      => ["wizard"]
-        }
-      }
-
-
-      # The main ()
-      Builtins.y2milestone("----------------------------------------")
-      Builtins.y2milestone("HttpServer module started")
-
-
-      # is this proposal or not?
-      @propose = false
-      @args = WFM.Args
-      if Ops.greater_than(Builtins.size(@args), 0)
-        if Ops.is_path?(WFM.Args(0)) && WFM.Args(0) == path(".propose")
-          Builtins.y2milestone("Using PROPOSE mode")
-          @propose = true
-        end
-      end
-
-      # main ui function
-      @ret = nil
-
-      if @propose
-        @ret = HttpServerAutoSequence()
-      else
-        @ret = CommandLine.Run(@cmdline_description)
-      end
-      Builtins.y2debug("ret=%1", @ret)
-
-      # Finish
-      Builtins.y2milestone("HttpServer module finished")
-      Builtins.y2milestone("----------------------------------------")
-
-      deep_copy(@ret) 
-
-      # EOF
-    end
-
-    # Handler for command line action "configure".
-    #
-    # @param [Hash{String => Object}] options    map of the options provided 
on the command line
-    # @return [Boolean]   true on success
-    def ConfigureHandler(options)
-      options = deep_copy(options)
-      hosts = YaST::HTTPDData.GetHostsList
-
-      if !Builtins.contains(hosts, Ops.get_string(options, "host", ""))
-        if !Builtins.haskey(options, "host")
-          # translators: error message in configure command line action
-          Report.Error(_("Configured host not specified"))
-        else
-          # translators: error message in configure command line action
-          Report.Error(
-            _("Only existing hosts can be specified as the host to configure")
-          )
-        end
-        return false
-      end
-
-      host = Ops.get_string(options, "host", "")
-      hostconfig = YaPI::HTTPD.GetHost(host)
-      if Builtins.haskey(options, "list")
-        CommandLine.Print(
-          Builtins.sformat(
-            "ServerName: %1",
-            HttpServerWidgets.get_host_value("ServerName", hostconfig, "")
-          )
-        )
-        CommandLine.Print(
-          Builtins.sformat(
-            "ServerAdmin: %1",
-            HttpServerWidgets.get_host_value("ServerAdmin", hostconfig, "")
-          )
-        )
-        CommandLine.Print(
-          Builtins.sformat(
-            "DocumentRoot: %1",
-            HttpServerWidgets.get_host_value("DocumentRoot", hostconfig, "")
-          )
-        )
-        return true
-      end
-
-      value = Ops.get_string(options, "servername", "")
-      if value != ""
-        if !Hostname.CheckFQ(value)
-          Report.Error(_("Invalid server name."))
-          return false
-        end
-        hostconfig = HttpServerWidgets.set_host_value(
-          "ServerName",
-          hostconfig,
-          value
-        )
-      end
-
-      value = Ops.get_string(options, "serveradmin", "")
-      if value != ""
-        if !Builtins.regexpmatch(value, ".+@.+")
-          Report.Error(_("Invalid server admin."))
-          return false
-        end
-        hostconfig = HttpServerWidgets.set_host_value(
-          "ServerAdmin",
-          hostconfig,
-          value
-        )
-      end
-
-      value = Ops.get_string(options, "documentroot", "")
-      if value != ""
-        hostconfig = HttpServerWidgets.set_host_value(
-          "DocumentRoot",
-          hostconfig,
-          value
-        )
-      end
-
-      if !HttpServerWidgets.validate_server(
-          Ops.get_string(options, "servername", ""),
-          hostconfig
-        )
-        Report.Error(_("Validate error "))
-        return false
-      end
-
-      YaPI::HTTPD.ModifyHost(host, hostconfig)
-
-      true
-    end
-
-    # Handler for command line action "modules".
-    #
-    # @param [Hash{String => String}] options    map of the options provided 
on the command line
-    # @return [Boolean]   true on success
-    def ModulesHandler(options)
-      options = deep_copy(options)
-      # check the command to be present exactly once
-      command = CommandLine.UniqueOption(options, ["enable", "disable", 
"list"])
-      return false if command == nil
-
-      if command == "enable"
-        mods = Builtins.splitstring(Ops.get(options, "enable", ""), ",")
-        YaPI::HTTPD.ModifyModuleList(mods, true)
-      elsif command == "disable"
-        mods = Builtins.splitstring(Ops.get(options, "disable", ""), ",")
-        YaPI::HTTPD.ModifyModuleList(mods, false)
-      elsif command == "list"
-        # translators: heading for the "modules list" command line action 
output
-        # please, try to align the texts if possible.
-        CommandLine.Print(_("Status \tModule\n=================="))
-
-        enabled = YaPI::HTTPD.GetModuleList
-
-        Builtins.foreach(YaPI::HTTPD.GetKnownModules) do |mod|
-          # translators: status of a module
-          CommandLine.Print(
-            Builtins.sformat(
-              "%1\t%2",
-              # translators: server module status
-              Builtins.contains(enabled, Ops.get_string(mod, "name", "")) ?
-                _("Enabled") :
-                # translators: server module status
-                _("Disabled"),
-              Ops.get_locale(mod, "name", _("unknown"))
-            )
-          )
-        end
-      end
-
-      true
-    end
-
-    # Handler for command line action "listen".
-    #
-    # @param [Hash{String => String}] options    map of the options provided 
on the command line
-    # @return [Boolean]   true on success
-    def ListenHandler(options)
-      options = deep_copy(options)
-      # check the command to be present exactly once
-      command = CommandLine.UniqueOption(options, ["add", "delete", "list"])
-      all_listens = YaST::HTTPDData.GetCurrentListen
-      if command == nil
-        return false
-      elsif command == "list"
-        # translators: heading for the "listen list" command line action output
-        # please, try to align the texts if possible.
-        CommandLine.Print(_("Listen Statements:"))
-        CommandLine.Print("==================")
-        Builtins.foreach(all_listens) do |listen|
-          CommandLine.Print(
-            Builtins.sformat(
-              "%1:%2",
-              Ops.get_locale(listen, "ADDRESS", _("All interfaces")),
-              Ops.get_string(listen, "PORT", "80")
-            )
-          )
-        end
-        return true
-      end
-
-      address = ""
-      port = ""
-      listens = Builtins.splitstring(Ops.get(options, command, ""), ":")
-      if Builtins.size(listens) == 1
-        port = Ops.get_string(listens, 0, "")
-      elsif Builtins.size(listens) == 2
-        address = Ops.get_string(listens, 0, "")
-        port = Ops.get_string(listens, 1, "")
-      else
-        return false
-      end
-
-      finded = false
-      Builtins.foreach(all_listens) do |listen|
-        if Ops.get_string(listen, "ADDRESS", "") == address &&
-            Ops.get_string(listen, "PORT", "") == port
-          finded = true
-        end
-      end
-
-      if command == "add"
-        #FIXME:  check, if new address and port are correct values (if address 
is from machine's interfaces)
-        if Ops.greater_than(Builtins.size(address), 0) &&
-            !Builtins.contains(Builtins.maplist(HttpServer.ip2device) do |ip, 
dev|
-              ip
-            end, address)
-          Report.Error(_("Can use only existing interfaces"))
-          return false
-        end
-        if finded
-          # translators: error message in "listen add" command line action
-          Report.Error(
-            Builtins.sformat(
-              _("The listen statement '%1' is already configured."),
-              Ops.get(options, "add", "")
-            )
-          )
-          return false
-        end
-        YaST::HTTPDData.CreateListen(
-          Builtins.tointeger(port),
-          Builtins.tointeger(port),
-          address
-        )
-        HttpServer.modified = true
-      elsif command == "delete"
-        if !finded
-          # translators: error message in "listen delete" command line action
-          Report.Error(_("Can remove only existing listeners"))
-          return false
-        end
-        YaST::HTTPDData.DeleteListen(
-          Builtins.tointeger(port),
-          Builtins.tointeger(port),
-          address
-        )
-        HttpServer.modified = true
-      end
-      true
-    end
-
-    # Handling hosts dialog
-    # @param [Hash{String => String}] options map to handle
-    # @return [Boolean] correct execution
-    def HostsHandler(options)
-      options = deep_copy(options)
-      # check the command to be present exactly once
-      hosts = YaST::HTTPDData.GetHostsList
-
-      if Builtins.haskey(options, "list")
-        CommandLine.Print(_("Hosts list:"))
-        CommandLine.Print("==================")
-        Builtins.foreach(hosts) { |host| CommandLine.Print(host) }
-        return true
-      end
-
-      # create
-      if Builtins.haskey(options, "create")
-        if !(Builtins.haskey(options, "servername") &&
-            Builtins.haskey(options, "serveradmin") &&
-            Builtins.haskey(options, "documentroot"))
-          Report.Error(_("Some parameter missing"))
-          return false
-        end
-        hostmap = [
-          {
-            "KEY"   => "ServerName",
-            "VALUE" => Ops.get(options, "servername", "")
-          },
-          {
-            "KEY"   => "ServerAdmin",
-            "VALUE" => Ops.get(options, "serveradmin", "")
-          },
-          {
-            "KEY"   => "DocumentRoot",
-            "VALUE" => Ops.get(options, "documentroot", "")
-          },
-          { "KEY" => "VirtualByName", "VALUE" => "1" },
-          { "KEY" => "SSL", "VALUE" => "0" },
-          {
-            "KEY"   => "HostIP",
-            "VALUE" => Ops.get(Builtins.maplist(HttpServer.ip2device) do |ip, 
dev|
-              ip
-            end, 0)
-          }
-        ]
-        if !HttpServerWidgets.validate_server(
-            Ops.get(options, "servername", ""),
-            hostmap
-          )
-          Report.Error(_("Validate error "))
-          return false
-        end
-
-        YaST::HTTPDData.CreateHost(
-          Ops.add(
-            Ops.add(Ops.get(Builtins.maplist(HttpServer.ip2device) { |ip, dev| 
ip }, 0, ""), "/"),
-            Ops.get(options, "servername", "")
-          ),
-          hostmap
-        )
-
-        return false if hostmap == nil
-        HttpServer.modified = true
-        return true
-      end
-      # remove and setdefault
-
-      if !Builtins.contains(hosts, Ops.get(options, "remove", "")) &&
-          !Builtins.contains(hosts, Ops.get(options, "setdefault", ""))
-        Report.Error(_("Argument can be only existing host"))
-        return false
-      end
-
-      if Builtins.haskey(options, "setdefault")
-        if Ops.get(options, "setdefault", "") == "default"
-          Report.Error(_("The host is already default."))
-          return false
-        else
-          CommandLine.Print("Will set default host")
-          host = Ops.get(options, "setdefault", "")
-          Builtins.y2milestone("Changing default host to '%1'", host)
-
-          defhost_options = YaST::HTTPDData.GetHost("default")
-          servername = Convert.to_string(
-            HttpServerWidgets.get_host_value("ServerName", defhost_options, "")
-          )
-          ip = Convert.to_string(
-            HttpServerWidgets.get_host_value("HostIP", defhost_options, "")
-          )
-
-          # move the old default host elsewhere
-          YaST::HTTPDData.CreateHost(
-            Ops.add(Ops.add(ip, "/"), servername),
-            defhost_options
-          )
-          #      YaST::HTTPDData::CreateHost ( res["ip"]:ip + "/" + 
res["name"]:ip, defhost_options );
-          # replace the values of the default host by the new one
-          YaST::HTTPDData.ModifyHost("default", YaST::HTTPDData.GetHost(host))
-          # remove the old non-default host
-          YaST::HTTPDData.DeleteHost(host)
-
-          HttpServer.modified = true
-
-          return true
-        end
-      end
-
-      if Ops.get(options, "remove", "") == "default"
-        Report.Error(_("Cannot delete the default host."))
-        return false
-      else
-        YaST::HTTPDData.DeleteHost(Ops.get(options, "remove", ""))
-      end
-
-      true
-    end
-
-    def ModeHandler(options)
-      options = deep_copy(options)
-      Builtins.y2internal("options %1", options)
-      mode = Ops.get(options, "wizard", "")
-      Builtins.y2internal("mode %1", mode)
-      if Ops.greater_than(Builtins.size(mode), 0)
-        if mode == "on" || mode == "true"
-          HttpServer.setWizardMode(true)
-        else
-          HttpServer.setWizardMode(false)
-        end
-      end
-      true
-    end
-  end
-end
+require "http-server/clients/main"
 
 Yast::HttpServerClient.new.main
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-http-server-4.2.2/src/lib/http-server/clients/main.rb 
new/yast2-http-server-4.2.3/src/lib/http-server/clients/main.rb
--- old/yast2-http-server-4.2.2/src/lib/http-server/clients/main.rb     
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-http-server-4.2.3/src/lib/http-server/clients/main.rb     
2019-10-15 10:02:45.000000000 +0200
@@ -0,0 +1,584 @@
+# encoding: utf-8
+
+# File:        clients/http-server.ycp
+# Package:     Configuration of http-server
+# Summary:     Main file
+# Authors:     Stanislav Visnovsky <[email protected]>
+#
+# $Id$
+#
+# Main file for http-server configuration. Uses all other files.
+module Yast
+  class HttpServerClient < Client
+    def main
+      Yast.import "UI"
+
+      #**
+      # <h3>Configuration of the http-server</h3>
+
+      textdomain "http-server"
+
+      Yast.import "CommandLine"
+      Yast.import "YaPI::HTTPD"
+      Yast.import "Popup"
+      Yast.import "Report"
+      Yast.import "Message"
+      Yast.import "Hostname"
+      Yast.import "HttpServerWidgets"
+      Yast.import "HttpServer"
+      Yast.import "YaST::HTTPDData"
+
+      Yast.include self, "http-server/wizards.rb"
+
+
+      @cmdline_description = {
+        "id"         => "http-server",
+        # translators: command line help for HTTP server module
+        "help"       => _(
+          "Configuration of HTTP server (Apache2)"
+        ),
+        "guihandler" => fun_ref(method(:HttpServerSequence), "boolean ()"),
+        "initialize" => fun_ref(HttpServer.method(:Read), "boolean ()"),
+        "finish"     => fun_ref(HttpServer.method(:Write), "boolean ()"),
+        "actions"    => {
+          "configure" => {
+            # translators: help text for configure command line action
+            "help"    => _(
+              "Configure host settings"
+            ),
+            "handler" => fun_ref(
+              method(:ConfigureHandler),
+              "boolean (map <string, any>)"
+            )
+          },
+          "modules"   => {
+            # translators: help text for modules command line action
+            "help"    => _(
+              "Configure the Apache2 server modules"
+            ),
+            "handler" => fun_ref(
+              method(:ModulesHandler),
+              "boolean (map <string, string>)"
+            )
+          },
+          "listen"    => {
+            # translators: help text for listen command line action
+            "help"    => _(
+              "Set up the ports and network addresses where the server should 
listen."
+            ),
+            "handler" => fun_ref(
+              method(:ListenHandler),
+              "boolean (map <string, string>)"
+            )
+          },
+          "hosts"     => {
+            "help"    => _("Configure virtual hosts"),
+            "handler" => fun_ref(
+              method(:HostsHandler),
+              "boolean (map <string, string>)"
+            )
+          },
+          "mode"      => {
+            "help"    => _("Enable or disable wizard mode."),
+            "handler" => fun_ref(
+              method(:ModeHandler),
+              "boolean (map <string, string>)"
+            )
+          }
+        },
+        "options"    => {
+          "servername"   => {
+            "type" => "fullhostname",
+            # translators: help text for servername option (configure command 
line action)
+            "help" => _(
+              "Server name, for example, www.example.com"
+            )
+          },
+          "serveradmin"  => {
+            "type" => "string",
+            # translators: help text for serveradmin option (configure command 
line action)
+            "help" => _(
+              "E-mail address of the server administrator"
+            )
+          },
+          "documentroot" => {
+            "type" => "string",
+            # translators: help text for documentroot option (configure 
command line action)
+            "help" => _(
+              "Directory where the documents of the server are stored"
+            )
+          },
+          "host"         => {
+            "type" => "string",
+            # translators: help text for host option (configure command line 
action)
+            "help" => _(
+              "Name of the host to configure."
+            )
+          },
+          "add"          => {
+            "type"     => "regex",
+            "typespec" => 
"([[0-9a-f:]+]:[0-9]+)|([0-9]+)|([0-9]+.[0-9]+.[0-9]+.[0-9]+.[0-9]+)",
+            # translators: help text for add subcommand (listen command line 
action)
+            "help"     => _(
+              "Add a new listen entry ([address:]port)"
+            )
+          },
+          "delete"       => {
+            "type"     => "regex",
+            "typespec" => 
"([[0-9a-f:]+]:[0-9]+)|([0-9]+)|([0-9]+.[0-9]+.[0-9]+.[0-9]+.[0-9]+)",
+            # translators: help text for delete subcommand (listen command 
line action)
+            "help"     => _(
+              "Delete an existing listen entry ([address:]port)"
+            )
+          },
+          "list"         => {
+            # translators: help text for list subcommand (listen command line 
action)
+            "help" => _(
+              "List configured entries"
+            )
+          },
+          "enable"       => {
+            "type"     => "regex",
+            "typespec" => ".+(,.+)*",
+            # translators: help text for enable subcommand (modules command 
line action)
+            "help"     => _(
+              "Comma-separated list of modules to enable"
+            )
+          },
+          "disable"      => {
+            "type"     => "regex",
+            "typespec" => ".+(,.+)*",
+            # translators: help text for disable subcommand (modules command 
line action)
+            "help"     => _(
+              "Comma-separated list of modules to disable"
+            )
+          },
+          "create"       => { "help" => _("Create new virtual host") },
+          "remove"       => {
+            "type" => "string",
+            "help" => _("Delete existing virtual host")
+          },
+          "setdefault"   => {
+            "type" => "string",
+            "help" => _("Set selected virtual host as default host")
+          },
+          "wizard"       => {
+            "type" => "string",
+            "help" => _("Set wizard mode \"on\" or \"off\".")
+          }
+        },
+        "mappings"   => {
+          "configure" => [
+            "host",
+            "servername",
+            "serveradmin",
+            "documentroot",
+            "list"
+          ],
+          "modules"   => ["enable", "disable", "list"],
+          "listen"    => ["add", "delete", "list"],
+          "hosts"     => [
+            "create",
+            "servername",
+            "serveradmin",
+            "documentroot",
+            "remove",
+            "setdefault",
+            "list"
+          ],
+          "mode"      => ["wizard"]
+        }
+      }
+
+
+      # The main ()
+      Builtins.y2milestone("----------------------------------------")
+      Builtins.y2milestone("HttpServer module started")
+
+
+      # is this proposal or not?
+      @propose = false
+      @args = WFM.Args
+      if Ops.greater_than(Builtins.size(@args), 0)
+        if Ops.is_path?(WFM.Args(0)) && WFM.Args(0) == path(".propose")
+          Builtins.y2milestone("Using PROPOSE mode")
+          @propose = true
+        end
+      end
+
+      # main ui function
+      @ret = nil
+
+      if @propose
+        @ret = HttpServerAutoSequence()
+      else
+        @ret = CommandLine.Run(@cmdline_description)
+      end
+      Builtins.y2debug("ret=%1", @ret)
+
+      # Finish
+      Builtins.y2milestone("HttpServer module finished")
+      Builtins.y2milestone("----------------------------------------")
+
+      deep_copy(@ret) 
+
+      # EOF
+    end
+
+    # Handler for command line action "configure".
+    #
+    # @param [Hash{String => Object}] options    map of the options provided 
on the command line
+    # @return [Boolean]   true on success
+    def ConfigureHandler(options)
+      options = deep_copy(options)
+      hosts = YaST::HTTPDData.GetHostsList
+
+      if !Builtins.contains(hosts, Ops.get_string(options, "host", ""))
+        if !Builtins.haskey(options, "host")
+          # translators: error message in configure command line action
+          Report.Error(_("Configured host not specified"))
+        else
+          # translators: error message in configure command line action
+          Report.Error(
+            _("Only existing hosts can be specified as the host to configure")
+          )
+        end
+        return false
+      end
+
+      host = Ops.get_string(options, "host", "")
+      hostconfig = YaPI::HTTPD.GetHost(host)
+      if Builtins.haskey(options, "list")
+        CommandLine.Print(
+          Builtins.sformat(
+            "ServerName: %1",
+            HttpServerWidgets.get_host_value("ServerName", hostconfig, "")
+          )
+        )
+        CommandLine.Print(
+          Builtins.sformat(
+            "ServerAdmin: %1",
+            HttpServerWidgets.get_host_value("ServerAdmin", hostconfig, "")
+          )
+        )
+        CommandLine.Print(
+          Builtins.sformat(
+            "DocumentRoot: %1",
+            HttpServerWidgets.get_host_value("DocumentRoot", hostconfig, "")
+          )
+        )
+        return true
+      end
+
+      value = Ops.get_string(options, "servername", "")
+      if value != ""
+        if !Hostname.CheckFQ(value)
+          Report.Error(_("Invalid server name."))
+          return false
+        end
+        hostconfig = HttpServerWidgets.set_host_value(
+          "ServerName",
+          hostconfig,
+          value
+        )
+      end
+
+      value = Ops.get_string(options, "serveradmin", "")
+      if value != ""
+        if !Builtins.regexpmatch(value, ".+@.+")
+          Report.Error(_("Invalid server admin."))
+          return false
+        end
+        hostconfig = HttpServerWidgets.set_host_value(
+          "ServerAdmin",
+          hostconfig,
+          value
+        )
+      end
+
+      value = Ops.get_string(options, "documentroot", "")
+      if value != ""
+        hostconfig = HttpServerWidgets.set_host_value(
+          "DocumentRoot",
+          hostconfig,
+          value
+        )
+      end
+
+      if !HttpServerWidgets.validate_server(
+          Ops.get_string(options, "servername", ""),
+          hostconfig
+        )
+        Report.Error(_("Validate error "))
+        return false
+      end
+
+      YaPI::HTTPD.ModifyHost(host, hostconfig)
+
+      true
+    end
+
+    # Handler for command line action "modules".
+    #
+    # @param [Hash{String => String}] options    map of the options provided 
on the command line
+    # @return [Boolean]   true on success
+    def ModulesHandler(options)
+      options = deep_copy(options)
+      # check the command to be present exactly once
+      command = CommandLine.UniqueOption(options, ["enable", "disable", 
"list"])
+      return false if command == nil
+
+      if command == "enable"
+        mods = Builtins.splitstring(Ops.get(options, "enable", ""), ",")
+        YaPI::HTTPD.ModifyModuleList(mods, true)
+      elsif command == "disable"
+        mods = Builtins.splitstring(Ops.get(options, "disable", ""), ",")
+        YaPI::HTTPD.ModifyModuleList(mods, false)
+      elsif command == "list"
+        # translators: heading for the "modules list" command line action 
output
+        # please, try to align the texts if possible.
+        CommandLine.Print(_("Status \tModule\n=================="))
+
+        enabled = YaPI::HTTPD.GetModuleList
+
+        Builtins.foreach(YaPI::HTTPD.GetKnownModules) do |mod|
+          # translators: status of a module
+          CommandLine.Print(
+            Builtins.sformat(
+              "%1\t%2",
+              # translators: server module status
+              Builtins.contains(enabled, Ops.get_string(mod, "name", "")) ?
+                _("Enabled") :
+                # translators: server module status
+                _("Disabled"),
+              Ops.get_locale(mod, "name", _("unknown"))
+            )
+          )
+        end
+      end
+
+      true
+    end
+
+    # Handler for command line action "listen".
+    #
+    # @param [Hash{String => String}] options    map of the options provided 
on the command line
+    # @return [Boolean]   true on success
+    def ListenHandler(options)
+      options = deep_copy(options)
+      # check the command to be present exactly once
+      command = CommandLine.UniqueOption(options, ["add", "delete", "list"])
+      all_listens = YaST::HTTPDData.GetCurrentListen
+      if command == nil
+        return false
+      elsif command == "list"
+        # translators: heading for the "listen list" command line action output
+        # please, try to align the texts if possible.
+        CommandLine.Print(_("Listen Statements:"))
+        CommandLine.Print("==================")
+        Builtins.foreach(all_listens) do |listen|
+          CommandLine.Print(
+            Builtins.sformat(
+              "%1:%2",
+              Ops.get_locale(listen, "ADDRESS", _("All interfaces")),
+              Ops.get_string(listen, "PORT", "80")
+            )
+          )
+        end
+        return true
+      end
+
+      address = ""
+      port = ""
+      listens = Builtins.splitstring(Ops.get(options, command, ""), ":")
+      if Builtins.size(listens) == 1
+        port = Ops.get_string(listens, 0, "")
+      elsif Builtins.size(listens) == 2
+        address = Ops.get_string(listens, 0, "")
+        port = Ops.get_string(listens, 1, "")
+      else
+        return false
+      end
+
+      finded = false
+      Builtins.foreach(all_listens) do |listen|
+        if Ops.get_string(listen, "ADDRESS", "") == address &&
+            Ops.get_string(listen, "PORT", "") == port
+          finded = true
+        end
+      end
+
+      if command == "add"
+        #FIXME:  check, if new address and port are correct values (if address 
is from machine's interfaces)
+        if Ops.greater_than(Builtins.size(address), 0) &&
+            !Builtins.contains(Builtins.maplist(HttpServer.ip2device) do |ip, 
dev|
+              ip
+            end, address)
+          Report.Error(_("Can use only existing interfaces"))
+          return false
+        end
+        if finded
+          # translators: error message in "listen add" command line action
+          Report.Error(
+            Builtins.sformat(
+              _("The listen statement '%1' is already configured."),
+              Ops.get(options, "add", "")
+            )
+          )
+          return false
+        end
+        YaST::HTTPDData.CreateListen(
+          Builtins.tointeger(port),
+          Builtins.tointeger(port),
+          address
+        )
+        HttpServer.modified = true
+      elsif command == "delete"
+        if !finded
+          # translators: error message in "listen delete" command line action
+          Report.Error(_("Can remove only existing listeners"))
+          return false
+        end
+        YaST::HTTPDData.DeleteListen(
+          Builtins.tointeger(port),
+          Builtins.tointeger(port),
+          address
+        )
+        HttpServer.modified = true
+      end
+      true
+    end
+
+    # Handling hosts dialog
+    # @param [Hash{String => String}] options map to handle
+    # @return [Boolean] correct execution
+    def HostsHandler(options)
+      options = deep_copy(options)
+      # check the command to be present exactly once
+      hosts = YaST::HTTPDData.GetHostsList
+
+      if Builtins.haskey(options, "list")
+        CommandLine.Print(_("Hosts list:"))
+        CommandLine.Print("==================")
+        Builtins.foreach(hosts) { |host| CommandLine.Print(host) }
+        return true
+      end
+
+      # create
+      if Builtins.haskey(options, "create")
+        if !(Builtins.haskey(options, "servername") &&
+            Builtins.haskey(options, "serveradmin") &&
+            Builtins.haskey(options, "documentroot"))
+          Report.Error(_("Some parameter missing"))
+          return false
+        end
+        hostmap = [
+          {
+            "KEY"   => "ServerName",
+            "VALUE" => Ops.get(options, "servername", "")
+          },
+          {
+            "KEY"   => "ServerAdmin",
+            "VALUE" => Ops.get(options, "serveradmin", "")
+          },
+          {
+            "KEY"   => "DocumentRoot",
+            "VALUE" => Ops.get(options, "documentroot", "")
+          },
+          { "KEY" => "VirtualByName", "VALUE" => "1" },
+          { "KEY" => "SSL", "VALUE" => "0" },
+          {
+            "KEY"   => "HostIP",
+            "VALUE" => Ops.get(Builtins.maplist(HttpServer.ip2device) do |ip, 
dev|
+              ip
+            end, 0)
+          }
+        ]
+        if !HttpServerWidgets.validate_server(
+            Ops.get(options, "servername", ""),
+            hostmap
+          )
+          Report.Error(_("Validate error "))
+          return false
+        end
+
+        YaST::HTTPDData.CreateHost(
+          Ops.add(
+            Ops.add(Ops.get(Builtins.maplist(HttpServer.ip2device) { |ip, dev| 
ip }, 0, ""), "/"),
+            Ops.get(options, "servername", "")
+          ),
+          hostmap
+        )
+
+        return false if hostmap == nil
+        HttpServer.modified = true
+        return true
+      end
+      # remove and setdefault
+
+      if !Builtins.contains(hosts, Ops.get(options, "remove", "")) &&
+          !Builtins.contains(hosts, Ops.get(options, "setdefault", ""))
+        Report.Error(_("Argument can be only existing host"))
+        return false
+      end
+
+      if Builtins.haskey(options, "setdefault")
+        if Ops.get(options, "setdefault", "") == "default"
+          Report.Error(_("The host is already default."))
+          return false
+        else
+          CommandLine.Print("Will set default host")
+          host = Ops.get(options, "setdefault", "")
+          Builtins.y2milestone("Changing default host to '%1'", host)
+
+          defhost_options = YaST::HTTPDData.GetHost("default")
+          servername = Convert.to_string(
+            HttpServerWidgets.get_host_value("ServerName", defhost_options, "")
+          )
+          ip = Convert.to_string(
+            HttpServerWidgets.get_host_value("HostIP", defhost_options, "")
+          )
+
+          # move the old default host elsewhere
+          YaST::HTTPDData.CreateHost(
+            Ops.add(Ops.add(ip, "/"), servername),
+            defhost_options
+          )
+          #      YaST::HTTPDData::CreateHost ( res["ip"]:ip + "/" + 
res["name"]:ip, defhost_options );
+          # replace the values of the default host by the new one
+          YaST::HTTPDData.ModifyHost("default", YaST::HTTPDData.GetHost(host))
+          # remove the old non-default host
+          YaST::HTTPDData.DeleteHost(host)
+
+          HttpServer.modified = true
+
+          return true
+        end
+      end
+
+      if Ops.get(options, "remove", "") == "default"
+        Report.Error(_("Cannot delete the default host."))
+        return false
+      else
+        YaST::HTTPDData.DeleteHost(Ops.get(options, "remove", ""))
+      end
+
+      true
+    end
+
+    def ModeHandler(options)
+      options = deep_copy(options)
+      Builtins.y2internal("options %1", options)
+      mode = Ops.get(options, "wizard", "")
+      Builtins.y2internal("mode %1", mode)
+      if Ops.greater_than(Builtins.size(mode), 0)
+        if mode == "on" || mode == "true"
+          HttpServer.setWizardMode(true)
+        else
+          HttpServer.setWizardMode(false)
+        end
+      end
+      true
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-http-server-4.2.2/test/Makefile.am 
new/yast2-http-server-4.2.3/test/Makefile.am
--- old/yast2-http-server-4.2.2/test/Makefile.am        1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-http-server-4.2.3/test/Makefile.am        2019-10-15 
10:02:45.000000000 +0200
@@ -0,0 +1,7 @@
+TESTS = \
+  http_server_test.rb
+
+TEST_EXTENSIONS = .rb
+RB_LOG_COMPILER = rspec
+VERBOSE = 1
+EXTRA_DIST = $(TESTS)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-http-server-4.2.2/test/http_server_test.rb 
new/yast2-http-server-4.2.3/test/http_server_test.rb
--- old/yast2-http-server-4.2.2/test/http_server_test.rb        1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-http-server-4.2.3/test/http_server_test.rb        2019-10-15 
10:02:45.000000000 +0200
@@ -0,0 +1,18 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+require "http-server/clients/main"
+
+Yast.import "CommandLine"
+
+describe Yast::HttpServerClient do
+  describe "#main" do
+    before do
+      allow(Yast::CommandLine).to receive(:Run)
+    end
+
+    it "does not crash" do
+      expect { subject.main }.to_not raise_error
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-http-server-4.2.2/test/test_helper.rb 
new/yast2-http-server-4.2.3/test/test_helper.rb
--- old/yast2-http-server-4.2.2/test/test_helper.rb     1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-http-server-4.2.3/test/test_helper.rb     2019-10-15 
10:02:45.000000000 +0200
@@ -0,0 +1,58 @@
+# Copyright (c) [2019] 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 SUSE LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+srcdir = File.expand_path("../../src", __FILE__)
+y2dirs = ENV.fetch("Y2DIR", "").split(":")
+ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":")
+
+# Ensure the tests runs with english locales
+ENV["LC_ALL"] = "en_US.UTF-8"
+ENV["LANG"] = "en_US.UTF-8"
+
+# load it early, so other stuffs are not ignored
+if ENV["COVERAGE"]
+  require "simplecov"
+  SimpleCov.start do
+    add_filter "/test/"
+  end
+
+  # track all ruby files under src
+  SimpleCov.track_files("#{srcdir}/**/*.rb")
+
+  # use coveralls for on-line code coverage reporting at Travis CI
+  if ENV["TRAVIS"]
+    require "coveralls"
+    SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
+      SimpleCov::Formatter::HTMLFormatter,
+      Coveralls::SimpleCov::Formatter
+    ]
+  end
+end
+
+require "yast"
+require "yast/rspec"
+
+RSpec.configure do |c|
+  c.extend Yast::I18n # available in context/describe
+  c.include Yast::I18n
+
+  c.mock_with :rspec do |mocks|
+    mocks.verify_partial_doubles = true
+  end
+end


Reply via email to