Ifd_Automation 1.6.0 → 1.7.0
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/Ifd_Automation +34 -15
- data/bin/console +14 -0
- data/bin/documentation_generator.rb +119 -0
- data/bin/helper.rb +24 -19
- data/bin/setup +8 -0
- data/lib/Ifd_Automation.rb +2 -1
- data/lib/Ifd_Automation/all_steps.rb +8 -0
- data/lib/Ifd_Automation/database_steps.rb +106 -0
- data/lib/Ifd_Automation/email_steps.rb +67 -82
- data/lib/Ifd_Automation/file_steps.rb +30 -0
- data/lib/Ifd_Automation/{javascript_handling_steps.rb → javascript_steps.rb} +1 -2
- data/lib/Ifd_Automation/required_libs.rb +7 -0
- data/lib/Ifd_Automation/response.rb +105 -0
- data/lib/Ifd_Automation/ssh_steps.rb +47 -0
- data/lib/Ifd_Automation/version.rb +3 -5
- data/lib/Ifd_Automation/web_steps.rb +293 -0
- data/lib/Ifd_Automation/webservice_steps.rb +261 -0
- data/lib/{Ifd_Automation/methods/IFD_Assertion_methods.rb → Ifd_Automation_support/assertion_helpers.rb} +0 -1
- data/lib/Ifd_Automation_support/connection_helpers.rb +14 -0
- data/lib/{Ifd_Automation/methods → Ifd_Automation_support}/core.rb +103 -34
- data/lib/{Ifd_Automation/methods/javascript_handling_methods.rb → Ifd_Automation_support/javascript_helpers.rb} +0 -1
- data/lib/Ifd_Automation_support/mail_helpers.rb +17 -0
- data/lib/Ifd_Automation_support/selenium_sync_issues.rb +62 -0
- data/lib/{Ifd_Automation/methods/web_methods.rb → Ifd_Automation_support/web_steps_helpers.rb} +6 -1
- data/project/Gemfile +1 -19
- data/project/Gemfile.lock +203 -0
- data/project/features/TestData/globalData.yml +3 -11
- data/project/features/TestData/sshtest.txt +2 -0
- data/project/features/TestData/testfile.sql +2 -0
- data/project/features/{TestData/DownloadFolder/test.txt → TestSuite/test} +0 -0
- data/project/features/step_definitions/lib_steps/test.rb +16 -0
- data/project/features/step_definitions/repositories/project_object.yml +6 -6
- data/project/features/support/env.rb +46 -68
- data/project/features/support/project_config.yml +6 -37
- metadata +231 -51
- data/lib/Ifd_Automation/assertion_steps.rb +0 -96
- data/lib/Ifd_Automation/lib_file_steps.rb +0 -54
- data/lib/Ifd_Automation/lib_schema_data_steps.rb +0 -115
- data/lib/Ifd_Automation/lib_web_steps.rb +0 -184
- data/lib/Ifd_Automation/lib_webservice_steps.rb +0 -44
- data/lib/Ifd_Automation/methods/IFD_Connection.rb +0 -28
- data/lib/Ifd_Automation/methods/IFD_email_methods.rb +0 -16
- data/lib/Ifd_Automation/methods/IFD_webservice.rb +0 -17
- data/lib/Ifd_Automation/methods/database_methods.rb +0 -25
- data/lib/Ifd_Automation/methods/db_utils.rb +0 -37
- data/lib/Ifd_Automation/methods/error_handling_methods.rb +0 -87
- data/lib/Ifd_Automation/methods/lib_var.rb +0 -59
- data/lib/Ifd_Automation/methods/misc_methods.rb +0 -33
- data/lib/Ifd_Automation/methods/required_files.rb +0 -33
- data/lib/Ifd_Automation/methods/util.rb +0 -168
- data/lib/Ifd_Automation/methods/web_service_methods.rb +0 -63
- data/project/config/cucumber.yml +0 -3
- data/project/features/TestData/ExpectedDataFile/test.txt +0 -0
- data/project/features/TestData/SqlScript/test.sql +0 -0
- data/project/features/TestData/actual_images/infodation.jpg +0 -0
- data/project/features/TestData/expected_images/infodation.jpg +0 -0
- data/project/features/TestData/image_difference/infodation.jpg +0 -0
- data/project/features/TestData/screenshots/infodation.jpg +0 -0
- data/project/features/TestSuite/Login/login.feature +0 -11
- data/project/features/step_definitions/lib_steps/login_steps.rb +0 -16
@@ -0,0 +1,261 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json-schema'
|
3
|
+
require 'savon'
|
4
|
+
require_relative 'required_libs'
|
5
|
+
require_relative 'response'
|
6
|
+
|
7
|
+
if ENV['webservice_verbose'] == 'true'
|
8
|
+
RestClient.log = 'stdout'
|
9
|
+
end
|
10
|
+
|
11
|
+
$cache = {}
|
12
|
+
|
13
|
+
Given /^I set headers:$/ do |headers|
|
14
|
+
headers.rows_hash.each {|k,v| header k, v }
|
15
|
+
end
|
16
|
+
|
17
|
+
Given /^I send and accept (XML|JSON)$/ do |type|
|
18
|
+
@headers = {
|
19
|
+
:'Accept' => "application/#{type.downcase}",
|
20
|
+
:'Content-Type' => "application/#{type.downcase}"
|
21
|
+
}
|
22
|
+
p @headers
|
23
|
+
end
|
24
|
+
|
25
|
+
# Example
|
26
|
+
# When I get SOAP operations list from 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
|
27
|
+
When /^I get SOAP operations list from '(.*?)'$/ do |request|
|
28
|
+
@client = Savon.client(ssl_verify_mode: :none,wsdl: "#{request}")
|
29
|
+
p @client.operations
|
30
|
+
end
|
31
|
+
|
32
|
+
# Example
|
33
|
+
# When I send "verify_email" SOAP request with the following:
|
34
|
+
# """
|
35
|
+
# { "email": "soap@example.com",
|
36
|
+
# "LicenseKey": "?" }
|
37
|
+
# """
|
38
|
+
When /^I send "(.*?)" SOAP request with the following:$/ do |operation, json|
|
39
|
+
params = JSON.parse(json)
|
40
|
+
@response = @client.call(operation.downcase.to_sym, :message => params)
|
41
|
+
# p JSON.parse(@response.body)
|
42
|
+
# p response_text = response.body[:verify_email_response][:verify_email_result][:response_text]
|
43
|
+
end
|
44
|
+
|
45
|
+
# Example
|
46
|
+
# Then the SOAP response node should have "$..response_text" with text "Email Domain Not Found"
|
47
|
+
Then /^the SOAP response node should have "(.*?)" with text "(.*?)"$/ do |json_path,text|
|
48
|
+
json = JSON.parse(@response.body.to_json)
|
49
|
+
results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
50
|
+
if self.respond_to?(:expect)
|
51
|
+
expect(results).to include(text)
|
52
|
+
else
|
53
|
+
assert results.include?(text)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
When(/^I set JSON request body to '(.*?)'$/) do |body|
|
58
|
+
@body = JSON.parse body
|
59
|
+
end
|
60
|
+
|
61
|
+
When(/^I set form request body to:$/) do |params|
|
62
|
+
@body = {}
|
63
|
+
params.rows_hash.each do |key, value|
|
64
|
+
p_value = value
|
65
|
+
@grabbed.each { |k, v| p_value = v if value == %/{#{k}}/ } unless @grabbed.nil?
|
66
|
+
p_value = File.new %-#{Dir.pwd}/#{p_value.sub 'file://', ''}- if %/#{p_value}/.start_with? "file://"
|
67
|
+
@body[%/#{key}/] = p_value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
When(/^I set request body from "(.*?).(yml|json)"$/) do |filename, extension|
|
72
|
+
path = %-#{Dir.pwd}/#{filename}.#{extension}-
|
73
|
+
if File.file? path
|
74
|
+
case extension
|
75
|
+
when 'yml'
|
76
|
+
@body = YAML.load File.open(path)
|
77
|
+
when 'json'
|
78
|
+
@body = JSON.parse File.read(path)
|
79
|
+
else
|
80
|
+
raise %/Unsupported file type: '#{path}'/
|
81
|
+
end
|
82
|
+
else
|
83
|
+
raise %/File not found: '#{path}'/
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Example
|
88
|
+
# When I grab "$[0]" as "id"
|
89
|
+
When(/^I grab "(.*?)" as "(.*?)"$/) do |json_path, place_holder|
|
90
|
+
if @response.nil?
|
91
|
+
raise 'No response found, a request need to be made first before you can grab response'
|
92
|
+
end
|
93
|
+
|
94
|
+
@grabbed = {} if @grabbed.nil?
|
95
|
+
@grabbed[%/#{place_holder}/] = @response.get json_path
|
96
|
+
p @grabbed
|
97
|
+
end
|
98
|
+
# Example
|
99
|
+
# And I send a GET request to "https://hacker-news.firebaseio.com/v0/item/8863.json" with:
|
100
|
+
# | print |
|
101
|
+
# | pretty |
|
102
|
+
When(/^I send a (GET|POST|PATCH|PUT|DELETE) request to "(.*?)" with:$/) do |method, url, params|
|
103
|
+
unless params.hashes.empty?
|
104
|
+
query = params.hashes.first.map{|key, value| %/#{key}=#{value}/}.join("&")
|
105
|
+
url = url.include?('?') ? %/#{url}&#{query}/ : %/#{url}?#{query}/
|
106
|
+
end
|
107
|
+
steps %Q{
|
108
|
+
When I send a #{method} request to "#{url}"
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
# Example
|
113
|
+
# And I send a POST request to "https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty"
|
114
|
+
When(/^I send a (GET|POST|PATCH|PUT|DELETE) request to "(.*?)"$/) do |method, url|
|
115
|
+
request_url = URI.encode check_match_url url
|
116
|
+
if 'GET' == %/#{method}/ and $cache.has_key? %/#{request_url}/
|
117
|
+
@response = $cache[%/#{request_url}/]
|
118
|
+
@headers = nil
|
119
|
+
@body = nil
|
120
|
+
@grabbed = nil
|
121
|
+
next
|
122
|
+
end
|
123
|
+
|
124
|
+
@headers = {} if @headers.nil?
|
125
|
+
begin
|
126
|
+
case method
|
127
|
+
when 'GET'
|
128
|
+
response = RestClient.get request_url, @headers
|
129
|
+
when 'POST'
|
130
|
+
response = RestClient.post request_url, @body, @headers
|
131
|
+
when 'PATCH'
|
132
|
+
response = RestClient.patch request_url, @body, @headers
|
133
|
+
when 'PUT'
|
134
|
+
response = RestClient.put request_url, @body, @headers
|
135
|
+
else
|
136
|
+
response = RestClient.delete request_url, @headers
|
137
|
+
end
|
138
|
+
rescue RestClient::Exception => e
|
139
|
+
response = e.response
|
140
|
+
end
|
141
|
+
@response = CucumberApi::Response.create response
|
142
|
+
@headers = nil
|
143
|
+
@body = nil
|
144
|
+
@grabbed = nil
|
145
|
+
$cache[%/#{request_url}/] = @response if 'GET' == %/#{method}/
|
146
|
+
end
|
147
|
+
|
148
|
+
# Example
|
149
|
+
# Then the response status should be "200"
|
150
|
+
Then(/^the response status should be "(\d+)"$/) do |status_code|
|
151
|
+
raise %/Expect #{status_code} but was #{@response.code}/ if @response.code != status_code.to_i
|
152
|
+
end
|
153
|
+
|
154
|
+
# Example
|
155
|
+
# Then the JSON response should be:
|
156
|
+
# """
|
157
|
+
# {
|
158
|
+
# "test" : "anh pham"
|
159
|
+
# }
|
160
|
+
# """
|
161
|
+
Then /^the JSON response should be:$/ do |json|
|
162
|
+
expected = JSON.parse(json)
|
163
|
+
actual = JSON.parse(@response.body)
|
164
|
+
|
165
|
+
if self.respond_to?(:expect)
|
166
|
+
# expect(actual).to eq(expected)
|
167
|
+
IFD_Assertion.assert_string_equal(actual, expected)
|
168
|
+
else
|
169
|
+
IFD_Assertion.assert_string_equal(actual, @response)
|
170
|
+
# assert_equal actual, response
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Example
|
175
|
+
# Then the JSON response should have "$..id"
|
176
|
+
Then /^the JSON response should have "(.*)"$/ do |json_path|
|
177
|
+
json = JSON.parse(@response.body)
|
178
|
+
results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
179
|
+
if self.respond_to?(:expect)
|
180
|
+
expect(results).not_to be_empty
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
Then(/^the JSON response root should be (object|array)$/) do |type|
|
185
|
+
steps %Q{
|
186
|
+
Then the JSON response should have required key "$" of type #{type}
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
Then(/^the JSON response should have key "([^\"]*)"$/) do |json_path|
|
191
|
+
steps %Q{
|
192
|
+
Then the JSON response should have required key "#{json_path}" of type any
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
Then(/^the JSON response should have (required|optional) key "(.*?)" of type \
|
198
|
+
(numeric|string|array|boolean|numeric_string|object|array|any)( or null)?$/) do |optionality, json_path, type, null_allowed|
|
199
|
+
next if optionality == 'optional' and not @response.has(json_path) # if optional and no such key then skip
|
200
|
+
if 'any' == type
|
201
|
+
@response.get json_path
|
202
|
+
elsif null_allowed.nil?
|
203
|
+
@response.get_as_type json_path, type
|
204
|
+
else
|
205
|
+
@response.get_as_type_or_null json_path, type
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Example
|
210
|
+
# Then the JSON response should have "$..kids" with a length of 2
|
211
|
+
Then /^the JSON response should have "(.*)" with a length of (\d+)$/ do |json_path, length|
|
212
|
+
json = JSON.parse(@response.body)
|
213
|
+
results = JsonPath.new(json_path).on(json)
|
214
|
+
if self.respond_to?(:expect)
|
215
|
+
expect(results.length).to eq(length.to_i)
|
216
|
+
else
|
217
|
+
assert_equal length.to_i, results.length
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# Example
|
222
|
+
# Then the JSON response node should have "$..by" with the text "dhouston"
|
223
|
+
Then /^the JSON response node should have "(.*)" with the text "(.*)"$/ do |json_path, text|
|
224
|
+
json = JSON.parse(@response.body)
|
225
|
+
results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
|
226
|
+
if self.respond_to?(:expect)
|
227
|
+
expect(results).to include(text)
|
228
|
+
else
|
229
|
+
assert results.include?(text)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# Bind grabbed values into placeholders in given URL
|
234
|
+
# Ex: http://example.com?id={id} with {id => 1} becomes http://example.com?id=1
|
235
|
+
# @param url [String] parameterized URL with placeholders
|
236
|
+
# @return [String] binded URL or original URL if no placeholders
|
237
|
+
# def resolve url
|
238
|
+
# unless @grabbed.nil?
|
239
|
+
# @grabbed.each { |key, value| url = url.gsub /\{#{key}\}/, %/#{value}/ }
|
240
|
+
# end
|
241
|
+
# url
|
242
|
+
# end
|
243
|
+
|
244
|
+
Then /^show me SOAP response$/ do
|
245
|
+
puts @response.body
|
246
|
+
end
|
247
|
+
|
248
|
+
Then /^show me REST (unparsed)?\s?response$/ do |unparsed|
|
249
|
+
last_response = @response
|
250
|
+
if unparsed == 'unparsed'
|
251
|
+
puts last_response.body
|
252
|
+
elsif last_response.headers['Content-Type'] =~ /json/
|
253
|
+
json_response = JSON.parse(last_response.body)
|
254
|
+
puts JSON.pretty_generate(json_response)
|
255
|
+
elsif last_response.headers['Content-Type'] =~ /xml/
|
256
|
+
puts Nokogiri::XML(last_response.body)
|
257
|
+
else
|
258
|
+
puts last_response.headers
|
259
|
+
puts last_response.body
|
260
|
+
end
|
261
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
require 'active_record'
|
3
|
+
|
4
|
+
module Connection
|
5
|
+
def self.new(connection_params)
|
6
|
+
begin
|
7
|
+
puts ("Connecting to Sql Server database...")
|
8
|
+
return ActiveRecord::Base.establish_connection(connection_params)
|
9
|
+
rescue Exception => e
|
10
|
+
raise e.message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -1,3 +1,55 @@
|
|
1
|
+
def check_match_url url
|
2
|
+
case url
|
3
|
+
when /params=/
|
4
|
+
resolve_params url
|
5
|
+
when /grabbed=/
|
6
|
+
resolve_ws_url url
|
7
|
+
when /stored=/
|
8
|
+
resolve_script url
|
9
|
+
else
|
10
|
+
url
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def resolve_params url
|
15
|
+
# if url.include? "params="
|
16
|
+
condition = url.match(/params='([^']*)'/)[0]
|
17
|
+
if condition
|
18
|
+
params_name = url.match(/params='([^']*)'/)[1]
|
19
|
+
params_value = $PARAMS["#{params_name}"]
|
20
|
+
if params_value
|
21
|
+
url = url.gsub(condition, params_value)
|
22
|
+
else
|
23
|
+
raise "ERROR: no data found with given params #{params_name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
url
|
28
|
+
# else
|
29
|
+
# url
|
30
|
+
# end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Bind grabbed values into placeholders in given URL
|
34
|
+
# Ex: http://example.com?id={id} with {id => 1} becomes http://example.com?id=1
|
35
|
+
# @param url [String] parameterized URL with placeholders
|
36
|
+
# @return [String] binded URL or original URL if no placeholders
|
37
|
+
def resolve_ws_url url
|
38
|
+
unless @grabbed.nil?
|
39
|
+
matched = url.match(/grabbed='([^']*)'/)[0]
|
40
|
+
@grabbed.each { |key, value| url = url.gsub(matched, %/#{value}/) }
|
41
|
+
end
|
42
|
+
url
|
43
|
+
end
|
44
|
+
|
45
|
+
def resolve_script script
|
46
|
+
unless @stored.nil?
|
47
|
+
matched = script.match(/stored='([^']*)'/)[0]
|
48
|
+
@stored.each { |key, value| script = script.gsub(matched, %/#{value}/) }
|
49
|
+
end
|
50
|
+
script
|
51
|
+
end
|
52
|
+
|
1
53
|
#Print script log to console
|
2
54
|
def put_log str
|
3
55
|
puts str if $_CFWEB['Print Log'] == true
|
@@ -305,45 +357,62 @@ def execute_gettext element
|
|
305
357
|
end
|
306
358
|
end
|
307
359
|
|
308
|
-
def read_file(filename)
|
309
|
-
data = ''
|
310
|
-
f = File.open(filename, "r")
|
311
|
-
f.each_line do |line|
|
312
|
-
data += line
|
313
|
-
end
|
314
|
-
return data.strip;
|
315
|
-
end
|
316
|
-
|
317
360
|
def set_time_out(timeout)
|
318
361
|
$_CFWEB['Wait Time'] = timeout
|
319
362
|
Capybara.default_wait_time = $_CFWEB['Wait Time']
|
320
363
|
end
|
321
364
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
365
|
+
def var_collect string_var
|
366
|
+
if string_var =~ /^.*{year}.*$/
|
367
|
+
string_var = replace_year(string_var)
|
368
|
+
end
|
369
|
+
|
370
|
+
if string_var =~ /^.*{month}.*$/
|
371
|
+
string_var = replace_month(string_var)
|
372
|
+
end
|
373
|
+
|
374
|
+
if string_var =~ /^.*{day}.*$/
|
375
|
+
string_var = replace_day(string_var)
|
376
|
+
end
|
377
|
+
|
378
|
+
if string_var =~ /^.*{store_value}.*$/
|
379
|
+
string_var = $context_value
|
380
|
+
end
|
381
|
+
|
382
|
+
return string_var
|
328
383
|
end
|
329
384
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
#
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
385
|
+
def replace_year str
|
386
|
+
t = Time.now()
|
387
|
+
return str.gsub("{year}", t.year.to_s)
|
388
|
+
end
|
389
|
+
|
390
|
+
def replace_month str
|
391
|
+
t = Time.now()
|
392
|
+
_month = t.month
|
393
|
+
if _month < 10
|
394
|
+
return str.gsub("{month}", "0#{_month.to_s}")
|
395
|
+
else
|
396
|
+
return str.gsub("{month}", "#{_month.to_s}")
|
397
|
+
end
|
398
|
+
return str
|
399
|
+
end
|
400
|
+
|
401
|
+
def replace_day str
|
402
|
+
t = Time.now()
|
403
|
+
_day = t.day
|
404
|
+
if _day < 10
|
405
|
+
return str.gsub("{day}", "0#{_day.to_s}")
|
406
|
+
else
|
407
|
+
return str.gsub("{day}", "#{_day.to_s}")
|
348
408
|
end
|
349
|
-
|
409
|
+
return str
|
410
|
+
end
|
411
|
+
|
412
|
+
def replace_pipe str_pipe
|
413
|
+
put_log ">>>> #{str_pipe}"
|
414
|
+
if str_pipe =~ /^.*{pipe}.*$/
|
415
|
+
return str_pipe.gsub("{pipe}", "|")
|
416
|
+
end
|
417
|
+
return str_pipe
|
418
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mail'
|
2
|
+
# require 'email_spec'
|
3
|
+
# include EmailSpec::Helpers
|
4
|
+
# include EmailSpec::Matcher
|
5
|
+
class IFD_Email
|
6
|
+
def self.send_email(to_address, subject, body_email, attachments)
|
7
|
+
include Mail::Matchers
|
8
|
+
# Mail::TestMailer.deliveries.clear
|
9
|
+
Mail.deliver do
|
10
|
+
from "anhpq.info@gmail.com"
|
11
|
+
to to_address if to_address
|
12
|
+
subject subject if subject
|
13
|
+
body body_email if body_email
|
14
|
+
add_file attachments if attachments
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|