teuton 2.1.8 → 2.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -8
  3. data/bin/check_teuton +43 -0
  4. data/docs/changelog/contributions.md +32 -0
  5. data/docs/changelog/v2.1.md +22 -0
  6. data/docs/changelog/v2.2.md +29 -0
  7. data/docs/commands/README.md +105 -7
  8. data/docs/commands/example_check.md +54 -0
  9. data/docs/commands/example_run.md +112 -0
  10. data/docs/dsl/README.md +11 -9
  11. data/docs/dsl/definition/expect.md +25 -21
  12. data/docs/dsl/definition/group.md +5 -1
  13. data/docs/dsl/definition/result.md +45 -34
  14. data/docs/dsl/definition/run_local.md +34 -0
  15. data/docs/dsl/definition/run_remote.md +119 -0
  16. data/docs/dsl/definition/target.md +6 -0
  17. data/docs/dsl/execution/export.md +27 -19
  18. data/docs/dsl/execution/play.md +4 -0
  19. data/docs/dsl/execution/send.md +21 -2
  20. data/docs/dsl/execution/show.md +13 -8
  21. data/docs/dsl/setting/get.md +24 -8
  22. data/docs/dsl/setting/set.md +8 -3
  23. data/docs/install/README.md +19 -26
  24. data/docs/install/modes_of_use.md +27 -26
  25. data/docs/install/scripts.md +53 -36
  26. data/docs/install/vagrant_docker.md +56 -0
  27. data/docs/learn/README.md +13 -6
  28. data/docs/learn/example-01-target.md +78 -61
  29. data/docs/learn/example-02-config.md +152 -0
  30. data/docs/learn/example-03-remote-hosts.md +31 -25
  31. data/docs/learn/example-04-use.md +23 -17
  32. data/docs/learn/example-05-debug.md +24 -17
  33. data/docs/learn/example-06-log.md +70 -0
  34. data/lib/teuton/application.rb +7 -4
  35. data/lib/teuton/case_manager/case/case.rb +4 -1
  36. data/lib/teuton/case_manager/case/dsl/expect.rb +3 -1
  37. data/lib/teuton/case_manager/case/dsl/goto.rb +12 -7
  38. data/lib/teuton/case_manager/case/dsl/macro.rb +38 -0
  39. data/lib/teuton/case_manager/case/dsl/main.rb +1 -2
  40. data/lib/teuton/case_manager/case/dsl/target.rb +1 -1
  41. data/lib/teuton/case_manager/case/runner.rb +7 -7
  42. data/lib/teuton/case_manager/case_manager.rb +1 -20
  43. data/lib/teuton/case_manager/check_cases.rb +12 -2
  44. data/lib/teuton/case_manager/dsl.rb +4 -6
  45. data/lib/teuton/case_manager/export_manager.rb +29 -3
  46. data/lib/teuton/case_manager/report.rb +29 -8
  47. data/lib/teuton/case_manager/show.rb +8 -4
  48. data/lib/teuton/cli.rb +1 -0
  49. data/lib/teuton/cli/play.rb +1 -0
  50. data/lib/teuton/cli/version.rb +1 -4
  51. data/lib/teuton/files/config.yaml +0 -1
  52. data/lib/teuton/files/start.rb +1 -1
  53. data/lib/teuton/files/template/case.html +135 -0
  54. data/lib/teuton/files/template/resume.html +115 -0
  55. data/lib/teuton/project/laboratory/builtin.rb +2 -1
  56. data/lib/teuton/project/laboratory/dsl.rb +13 -15
  57. data/lib/teuton/project/laboratory/laboratory.rb +5 -1
  58. data/lib/teuton/project/laboratory/show.rb +21 -13
  59. data/lib/teuton/project/name_file_finder.rb +6 -1
  60. data/lib/teuton/project/project.rb +7 -3
  61. data/lib/teuton/project/readme/dsl.rb +3 -1
  62. data/lib/teuton/project/readme/readme.rb +37 -26
  63. data/lib/teuton/project/skeleton.rb +20 -4
  64. data/lib/teuton/report/close.rb +15 -11
  65. data/lib/teuton/report/formatter/formatter_factory.rb +10 -6
  66. data/lib/teuton/report/formatter/html_formatter.rb +16 -79
  67. data/lib/teuton/report/formatter/resume_html_formatter.rb +39 -0
  68. data/lib/teuton/report/formatter/resume_yaml_formatter.rb +7 -1
  69. data/lib/teuton/report/report.rb +5 -4
  70. data/lib/teuton/report/show.rb +55 -26
  71. metadata +26 -39
  72. data/docs/changelog/todo.md +0 -46
  73. data/docs/commands/create_skeleton.md +0 -31
  74. data/docs/commands/help.md +0 -13
  75. data/docs/commands/revise_test.md +0 -46
  76. data/docs/commands/run_test_unit.md +0 -78
  77. data/docs/commands/show_version.md +0 -9
  78. data/docs/developers/01-telnet.md +0 -121
  79. data/docs/developers/02-ssh.md +0 -93
  80. data/docs/developers/03-encoding.md +0 -153
  81. data/docs/developers/comparative.md +0 -17
  82. data/docs/dsl/_Sidebar.md +0 -30
  83. data/docs/dsl/definition/goto.md +0 -112
  84. data/docs/dsl/definition/run.md +0 -23
  85. data/docs/install/tested_os.md +0 -25
  86. data/docs/install/vagrant.md +0 -9
  87. data/docs/learn/example-02-configfile.md +0 -174
  88. data/docs/learn/quick-demo.md +0 -170
  89. data/lib/teuton/case_manager/case/dsl/check.rb +0 -24
  90. data/lib/teuton/case_manager/case/dsl/missing.rb +0 -12
  91. data/lib/teuton/files/gitignore +0 -2
