teuton 2.9.2 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06e0c0a5f8d4ac08060478f7cb9eb10b3026873f8161eb78c39e8af72906df82
4
- data.tar.gz: b8d7b1b3bed7e487c4cfc202661f723d4cf4191166addb3e904f5b457911fbf2
3
+ metadata.gz: 6df4861135eb226e52818814c68af43772f58cd196c5cd8008572a4bbaa26065
4
+ data.tar.gz: fe68c2d388c2e506641addcb32476c8de97c77224d50333a8026e2fc263656a2
5
5
  SHA512:
6
- metadata.gz: 8abad1b079988ca544d1a96bbf8883c904b53854de1819bab42d93be1f6cd8c1f755b5967dccbb4b5b01ddd9e02877e715be5a327e8af401bca03e015b85e850
7
- data.tar.gz: 5f50a3a06135fcfd57749da9075965a84cb33645cb6aed458ee94b44b8c688b54df750e7a2c8f658189b1dfbcd1d8bb778ead8c46542090f5a7eb23e7da2e61d
6
+ metadata.gz: 3b853fecce334497ee93d289e90f67ce8ab1d6f3f78d67072d0ed424df431e1e967a3f529c20cec4089e76d05209b7854f1d311115ec5e385185bcbf6d8cacb5
7
+ data.tar.gz: 56d989afeeca6f82b9f03a8a3d1613814db19e47df0d4e301934affa03e8faff033c7d85a6c60d14b04b9764ca56392db66659d5238cb314f204594b07393676
@@ -107,3 +107,22 @@ DSL send:
107
107
  ## [2.9.1] 20231117
108
108
 
109
109
  - [FIX] Config option `tt_include` doubled readed data on Windows platforms.
110
+
111
+ ## [2.9.2] 20231201
112
+
113
+ - [FIX] Change error message when running a non-existent challenge
114
+ ```
115
+ ❯ teuton run example/foo
116
+ [ERROR] Cannot find main file!
117
+ /home/username/example/foo/start.rb
118
+ or /home/username/example/foo.rb
119
+ ```
120
+
121
+ ## [2.9.3] 20250402
122
+
123
+ - [FIX] Error with telnet connections.
124
+
125
+ ## [2.9.4] 20250410
126
+
127
+ - [FIX] Improve the markdown output of the readme.
128
+ - [FIX] Telnet exitcode
@@ -2,14 +2,14 @@
2
2
 
3
3
  # Installation
4
4
 
5
- There are 2 types of nodes/hosts, so there are 2 installations:
5
+ There are 2 types of nodes (hosts), so there are 2 installations:
6
6
 
7
7
  | ID | Software | Description |
8
8
  | -- | -------- | ----------- |
9
9
  | **T-node** | [Teuton installation](t-node.md) | T-NODE host monitors one or severals S-NODE hosts |
10
10
  | **S-node** | [SSH server installation](s-node.md) | S-NODE hosts are monitorized by T-NODE host |
11
11
 
12
- Read [modes of use](modes_of_use.md) to know more about differents T-NODE/S-NODE schemes.
12
+ > Read [modes of use](modes_of_use.md) to know more about differents T-NODE/S-NODE schemes.
13
13
 
14
14
  ## Tested OS list
15
15
 
@@ -38,4 +38,4 @@ There are diferents Teuton [Modes of use](Modes of use). For every mode there ar
38
38
 
39
39
  * Install SSH server on your host.
40
40
 
41
- > How to [install SSH on Windows](windows-ssh)
41
+ > How to [install SSH on Windows](s-node.md)
@@ -11,7 +11,7 @@ Install SSH server on every machine with S-NODE role.
11
11
  Run this command as `root` user:
12
12
 
13
13
  ```bash
14
- wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/linux_s-node_install.sh | bash
14
+ wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/s-node_install.sh | bash
15
15
  ```
16
16
 
17
17
  **S-node Windows installation**
@@ -23,7 +23,7 @@ Requirements:
23
23
  Run this command on **PowerShell (PS)** as `Administrator` user:
