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
@@ -2,178 +2,175 @@
|
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
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
|
-
|
5
|
+
module RokuBuilder
|
6
|
+
class KeyerTest < Minitest::Test
|
7
|
+
def test_keyer_dev_id
|
8
|
+
connection = Minitest::Mock.new
|
9
|
+
faraday = Minitest::Mock.new
|
10
|
+
response = Minitest::Mock.new
|
11
|
+
|
12
|
+
device_config = {
|
13
|
+
ip: "111.222.333",
|
14
|
+
user: "user",
|
15
|
+
password: "password"
|
16
|
+
}
|
17
|
+
path = "/plugin_package"
|
18
|
+
body = "v class=\"roku-font-5\"><label>Your Dev ID: </label> dev_id<hr></div>"
|
19
|
+
|
20
|
+
connection.expect(:get, response, [path])
|
21
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
22
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
23
|
+
response.expect(:body, body)
|
24
|
+
response.expect(:body, body)
|
25
|
+
|
26
|
+
|
27
|
+
dev_id = nil
|
28
|
+
keyer = Keyer.new(**device_config)
|
29
|
+
Faraday.stub(:new, connection, faraday) do
|
30
|
+
dev_id = keyer.dev_id
|
31
|
+
end
|
32
32
|
|
33
|
-
|
33
|
+
assert_equal "dev_id", dev_id
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
def test_keyer_dev_id_old_interface
|
40
|
-
connection = Minitest::Mock.new
|
41
|
-
faraday = Minitest::Mock.new
|
42
|
-
response = Minitest::Mock.new
|
43
|
-
|
44
|
-
device_config = {
|
45
|
-
ip: "111.222.333",
|
46
|
-
user: "user",
|
47
|
-
password: "password",
|
48
|
-
logger: Logger.new("/dev/null")
|
49
|
-
}
|
50
|
-
path = "/plugin_package"
|
51
|
-
body = "<p> Your Dev ID: <font face=\"Courier\">dev_id</font> </p>"
|
52
|
-
|
53
|
-
connection.expect(:get, response, [path])
|
54
|
-
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
55
|
-
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
56
|
-
response.expect(:body, body)
|
57
|
-
|
58
|
-
|
59
|
-
dev_id = nil
|
60
|
-
keyer = RokuBuilder::Keyer.new(**device_config)
|
61
|
-
Faraday.stub(:new, connection, faraday) do
|
62
|
-
dev_id = keyer.dev_id
|
35
|
+
connection.verify
|
36
|
+
faraday.verify
|
37
|
+
response.verify
|
63
38
|
end
|
39
|
+
def test_keyer_dev_id_old_interface
|
40
|
+
connection = Minitest::Mock.new
|
41
|
+
faraday = Minitest::Mock.new
|
42
|
+
response = Minitest::Mock.new
|
43
|
+
|
44
|
+
device_config = {
|
45
|
+
ip: "111.222.333",
|
46
|
+
user: "user",
|
47
|
+
password: "password"
|
48
|
+
}
|
49
|
+
path = "/plugin_package"
|
50
|
+
body = "<p> Your Dev ID: <font face=\"Courier\">dev_id</font> </p>"
|
51
|
+
|
52
|
+
connection.expect(:get, response, [path])
|
53
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
54
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
55
|
+
response.expect(:body, body)
|
56
|
+
|
57
|
+
|
58
|
+
dev_id = nil
|
59
|
+
keyer = Keyer.new(**device_config)
|
60
|
+
Faraday.stub(:new, connection, faraday) do
|
61
|
+
dev_id = keyer.dev_id
|
62
|
+
end
|
64
63
|
|
65
|
-
|
64
|
+
assert_equal "dev_id", dev_id
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_keyer_rekey_changed
|
73
|
-
connection = Minitest::Mock.new
|
74
|
-
faraday = Minitest::Mock.new
|
75
|
-
io = Minitest::Mock.new
|
76
|
-
response = Minitest::Mock.new
|
77
|
-
|
78
|
-
device_config = {
|
79
|
-
ip: "111.222.333",
|
80
|
-
user: "user",
|
81
|
-
password: "password",
|
82
|
-
logger: Logger.new("/dev/null")
|
83
|
-
}
|
84
|
-
path = "/plugin_inspect"
|
85
|
-
password = "password"
|
86
|
-
payload ={
|
87
|
-
mysubmit: "Rekey",
|
88
|
-
password: password,
|
89
|
-
archive: io
|
90
|
-
}
|
91
|
-
|
92
|
-
connection.expect(:post, response) do |arg1, arg2|
|
93
|
-
assert_equal path, arg1
|
94
|
-
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
95
|
-
assert_equal payload[:password], arg2[:passwd]
|
96
|
-
assert payload[:archive] === arg2[:archive]
|
66
|
+
connection.verify
|
67
|
+
faraday.verify
|
68
|
+
response.verify
|
97
69
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
70
|
+
|
71
|
+
def test_keyer_rekey_changed
|
72
|
+
connection = Minitest::Mock.new
|
73
|
+
faraday = Minitest::Mock.new
|
74
|
+
io = Minitest::Mock.new
|
75
|
+
response = Minitest::Mock.new
|
76
|
+
|
77
|
+
device_config = {
|
78
|
+
ip: "111.222.333",
|
79
|
+
user: "user",
|
80
|
+
password: "password"
|
81
|
+
}
|
82
|
+
path = "/plugin_inspect"
|
83
|
+
password = "password"
|
84
|
+
payload ={
|
85
|
+
mysubmit: "Rekey",
|
86
|
+
password: password,
|
87
|
+
archive: io
|
88
|
+
}
|
89
|
+
|
90
|
+
connection.expect(:post, response) do |arg1, arg2|
|
91
|
+
assert_equal path, arg1
|
92
|
+
assert_equal payload[:mysubmit], arg2[:mysubmit]
|
93
|
+
assert_equal payload[:password], arg2[:passwd]
|
94
|
+
assert payload[:archive] === arg2[:archive]
|
95
|
+
end
|
96
|
+
faraday.expect(:headers, {})
|
97
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
98
|
+
faraday.expect(:request, nil, [:multipart])
|
99
|
+
faraday.expect(:request, nil, [:url_encoded])
|
100
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
101
|
+
|
102
|
+
# This test fails with the following seeds due to the random number
|
103
|
+
# generator spitting out the same number twice
|
104
|
+
# SEED=21894
|
105
|
+
# SEED=31813
|
106
|
+
dev_id = Proc.new {"#{Random.rand(100)}"}
|
107
|
+
keyer = Keyer.new(**device_config)
|
108
|
+
key_changed = nil
|
109
|
+
Faraday.stub(:new, connection, faraday) do
|
110
|
+
Faraday::UploadIO.stub(:new, io) do
|
111
|
+
keyer.stub(:dev_id, dev_id) do
|
112
|
+
key_changed = keyer.rekey(keyed_pkg: "pkg/path", password: password)
|
113
|
+
end
|
115
114
|
end
|
116
115
|
end
|
117
|
-
end
|
118
116
|
|
119
|
-
|
117
|
+
assert key_changed
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
119
|
+
connection.verify
|
120
|
+
faraday.verify
|
121
|
+
io.verify
|
122
|
+
response.verify
|
123
|
+
end
|
126
124
|
|
127
|
-
|
128
|
-
|
125
|
+
def test_keyer_generate_new_key
|
126
|
+
connection = Minitest::Mock.new
|
129
127
|
|
130
|
-
|
131
|
-
|
128
|
+
connection.expect(:puts, nil, ["genkey"])
|
129
|
+
connection.expect(:waitfor, nil) do |config, &blk|
|
132
130
|
assert_equal(/./, config['Match'])
|
133
131
|
assert_equal(false, config['Timeout'])
|
134
132
|
txt = "Password: password\nDevID: devid\n"
|
135
133
|
blk.call(txt)
|
136
134
|
true
|
135
|
+
end
|
136
|
+
connection.expect(:close, nil, [])
|
137
|
+
|
138
|
+
device_config = {
|
139
|
+
ip: "111.222.333",
|
140
|
+
user: "user",
|
141
|
+
password: "password"
|
142
|
+
}
|
143
|
+
keyer = Keyer.new(**device_config)
|
144
|
+
Net::Telnet.stub(:new, connection) do
|
145
|
+
keyer.send(:generate_new_key)
|
146
|
+
end
|
137
147
|
end
|
138
|
-
connection.expect(:close, nil, [])
|
139
|
-
|
140
|
-
device_config = {
|
141
|
-
ip: "111.222.333",
|
142
|
-
user: "user",
|
143
|
-
password: "password",
|
144
|
-
logger: Logger.new("/dev/null")
|
145
|
-
}
|
146
|
-
keyer = RokuBuilder::Keyer.new(**device_config)
|
147
|
-
Net::Telnet.stub(:new, connection) do
|
148
|
-
keyer.send(:generate_new_key)
|
149
|
-
end
|
150
|
-
end
|
151
148
|
|
152
|
-
|
153
|
-
|
154
|
-
|
149
|
+
def test_keyer_genkey
|
150
|
+
loader = Minitest::Mock.new
|
151
|
+
packager = Minitest::Mock.new
|
155
152
|
|
156
|
-
|
157
|
-
|
153
|
+
loader.expect(:sideload, nil)
|
154
|
+
packager.expect(:package, nil, [app_name_version: "key_dev_id", out_file: "/tmp/key_dev_id.pkg", password: "password"])
|
158
155
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
}
|
156
|
+
device_config = {
|
157
|
+
ip: "111.222.333",
|
158
|
+
user: "user",
|
159
|
+
password: "password"
|
160
|
+
}
|
165
161
|
|
166
|
-
|
162
|
+
keyer = Keyer.new(**device_config)
|
167
163
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
164
|
+
Loader.stub(:new, loader) do
|
165
|
+
Packager.stub(:new, packager) do
|
166
|
+
keyer.stub(:generate_new_key, ["password", "dev_id"]) do
|
167
|
+
keyer.genkey
|
168
|
+
end
|
172
169
|
end
|
173
170
|
end
|
174
|
-
end
|
175
171
|
|
176
|
-
|
177
|
-
|
172
|
+
loader.verify
|
173
|
+
packager.verify
|
174
|
+
end
|
178
175
|
end
|
179
176
|
end
|
@@ -2,113 +2,109 @@
|
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module RokuBuilder
|
6
|
+
class LinkerTest < Minitest::Test
|
7
|
+
def test_linker_link
|
8
|
+
connection = Minitest::Mock.new
|
9
|
+
faraday = Minitest::Mock.new
|
10
|
+
response = Minitest::Mock.new
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
options = 'a:A, b:B:C, d:a\b'
|
12
|
+
device_config = {
|
13
|
+
ip: "111.222.333",
|
14
|
+
user: "user",
|
15
|
+
password: "password"
|
16
|
+
}
|
17
|
+
path = "/launch/dev?a=A&b=B%3AC&d=a%5Cb"
|
18
|
+
options = 'a:A, b:B:C, d:a\b'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
connection.expect(:post, response, [path])
|
21
|
+
faraday.expect(:headers, {})
|
22
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
23
|
+
faraday.expect(:request, nil, [:multipart])
|
24
|
+
faraday.expect(:request, nil, [:url_encoded])
|
25
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
26
|
+
response.expect(:success?, true)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
linker = Linker.new(**device_config)
|
29
|
+
success = nil
|
30
|
+
Faraday.stub(:new, connection, faraday) do
|
31
|
+
success = linker.launch(options: options)
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
assert success
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
def test_linker_link_nothing
|
41
|
-
logger = Minitest::Mock.new
|
42
|
-
connection = Minitest::Mock.new
|
43
|
-
faraday = Minitest::Mock.new
|
44
|
-
response = Minitest::Mock.new
|
45
|
-
|
46
|
-
device_config = {
|
47
|
-
ip: "111.222.333",
|
48
|
-
user: "user",
|
49
|
-
password: "password",
|
50
|
-
logger: logger
|
51
|
-
}
|
52
|
-
path = "/launch/dev"
|
53
|
-
options = ''
|
54
|
-
logger.expect(:warn, nil, ["No options sent to launched app"])
|
55
|
-
connection.expect(:post, response, [path])
|
56
|
-
faraday.expect(:headers, {})
|
57
|
-
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
58
|
-
faraday.expect(:request, nil, [:multipart])
|
59
|
-
faraday.expect(:request, nil, [:url_encoded])
|
60
|
-
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
61
|
-
response.expect(:success?, true)
|
62
|
-
linker = RokuBuilder::Linker.new(**device_config)
|
63
|
-
success = nil
|
64
|
-
Faraday.stub(:new, connection, faraday) do
|
65
|
-
success = linker.launch(options: options)
|
36
|
+
connection.verify
|
37
|
+
faraday.verify
|
38
|
+
response.verify
|
66
39
|
end
|
40
|
+
def test_linker_link_nothing
|
41
|
+
connection = Minitest::Mock.new
|
42
|
+
faraday = Minitest::Mock.new
|
43
|
+
response = Minitest::Mock.new
|
67
44
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
45
|
+
device_config = {
|
46
|
+
ip: "111.222.333",
|
47
|
+
user: "user",
|
48
|
+
password: "password"
|
49
|
+
}
|
50
|
+
path = "/launch/dev"
|
51
|
+
options = ''
|
52
|
+
connection.expect(:post, response, [path])
|
53
|
+
faraday.expect(:headers, {})
|
54
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
55
|
+
faraday.expect(:request, nil, [:multipart])
|
56
|
+
faraday.expect(:request, nil, [:url_encoded])
|
57
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
58
|
+
response.expect(:success?, true)
|
59
|
+
linker = Linker.new(**device_config)
|
60
|
+
success = nil
|
61
|
+
Faraday.stub(:new, connection, faraday) do
|
62
|
+
success = linker.launch(options: options)
|
63
|
+
end
|
64
|
+
|
65
|
+
assert success
|
66
|
+
connection.verify
|
67
|
+
faraday.verify
|
68
|
+
response.verify
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
def test_linker_list
|
72
|
+
connection = Minitest::Mock.new
|
73
|
+
faraday = Minitest::Mock.new
|
74
|
+
response = Minitest::Mock.new
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
<app id=\"
|
89
|
-
<app id=\"
|
90
|
-
<app id=\"
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
linker = RokuBuilder::Linker.new(**device_config)
|
76
|
+
device_config = {
|
77
|
+
ip: "111.222.333",
|
78
|
+
user: "user",
|
79
|
+
password: "password"
|
80
|
+
}
|
81
|
+
path = "/query/apps"
|
82
|
+
body = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<apps>\n\t
|
83
|
+
<app id=\"31012\" type=\"menu\" version=\"1.6.3\">Movie Store and TV Store</app>\n\t
|
84
|
+
<app id=\"31863\" type=\"menu\" version=\"1.2.6\">Roku Home News</app>\n\t
|
85
|
+
<app id=\"65066\" type=\"appl\" version=\"1.3.0\">Nick</app>\n\t
|
86
|
+
<app id=\"68161\" type=\"appl\" version=\"1.3.0\">Nick</app>\n\t
|
87
|
+
</apps>\n"
|
88
|
+
connection.expect(:get, response, [path])
|
89
|
+
faraday.expect(:headers, {})
|
90
|
+
faraday.expect(:request, nil, [:digest, device_config[:user], device_config[:password]])
|
91
|
+
faraday.expect(:request, nil, [:multipart])
|
92
|
+
faraday.expect(:request, nil, [:url_encoded])
|
93
|
+
faraday.expect(:adapter, nil, [Faraday.default_adapter])
|
94
|
+
response.expect(:success?, true)
|
95
|
+
response.expect(:body, body)
|
96
|
+
linker = Linker.new(**device_config)
|
102
97
|
|
103
|
-
|
104
|
-
|
98
|
+
print_count = 0
|
99
|
+
did_print = Proc.new { |msg| print_count+=1 }
|
105
100
|
|
106
|
-
|
107
|
-
|
108
|
-
|
101
|
+
Faraday.stub(:new, connection, faraday) do
|
102
|
+
linker.stub(:printf, did_print) do
|
103
|
+
linker.list
|
104
|
+
end
|
109
105
|
end
|
110
|
-
end
|
111
106
|
|
112
|
-
|
107
|
+
assert_equal 6, print_count
|
108
|
+
end
|
113
109
|
end
|
114
110
|
end
|