data/docs/dsl/README.md CHANGED
@@ -1,5 +1,12 @@
1
+ [<< back](../../README.md)
2
+
3
+ # Teuton language
1
4
 
2
5
  To define and run our activity test we use the next DSL keywords:
6
+ 1. [Definition instructions](#definition-instructions)
7
+ 2. [Execution instructions](#execution-instructions)
8
+ 3. [Setting instructions](#setting-instructions)
9
+ 4. [Ruby language](#ruby-language)
3
10
 
4
11
  ## Definition instructions
5
12
 
@@ -9,13 +16,11 @@ These are the main DSL key words, usefull to define items to be evaluated.
9
16
  | :----------------------------- | :---------- |
10
17
  | [group](definition/group.md) | Define a group of items to check. |
11
18
  | [target](definition/target.md) | Define a target. This is the item to be checked. |
12
- | [goto](definition/goto.md) | Execute command into remote host. |
13
- | [run](definition/run.md) | Execute command into localhost. |
19
+ | Remote [run](definition/run_remote.md)| Execute command into remote host. |
20
+ | Local [run](definition/run_local.md) | Execute command into local host. |
14
21
  | [result](definition/result.md) | Contain the output of previous `goto` order. |
15
22
  | [expect](definition/expect.md) | Check the obtained result with the expected value. |
16
23
 
17
- ---
18
-
19
24
  ## Execution instructions
20
25
 
21
26
  DSL key word related with reports and information.
@@ -27,8 +32,6 @@ DSL key word related with reports and information.
27
32
  | [export](execution/export.md) | Make reports with the results of every evaluation. |
28
33
  | [send](execution/send.md) | Send copy of report file to remote host. |
29
34
 
30
- ---
31
-
32
35
  ## Setting instructions
33
36
 
34
37
  | DSL | Descripción |
@@ -36,10 +39,9 @@ DSL key word related with reports and information.
36
39
  | [get](setting/get.md) | Read param value from configuration file. |
37
40
  | [set](setting/set.md) | Set new param value for running configuration. |
38
41
 
39
- ---
40
42
  ## Ruby language
41
43
 
42
- It is possible to use ruby language programming structures, in the definition of challenges (iterators, arrays, etc.). Very useful when we have repetitive lines.
44
+ It is possible to use ruby language programming structures, in the definition of our test (iterators, arrays, etc.). Useful when we have repetitive lines, etc.
43
45
 
44
46
  Example, how to create 4 target evaluation using an Array:
45
47
  ```ruby
@@ -47,7 +49,7 @@ users = ['Obiwan', 'Yoda', 'Maul', 'Vader']
47
49
 
48
50
  users.each do |user|
49
51
  target "Exist user #{user}"
50
- goto :host1, :exec => "id #{user}"
52
+ run "id #{user}", on: :host1
51
53
  expect_one user
52
54
  end
53
55
  ```
@@ -1,3 +1,10 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
5
+ 3. [Example](#example)
6
+ 4. [Basic](#basic)
7
+ 5. [Advanced](#advanced)
1
8
 
2
9
  ## Description
3
10
 
@@ -23,34 +30,31 @@ run 'id obiwan'
23
30
  expect 'obiwan' # Expect previous command output contains obiwan text
24
31
  ```
25
32
 
26
- ## Other uses
27
-
28
- | Command | Description |
29
- | ---------------------------- | ----------------------------------- |
30
- | expect 'obiwan' | Expect line/s with obiwan |
31
- | expect ['obiwan', 'kenobi' ] | Expect line/s with obiwan and kenobi|
32
- | expect_one 'obiwan' | Expect one line with obiwan |
33
- | expect_one ['obiwan','kenobi'] | Expect one line with obiwan and kenobi |
34
- | expect_none 'obiwan' | Expect no line with obiwan |
35
- | expect_none ['obiwan', 'kenobi' ] | Expect no line with obiwan and kenobi |
33
+ ## Basic
36
34
 
35
+ * **expect 'obiwan'**, expect line/s with "obiwan".
36
+ * **expect ['obiwan', 'kenobi'**, expect line/s with "obiwan" and kenobi".
37
+ * **expect_one 'obiwan'**, expect only one line with "obiwan".
38
+ * **expect_one ['obiwan','kenobi']**, expect only one line with "obiwan" and "kenobi".
39
+ * **expect_none 'obiwan'**, expect no line with "obiwan".
40
+ * **expect_none ['obiwan', 'kenobi']**, expect no line with "obiwan" and "kenobi".
37
41
  * **expect /Obiwan|obi-wan/**, Expect line/s with Obiwan or obi-wan. This example uses regular expresions.
38
42
 
39
- ---
40
-
41
- ## Expert mode
43
+ ## Advanced
42
44
 
43
- After every execution keyword (`goto`, or `run`), we get command outputs and save it into `result` object. So we can ask to `result` to create more complex evaluations.
45
+ After every execution keyword (`run`, `on` or `goto`), command outputs is saved by **result** object. Use **result** to create more complex evaluations.
44
46
 
45
47
  For example, if we have this execution
48
+
46
49
  ```ruby
47
50
  target 'Exist user vader'
48
- run 'cat /etc/passwd'
51
+ run 'cat /etc/passwd'
49
52
  ```
50
53
 
51
- Then we check result with
52
- ```ruby
53
- expect result.find("vader").count.eq(1)
54
- expect result.find(/Darth|darth/).find(/Vader|vader/).count.eq(1)
55
- expect result.not_find('#').find(/vader).count.eq(1)
56
- ```
54
+ Then we check result with:
55
+
56
+ * **expect result.find("vader").count.eq(1)**, expect there exists only 1 line with "vader" text.
57
+ * **expect result.find(/Darth|darth/).find(/Vader|vader/).count.gt(2)**, expect there exists more than 2 lines with texts "Darth" and "Vader".
58
+ * **expect result.not_find('#').find('vader').count.lt(3)**, expects there exists less than 3 lines with text "vader" and without "#" symbol.
59
+
60
+ Read [result](result.md) documentation.
@@ -1,3 +1,7 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
1
5
 
2
6
  ## Description
3
7
 
@@ -6,7 +10,7 @@ Groups targets/goals.
6
10
  ## Usage
7
11
 
8
12
  ```ruby
9
- group "group_name" do
13
+ group "Group name" do
10
14
  ...
11
15
  end
12
16
  ```
@@ -1,26 +1,59 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Example 1](#example-1)
5
+ 3. [Example 2](#example-2)
6
+ 4. [Functions](#functions)
1
7
 
2
8
  ## Description
3
9
 
4
- `result` saves the output from previous execution.
10
+ **result** object saves the output from previous execution.
5
11
  It is usefull to build advanced `expect result...` sentences.
6
12
 
7
- * After every execution (For example, `goto :host1, :exec => "whoami"`), Teuton gets output and saves it into `result` object.
8
- * Use `result` object to read or filter that output.
13
+ After every execution (For example, `run "whoami", on: :host1`), Teuton gets output and saves it into **result** object. Then use **result** object to read or filter previous command output.
14
+
15
+ ## Example 1
9
16
 
10
- ## Usage
17
+ This example:
18
+ 1. get `/etc/passwd` file from `host1`, then
19
+ 2. filter lines without `#` and with `/bin/bash`.
20
+ 3. count lines number and
21
+ 4. expect it to be greater that 6.
11
22
 
12
- This example get /etc/passwd file from host1, then filter lines without '#' and with '/bin/bash'.
13
- Count lines number and expect it to be greater that 6.
23
+ Let's see:
14
24
 
15
25
  ```
16
- target "Active users number configured with bash > 6"
17
- goto :host1, :exec => "cat /etc/passwd"
26
+ target "Active users with bash > 6"
27
+ run "cat /etc/passwd", on: :host1
18
28
  expect result.grep_v('#').grep('/bin/bash').count.gt 6
19
29
  ```
20
30
 
21
- ## Examples
31
+ ## Example 2
32
+
33
+ It's posible contenate a sequence of several results orders. Examples:
34
+
35
+ Supose we execute this:
36
+ ```
37
+ run "cat /etc/passwd", on: :host1
38
+ ```
39
+
40
+ And then we could do:
41
+ * Get all lines that dosn't contain "nologin" and contain "/bin/bash"
42
+ ```
43
+ result.grep_v("nologin").grep("/bin/bash")
44
+ ```
45
+ * Count all lines that dosn't contain "nologin" and contain "/bin/bash"
46
+ ```
47
+ result.grep_v("nologin").grep("/bin/bash").count
48
+ ```
49
+ * Return true if the number when count all lines that dosn't contain "nologin" and contain "/bin/bash" is greater than 0
50
+ ```
51
+ result.grep_v("nologin").grep("/bin/bash").count.gt 0
52
+ ```
22
53
 
23
- Boolean functions:
54
+ ## Functions
55
+
56
+ **Boolean functions:**
24
57
 
25
58
  | Function | Description |
26
59
  | ------------------- | ------------------------- |
@@ -31,7 +64,7 @@ Boolean functions:
31
64
  | `result.lt(VALUE)` | Result lesser than VALUE |
32
65
  | `result.le(VALUE)` | Result equal or lesser than VALUE |
33
66
 
34
- Filtering functions:
67
+ **Filtering functions:**
35
68
 
36
69
  | Function | VALUE type | Description |
37
70
  | -------------------- | ----------- | ------------------------------------- |
@@ -44,7 +77,7 @@ Filtering functions:
44
77
  | `result.count` | | Count lines from result and save this number into result object. |
45
78
  | `result.restore` | | Restore result data. After every filtering action result is modified, but this function restore data to their original state. |
46
79
 
47
- Information functions:
80
+ **Information functions:**
48
81
 
49
82
  | Function | Description |
50
83
  | -------------------- | --------------------------------- |
@@ -52,25 +85,3 @@ Information functions:
52
85
  | `result.content` | Return all output lines |
53
86
  | `result.alterations` | Return transformations applied to the output |
54
87
  | `result.debug` | Print the result content on screen. Usefull for debugging process |
55
-
56
- ## Expert use
57
-
58
- It's posible contenate a sequence of several results orders. Examples:
59
-
60
- Supose we execute this:
61
- ```
62
- goto :host1, :exec => "cat /etc/passwd"
63
- ```
64
- And then we could do:
65
- * Get all lines that dosn't contain "nologin" and contain "/bin/bash"
66
- ```
67
- result.grep_v("nologin").grep("/bin/bash")
68
- ```
69
- * Count all lines that dosn't contain "nologin" and contain "/bin/bash"
70
- ```
71
- result.grep_v("nologin").grep("/bin/bash").count
72
- ```
73
- * Return true if the number when count all lines that dosn't contain "nologin" and contain "/bin/bash" is greater than 0
74
- ```
75
- result.grep_v("nologin").grep("/bin/bash").count.gt 0
76
- ```
@@ -0,0 +1,34 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
5
+ 3. [Alias](#alias)
6
+ 4. [Example](#example)
7
+
8
+ ## Description
9
+
10
+ Execute command on localhost and save output into result object.
11
+
12
+ ## Usage
13
+
14
+ ```ruby
15
+ run "id COMMAND"
16
+ ```
17
+
18
+ ## Alias
19
+
20
+ In fact it's the same as doing next:
21
+
22
+ ```ruby
23
+ run "COMMAND", on: :localhost
24
+ run "COMMAND", :on => :localhost
25
+ ```
26
+
27
+ ## Example
28
+
29
+ ```ruby
30
+ run "id david"
31
+ ```
32
+
33
+ * This instruction execute "id david" command on local machine, and save results into **result** object.
34
+ * Local machine is where the `Teuton` program is running.
@@ -0,0 +1,119 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
5
+ 3. [Examples](#examples)
6
+ 4. [Protocol](#protocol)
7
+
8
+ ## Description
9
+
10
+ Connect to remote host and executes command. The command output is saved into **result** object.
11
+
12
+ ## Usage
13
+
14
+ ```ruby
15
+ run "COMMAND", on: :hostID
16
+ on :hostID, run: "COMMAND"
17
+ goto :hostID, :exec => "COMMAND"
18
+ ```
19
+ > ADVISE: I know that programers dislike `goto` sentence, but this is diferent. Think of it as english speaker, not as developer.
20
+
21
+ * This example connect to remote host identified by `hostID`. Then we execute the command into it and save the output commadn into result object.
22
+ * Label `hostID` identifies specific machine. Host information (ip, username, password, protocol) cames from config file.
23
+
24
+ ## Examples
25
+
26
+ Execute `id obiwan` comand into remote host `:linux1`.
27
+
28
+ ```Ruby
29
+ run "id obiwan", on: :linux1
30
+ run "id obiwan", :on => :linux1
31
+ on :linux1, run: "id obiwan"
32
+ on :linux1, :run => "id obiwan"
33
+ goto :linux1, exec: "id obiwan"
34
+ goto :linux1, :exec => "id obiwan"
35
+ ```
36
+
37
+ Execute `id yoda` command into `localhost`.
38
+
39
+ ```Ruby
40
+ run "id yoda"
41
+ run "id yoda", on: :localhost
42
+ run "id yoda", :on => :localhost
43
+ on :localhost, run: "id yoda"
44
+ on :localhost, :run => "id yoda"
45
+ goto :localhost, :exec => "id yoda"
46
+ goto :localhost, :execute => "id yoda"
47
+ ```
48
+
49
+ ## Protocol
50
+
51
+ **SSH connection**
52
+
53
+ Invoking `run` or `goto` sentence, Teuton opens SSH remote session by default. This config files examples do the same:
54
+
55
+ Sample 1:
56
+ ```
57
+ ---
58
+ :config:
59
+ ---
60
+ :global:
61
+ :cases:
62
+ - :tt_members: Student1
63
+ :host1_ip: 1.1.1.1
64
+ :host1_username: student
65
+ :host1_password: secret
66
+ ```
67
+
68
+ Sample 2:
69
+ ```
70
+ ---
71
+ :config:
72
+ ---
73
+ :global:
74
+ :cases:
75
+ - :tt_members: Student1
76
+ :host1_ip: 1.1.1.1
77
+ :host1_username: student
78
+ :host1_password: secret
79
+ :host1_protocol: ssh
80
+ ```
81
+
82
+ **Telnet connection**: Open Telnet remote session.
83
+
84
+ For example:
85
+ ```
86
+ ---
87
+ :global:
88
+ :cases:
89
+ - :tt_members: Student2
90
+ :host1_ip: 2.2.2.2
91
+ :host1_username: student
92
+ :host1_password: secret
93
+ :host1_protocol: telnet
94
+ ```
95
+
96
+ **Localhost**: When hostname is localhost, or host IP is 127.0.0.X, then Teuton will assume that you want to run your command on local system, and no session is opened. This examples are the same:
97
+
98
+ ```
99
+ run "id david"
100
+ ```
101
+
102
+ And
103
+
104
+ ```
105
+ goto :localhost, :exec => "id david"
106
+ ```
107
+
108
+ **SSH to localhost**: Force SSH session to localhost, then:
109
+
110
+ ```
111
+ ---
112
+ :global:
113
+ :cases:
114
+ - :tt_members: Student3
115
+ :host1_ip: 127.0.0.1
116
+ :host1_username: student
117
+ :host1_password: secret
118
+ :host1_protocol: ssh
119
+ ```
@@ -1,3 +1,9 @@
1
+ [<< back](../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
5
+ 3. [Alias](#alias)
6
+ 4. [Weight](#weight)
1
7
 
2
8
  ## Description
3
9
 
@@ -1,7 +1,13 @@
1
+ [<< back](../../README.md)
2
+
3
+ 1. [Description](#description)
4
+ 2. [Usage](#usage)
5
+ 3. [Example](#example)
6
+ 4. [Formats](#formats)
1
7
 
2
8
  ## Description
3
9
 
4
- Create reports and save then into `var/CHALLENGE-NAME` folder.
10
+ Create reports and save then into `var/TEST-NAME` folder.
5
11
 
6
12
  ## Usage
7
13
 
@@ -11,29 +17,31 @@ play do
11
17
  end
12
18
  ```
13
19
 
20
+ ## Example
21
+
22
+ Run export and build reports using txt output format by default:
23
+
24
+ ```ruby
25
+ play do
26
+ export
27
+ end
28
+ ```
29
+
30
+ Run test and build reports using `html` output format:
31
+
32
+ ```ruby
33
+ play do
34
+ export :format => :html
35
+ end
36
+ ```
14
37
 
15
- ## Other
38
+ ## Formats
16
39
 
17
40
  | Command | Description |
18
41
  | ------------------------ | ----------- |
19
42
  | `export` | Export report files using default ouput format |
20
43
  | `export :format => :txt` | Export file using TXT ouput format |
21
- | `export :format => :colored_text` | Export file using colored TXT ouput format |
44
+ | `export :format => :html` | Export file using HTML ouput format |
22
45
  | `export :format => :yaml` | Export file using YAML ouput format |
23
46
  | `export :format => :json` | Export file using JSON ouput format |
24
-
25
- ## Examples
26
-
27
- Run challenge and build reports using default output format:
28
- ```
29
- play do
30
- export
31
- end
32
- ```
33
-
34
- Run challenge and build reports using `colored_text` output format:
35
- ```
36
- play do
37
- export :format => :colored_text
38
- end
39
- ```
47
+ | `export :format => :colored_text` | Export file using colored TXT ouput format |