roku_builder 3.12.8 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG +9 -0
- data/Gemfile.lock +17 -11
- data/bin/roku +4 -8
- data/lib/roku_builder.rb +16 -24
- data/lib/roku_builder/config.rb +213 -0
- data/lib/roku_builder/config_parser.rb +304 -267
- data/lib/roku_builder/config_validator.rb +149 -126
- data/lib/roku_builder/controller.rb +34 -184
- data/lib/roku_builder/controller_commands.rb +85 -79
- data/lib/roku_builder/error_handler.rb +0 -11
- data/lib/roku_builder/errors.rb +12 -0
- data/lib/roku_builder/inspector.rb +6 -4
- data/lib/roku_builder/keyer.rb +1 -1
- data/lib/roku_builder/loader.rb +1 -1
- data/lib/roku_builder/logger.rb +32 -0
- data/lib/roku_builder/manifest_manager.rb +2 -2
- data/lib/roku_builder/monitor.rb +1 -1
- data/lib/roku_builder/options.rb +113 -0
- data/lib/roku_builder/stager.rb +2 -2
- data/lib/roku_builder/tester.rb +57 -11
- data/lib/roku_builder/util.rb +3 -4
- data/lib/roku_builder/version.rb +1 -1
- data/roku_builder.gemspec +2 -1
- data/test/roku_builder/test_config.rb +168 -0
- data/test/roku_builder/test_config_parser.rb +347 -394
- data/test/roku_builder/test_config_validator.rb +193 -190
- data/test/roku_builder/test_controller.rb +59 -178
- data/test/roku_builder/test_controller_commands.rb +407 -394
- data/test/roku_builder/test_error_handler.rb +67 -69
- data/test/roku_builder/test_files/config_test/bad.json +2 -0
- data/test/roku_builder/test_files/config_test/child.json +11 -0
- data/test/roku_builder/test_files/config_test/config.json +29 -0
- data/test/roku_builder/test_files/config_test/non_json.json +1 -0
- data/test/roku_builder/test_files/config_test/parent.json +21 -0
- data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
- data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
- data/test/roku_builder/test_helper.rb +55 -45
- data/test/roku_builder/test_inspector.rb +278 -213
- data/test/roku_builder/test_keyer.rb +144 -147
- data/test/roku_builder/test_linker.rb +91 -95
- data/test/roku_builder/test_loader.rb +279 -289
- data/test/roku_builder/test_logger.rb +47 -0
- data/test/roku_builder/test_manifest_manager.rb +92 -94
- data/test/roku_builder/test_monitor.rb +101 -103
- data/test/roku_builder/test_navigator.rb +240 -245
- data/test/roku_builder/test_options.rb +156 -0
- data/test/roku_builder/test_packager.rb +108 -108
- data/test/roku_builder/test_profiler.rb +20 -19
- data/test/roku_builder/test_scripter.rb +83 -81
- data/test/roku_builder/test_stager.rb +299 -311
- data/test/roku_builder/test_tester.rb +112 -115
- data/test/roku_builder/test_util.rb +18 -17
- metadata +39 -6
- data/lib/roku_builder/config_manager.rb +0 -161
- data/test/roku_builder/test_config_manager.rb +0 -372
@@ -1,90 +1,88 @@
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
|
-
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module RokuBuilder
|
5
|
+
class ErrorHandler
|
6
|
+
class << self
|
7
|
+
def abort
|
8
|
+
#do nothing
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
|
-
end
|
12
12
|
|
13
|
-
class ErrorHandlerTest < Minitest::Test
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
class ErrorHandlerTest < Minitest::Test
|
14
|
+
def test_handle_error_codes
|
15
|
+
error_groups = {
|
16
|
+
fatal: {
|
17
17
|
options_code: [
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
EXTRA_COMMANDS,
|
19
|
+
NO_COMMANDS,
|
20
|
+
EXTRA_SOURCES,
|
21
|
+
NO_SOURCE,
|
22
|
+
BAD_CURRENT,
|
23
|
+
BAD_IN_FILE
|
24
|
+
],
|
25
25
|
configure_code:[
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
26
|
+
CONFIG_OVERWRITE,
|
27
|
+
],
|
28
|
+
device_code: [
|
29
|
+
BAD_DEVICE,
|
30
|
+
NO_DEVICES,
|
31
|
+
],
|
32
|
+
load_code: [
|
33
|
+
MISSING_CONFIG,
|
34
|
+
INVALID_CONFIG,
|
35
|
+
MISSING_MANIFEST,
|
36
|
+
UNKNOWN_DEVICE,
|
37
|
+
UNKNOWN_PROJECT,
|
38
|
+
UNKNOWN_STAGE,
|
39
|
+
BAD_PROJECT_DIR,
|
40
|
+
BAD_KEY_FILE
|
41
|
+
],
|
42
42
|
command_code: [
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
FAILED_SIDELOAD,
|
44
|
+
FAILED_SIGNING,
|
45
|
+
FAILED_DEEPLINKING,
|
46
|
+
FAILED_NAVIGATING,
|
47
|
+
FAILED_SCREENCAPTURE,
|
48
|
+
MISSING_MANIFEST,
|
49
|
+
BAD_PRINT_ATTRIBUTE
|
50
|
+
],
|
51
51
|
configs_code: [
|
52
|
-
|
53
|
-
|
52
|
+
MISSING_OUT_FOLDER
|
53
|
+
]
|
54
54
|
},
|
55
|
-
|
55
|
+
info: {
|
56
56
|
device_code: [
|
57
|
-
|
58
|
-
|
57
|
+
CHANGED_DEVICE
|
58
|
+
],
|
59
59
|
configure_code:[
|
60
|
-
|
61
|
-
|
60
|
+
SUCCESS
|
61
|
+
]
|
62
62
|
},
|
63
|
-
|
63
|
+
warn: {
|
64
64
|
load_code: [
|
65
|
-
|
66
|
-
|
67
|
-
options_code: [
|
68
|
-
RokuBuilder::DEPRICATED
|
69
|
-
]
|
65
|
+
DEPRICATED_CONFIG
|
66
|
+
]
|
70
67
|
},
|
71
|
-
|
68
|
+
debug: {
|
72
69
|
configs_code: [
|
73
|
-
|
74
|
-
|
70
|
+
VALID
|
71
|
+
]
|
72
|
+
}
|
75
73
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
error_groups.each_pair do |type,errors|
|
75
|
+
errors.each_pair do |key,value|
|
76
|
+
value.each do |code|
|
77
|
+
logger = Minitest::Mock.new
|
78
|
+
options = {logger: logger}
|
79
|
+
options[:options] = {deeplink_depricated: true} if key == :load_code or key == :options_code
|
80
|
+
options[key] = code
|
81
|
+
logger.expect(type, nil) {|string| string.class == String}
|
82
|
+
method = "handle_#{key}s"
|
83
|
+
ErrorHandler.send(method.to_sym, **options)
|
84
|
+
logger.verify
|
85
|
+
end
|
88
86
|
end
|
89
87
|
end
|
90
88
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"devices": {
|
3
|
+
"default": "roku",
|
4
|
+
"roku": {
|
5
|
+
"ip": "111.222.333.444",
|
6
|
+
"user": "user",
|
7
|
+
"password": "pass"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"projects": {
|
11
|
+
"default": "p1",
|
12
|
+
"p1": {
|
13
|
+
"directory": "/tmp",
|
14
|
+
"folders": ["resources","source"],
|
15
|
+
"files": ["manifest"],
|
16
|
+
"app_name": "app",
|
17
|
+
"stage_method": "git",
|
18
|
+
"stages":{
|
19
|
+
"production": {
|
20
|
+
"branch": "master",
|
21
|
+
"key": {
|
22
|
+
"keyed_pkg": "/tmp/package.pkg",
|
23
|
+
"password": "password"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
badconfig
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"projects": {
|
3
|
+
"default": "p1",
|
4
|
+
"p1": {
|
5
|
+
"directory": "/tmp",
|
6
|
+
"folders": ["resources","source"],
|
7
|
+
"files": ["manifest"],
|
8
|
+
"app_name": "app",
|
9
|
+
"stage_method": "git",
|
10
|
+
"stages":{
|
11
|
+
"production": {
|
12
|
+
"branch": "master",
|
13
|
+
"key": {
|
14
|
+
"keyed_pkg": "/tmp/package.pkg",
|
15
|
+
"password": "password"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"devices": {
|
3
|
+
"default": "roku",
|
4
|
+
"roku": {
|
5
|
+
"ip": "111.222.333.444",
|
6
|
+
"user": "user",
|
7
|
+
"password": "pass"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"projects": {
|
11
|
+
"default": "p1",
|
12
|
+
"p1": {
|
13
|
+
"parent": "parent2"
|
14
|
+
},
|
15
|
+
"parent1": {
|
16
|
+
"directory": "/tmp",
|
17
|
+
"folders": ["resources","source"],
|
18
|
+
"files": ["manifest"],
|
19
|
+
"app_name": "app",
|
20
|
+
"stage_method": "git",
|
21
|
+
"stages":{
|
22
|
+
"production": {
|
23
|
+
"branch": "master",
|
24
|
+
"key": {
|
25
|
+
"keyed_pkg": "/tmp/package.pkg",
|
26
|
+
"password": "password"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"parent2": {
|
32
|
+
"parent": "parent1"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
@@ -13,57 +13,67 @@ require "byebug"
|
|
13
13
|
require "roku_builder"
|
14
14
|
require "minitest/autorun"
|
15
15
|
|
16
|
+
RokuBuilder::Logger.set_testing
|
17
|
+
|
18
|
+
def test_files_path(klass)
|
19
|
+
klass = klass.to_s.split("::")[1].underscore
|
20
|
+
File.join(File.dirname(__FILE__), "test_files", klass)
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_options(options)
|
24
|
+
RokuBuilder::Options.new(options: options)
|
25
|
+
end
|
16
26
|
|
17
27
|
def good_config
|
18
28
|
{
|
19
29
|
devices: {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
default: :roku,
|
31
|
+
roku: {
|
32
|
+
ip: "192.168.0.100",
|
33
|
+
user: "user",
|
34
|
+
password: "password"
|
35
|
+
}
|
36
|
+
},
|
27
37
|
projects: {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
38
|
+
default: :project1,
|
39
|
+
project1: {
|
40
|
+
directory: "/tmp",
|
41
|
+
folders: ["resources","source"],
|
42
|
+
files: ["manifest"],
|
43
|
+
app_name: "<app name>",
|
44
|
+
stage_method: :git,
|
45
|
+
stages:{
|
46
|
+
production: {
|
47
|
+
branch: "production",
|
48
|
+
key: {
|
49
|
+
keyed_pkg: "/tmp",
|
50
|
+
password: "<password for pkg>"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
},
|
55
|
+
project2: {
|
56
|
+
directory: "/tmp",
|
57
|
+
folders: ["resources","source"],
|
58
|
+
files: ["manifest"],
|
59
|
+
app_name: "<app name>",
|
60
|
+
stage_method: :git,
|
61
|
+
stages:{
|
62
|
+
production: {
|
63
|
+
branch: "production",
|
64
|
+
key: "a"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
},
|
59
69
|
keys: {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
70
|
+
a: {
|
71
|
+
keyed_pkg: "/tmp",
|
72
|
+
password: "password"
|
73
|
+
}
|
74
|
+
},
|
65
75
|
input_mapping: {
|
66
|
-
|
67
|
-
|
76
|
+
"a": ["home", "Home"]
|
77
|
+
}
|
68
78
|
}
|
69
79
|
end
|
@@ -1,233 +1,298 @@
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
|
+
module RokuBuilder
|
5
|
+
class InspectorTest < Minitest::Test
|
6
|
+
def test_inspector_inspect
|
7
|
+
connection = Minitest::Mock.new
|
8
|
+
faraday = Minitest::Mock.new
|
9
|
+
io = Minitest::Mock.new
|
10
|
+
response = Minitest::Mock.new
|
4
11
|
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
" r4.insertCell(0).innerHTML = 'dev.zip: ';"+
|
52
|
-
" r4.insertCell(1).innerHTML = '<div class=\"roku-color-c3\"><font face=\"Courier\">dev_zip</font></div>';"
|
53
|
-
|
54
|
-
connection.expect(:post, response) do |arg1, arg2|
|
55
|
-
assert_equal path, arg1
|
56
|
-
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
57
|
-
assert_equal payload[:password], arg2[:passwd]
|
58
|
-
assert payload[:archive] === arg2[:archive]
|
59
|
-
end
|
60
|
-
faraday.expect(:headers, {})
|
61
|
-
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
62
|
-
faraday.expect(:request, nil, [:multipart])
|
63
|
-
faraday.expect(:request, nil, [:url_encoded])
|
64
|
-
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
65
|
-
response.expect(:body, body)
|
66
|
-
response.expect(:body, body)
|
67
|
-
response.expect(:body, body)
|
68
|
-
response.expect(:body, body)
|
69
|
-
response.expect(:body, body)
|
70
|
-
|
71
|
-
|
72
|
-
package_info = {}
|
73
|
-
inspector = RokuBuilder::Inspector.new(**device_config)
|
74
|
-
Faraday.stub(:new, connection, faraday) do
|
75
|
-
Faraday::UploadIO.stub(:new, io) do
|
76
|
-
package_info = inspector.inspect(pkg: "pkg/path", password: password)
|
12
|
+
device_config = {
|
13
|
+
ip: "111.222.333",
|
14
|
+
user: "user",
|
15
|
+
password: "password"
|
16
|
+
}
|
17
|
+
path = "/plugin_inspect"
|
18
|
+
password = "password"
|
19
|
+
payload ={
|
20
|
+
mysubmit: "Inspect",
|
21
|
+
password: password,
|
22
|
+
archive: io
|
23
|
+
}
|
24
|
+
body = "r1.insertCell(0).innerHTML = 'App Name: ';"+
|
25
|
+
" r1.insertCell(1).innerHTML = '<div class=\"roku-color-c3\">app_name</div>';"+
|
26
|
+
""+
|
27
|
+
" var r2 = table.insertRow(1);"+
|
28
|
+
" r2.insertCell(0).innerHTML = 'Dev ID: ';"+
|
29
|
+
" r2.insertCell(1).innerHTML = '<div class=\"roku-color-c3\"><font face=\"Courier\">dev_id</font></div>';"+
|
30
|
+
" "+
|
31
|
+
" var dd = new Date(628232400);"+
|
32
|
+
" var ddStr = \"\";"+
|
33
|
+
" ddStr += (dd.getMonth()+1);"+
|
34
|
+
" ddStr += \"/\";"+
|
35
|
+
" ddStr += dd.getDate();"+
|
36
|
+
" ddStr += \"/\";"+
|
37
|
+
" ddStr += dd.getFullYear();"+
|
38
|
+
" ddStr += \" \";"+
|
39
|
+
" ddStr += dd.getHours();"+
|
40
|
+
" ddStr += \":\";"+
|
41
|
+
" ddStr += dd.getMinutes();"+
|
42
|
+
" ddStr += \":\";"+
|
43
|
+
" ddStr += dd.getSeconds(); "+
|
44
|
+
" "+
|
45
|
+
" var r3 = table.insertRow(2);"+
|
46
|
+
" r3.insertCell(0).innerHTML = 'Creation Date: ';"+
|
47
|
+
" r3.insertCell(1).innerHTML = '<div class=\"roku-color-c3\">'+ddStr+'</div>';"+
|
48
|
+
" "+
|
49
|
+
" var r4 = table.insertRow(3);"+
|
50
|
+
" r4.insertCell(0).innerHTML = 'dev.zip: ';"+
|
51
|
+
" r4.insertCell(1).innerHTML = '<div class=\"roku-color-c3\"><font face=\"Courier\">dev_zip</font></div>';"
|
52
|
+
|
53
|
+
connection.expect(:post, response) do |arg1, arg2|
|
54
|
+
assert_equal path, arg1
|
55
|
+
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
56
|
+
assert_equal payload[:password], arg2[:passwd]
|
57
|
+
assert payload[:archive] === arg2[:archive]
|
77
58
|
end
|
78
|
-
|
59
|
+
faraday.expect(:headers, {})
|
60
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
61
|
+
faraday.expect(:request, nil, [:multipart])
|
62
|
+
faraday.expect(:request, nil, [:url_encoded])
|
63
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
64
|
+
response.expect(:body, body)
|
65
|
+
response.expect(:body, body)
|
66
|
+
response.expect(:body, body)
|
67
|
+
response.expect(:body, body)
|
68
|
+
response.expect(:body, body)
|
79
69
|
|
80
|
-
assert_equal "app_name", package_info[:app_name]
|
81
|
-
assert_equal "dev_id", package_info[:dev_id]
|
82
|
-
assert_equal Time.at(628232400).to_s, package_info[:creation_date]
|
83
|
-
assert_equal "dev_zip", package_info[:dev_zip]
|
84
70
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
connection = Minitest::Mock.new
|
92
|
-
faraday = Minitest::Mock.new
|
93
|
-
io = Minitest::Mock.new
|
94
|
-
response = Minitest::Mock.new
|
95
|
-
|
96
|
-
device_config = {
|
97
|
-
ip: "111.222.333",
|
98
|
-
user: "user",
|
99
|
-
password: "password",
|
100
|
-
logger: Logger.new("/dev/null")
|
101
|
-
}
|
102
|
-
path = "/plugin_inspect"
|
103
|
-
password = "password"
|
104
|
-
payload ={
|
105
|
-
mysubmit: "Inspect",
|
106
|
-
password: password,
|
107
|
-
archive: io
|
108
|
-
}
|
109
|
-
body = " <table cellpadding=\"2\">"+
|
110
|
-
" <tbody><tr><td> App Name: </td><td> <font color=\"blue\">app_name</font> </td></tr>"+
|
111
|
-
" <tr><td> Dev ID: </td><td> <font face=\"Courier\" color=\"blue\">dev_id</font> </td></tr>"+
|
112
|
-
" <tr><td> Creation Date: </td><td> <font color=\"blue\">"+
|
113
|
-
" <script type=\"text/javascript\">"+
|
114
|
-
" var d = new Date(628232400)"+
|
115
|
-
" document.write(d.getMonth()+1)"+
|
116
|
-
" document.write(\"/\")"+
|
117
|
-
" document.write(d.getDate())"+
|
118
|
-
" document.write(\"/\");"+
|
119
|
-
" document.write(d.getFullYear())"+
|
120
|
-
" document.write(\" \")"+
|
121
|
-
" document.write(d.getHours())"+
|
122
|
-
" document.write(\":\")"+
|
123
|
-
" document.write(d.getMinutes())"+
|
124
|
-
" document.write(\":\")"+
|
125
|
-
" document.write(d.getSeconds())"+
|
126
|
-
" </script>1/17/1970 16:42:28"+
|
127
|
-
" </font> </td></tr>"+
|
128
|
-
" <tr><td> dev.zip: </td><td> <font face=\"Courier\" color=\"blue\">dev_zip</font> </td></tr>"+
|
129
|
-
" </tbody></table>"
|
130
|
-
|
131
|
-
connection.expect(:post, response) do |arg1, arg2|
|
132
|
-
assert_equal path, arg1
|
133
|
-
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
134
|
-
assert_equal payload[:password], arg2[:passwd]
|
135
|
-
assert payload[:archive] === arg2[:archive]
|
136
|
-
end
|
137
|
-
faraday.expect(:headers, {})
|
138
|
-
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
139
|
-
faraday.expect(:request, nil, [:multipart])
|
140
|
-
faraday.expect(:request, nil, [:url_encoded])
|
141
|
-
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
142
|
-
response.expect(:body, body)
|
143
|
-
response.expect(:body, body)
|
144
|
-
response.expect(:body, body)
|
145
|
-
response.expect(:body, body)
|
146
|
-
|
147
|
-
|
148
|
-
package_info = {}
|
149
|
-
inspector = RokuBuilder::Inspector.new(**device_config)
|
150
|
-
Faraday.stub(:new, connection, faraday) do
|
151
|
-
Faraday::UploadIO.stub(:new, io) do
|
152
|
-
package_info = inspector.inspect(pkg: "pkg/path", password: password)
|
71
|
+
package_info = {}
|
72
|
+
inspector = Inspector.new(**device_config)
|
73
|
+
Faraday.stub(:new, connection, faraday) do
|
74
|
+
Faraday::UploadIO.stub(:new, io) do
|
75
|
+
package_info = inspector.inspect(pkg: "pkg/path", password: password)
|
76
|
+
end
|
153
77
|
end
|
78
|
+
|
79
|
+
assert_equal "app_name", package_info[:app_name]
|
80
|
+
assert_equal "dev_id", package_info[:dev_id]
|
81
|
+
assert_equal Time.at(628232400).to_s, package_info[:creation_date]
|
82
|
+
assert_equal "dev_zip", package_info[:dev_zip]
|
83
|
+
|
84
|
+
connection.verify
|
85
|
+
faraday.verify
|
86
|
+
io.verify
|
87
|
+
response.verify
|
154
88
|
end
|
89
|
+
def test_inspector_inspect_old_interface
|
90
|
+
connection = Minitest::Mock.new
|
91
|
+
faraday = Minitest::Mock.new
|
92
|
+
io = Minitest::Mock.new
|
93
|
+
response = Minitest::Mock.new
|
155
94
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
95
|
+
device_config = {
|
96
|
+
ip: "111.222.333",
|
97
|
+
user: "user",
|
98
|
+
password: "password"
|
99
|
+
}
|
100
|
+
path = "/plugin_inspect"
|
101
|
+
password = "password"
|
102
|
+
payload ={
|
103
|
+
mysubmit: "Inspect",
|
104
|
+
password: password,
|
105
|
+
archive: io
|
106
|
+
}
|
107
|
+
body = " <table cellpadding=\"2\">"+
|
108
|
+
" <tbody><tr><td> App Name: </td><td> <font color=\"blue\">app_name</font> </td></tr>"+
|
109
|
+
" <tr><td> Dev ID: </td><td> <font face=\"Courier\" color=\"blue\">dev_id</font> </td></tr>"+
|
110
|
+
" <tr><td> Creation Date: </td><td> <font color=\"blue\">"+
|
111
|
+
" <script type=\"text/javascript\">"+
|
112
|
+
" var d = new Date(628232400)"+
|
113
|
+
" document.write(d.getMonth()+1)"+
|
114
|
+
" document.write(\"/\")"+
|
115
|
+
" document.write(d.getDate())"+
|
116
|
+
" document.write(\"/\");"+
|
117
|
+
" document.write(d.getFullYear())"+
|
118
|
+
" document.write(\" \")"+
|
119
|
+
" document.write(d.getHours())"+
|
120
|
+
" document.write(\":\")"+
|
121
|
+
" document.write(d.getMinutes())"+
|
122
|
+
" document.write(\":\")"+
|
123
|
+
" document.write(d.getSeconds())"+
|
124
|
+
" </script>1/17/1970 16:42:28"+
|
125
|
+
" </font> </td></tr>"+
|
126
|
+
" <tr><td> dev.zip: </td><td> <font face=\"Courier\" color=\"blue\">dev_zip</font> </td></tr>"+
|
127
|
+
" </tbody></table>"
|
160
128
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
129
|
+
connection.expect(:post, response) do |arg1, arg2|
|
130
|
+
assert_equal path, arg1
|
131
|
+
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
132
|
+
assert_equal payload[:password], arg2[:passwd]
|
133
|
+
assert payload[:archive] === arg2[:archive]
|
134
|
+
end
|
135
|
+
faraday.expect(:headers, {})
|
136
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
137
|
+
faraday.expect(:request, nil, [:multipart])
|
138
|
+
faraday.expect(:request, nil, [:url_encoded])
|
139
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
140
|
+
response.expect(:body, body)
|
141
|
+
response.expect(:body, body)
|
142
|
+
response.expect(:body, body)
|
143
|
+
response.expect(:body, body)
|
144
|
+
|
145
|
+
|
146
|
+
package_info = {}
|
147
|
+
inspector = Inspector.new(**device_config)
|
148
|
+
Faraday.stub(:new, connection, faraday) do
|
149
|
+
Faraday::UploadIO.stub(:new, io) do
|
150
|
+
package_info = inspector.inspect(pkg: "pkg/path", password: password)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
assert_equal "app_name", package_info[:app_name]
|
155
|
+
assert_equal "dev_id", package_info[:dev_id]
|
156
|
+
assert_equal Time.at(628232400).to_s, package_info[:creation_date]
|
157
|
+
assert_equal "dev_zip", package_info[:dev_zip]
|
166
158
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
io = Minitest::Mock.new
|
172
|
-
|
173
|
-
device_config = {
|
174
|
-
ip: "111.222.333",
|
175
|
-
user: "user",
|
176
|
-
password: "password",
|
177
|
-
logger: Logger.new("/dev/null")
|
178
|
-
}
|
179
|
-
screencapture_config = {
|
180
|
-
out_folder: "out/folder/path",
|
181
|
-
out_file: nil
|
182
|
-
}
|
183
|
-
path = "/plugin_inspect"
|
184
|
-
password = "password"
|
185
|
-
payload ={
|
186
|
-
mysubmit: "Screenshot",
|
187
|
-
password: password,
|
188
|
-
archive: io
|
189
|
-
}
|
190
|
-
body = "<hr /><img src=\"pkgs/dev.jpg?time=1455629573\">"
|
191
|
-
connection.expect(:post, response) do |arg1, arg2|
|
192
|
-
assert_equal path, arg1
|
193
|
-
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
194
|
-
assert_equal payload[:password], arg2[:passwd]
|
195
|
-
assert payload[:archive] === arg2[:archive]
|
159
|
+
connection.verify
|
160
|
+
faraday.verify
|
161
|
+
io.verify
|
162
|
+
response.verify
|
196
163
|
end
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
164
|
+
|
165
|
+
def test_screencapture
|
166
|
+
connection = Minitest::Mock.new
|
167
|
+
faraday = Minitest::Mock.new
|
168
|
+
response = Minitest::Mock.new
|
169
|
+
io = Minitest::Mock.new
|
170
|
+
|
171
|
+
device_config = {
|
172
|
+
ip: "111.222.333",
|
173
|
+
user: "user",
|
174
|
+
password: "password"
|
175
|
+
}
|
176
|
+
screencapture_config = {
|
177
|
+
out_folder: "out/folder/path",
|
178
|
+
out_file: nil
|
179
|
+
}
|
180
|
+
path = "/plugin_inspect"
|
181
|
+
password = "password"
|
182
|
+
payload ={
|
183
|
+
mysubmit: "Screenshot",
|
184
|
+
password: password,
|
185
|
+
archive: io
|
186
|
+
}
|
187
|
+
body = "<hr /><img src=\"pkgs/dev.jpg?time=1455629573\">"
|
188
|
+
connection.expect(:post, response) do |arg1, arg2|
|
189
|
+
assert_equal path, arg1
|
190
|
+
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
191
|
+
assert_equal payload[:password], arg2[:passwd]
|
192
|
+
assert payload[:archive] === arg2[:archive]
|
193
|
+
end
|
194
|
+
faraday.expect(:headers, {})
|
195
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
196
|
+
faraday.expect(:request, nil, [:multipart])
|
197
|
+
faraday.expect(:request, nil, [:url_encoded])
|
198
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
199
|
+
response.expect(:body, body)
|
200
|
+
response.expect(:body, body)
|
201
|
+
response.expect(:body, body)
|
202
|
+
|
203
|
+
|
204
|
+
path2 = "pkgs/dev.jpg?time=1455629573"
|
205
|
+
body2 = "<screencapture>"
|
206
|
+
connection.expect(:get, response, [path2])
|
207
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
208
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
209
|
+
response.expect(:body, body2)
|
210
|
+
response.expect(:success?, true)
|
211
|
+
io.expect("write", nil, [body2])
|
212
|
+
|
213
|
+
|
214
|
+
success = false
|
215
|
+
inspector = Inspector.new(**device_config)
|
216
|
+
Faraday.stub(:new, connection, faraday) do
|
217
|
+
Faraday::UploadIO.stub(:new, io) do
|
218
|
+
File.stub(:open, nil, io) do
|
219
|
+
success = inspector.screencapture(**screencapture_config)
|
220
|
+
end
|
222
221
|
end
|
223
222
|
end
|
223
|
+
|
224
|
+
assert success
|
225
|
+
|
226
|
+
connection.verify
|
227
|
+
faraday.verify
|
228
|
+
io.verify
|
229
|
+
response.verify
|
224
230
|
end
|
231
|
+
def test_screencapture_png
|
232
|
+
connection = Minitest::Mock.new
|
233
|
+
faraday = Minitest::Mock.new
|
234
|
+
response = Minitest::Mock.new
|
235
|
+
io = Minitest::Mock.new
|
236
|
+
|
237
|
+
device_config = {
|
238
|
+
ip: "111.222.333",
|
239
|
+
user: "user",
|
240
|
+
password: "password"
|
241
|
+
}
|
242
|
+
screencapture_config = {
|
243
|
+
out_folder: "out/folder/path",
|
244
|
+
out_file: nil
|
245
|
+
}
|
246
|
+
path = "/plugin_inspect"
|
247
|
+
password = "password"
|
248
|
+
payload ={
|
249
|
+
mysubmit: "Screenshot",
|
250
|
+
password: password,
|
251
|
+
archive: io
|
252
|
+
}
|
253
|
+
body = "<hr /><img src=\"pkgs/dev.png?time=1455629573\">"
|
254
|
+
connection.expect(:post, response) do |arg1, arg2|
|
255
|
+
assert_equal path, arg1
|
256
|
+
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
257
|
+
assert_equal payload[:password], arg2[:passwd]
|
258
|
+
assert payload[:archive] === arg2[:archive]
|
259
|
+
end
|
260
|
+
faraday.expect(:headers, {})
|
261
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
262
|
+
faraday.expect(:request, nil, [:multipart])
|
263
|
+
faraday.expect(:request, nil, [:url_encoded])
|
264
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
265
|
+
response.expect(:body, body)
|
266
|
+
response.expect(:body, body)
|
267
|
+
response.expect(:body, body)
|
268
|
+
|
269
|
+
|
270
|
+
path2 = "pkgs/dev.png?time=1455629573"
|
271
|
+
body2 = "<screencapture>"
|
272
|
+
connection.expect(:get, response, [path2])
|
273
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
274
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
275
|
+
response.expect(:body, body2)
|
276
|
+
response.expect(:success?, true)
|
277
|
+
io.expect("write", nil, [body2])
|
278
|
+
|
225
279
|
|
226
|
-
|
280
|
+
success = false
|
281
|
+
inspector = Inspector.new(**device_config)
|
282
|
+
Faraday.stub(:new, connection, faraday) do
|
283
|
+
Faraday::UploadIO.stub(:new, io) do
|
284
|
+
File.stub(:open, nil, io) do
|
285
|
+
success = inspector.screencapture(**screencapture_config)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
227
289
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
290
|
+
assert success
|
291
|
+
|
292
|
+
connection.verify
|
293
|
+
faraday.verify
|
294
|
+
io.verify
|
295
|
+
response.verify
|
296
|
+
end
|
232
297
|
end
|
233
298
|
end
|