lczub / robotframework-magik

Robot Framework high level keywords for automated testing Smallworld Magik images
13 stars 2 forks source link

robot_start_remote_cli should except unconventional localhost address #14

Closed lczub closed 9 years ago

lczub commented 9 years ago

IP determination under sw5 seams to work a little bit different as under sw4. Example local remote cli communication under sw4

MagikSF> remote_cli.new(14002)
$
remote_cli listening on 14002
a remote_cli(server - port 14002)

MagikSF> **** Warnung: Client IKARUS.SC.local(127.0.0.1) port 49235 has opened a remote_cli connection to this image.
     remote_cli_client_allowed(host="IKARUS.SC.local", addr="127.0.0.1", port=49235)

Example local remote cli communication under sw5 (same machine, same windows session)

Magik> remote_cli.new(14002)
a remote_cli(server - port 14002)

remote_cli listening on
Magik> 14002
**** Warnung: Client IKARUS.SC.local(0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1) port 49408
 has attempted a remote_cli connection to this image. Connection was refused.
     remote_cli_client_refused(host="IKARUS.SC.local", addr="0.0.0.0.0.0.0.0.0.0
.0.0.0.0.0.1", port=49408)

Why sw5 detects a different local ip than sw4 is not clear. One reason for unconventional IP might be, that the machine has no connection to the normal domain network (but it has a valid IP in a local network).

Problem is, the normal testing can not start, cause sw5 images does not accept these local telnet connection . As workaround, the script _robot_remotecli can be used in combination with an environment variable _ROBOTHOSTADDR set to "*.0.0.0.1". This will initialize the remote_cli with a special AUTH_PROC for validate the connection.

But the idea of _ROBOTHOSTADDR is, to define valid not local addresses. So it would be better, when _robot_remotecli accept as local adress also the unconventional IP "*.0.0.0.0.0.0.1"

lczub commented 9 years ago

Workaround to start remote_cli with AUTH_PROC without using _robot_remotecli, accepting unconventional local ip

_global example_auth_proc << _proc (hostname, hostaddr)
  ## a customised remote_cli auth_proc
   _if hostaddr = "127.0.0.1" _orif             # default local host ip
       hostaddr.matches?("*.0.0.0.0.0.1") _orif # unconventional local ip under sw5
       hostaddr.matches?("111.222.333.*")       # special authorised none local ip
   _then
      # trust localhost or local network
      _return _true
   _else
      # trust nobody
      _return _false
   _endif
_endproc
$
remote_cli.new(14099, example_auth_proc)
$