24
24
 
25
25
  ```powershell
26
- Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/windows_s-node_install.ps1'))
26
+ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/s-node_install.ps1'))
27
27
  ```
28
28
 
29
29
  **S-node Mac OS X installation**
@@ -31,5 +31,5 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.We
31
31
  Run this command as `root` user:
32
32
 
33
33
  ```bash
34
- curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/macosx_s-node_install.sh | bash
34
+ curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/s-node_install.sh | bash
35
35
  ```
@@ -4,24 +4,19 @@
4
4
 
5
5
  # 1. Recommended
6
6
 
7
- **Installation**
8
-
7
+ Installation:
9
8
  1. Install Ruby on your system.
10
9
  2. `gem install teuton`
11
10
 
12
11
  Run `teuton version` to check the installed version.
13
12
 
14
- **Update**
15
-
16
- `gem teuton update`.
17
-
18
- **Uninstall**
19
-
20
- `gem uninstall teuton`.
13
+ > NOTE:
14
+ > * Update: `gem update teuton`.
15
+ > * Uninstall: `gem uninstall teuton`.
21
16
 
22
17
  # 2. Problems
23
18
 
24
- Don't find `teuton` command (OpenSUSE distro, for example), try this:
19
+ Sometimes we don't find `teuton` command (OpenSUSE distro, for example), so try this:
25
20
 
26
21
  Option A:
27
22
  * `ruby -v`, display your current ruby version. Suppose it is "2.5".
@@ -40,7 +35,7 @@ If you don't know how to install Ruby on your system, execute this script to run
40
35
  Run this command as `root` user:
41
36
 
42
37
  ```bash
43
- wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/linux_t-node_install.sh | bash
38
+ wget -qO- https://raw.githubusercontent.com/teuton-software/teuton/master/install/linux/t-node_install.sh | bash
44
39
  ```
45
40
 
46
41
  **T-node Windows installation**
@@ -52,7 +47,7 @@ Requirements:
52
47
  Run this command on **PowerShell (PS)** as `Administrator` user:
53
48
 
54
49
  ```powershell
55
- Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/windows_t-node_install.ps1'))
50
+ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/teuton-software/teuton/master/install/windows/t-node_install.ps1'))
56
51
  ```
57
52
 
58
53
  **T-node Mac OS X installation**
@@ -60,7 +55,7 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.We
60
55
  Run this command as admin user (member of `admin` group):
61
56
 
62
57
  ```bash
63
- curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/macosx_t-node_install.sh | bash
58
+ curl -sL https://raw.githubusercontent.com/teuton-software/teuton/master/install/mac/t-node_install.sh | bash
64
59
  ```
65
60
 
66
61
  # 4. Vagrant/Docker
@@ -8,7 +8,7 @@ A [target](../dsl/target.md) is a feature you want to check. Targets are defined
8
8
 
9
9
  * [target](dsl/target.md): Description of the element to be tested.
10
10
  * [run](../dsl/run.md): Execute a command `id obiwan` on localhost.
11
- * [expect](../&dsl/expect.md): Verify that the result contains expected value.
11
+ * [expect](../dsl/expect.md): Verify that the result contains expected value.
12
12
 
13
13
  ```ruby
14
14
  group "Learn about targets" do
@@ -28,17 +28,17 @@ end
28
28
  When the user exists, we expect this words: `uid=, (obiwan), gid=`.
29
29
 
30
30
  ```
31
- id obiwan
31
+ > id obiwan
32
32
  uid=1000(obiwan) gid=1000(obiwan) grupos=1000(obiwan)
33
33
  ```
34
34
 
35
35
  But when user does not exist, we expect different words: `id:, vader, no exist`.
36
36
 
37
37
  ```
38
- id vader
38
+ > id vader
39
39
  id: «vader»: no such user
40
40
 
41
- echo $?
41
+ > echo $?
42
42
  1
43
43
 
