glib-web 0.4.60 → 0.4.61
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 187ee3620edc45227fa9735cf7fa76dcc3222e2f
|
4
|
+
data.tar.gz: 8186ad4c2983ff890edf11ec300be961d9c8687a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ad724fbafa89f6401c08477abe1d64f3d0b0fd3c8732fa84efcef6fd24eac5a4f6e411f914b65666e25c423560d1a3dafba4ab59ffd11ab0ccf20fe020292f
|
7
|
+
data.tar.gz: 881746e07bfea3b4d200fbbed451bb6ffa8dcec1f3d530318417cf9859a9e87f2bc681f1cd7a3ee6d6fa1e461f87204f7bd2d32c2844ebe429776fdb464f751a
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Glib
|
2
2
|
module JsonCrawler
|
3
3
|
class NavInitiate < ActionCrawler
|
4
|
-
def initialize(http, args,
|
4
|
+
def initialize(http, args, action)
|
5
5
|
super(http)
|
6
|
-
|
6
|
+
|
7
7
|
@http = http
|
8
|
-
if (json = @http.get args['url'],
|
8
|
+
if (json = @http.get args['url'], action) && (left_drawer = json['leftDrawer'])
|
9
9
|
crawl left_drawer['header']&.[]('childViews')
|
10
10
|
crawl left_drawer['rows']
|
11
11
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Glib
|
2
2
|
module JsonCrawler
|
3
3
|
class WindowsOpen < ActionCrawler
|
4
|
-
def initialize
|
4
|
+
def initialize(http, args, action)
|
5
5
|
@http = http
|
6
6
|
if (url = args['url'])
|
7
|
-
json = @http.get url,
|
7
|
+
json = @http.get url, action
|
8
8
|
|
9
9
|
unless json.nil?
|
10
10
|
crawl json['header']&.[]('childViews')
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Glib
|
3
2
|
module JsonCrawler
|
4
3
|
class Http
|
@@ -21,30 +20,26 @@ module Glib
|
|
21
20
|
@router = router
|
22
21
|
end
|
23
22
|
|
24
|
-
def get(url,
|
25
|
-
fetch(:get, url,
|
23
|
+
def get(url, action, inspect_result = true)
|
24
|
+
fetch(:get, url, action, {}, inspect_result)
|
26
25
|
end
|
27
26
|
|
28
|
-
def post(url,
|
29
|
-
fetch(:post, url,
|
27
|
+
def post(url, action, params)
|
28
|
+
fetch(:post, url, action, params)
|
30
29
|
end
|
31
30
|
|
32
|
-
def patch(url,
|
33
|
-
fetch(:patch, url,
|
31
|
+
def patch(url, action, params)
|
32
|
+
fetch(:patch, url, action, params)
|
34
33
|
end
|
35
34
|
|
36
|
-
def put(url,
|
37
|
-
fetch(:put, url,
|
35
|
+
def put(url, action, params)
|
36
|
+
fetch(:put, url, action, params)
|
38
37
|
end
|
39
38
|
|
40
|
-
def delete(url,
|
41
|
-
fetch(:delete, url,
|
39
|
+
def delete(url, action, params = {})
|
40
|
+
fetch(:delete, url, action, {})
|
42
41
|
end
|
43
42
|
|
44
|
-
# def log(controller, url, response)
|
45
|
-
# @router.log(controller, url, response)
|
46
|
-
# end
|
47
|
-
|
48
43
|
def controller
|
49
44
|
@context.integration_session.controller
|
50
45
|
end
|
@@ -54,7 +49,7 @@ module Glib
|
|
54
49
|
end
|
55
50
|
|
56
51
|
private
|
57
|
-
def fetch(method, url,
|
52
|
+
def fetch(method, url, action, params = {}, inspect_result = true)
|
58
53
|
return nil if url.blank?
|
59
54
|
|
60
55
|
if method == :get
|
@@ -82,19 +77,21 @@ module Glib
|
|
82
77
|
raise
|
83
78
|
end
|
84
79
|
response = @context.response
|
85
|
-
@router.log(
|
86
|
-
|
87
|
-
if
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
response_times << response.headers['X-Runtime'].to_f
|
93
|
-
@context.assert_includes VALID_RESPONSE_CODES, code, "Expected a valid response but was [#{response.code}] #{Rack::Utils::HTTP_STATUS_CODES[response.code.to_i]}:\n#{url}"
|
94
|
-
if response.media_type == 'application/json'
|
95
|
-
JSON.parse(response.body)
|
80
|
+
@router.log(action, url, response)
|
81
|
+
|
82
|
+
if inspect_result
|
83
|
+
if (code = response.code.to_i) == 302
|
84
|
+
redirect_uri = URI(response.headers['Location'])
|
85
|
+
redirect_uri.query = [redirect_uri.query, 'format=json'].compact.join('&')
|
86
|
+
get redirect_uri.to_s, action
|
96
87
|
else
|
97
|
-
|
88
|
+
response_times << response.headers['X-Runtime'].to_f
|
89
|
+
@context.assert_includes VALID_RESPONSE_CODES, code, "Expected a valid response but was [#{response.code}] #{Rack::Utils::HTTP_STATUS_CODES[response.code.to_i]}:\n#{url}"
|
90
|
+
if response.media_type == 'application/json'
|
91
|
+
JSON.parse(response.body)
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
98
95
|
end
|
99
96
|
end
|
100
97
|
end
|
@@ -1,84 +1,85 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
JsonCrawler::
|
49
|
-
when '
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
1
|
+
module Glib
|
2
|
+
module JsonCrawler
|
3
|
+
class Router
|
4
|
+
attr_reader :read_only_actions
|
5
|
+
|
6
|
+
def log(action, url, response = nil)
|
7
|
+
@logger.puts ' ' * @depth + [
|
8
|
+
action,
|
9
|
+
response.present? ? response.code : nil,
|
10
|
+
url
|
11
|
+
].compact.join(' :: ')
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(logger)
|
15
|
+
@depth = -1
|
16
|
+
@logger = logger
|
17
|
+
@visitor = Glib::Json::Traversal::Visitor.new
|
18
|
+
|
19
|
+
# @store_action = store_action
|
20
|
+
|
21
|
+
@read_only_actions = Set.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def step(http, args)
|
25
|
+
if (controller = http.controller)
|
26
|
+
Glib::JsonCrawler::Coverage.coverage_files.add(controller.class.instance_method(http.action_name).source_location.first)
|
27
|
+
end
|
28
|
+
|
29
|
+
if args.is_a?(Hash) && args['rel'] != 'nofollow'
|
30
|
+
if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
|
31
|
+
action = onClick['action']
|
32
|
+
params = onClick
|
33
|
+
end
|
34
|
+
|
35
|
+
if action.present?
|
36
|
+
@depth += 1
|
37
|
+
child = case action
|
38
|
+
when 'initiate_navigation'
|
39
|
+
# @@crawler_actions.add([action, params['url']]) if @@store_action
|
40
|
+
@read_only_actions.add([action, params['url']])
|
41
|
+
JsonCrawler::NavInitiate.new(http, params, action)
|
42
|
+
when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1'
|
43
|
+
# TODO: Shouldn't dialog be crawled as well?
|
44
|
+
unless action == 'dialogs/open-v1'
|
45
|
+
# @@crawler_actions.add([action, params['url']]) if @@store_action
|
46
|
+
@read_only_actions.add([action, params['url']])
|
47
|
+
end
|
48
|
+
JsonCrawler::WindowsOpen.new(http, params, action)
|
49
|
+
when 'http/post-v1'
|
50
|
+
JsonCrawler::ActionHttp.new(:post, http, params, action)
|
51
|
+
when 'forms/submit-v1'
|
52
|
+
forms = @visitor.forms
|
53
|
+
raise 'Submit action needs to be inside a form' if forms.size < 1
|
54
|
+
JsonCrawler::FormsSubmit.new(http, params, action, forms.last)
|
55
|
+
else
|
56
|
+
unless ['http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1'].include?(action)
|
57
|
+
# @@crawler_actions.add([action, params['url']]) if @@store_action
|
58
|
+
@read_only_actions.add([action, params['url']])
|
59
|
+
end
|
60
|
+
self.log action, params['url']
|
61
|
+
end
|
62
|
+
@depth -= 1
|
63
|
+
child
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def follow(http, target_router)
|
69
|
+
@depth += 1
|
70
|
+
target_router.read_only_actions.each do |crawler_action|
|
71
|
+
action, url = crawler_action
|
72
|
+
http.get url, action, false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def tear_down
|
77
|
+
@logger.close
|
78
|
+
end
|
79
|
+
|
80
|
+
def crawl_multiple(views, block)
|
81
|
+
@visitor.traverse_multiple views, block
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|