t2-server 1.1.0 → 1.2.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 +15 -0
- data/.gitignore +1 -0
- data/.ruby-env +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -1
- data/CHANGES.rdoc +49 -0
- data/README.rdoc +10 -8
- data/bin/t2-delete-runs +0 -3
- data/lib/t2-server-cli.rb +16 -9
- data/lib/t2-server/exceptions.rb +7 -19
- data/lib/t2-server/net/connection.rb +14 -6
- data/lib/t2-server/net/credentials.rb +12 -1
- data/lib/t2-server/net/parameters.rb +3 -3
- data/lib/t2-server/port.rb +12 -29
- data/lib/t2-server/run.rb +54 -35
- data/lib/t2-server/server.rb +3 -4
- data/lib/t2-server/xml.rb +0 -1
- data/lib/t2-server/xml/methods.rb +97 -4
- data/t2-server.gemspec +4 -1
- data/test/helpers/fake-run.rb +47 -0
- data/test/helpers/test-cache.rb +49 -0
- data/test/helpers/test-xml.rb +36 -0
- data/test/helpers/timezone.rb +39 -0
- data/test/mocked-server-responses/.gitattributes +1 -0
- data/test/mocked-server-responses/get-admin.raw +6 -0
- data/test/mocked-server-responses/get-rest-policy-runlimit.raw +6 -0
- data/test/mocked-server-responses/get-rest-policy.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-input-expected.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-input.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-interaction-feed-0.raw +11 -0
- data/test/mocked-server-responses/get-rest-run-interaction-feed-1.raw +92 -0
- data/test/mocked-server-responses/get-rest-run-interaction-feed-2.raw +80 -0
- data/test/mocked-server-responses/get-rest-run-name.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-output-list-errors.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-output.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-security-permissions.raw +6 -0
- data/test/mocked-server-responses/get-rest-run-security.raw +6 -0
- data/test/mocked-server-responses/get-rest-run.raw +6 -0
- data/test/mocked-server-responses/get-rest-runs.raw +6 -0
- data/test/mocked-server-responses/get-rest.raw +6 -0
- data/test/mocked-server-responses/log.txt +1 -0
- data/test/mocked-server-responses/mocks.rb +107 -0
- data/test/mocked-server-responses/options-admin-allownew.raw +7 -0
- data/test/tc_admin.rb +52 -24
- data/test/tc_admin_live.rb +66 -0
- data/test/tc_connection.rb +87 -0
- data/test/tc_connection_exceptions.rb +86 -0
- data/test/tc_credentials.rb +73 -0
- data/test/tc_interaction.rb +182 -0
- data/test/{tc_misc.rb → tc_misc_live.rb} +3 -1
- data/test/tc_params.rb +82 -4
- data/test/tc_perms.rb +54 -101
- data/test/tc_perms_live.rb +150 -0
- data/test/tc_ports.rb +192 -0
- data/test/tc_run.rb +333 -350
- data/test/tc_run_live.rb +453 -0
- data/test/{tc_secure.rb → tc_secure_live.rb} +30 -29
- data/test/tc_server.rb +115 -42
- data/test/tc_server_live.rb +92 -0
- data/test/tc_server_version.rb +19 -0
- data/test/tc_xml_messages.rb +201 -0
- data/test/ts_t2server.rb +37 -43
- data/test/workflows/secure/heater-pk.pem +24 -18
- data/test/workflows/secure/user-cert.p12 +0 -0
- data/version.yml +1 -1
- metadata +136 -29
- data/lib/t2-server/xml/fragments.rb +0 -78
data/test/tc_perms.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
2
2
|
#
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
@@ -30,119 +30,72 @@
|
|
30
30
|
#
|
31
31
|
# Author: Robert Haines
|
32
32
|
|
33
|
+
require 'mocked-server-responses/mocks'
|
33
34
|
require 't2-server'
|
34
35
|
|
35
36
|
class TestPermissions < Test::Unit::TestCase
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
37
|
+
include T2Server::Mocks
|
38
|
+
|
39
|
+
WKF_PASS = "test/workflows/pass_through.t2flow"
|
40
|
+
|
41
|
+
# Need to lock down the run UUID so recorded server responses make sense.
|
42
|
+
RUN_UUID = "a341b87f-25cc-4dfd-be36-f5b073a6ba74"
|
43
|
+
RUN_PATH = "/rest/runs/#{RUN_UUID}"
|
44
|
+
|
45
|
+
def setup
|
46
|
+
# Register common mocks.
|
47
|
+
mock("/rest/", :accept => "application/xml", :output => "get-rest.raw")
|
48
|
+
mock("/rest/policy", :accept => "application/xml",
|
49
|
+
:output => "get-rest-policy.raw")
|
50
|
+
mock("/rest/runs", :method => :post, :credentials => $userinfo,
|
51
|
+
:status => 201,
|
52
|
+
:location => "https://localhost/taverna#{RUN_PATH}")
|
53
|
+
mock(RUN_PATH, :accept => "application/xml", :credentials => $userinfo,
|
54
|
+
:output => "get-rest-run.raw")
|
55
|
+
mock("#{RUN_PATH}/input", :accept => "application/xml",
|
56
|
+
:credentials => $userinfo, :output => "get-rest-run-input.raw")
|
57
|
+
mock("#{RUN_PATH}/security", :accept => "application/xml",
|
58
|
+
:credentials => $userinfo, :output => "get-rest-run-security.raw")
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
run.grant_permission($creds1.username, :read)
|
67
|
-
end
|
68
|
-
|
69
|
-
run_id = run.identifier
|
70
|
-
|
71
|
-
run1 = nil
|
72
|
-
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
73
|
-
run1 = server.run(run_id, $creds1)
|
74
|
-
end
|
75
|
-
|
76
|
-
assert_raise(T2Server::AccessForbiddenError) do
|
77
|
-
run1.input_port("IN").value = "Hello, World!"
|
78
|
-
run1.start
|
79
|
-
end
|
80
|
-
|
81
|
-
run.input_port("IN").value = "Hello, World!"
|
82
|
-
run.start
|
83
|
-
run.wait
|
84
|
-
|
85
|
-
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
86
|
-
run1.output_port("OUT").value
|
87
|
-
end
|
88
|
-
|
89
|
-
assert_raise(T2Server::AccessForbiddenError) do
|
90
|
-
run1.delete
|
91
|
-
end
|
92
|
-
|
93
|
-
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
94
|
-
run.delete
|
95
|
-
end
|
61
|
+
def test_ownership
|
62
|
+
T2Server::Run.create($uri, WKF_PASS, $creds, $conn_params) do |run|
|
63
|
+
assert run.owner?
|
64
|
+
assert_equal $creds.username, run.owner
|
65
|
+
assert_not_equal $creds1.username, run.owner
|
96
66
|
end
|
97
67
|
end
|
98
68
|
|
99
|
-
def
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
69
|
+
def test_grant_and_revocation
|
70
|
+
mock("/rest/runs", :accept => "application/xml",
|
71
|
+
:credentials => $userinfo1, :output => "get-rest-runs.raw")
|
72
|
+
mock(RUN_PATH, :accept => "application/xml", :credentials => $userinfo1,
|
73
|
+
:output => "get-rest-run.raw")
|
74
|
+
mock("#{RUN_PATH}/security/permissions", :accept => "application/xml",
|
75
|
+
:credentials => $userinfo,
|
76
|
+
:output => "get-rest-run-security-permissions.raw")
|
77
|
+
mock("#{RUN_PATH}/security/permissions", :method => :post, :status => 201,
|
78
|
+
:credentials => $userinfo,
|
79
|
+
:location => "https://localhost/taverna#{RUN_PATH}/security/permissions/#{$creds1.username}")
|
80
|
+
mock("#{RUN_PATH}/security/permissions/#{$creds1.username}",
|
81
|
+
:method => :delete, :credentials => $userinfo, :status => 204)
|
82
|
+
|
83
|
+
T2Server::Run.create($uri, WKF_PASS, $creds, $conn_params) do |run|
|
84
|
+
assert_equal :none, run.permission($creds1.username)
|
106
85
|
|
107
|
-
|
86
|
+
run.grant_permission($creds1.username, :read)
|
108
87
|
|
109
|
-
run1 =
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
run1.start
|
114
|
-
run1.wait
|
115
|
-
run1.output_port("OUT").value
|
116
|
-
end
|
88
|
+
run1 = run.server.run(run.id, $creds1)
|
89
|
+
refute run1.owner?
|
90
|
+
assert_not_equal $creds1.username, run1.owner
|
91
|
+
assert_equal $creds.username, run1.owner
|
117
92
|
|
118
|
-
|
119
|
-
|
120
|
-
|
93
|
+
# Can't do permissions stuff if not the run's owner.
|
94
|
+
refute run1.grant_permission($creds1.username, :update)
|
95
|
+
refute run1.revoke_permission($creds1.username)
|
121
96
|
|
122
|
-
|
123
|
-
run.delete
|
124
|
-
end
|
97
|
+
assert run.revoke_permission($creds1.username)
|
125
98
|
end
|
126
99
|
end
|
127
100
|
|
128
|
-
def test_destroy_permission
|
129
|
-
server = T2Server::Server.new($uri, $conn_params)
|
130
|
-
|
131
|
-
server.create_run($wkf_pass, $creds) do |run|
|
132
|
-
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
133
|
-
run.grant_permission($creds1.username, :destroy)
|
134
|
-
end
|
135
|
-
|
136
|
-
run_id = run.identifier
|
137
|
-
|
138
|
-
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
139
|
-
run1 = server.run(run_id, $creds1)
|
140
|
-
run1.input_port("IN").value = "Hello, World!"
|
141
|
-
run1.start
|
142
|
-
run1.wait
|
143
|
-
run1.output_port("OUT").value
|
144
|
-
run1.delete
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
101
|
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# Copyright (c) 2010-2012 The University of Manchester, UK.
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# * Neither the names of The University of Manchester nor the names of its
|
16
|
+
# contributors may be used to endorse or promote products derived from this
|
17
|
+
# software without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
#
|
31
|
+
# Author: Robert Haines
|
32
|
+
|
33
|
+
require 't2-server'
|
34
|
+
|
35
|
+
class TestPermissions < Test::Unit::TestCase
|
36
|
+
|
37
|
+
WKF_PASS = "test/workflows/pass_through.t2flow"
|
38
|
+
|
39
|
+
def test_ownership_and_revokation
|
40
|
+
server = T2Server::Server.new($uri, $conn_params)
|
41
|
+
|
42
|
+
server.create_run(WKF_PASS, $creds) do |run|
|
43
|
+
assert(run.owner?)
|
44
|
+
assert_equal(run.owner, $creds.username)
|
45
|
+
|
46
|
+
assert_equal(run.permission($creds1.username), :none)
|
47
|
+
run.grant_permission($creds1.username, :read)
|
48
|
+
assert_equal(run.permission($creds1.username), :read)
|
49
|
+
run_id = run.identifier
|
50
|
+
run1 = server.run(run_id, $creds1)
|
51
|
+
|
52
|
+
assert(!run1.owner?)
|
53
|
+
assert_not_equal(run1.owner, $creds1.username)
|
54
|
+
|
55
|
+
assert(run.revoke_permission($creds1.username))
|
56
|
+
assert_equal(run.permission($creds1.username), :none)
|
57
|
+
assert(run.revoke_permission($creds1.username))
|
58
|
+
|
59
|
+
assert(run.delete)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_read_permission
|
64
|
+
server = T2Server::Server.new($uri, $conn_params)
|
65
|
+
|
66
|
+
server.create_run(WKF_PASS, $creds) do |run|
|
67
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
68
|
+
run.grant_permission($creds1.username, :read)
|
69
|
+
end
|
70
|
+
|
71
|
+
run_id = run.identifier
|
72
|
+
|
73
|
+
run1 = nil
|
74
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
75
|
+
run1 = server.run(run_id, $creds1)
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_raise(T2Server::AccessForbiddenError) do
|
79
|
+
run1.input_port("IN").value = "Hello, World!"
|
80
|
+
run1.start
|
81
|
+
end
|
82
|
+
|
83
|
+
run.input_port("IN").value = "Hello, World!"
|
84
|
+
run.start
|
85
|
+
run.wait
|
86
|
+
|
87
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
88
|
+
run1.output_port("OUT").value
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_raise(T2Server::AccessForbiddenError) do
|
92
|
+
run1.delete
|
93
|
+
end
|
94
|
+
|
95
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
96
|
+
run.delete
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_update_permission
|
102
|
+
server = T2Server::Server.new($uri, $conn_params)
|
103
|
+
|
104
|
+
server.create_run(WKF_PASS, $creds) do |run|
|
105
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
106
|
+
run.grant_permission($creds1.username, :update)
|
107
|
+
end
|
108
|
+
|
109
|
+
run_id = run.identifier
|
110
|
+
|
111
|
+
run1 = nil
|
112
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
113
|
+
run1 = server.run(run_id, $creds1)
|
114
|
+
run1.input_port("IN").value = "Hello, World!"
|
115
|
+
run1.start
|
116
|
+
run1.wait
|
117
|
+
run1.output_port("OUT").value
|
118
|
+
end
|
119
|
+
|
120
|
+
assert_raise(T2Server::AccessForbiddenError) do
|
121
|
+
run1.delete
|
122
|
+
end
|
123
|
+
|
124
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
125
|
+
run.delete
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_destroy_permission
|
131
|
+
server = T2Server::Server.new($uri, $conn_params)
|
132
|
+
|
133
|
+
server.create_run(WKF_PASS, $creds) do |run|
|
134
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
135
|
+
run.grant_permission($creds1.username, :destroy)
|
136
|
+
end
|
137
|
+
|
138
|
+
run_id = run.identifier
|
139
|
+
|
140
|
+
assert_nothing_raised(T2Server::AccessForbiddenError) do
|
141
|
+
run1 = server.run(run_id, $creds1)
|
142
|
+
run1.input_port("IN").value = "Hello, World!"
|
143
|
+
run1.start
|
144
|
+
run1.wait
|
145
|
+
run1.output_port("OUT").value
|
146
|
+
run1.delete
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/test/tc_ports.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# Copyright (c) 2014 The University of Manchester, UK.
|
2
|
+
#
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# * Neither the names of The University of Manchester nor the names of its
|
16
|
+
# contributors may be used to endorse or promote products derived from this
|
17
|
+
# software without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
#
|
31
|
+
# Author: Robert Haines
|
32
|
+
|
33
|
+
require 't2-server'
|
34
|
+
|
35
|
+
require 'helpers/fake-run'
|
36
|
+
|
37
|
+
class TestXMLMessages < Test::Unit::TestCase
|
38
|
+
|
39
|
+
SINGLE_INPUT_XML = LibXML::XML::Document.string(
|
40
|
+
'<port:input xmlns:port="http://ns.taverna.org.uk/2010/port/" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://localhost/taverna/rest/runs/a341b87f-25cc-4dfd-be36-f5b073a6ba74/input/expected/input/IN" port:name="IN" port:depth="0"/>'
|
41
|
+
).root
|
42
|
+
|
43
|
+
SINGLE_OUTPUT_XML = LibXML::XML::Document.string(
|
44
|
+
'<port:output xmlns:port="http://ns.taverna.org.uk/2010/port/" xmlns:xlink="http://www.w3.org/1999/xlink" port:name="OUT" port:depth="0">'\
|
45
|
+
'<port:value port:contentFile="/out/OUT" port:contentType="text/plain" port:contentByteLength="5" xlink:href="https://localhost/taverna/rest/runs/a341b87f-25cc-4dfd-be36-f5b073a6ba74/wd/out/OUT"/>'\
|
46
|
+
'</port:output>'
|
47
|
+
).root
|
48
|
+
|
49
|
+
LIST_OUTPUT_XML = LibXML::XML::Document.string(
|
50
|
+
'<port:output xmlns:port="http://ns.taverna.org.uk/2010/port/" xmlns:xlink="http://www.w3.org/1999/xlink" port:name="OUT" port:depth="1">'\
|
51
|
+
'<port:list port:length="3" xlink:href="https://localhost/taverna/rest/runs/a341b87f-25cc-4dfd-be36-f5b073a6ba74/wd/out/OUT">'\
|
52
|
+
'<port:value port:contentFile="/out/OUT/1" port:contentType="text/plain" port:contentByteLength="7" xlink:href="https://localhost/taverna/rest/runs/a341b87f-25cc-4dfd-be36-f5b073a6ba74/wd/out/OUT/1"/>'\
|
53
|
+
'<port:error port:errorFile="/out/OUT/2.error" port:errorByteLength="101" xlink:href="https://localhost/taverna/rest/runs/a341b87f-25cc-4dfd-be36-f5b073a6ba74/wd/out/OUT/2.error"/>'\
|
54
|
+
'<port:absent/>'\
|
55
|
+
'</port:list>'\
|
56
|
+
'</port:output>'
|
57
|
+
).root
|
58
|
+
|
59
|
+
def test_singleton_input_port
|
60
|
+
run = FakeRun.new
|
61
|
+
port = T2Server::InputPort.new(run, SINGLE_INPUT_XML)
|
62
|
+
|
63
|
+
assert_equal "IN", port.name
|
64
|
+
assert_equal 0, port.depth
|
65
|
+
|
66
|
+
refute port.remote_file?
|
67
|
+
refute port.file?
|
68
|
+
assert_nil port.value
|
69
|
+
refute port.set?
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_set_input_port_value
|
73
|
+
value = "test"
|
74
|
+
run = FakeRun.new
|
75
|
+
port = T2Server::InputPort.new(run, SINGLE_INPUT_XML)
|
76
|
+
port.value = value
|
77
|
+
|
78
|
+
assert port.set?
|
79
|
+
refute port.file?
|
80
|
+
refute port.remote_file?
|
81
|
+
assert_equal value, port.value
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_set_input_port_file
|
85
|
+
filename = "/test/filename.txt"
|
86
|
+
run = FakeRun.new
|
87
|
+
port = T2Server::InputPort.new(run, SINGLE_INPUT_XML)
|
88
|
+
port.file = filename
|
89
|
+
|
90
|
+
assert port.set?
|
91
|
+
assert port.file?
|
92
|
+
refute port.remote_file?
|
93
|
+
assert_equal filename, port.file
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_set_input_port_remote_file
|
97
|
+
filename = "/test/filename.txt"
|
98
|
+
run = FakeRun.new
|
99
|
+
port = T2Server::InputPort.new(run, SINGLE_INPUT_XML)
|
100
|
+
port.remote_file = filename
|
101
|
+
|
102
|
+
assert port.set?
|
103
|
+
assert port.file?
|
104
|
+
assert port.remote_file?
|
105
|
+
assert_equal filename, port.file
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_set_and_reset_input_port
|
109
|
+
value = "test"
|
110
|
+
filename = "/test/filename.txt"
|
111
|
+
run = FakeRun.new
|
112
|
+
port = T2Server::InputPort.new(run, SINGLE_INPUT_XML)
|
113
|
+
|
114
|
+
# Value
|
115
|
+
port.value = value
|
116
|
+
assert port.set?
|
117
|
+
refute port.file?
|
118
|
+
refute port.remote_file?
|
119
|
+
assert_equal value, port.value
|
120
|
+
|
121
|
+
# Local file
|
122
|
+
port.file = filename
|
123
|
+
assert port.set?
|
124
|
+
assert port.file?
|
125
|
+
refute port.remote_file?
|
126
|
+
assert_equal filename, port.file
|
127
|
+
|
128
|
+
# Remote file
|
129
|
+
port.remote_file = filename
|
130
|
+
assert port.set?
|
131
|
+
assert port.file?
|
132
|
+
assert port.remote_file?
|
133
|
+
assert_equal filename, port.file
|
134
|
+
|
135
|
+
# And back to a value
|
136
|
+
port.value = value
|
137
|
+
assert port.set?
|
138
|
+
refute port.file?
|
139
|
+
refute port.remote_file?
|
140
|
+
assert_equal value, port.value
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_singleton_output_port
|
144
|
+
port = T2Server::OutputPort.new(nil, SINGLE_OUTPUT_XML)
|
145
|
+
|
146
|
+
refute port.empty?
|
147
|
+
refute port.error?
|
148
|
+
assert_equal "OUT", port.name
|
149
|
+
assert_equal 0, port.depth
|
150
|
+
assert_equal "text/plain", port.type
|
151
|
+
assert_equal 5, port.size
|
152
|
+
assert_equal 5, port.total_size
|
153
|
+
assert port.reference.instance_of?(URI::HTTPS)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_list_output_port
|
157
|
+
sizes = [7, 101, 0]
|
158
|
+
types = ["text/plain", "application/x-error", "application/x-empty"]
|
159
|
+
|
160
|
+
port = T2Server::OutputPort.new(nil, LIST_OUTPUT_XML)
|
161
|
+
|
162
|
+
refute port.empty?
|
163
|
+
assert port.error?
|
164
|
+
assert_equal "OUT", port.name
|
165
|
+
assert_equal 1, port.depth
|
166
|
+
assert_equal 108, port.total_size
|
167
|
+
|
168
|
+
assert_equal sizes, port.size
|
169
|
+
assert_equal types, port.type
|
170
|
+
|
171
|
+
assert_equal 3, port.size.length
|
172
|
+
|
173
|
+
refute port[0].empty?
|
174
|
+
refute port[0].error?
|
175
|
+
assert_equal types[0], port[0].type
|
176
|
+
assert_equal sizes[0], port[0].size
|
177
|
+
assert port[0].reference.instance_of?(URI::HTTPS)
|
178
|
+
|
179
|
+
refute port[1].empty?
|
180
|
+
assert port[1].error?
|
181
|
+
assert_equal types[1], port[1].type
|
182
|
+
assert_equal sizes[1], port[1].size
|
183
|
+
assert port[1].reference.instance_of?(URI::HTTPS)
|
184
|
+
|
185
|
+
assert port[2].empty?
|
186
|
+
refute port[2].error?
|
187
|
+
assert_equal types[2], port[2].type
|
188
|
+
assert_equal sizes[2], port[2].size
|
189
|
+
assert port[2].reference.instance_of?(URI::Generic)
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|