Ifd_Automation 2.6 → 2.7
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 +4 -4
- data/bin/generate.rb +21 -3
- data/bin/helper.rb +5 -4
- data/lib/Ifd_Automation/require_libs.rb +9 -6
- data/lib/Ifd_Automation/version.rb +1 -1
- data/lib/helper/{assertion_helpers.rb → assertion_helper.rb} +5 -5
- data/lib/helper/auto_util.rb +164 -0
- data/lib/helper/database_helper.rb +81 -0
- data/lib/helper/file_helper.rb +36 -0
- data/lib/helper/mail_helper.rb +58 -0
- data/lib/helper/rest_helper.rb +91 -0
- data/lib/helper/soap_helper.rb +59 -0
- data/lib/helper/ssh_helper.rb +39 -0
- data/lib/helper/web_steps_helper.rb +447 -0
- data/project/Dockerfile +20 -0
- data/project/Gemfile.lock +176 -0
- data/project/README.md +60 -0
- data/project/cucumber.yml +6 -0
- data/project/docker-compose.yml +7 -0
- data/project/features/TestData/globalData.yml +3 -1
- data/project/features/TestSuite/WebGUI.feature +16 -2
- data/project/features/step_definitions/IFD_Libraries/REST_steps.rb +34 -0
- data/project/features/step_definitions/IFD_Libraries/SOAP_steps.rb +38 -0
- data/project/features/step_definitions/IFD_Libraries/database_steps.rb +44 -0
- data/{lib/Ifd_Automation/dynamic_store_vavue_steps.rb → project/features/step_definitions/IFD_Libraries/dynamic_store_value_steps.rb} +8 -10
- data/project/features/step_definitions/IFD_Libraries/email_steps.rb +36 -0
- data/project/features/step_definitions/IFD_Libraries/file_steps.rb +11 -0
- data/project/features/step_definitions/IFD_Libraries/ssh_steps.rb +20 -0
- data/{lib/Ifd_Automation → project/features/step_definitions/IFD_Libraries}/web_steps.rb +18 -8
- data/project/features/step_definitions/lib_steps/actionwords.rb +14 -10
- data/project/features/step_definitions/lib_steps/steps.rb +6 -0
- data/project/features/step_definitions/repositories/project_object.yml +2 -6
- data/project/features/support/env.rb +18 -18
- data/project/features/support/hooks.rb +22 -59
- metadata +45 -17
- data/lib/Ifd_Automation/REST_steps.rb +0 -90
- data/lib/Ifd_Automation/SOAP_steps.rb +0 -68
- data/lib/Ifd_Automation/database_steps.rb +0 -80
- data/lib/Ifd_Automation/email_steps.rb +0 -72
- data/lib/Ifd_Automation/file_steps.rb +0 -24
- data/lib/Ifd_Automation/ssh_steps.rb +0 -38
- data/lib/helper/auto_utils.rb +0 -67
- data/lib/helper/connection_helpers.rb +0 -15
- data/lib/helper/core.rb +0 -646
- data/lib/helper/mail_helpers.rb +0 -17
- data/lib/helper/web_steps_helpers.rb +0 -176
- data/project/features/step_definitions/lib_steps/test.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 448bca8ed2c82ab7bdfed43ec4abdd4a98b5d1c6
|
4
|
+
data.tar.gz: a710f31d2495e1a69074b643e452f674435ab7e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd25a2035bf56ce7270ab46a922384dc99c6dbc4dcc647c675812c9f989d9ec4698053a0b604e6b3619ba8262ed0e56b8d92959f6d2aa114c70836efe418e369
|
7
|
+
data.tar.gz: 140494a94643f479dd4bf4959de923948587078117bb693c9ce54e8cf9f11fa86c00aa8ed4760a463abb7d7fe30d60b5e94470cfdfd93fe87453533a9622f90a
|
data/bin/generate.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
def ifd_automation_scaffold
|
3
3
|
if File.exists?(@features_dir)
|
4
|
-
puts
|
4
|
+
puts 'There is already cucumber directory. Please move existing cucumber directory to carry on '
|
5
5
|
exit 1
|
6
6
|
end
|
7
7
|
# msg("Question") do
|
@@ -13,8 +13,26 @@ def ifd_automation_scaffold
|
|
13
13
|
|
14
14
|
FileUtils.cp_r(@source_dir, @features_dir)
|
15
15
|
|
16
|
-
msg(
|
17
|
-
puts "
|
16
|
+
msg('Info') do
|
17
|
+
puts "INFOdation Automation is creating 'cucumber' framework. Please have a look which files are being created\n"
|
18
|
+
end
|
19
|
+
msg('Gemfile') do
|
20
|
+
puts "INFOdation Automation created Gemfile containing all required Gems\n"
|
21
|
+
end
|
22
|
+
msg('cucumber.yml') do
|
23
|
+
puts "INFOdation Automation created cucumber.yml file with profiles of all needed configurations\n"
|
24
|
+
end
|
25
|
+
msg('README.md') do
|
26
|
+
puts "INFOdation Automation created README.md file with template usage\n"
|
27
|
+
end
|
28
|
+
msg('Dockerfile') do
|
29
|
+
puts "INFOdation Automation created Dockerfile\n"
|
30
|
+
end
|
31
|
+
msg('docker-compose.yml') do
|
32
|
+
puts "INFOdation Automation created Dockerfile\n"
|
33
|
+
end
|
34
|
+
msg('Info') do
|
35
|
+
puts "All Config files created. \n"
|
18
36
|
end
|
19
37
|
|
20
38
|
end
|
data/bin/helper.rb
CHANGED
@@ -3,9 +3,10 @@ require 'json'
|
|
3
3
|
require "rubygems"
|
4
4
|
|
5
5
|
def msg(title, &block)
|
6
|
-
puts "\n" +
|
7
|
-
|
8
|
-
puts
|
6
|
+
puts "\n" + '-' * 10 + title + '-' * 10
|
7
|
+
yield
|
8
|
+
puts '-' * 10 + '-------' + '-' * 10 + "\n"
|
9
|
+
sleep 1
|
9
10
|
end
|
10
11
|
|
11
12
|
# def print_usage
|
@@ -29,7 +30,7 @@ end
|
|
29
30
|
|
30
31
|
def print_help
|
31
32
|
puts <<EOF
|
32
|
-
Author:
|
33
|
+
Author: INFODation company
|
33
34
|
|
34
35
|
Usage: Ifd_Automation <command-name> [parameters] [options]
|
35
36
|
|
@@ -1,6 +1,9 @@
|
|
1
|
-
require_relative '../helper/
|
2
|
-
require_relative '../helper/
|
3
|
-
require_relative '../helper/
|
4
|
-
require_relative '../helper/
|
5
|
-
require_relative '../helper/
|
6
|
-
require_relative '../helper/
|
1
|
+
require_relative '../helper/web_steps_helper.rb'
|
2
|
+
require_relative '../helper/auto_util.rb'
|
3
|
+
require_relative '../helper/mail_helper.rb'
|
4
|
+
require_relative '../helper/assertion_helper.rb'
|
5
|
+
require_relative '../helper/database_helper.rb'
|
6
|
+
require_relative '../helper/file_helper.rb'
|
7
|
+
require_relative '../helper/rest_helper.rb'
|
8
|
+
require_relative '../helper/soap_helper.rb'
|
9
|
+
require_relative '../helper/ssh_helper.rb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class IFD_Assertion
|
2
2
|
#Assert two files, rows not in order and REMOVE 1 COLUMN OF ID
|
3
3
|
def self.do_assertion_csv_tab_non_order(expected_obj, actual_obj)
|
4
4
|
for i in (1..expected_obj.length - 1)
|
@@ -60,19 +60,19 @@ class Assertion
|
|
60
60
|
if actual_obj[key].nil?
|
61
61
|
raise "[%s] expected [%s] but actual value was nil." % [key, expected_obj[key].to_s]
|
62
62
|
else
|
63
|
-
|
63
|
+
IFD_Assertion.do_assertion_json(expected_obj[key], actual_obj[key], options)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
elsif expected_obj.kind_of? Array
|
67
67
|
if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false
|
68
|
-
|
68
|
+
IFD_Assertion.do_assertion_json(expected_obj.size, actual_obj.size)
|
69
69
|
end
|
70
70
|
for i in (0..expected_obj.length-1)
|
71
|
-
|
71
|
+
IFD_Assertion.do_assertion_json(expected_obj[i], actual_obj[i], options)
|
72
72
|
end
|
73
73
|
else
|
74
74
|
begin
|
75
|
-
|
75
|
+
IFD_Assertion.assert_string_equal(expected_obj.to_s, actual_obj.to_s)
|
76
76
|
rescue => e
|
77
77
|
raise("Assert fail. \n\n Expected: '#{expected_obj}' \n\n Got: '#{actual_obj}'. Detail info: #{e.message}")
|
78
78
|
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
class Utils
|
2
|
+
#-----------------------------------------------------
|
3
|
+
# support define and bind variable dynamically
|
4
|
+
#-----------------------------------------------------
|
5
|
+
$dyn_vars = nil
|
6
|
+
|
7
|
+
# set value to a variable
|
8
|
+
def self.set_var(var_name, var_value)
|
9
|
+
if $dyn_vars == nil
|
10
|
+
$dyn_vars = binding
|
11
|
+
end
|
12
|
+
|
13
|
+
strEval = var_name + "=" + var_value
|
14
|
+
eval strEval, $dyn_vars
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.check_dynamic_value value
|
18
|
+
if !value.is_a? Fixnum
|
19
|
+
if value.include? "params="
|
20
|
+
resolve_params value
|
21
|
+
else
|
22
|
+
bind_with_dyn_vars value
|
23
|
+
end
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def self.resolve_params url
|
31
|
+
condition = url.match(/params='([^']*)'/)[0]
|
32
|
+
if condition
|
33
|
+
params_name = url.match(/params='([^']*)'/)[1]
|
34
|
+
params_value = $PARAMS["#{params_name.downcase}"].to_s.strip
|
35
|
+
if params_value.present?
|
36
|
+
url = url.gsub(condition, params_value)
|
37
|
+
else
|
38
|
+
raise "ERROR: no data found with given params #{params_name}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
url
|
42
|
+
end
|
43
|
+
|
44
|
+
# bind string with $dyn_vars context
|
45
|
+
def self.bind_with_dyn_vars(str)
|
46
|
+
if $dyn_vars == nil
|
47
|
+
$dyn_vars = binding
|
48
|
+
end
|
49
|
+
|
50
|
+
strEval = '"' + str + '"'
|
51
|
+
return eval strEval, $dyn_vars
|
52
|
+
end
|
53
|
+
|
54
|
+
# evaluate operation/statement with $dyn_vars context
|
55
|
+
def self.eval_with_dyn_vars(operation)
|
56
|
+
if $dyn_vars == nil
|
57
|
+
$dyn_vars = binding
|
58
|
+
end
|
59
|
+
|
60
|
+
eval operation, $dyn_vars
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.bind_with_dyn_json_vars(json, bind_json)
|
64
|
+
if json.kind_of? Hash
|
65
|
+
json.each_pair do |k, v|
|
66
|
+
if v.kind_of? String
|
67
|
+
bind_json[bind_with_dyn_vars(k)] = bind_with_dyn_json_vars(v, bind_json)
|
68
|
+
elsif v.kind_of? Hash
|
69
|
+
temp = Hash.new
|
70
|
+
v.each_pair do |k1, v1|
|
71
|
+
temp[bind_with_dyn_vars(k1)] = bind_with_dyn_json_vars(v1, temp)
|
72
|
+
end
|
73
|
+
bind_json[bind_with_dyn_vars(k)] = temp
|
74
|
+
elsif v.kind_of? Array
|
75
|
+
temp1 = Array.new
|
76
|
+
v.each { |item|
|
77
|
+
temp2 = Hash.new
|
78
|
+
bind_with_dyn_json_vars(item, temp2)
|
79
|
+
temp1 << temp2
|
80
|
+
}
|
81
|
+
bind_json[bind_with_dyn_vars(k)] = temp1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
elsif json.kind_of? Array
|
85
|
+
temp1 = Array.new
|
86
|
+
json.each { |item|
|
87
|
+
temp2 = Hash.new
|
88
|
+
bind_with_dyn_json_vars(item, temp2)
|
89
|
+
temp1 << temp2
|
90
|
+
}
|
91
|
+
return temp1
|
92
|
+
else
|
93
|
+
return bind_with_dyn_vars(json)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def self.var_collect string_var
|
99
|
+
if string_var =~ /^.*{year}.*$/
|
100
|
+
string_var = replace_year(string_var)
|
101
|
+
end
|
102
|
+
|
103
|
+
if string_var =~ /^.*{month}.*$/
|
104
|
+
string_var = replace_month(string_var)
|
105
|
+
end
|
106
|
+
|
107
|
+
if string_var =~ /^.*{day}.*$/
|
108
|
+
string_var = replace_day(string_var)
|
109
|
+
end
|
110
|
+
|
111
|
+
if string_var =~ /^.*{store_value}.*$/
|
112
|
+
string_var = $context_value
|
113
|
+
end
|
114
|
+
|
115
|
+
return string_var
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.replace_year str
|
119
|
+
t = Time.now()
|
120
|
+
return str.gsub("{year}", t.year.to_s)
|
121
|
+
end
|
122
|
+
|
123
|
+
def replace_month str
|
124
|
+
t = Time.now()
|
125
|
+
_month = t.month
|
126
|
+
if _month < 10
|
127
|
+
return str.gsub("{month}", "0#{_month.to_s}")
|
128
|
+
else
|
129
|
+
return str.gsub("{month}", "#{_month.to_s}")
|
130
|
+
end
|
131
|
+
return str
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.replace_day str
|
135
|
+
t = Time.now()
|
136
|
+
_day = t.day
|
137
|
+
if _day < 10
|
138
|
+
return str.gsub("{day}", "0#{_day.to_s}")
|
139
|
+
else
|
140
|
+
return str.gsub("{day}", "#{_day.to_s}")
|
141
|
+
end
|
142
|
+
return str
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.replace_pipe str_pipe
|
146
|
+
put_log ">>>> #{str_pipe}"
|
147
|
+
if str_pipe =~ /^.*{pipe}.*$/
|
148
|
+
return str_pipe.gsub("{pipe}", "|")
|
149
|
+
end
|
150
|
+
return str_pipe
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.store_string_as_variable(string,variable)
|
154
|
+
# $context_value = Utils.bind_with_dyn_vars(string)
|
155
|
+
# Utils.set_var(variable, '$context_value')
|
156
|
+
require 'erb'
|
157
|
+
ERB.new(string, 0, "", "#{variable}").result(binding)
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.print_variable(variable)
|
161
|
+
puts "VALUE OF #{variable}: #{Utils.eval_with_dyn_vars(variable)}"
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'tiny_tds'
|
2
|
+
require 'activerecord-sqlserver-adapter'
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
module IFD_DBConnection
|
6
|
+
def self.new(connection_params)
|
7
|
+
begin
|
8
|
+
put_log ("Connecting to database...")
|
9
|
+
return ActiveRecord::Base.establish_connection(connection_params)
|
10
|
+
rescue Exception => e
|
11
|
+
raise e.message
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create_database_connection(data)
|
16
|
+
unless data.hashes.empty?
|
17
|
+
data = data.hashes[0]
|
18
|
+
data = JSON.parse(data) unless data.is_a? Hash
|
19
|
+
|
20
|
+
data.each_pair do |k, v|
|
21
|
+
data[k] = Utils.check_dynamic_value(v)
|
22
|
+
end
|
23
|
+
@connection = IFD_DBConnection.new(data)
|
24
|
+
put_log "Connect to database successfully!" if @connection
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.close_database_connection
|
29
|
+
@connection.disconnect!
|
30
|
+
if !@connection.connected?
|
31
|
+
put_log "Disconnected to Database!"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.execute_select(script)
|
36
|
+
script = Utils.check_dynamic_value(script)
|
37
|
+
if @connection
|
38
|
+
@result = @connection.connection.exec_query(script)
|
39
|
+
else
|
40
|
+
raise "ERROR: Create connection to database first!"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.execute_script(script)
|
45
|
+
script = Utils.check_dynamic_value(script)
|
46
|
+
if @connection
|
47
|
+
@result = @connection.connection.execute(script)
|
48
|
+
else
|
49
|
+
raise "ERROR: Create connection to database first!"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.print_sql_result
|
54
|
+
if @result.present?
|
55
|
+
@result.each do |row|
|
56
|
+
p row
|
57
|
+
end
|
58
|
+
else
|
59
|
+
p "WARNING: No result from SQL statement"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.verify_sql_result_with_json(json)
|
64
|
+
expected = JSON.parse(json)
|
65
|
+
@result.each do |row|
|
66
|
+
IFD_Assertion.assert_string_equal(expected,row)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.verify_sql_result_with_json_node(json_node, value)
|
71
|
+
@result.each do|row|
|
72
|
+
results = JsonPath.new(json_node).on(row).to_a.map(&:to_s)
|
73
|
+
IFD_Assertion.assert_string_equal(results[0], value)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.store_sql_result_into_string(string)
|
78
|
+
Utils.set_var(string, @result)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class IFD_File
|
2
|
+
|
3
|
+
def self.delete_file(file_name)
|
4
|
+
file_path = ($test_data_dir + file_name.gsub(" ", "_"))
|
5
|
+
if File.exists?(file_path)
|
6
|
+
File.delete(file_path)
|
7
|
+
puts "#{file_name} is deleted successfully"
|
8
|
+
else
|
9
|
+
puts "File #{file_name} does not exists"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.read_file(file_name)
|
14
|
+
@file_data = ""
|
15
|
+
file_path = $test_data_dir + file_name.downcase
|
16
|
+
if File.exist?(file_path)
|
17
|
+
file = File.open(file_path)
|
18
|
+
@file_data += file.read
|
19
|
+
file.close
|
20
|
+
else
|
21
|
+
raise "*** WARNING: File #{file_name} does not exist."
|
22
|
+
end
|
23
|
+
p @file_data
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.execute_windows_file(filename, file_location)
|
27
|
+
file = file_location + filename
|
28
|
+
p file
|
29
|
+
if File.exist? file
|
30
|
+
system("'"+file+"'")
|
31
|
+
else
|
32
|
+
raise "*** ERROR: File #{file} is not existed."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'mail'
|
2
|
+
# require 'email_spec'
|
3
|
+
# include EmailSpec::Helpers
|
4
|
+
# include EmailSpec::Matcher
|
5
|
+
class IFD_Email
|
6
|
+
|
7
|
+
def self.send_email(raw_data)
|
8
|
+
include Mail::Matchers
|
9
|
+
raw_data.strip!
|
10
|
+
header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
|
11
|
+
conditions = {}
|
12
|
+
header.split("\n").each do |row|
|
13
|
+
if row.lstrip.chop.match(/^[a-z\-]+:/i)
|
14
|
+
key, value = row.split(":", 2)
|
15
|
+
conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
conditions[:body] = body if body
|
20
|
+
filepath = ($test_data_dir + conditions[:attachments] if conditions[:attachments])
|
21
|
+
# Mail::TestMailer.deliveries.clear
|
22
|
+
Mail.deliver do
|
23
|
+
from "abc@gmail.com"
|
24
|
+
to to_address if conditions[:to]
|
25
|
+
subject subject if conditions[:subject]
|
26
|
+
body body_email if conditions[:body]
|
27
|
+
add_file attachments if filepath
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.verify_receive_email(raw_data)
|
32
|
+
raw_data.strip!
|
33
|
+
header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
|
34
|
+
conditions = {}
|
35
|
+
header.split("\n").each do |row|
|
36
|
+
if row.lstrip.chop.match(/^[a-z\-]+:/i)
|
37
|
+
key, value = row.split(":", 2)
|
38
|
+
conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
conditions[:body] = body.squeeze(' ').strip if body
|
43
|
+
sleep 5
|
44
|
+
emails = Mail.find(:what => :last, :count => 1)
|
45
|
+
|
46
|
+
if emails.instance_of? Mail::Message
|
47
|
+
IFD_Assertion.assert_string_equal(conditions[:from], emails.from[0].to_s)
|
48
|
+
IFD_Assertion.assert_string_equal(conditions[:subject], emails.subject)
|
49
|
+
IFD_Assertion.assert_string_contain(conditions[:body], emails.body)
|
50
|
+
emails.attachments.each do |attachment|
|
51
|
+
IFD_Assertion.assert_string_equal(conditions[:attachments], attachment.filename)
|
52
|
+
end if conditions[:attachments]
|
53
|
+
else
|
54
|
+
raise "WARNING: *** No new Email is found"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|