44
44
  ```
@@ -21,7 +21,7 @@ class Case
21
21
  attr_accessor :conn_status # Updated by ExecuteManager
22
22
 
23
23
  attr_reader :id
24
- attr_reader :config # Readed by ExecuteManager
24
+ attr_reader :config # Readed by ExecuteManager
25
25
  attr_reader :uniques
26
26
  attr_reader :skip
27
27
  @@id = "01" # First case ID value
@@ -23,6 +23,8 @@ module DSL
23
23
  @action_counter += 1
24
24
  @action[:id] = @action_counter
25
25
  if @result.exitcode < 0
26
+ # When exitcode is less than zero, it is because there has been
27
+ # an error in the remote connection (SSH or Telnet)
26
28
  @action[:check] = false
27
29
  @action[:result] = @action[:output]
28
30
  else
@@ -5,7 +5,7 @@ module DSL
5
5
  def run_script(script, args = {})
6
6
  items = script.split(" ")
7
7
  if items.size == 1
8
- shell = args[:shell] || ((get(:shell) != "NODATA") ? get(:shell) : nil)
8
+ shell = args[:shell] || (get(:shell) != "NODATA" ? get(:shell) : nil)
9
9
  script = "#{shell} #{script}" if shell
10
10
  script = "#{script} #{args[:args]} " if args[:args]
11
11
  end
@@ -38,8 +38,12 @@ class ExecuteBase
38
38
  def encode_and_split(encoding, text)
39
39
  # Convert text to UTF-8 deleting unknown chars
40
40
  text ||= "" # Ensure text is not nil
41
- flag = [:default, "UTF-8"].include? encoding
42
- return text.encode("UTF-8", invalid: :replace).split("\n") if flag
41
+
42
+ # TODO: text.gsub!('\r', '')
43
+ if [:default, "UTF-8"].include? encoding
44
+ text.encode!("UTF-8", invalid: :replace, :undef => :replace, :replace => '')
45
+ return text.split("\n")
46
+ end
43
47
 
44
48
  # Convert text from input ENCODING to UTF-8
45
49
  ec = Encoding::Converter.new(encoding.to_s, "UTF-8")
@@ -47,9 +51,9 @@ class ExecuteBase
47
51
  text = ec.convert(text)
48
52
  rescue => e
49
53
  puts "[ERROR] #{e}: Declare text encoding..."
50
- puts " run 'command', on: :host, :encoding => 'ISO-8859-1'"
54
+ puts " run 'command', on: :host, encoding: 'ISO-8859-1'"
51
55
  end
52
56
 
53
- text.split("\n")
57
+ text.split("\n").compact
54
58
  end
55
59
  end
@@ -89,6 +89,5 @@ class ExecuteSSH < ExecuteBase
89
89
  end
90
90
  result.exitcode = exitcode
91
91
  result.content = encode_and_split(action[:encoding], text)
92
- result.content.compact!
93
92
  end
94
93
  end
@@ -1,7 +1,7 @@
1
1
  require "net/telnet"
2
- require "rainbow"
2
+ # require "rainbow"
3
3
  require_relative "../../utils/project"
4
- require_relative "../../utils/verbose"
4
+ # require_relative "../../utils/verbose"
5
5
  require_relative "execute_base"
6
6
 
7
7
  class ExecuteTelnet < ExecuteBase
@@ -9,48 +9,55 @@ class ExecuteTelnet < ExecuteBase
9
9
  action[:conn_type] = :telnet
10
10
  hostname = input_hostname.to_s
11
11
  ip = config.get((hostname + "_ip").to_sym)
12
- username = config.get((hostname + "_username").to_sym).to_s
13
- password = config.get((hostname + "_password").to_sym).to_s
12
+ port = config.get((hostname + "_port").to_sym)
13
+ mode = true
14
+ if port.to_i == 0
15
+ port = "23"
16
+ mode = false
17
+ end
14
18
  text = ""
19
+ exitcode = -1
15
20
  begin
16
21
  if sessions[hostname].nil? || sessions[hostname] == :ok
17
22
  h = Net::Telnet.new(
18
23
  "Host" => ip,
24
+ "Port" => port,
25
+ "Telnetmode" => mode,
19
26
  "Timeout" => 30,
20
27
  "Prompt" => /login|teuton|[$%#>]/
21
28
  )
22
29
  # "Prompt" => Regexp.new(username[1, 40]))
23
30
  # "Prompt" => /[$%#>] \z/n)
24
- h.login(username, password)
31
+ unless mode
32
+ username = config.get((hostname + "_username").to_sym).to_s
33
+ password = config.get((hostname + "_password").to_sym).to_s
34
+ h.login(username, password)
35
+ end
25
36
  h.cmd(action[:command]) { |i| text << i }
26
37
  h.close
27
38
  sessions[hostname] = :ok
39
+ exitcode = 0
28
40
  else
29
- text = "TELNET: NO CONNECTION!"
41
+ text = "Telnet: NO CONNECTION!"
30
42
  end
31
43
  rescue Net::OpenTimeout
32
44
  sessions[hostname] = :nosession
33
45
  conn_status[hostname] = :open_timeout
34
- verbose Rainbow(Application.instance.letter[:error]).red.bright
35
46
  log(" ExceptionType=<Net::OpenTimeout> doing <telnet #{ip}>", :error)
36
47
  log(" └── Revise host IP!", :warn)
37
48
  rescue Net::ReadTimeout
38
49
  sessions[hostname] = :nosession
39
50
  conn_status[hostname] = :read_timeout
40
- verbose Rainbow(Application.instance.letter[:error]).red.bright
41
51
  log(" ExceptionType=<Net::ReadTimeout> doing <telnet #{ip}>", :error)
42
52
  rescue => e
43
53
  sessions[hostname] = :nosession
44
54
  conn_status[hostname] = :error
45
- verbose Rainbow(Application.instance.letter[:error]).red.bright
46
55
  log(" ExceptionType=<#{e.class}> doing telnet on <#{username}@#{ip}>" \
47
56
  " exec: #{action[:command]}", :error)
48
57
  log(" └── username=<#{username}>, password=<#{password}>," \
49
58
  " ip=<#{ip}>, HOSTID=<#{hostname}>", :warn)
50
59
  end
51
- output = encode_and_split(action[:encoding], text)
52
- result.exitcode = -1
53
- result.content = output
54
- result.content.compact!
60
+ result.exitcode = exitcode
61
+ result.content = encode_and_split(action[:encoding], text)
55
62
  end
56
63
  end
@@ -6,7 +6,7 @@ require_relative "run"
6
6
  module CheckDSL
7
7
  def log(text = "", type = :info)
8
8
  @stats[:logs] += 1
9
- prefix = (type == :info) ? "" : "#{type.to_s.upcase}: "
9
+ prefix = type == :info ? "" : "#{type.to_s.upcase}: "
10
10
  Logger.info " log #{prefix}" + text.to_s
11
11
  end
12
12
 
@@ -71,8 +71,8 @@ class Readme
71
71
  unless @required_hosts.empty?
72
72
  puts Lang.get(:hosts)
73
73
  puts "\n"
74
- puts "| ID | Host | Configuration |"
75
- puts "| --- | --- | --- |"
74
+ puts "| ID | Host | Configuration |"
75
+ puts "| --- | ---- | ------------- |"
76
76
  @required_hosts.each_pair do |k, v|
77
77
  c = []
78
78
  v.each_pair { |k2, v2| c << "#{k2}=#{v2}" }
@@ -123,15 +123,15 @@ class Readme
123
123
  puts Lang.get(:global_params)
124
124
  puts "\n"
125
125
  puts "| Param | Value |"
126
- puts "| --- | --- |"
126
+ puts "| ----- | ----- |"
127
127
  @global_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
128
128
  end
129
129
  if @setted_params.size.positive?
130
130
  puts Lang.get(:created_params)
131
131
  puts "\n"
132
- puts "| Param | Value |"
133
- puts "| --- | --- |"
134
- @setted_params.each_pair { |k, v| puts "|#{k}|#{v}|" }
132
+ puts "| Param |"
133
+ puts "| ----- |"
134
+ @setted_params.each_pair { |k, v| puts "|#{k}|" }
135
135
  end
136
136
  end
137
137
  end
@@ -85,9 +85,19 @@ module ConfigFileReader
85
85
  begin
86
86
  ext = File.extname(filename)
87
87
  if exts[:yaml].include? ext
88
- data[:cases] << YAML.load(File.open(filename))
88
+ begin
89
+ data[:cases] << YAML.load(File.open(filename))
90
+ rescue
91
+ msg = "[ERROR] Loading configuration file(#{filename})"
92
+ warn msg
93
+ end
89
94
  elsif exts[:json].include? ext
90
- data[:cases] = JSON.parse(File.read(filename), symbolize_names: true)
95
+ begin
96
+ data[:cases] = JSON.parse(File.read(filename), symbolize_names: true)
97
+ rescue
98
+ msg = "[ERROR] Loading configuration file(#{filename})"
99
+ warn msg
100
+ end
91
101
  elsif File.file? filename
92
102
  msg = "[ERROR] Loading configuration files: " \
93
103
  " No yaml/json valid extension " \
@@ -1,5 +1,3 @@
1
- # Development in progress...
2
-
3
1
  require_relative "name_file_finder"
4
2
 
5
3
  class Project
@@ -21,7 +19,7 @@ class Project
21
19
  @project[:ialias] = {} # Hash of Internal alias
22
20
  @project[:macros] = {} # Hash of macros
23
21
  @project[:groups] = [] # Array of groups
24
- @project[:uses] = [] # TODO: Array of files used
22
+ @project[:uses] = [] # TODO: Array of used files
25
23
  @project[:hall_of_fame] = []
26
24
  end
27
25
 
@@ -1,5 +1,5 @@
1
1
  module Teuton
2
- VERSION = "2.9.2"
2
+ VERSION = "2.9.4"
3
3
  APPNAME = "teuton"
4
4
  GEMNAME = "teuton"
5
5
  DOCKERNAME = "dvarrui/#{GEMNAME}"
data/lib/teuton.rb CHANGED
@@ -22,7 +22,6 @@ module Teuton
22
22
  end
23
23
 
24
24
  def self.run(projectpath, options = {})
25
- # Application.instance.add_input_params(projectpath, options)
26
25
  Project.add_input_params(projectpath, options)
27
26
  require_dsl_and_script("teuton/case_manager/dsl") # Define DSL
28
27
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
10
+ date: 2025-04-10 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rainbow
@@ -44,14 +43,14 @@ dependencies:
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '7.0'
46
+ version: '7.2'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '7.0'
53
+ version: '7.2'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: net-telnet
57
56
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +71,28 @@ dependencies:
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '2.6'
74
+ version: '2.8'
76
75
  type: :runtime
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '2.6'
81
+ version: '2.8'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: thor
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - "~>"
88
87
  - !ruby/object:Gem::Version
89
- version: '1.2'
88
+ version: '1.3'
90
89
  type: :runtime
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - "~>"
95
94
  - !ruby/object:Gem::Version
96
- version: '1.2'
95
+ version: '1.3'
97
96
  - !ruby/object:Gem::Dependency
98
97
  name: terminal-table
99
98
  requirement: !ruby/object:Gem::Requirement
@@ -351,7 +350,6 @@ homepage: https://github.com/teuton-software/teuton
351
350
  licenses:
352
351
  - GPL-3.0
353
352
  metadata: {}
354
- post_install_message:
355
353
  rdoc_options: []
356
354
  require_paths:
357
355
  - lib
@@ -366,8 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
364
  - !ruby/object:Gem::Version
367
365
  version: '0'
368
366
  requirements: []
369
- rubygems_version: 3.2.33
370
- signing_key:
367
+ rubygems_version: 3.6.2
371
368
  specification_version: 4
372
369
  summary: Teuton (Infrastructure test)
373
370
  test_files: []