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.
Files changed (68) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -0
  3. data/.ruby-env +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -1
  7. data/CHANGES.rdoc +49 -0
  8. data/README.rdoc +10 -8
  9. data/bin/t2-delete-runs +0 -3
  10. data/lib/t2-server-cli.rb +16 -9
  11. data/lib/t2-server/exceptions.rb +7 -19
  12. data/lib/t2-server/net/connection.rb +14 -6
  13. data/lib/t2-server/net/credentials.rb +12 -1
  14. data/lib/t2-server/net/parameters.rb +3 -3
  15. data/lib/t2-server/port.rb +12 -29
  16. data/lib/t2-server/run.rb +54 -35
  17. data/lib/t2-server/server.rb +3 -4
  18. data/lib/t2-server/xml.rb +0 -1
  19. data/lib/t2-server/xml/methods.rb +97 -4
  20. data/t2-server.gemspec +4 -1
  21. data/test/helpers/fake-run.rb +47 -0
  22. data/test/helpers/test-cache.rb +49 -0
  23. data/test/helpers/test-xml.rb +36 -0
  24. data/test/helpers/timezone.rb +39 -0
  25. data/test/mocked-server-responses/.gitattributes +1 -0
  26. data/test/mocked-server-responses/get-admin.raw +6 -0
  27. data/test/mocked-server-responses/get-rest-policy-runlimit.raw +6 -0
  28. data/test/mocked-server-responses/get-rest-policy.raw +6 -0
  29. data/test/mocked-server-responses/get-rest-run-input-expected.raw +6 -0
  30. data/test/mocked-server-responses/get-rest-run-input.raw +6 -0
  31. data/test/mocked-server-responses/get-rest-run-interaction-feed-0.raw +11 -0
  32. data/test/mocked-server-responses/get-rest-run-interaction-feed-1.raw +92 -0
  33. data/test/mocked-server-responses/get-rest-run-interaction-feed-2.raw +80 -0
  34. data/test/mocked-server-responses/get-rest-run-name.raw +6 -0
  35. data/test/mocked-server-responses/get-rest-run-output-list-errors.raw +6 -0
  36. data/test/mocked-server-responses/get-rest-run-output.raw +6 -0
  37. data/test/mocked-server-responses/get-rest-run-security-permissions.raw +6 -0
  38. data/test/mocked-server-responses/get-rest-run-security.raw +6 -0
  39. data/test/mocked-server-responses/get-rest-run.raw +6 -0
  40. data/test/mocked-server-responses/get-rest-runs.raw +6 -0
  41. data/test/mocked-server-responses/get-rest.raw +6 -0
  42. data/test/mocked-server-responses/log.txt +1 -0
  43. data/test/mocked-server-responses/mocks.rb +107 -0
  44. data/test/mocked-server-responses/options-admin-allownew.raw +7 -0
  45. data/test/tc_admin.rb +52 -24
  46. data/test/tc_admin_live.rb +66 -0
  47. data/test/tc_connection.rb +87 -0
  48. data/test/tc_connection_exceptions.rb +86 -0
  49. data/test/tc_credentials.rb +73 -0
  50. data/test/tc_interaction.rb +182 -0
  51. data/test/{tc_misc.rb → tc_misc_live.rb} +3 -1
  52. data/test/tc_params.rb +82 -4
  53. data/test/tc_perms.rb +54 -101
  54. data/test/tc_perms_live.rb +150 -0
  55. data/test/tc_ports.rb +192 -0
  56. data/test/tc_run.rb +333 -350
  57. data/test/tc_run_live.rb +453 -0
  58. data/test/{tc_secure.rb → tc_secure_live.rb} +30 -29
  59. data/test/tc_server.rb +115 -42
  60. data/test/tc_server_live.rb +92 -0
  61. data/test/tc_server_version.rb +19 -0
  62. data/test/tc_xml_messages.rb +201 -0
  63. data/test/ts_t2server.rb +37 -43
  64. data/test/workflows/secure/heater-pk.pem +24 -18
  65. data/test/workflows/secure/user-cert.p12 +0 -0
  66. data/version.yml +1 -1
  67. metadata +136 -29
  68. data/lib/t2-server/xml/fragments.rb +0 -78
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2012 The University of Manchester, UK.
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
- def test_ownership_and_revokation
38
- server = T2Server::Server.new($uri, $conn_params)
39
-
40
- server.create_run($wkf_pass, $creds) do |run|
41
- assert(run.owner?)
42
- assert_equal(run.owner, $creds.username)
43
-
44
- assert_equal(run.permission($creds1.username), :none)
45
- run.grant_permission($creds1.username, :read)
46
- assert_equal(run.permission($creds1.username), :read)
47
- run_id = run.identifier
48
- run1 = server.run(run_id, $creds1)
49
-
50
- assert(!run1.owner?)
51
- assert_not_equal(run1.owner, $creds1.username)
52
-
53
- assert(run.revoke_permission($creds1.username))
54
- assert_equal(run.permission($creds1.username), :none)
55
- assert(run.revoke_permission($creds1.username))
56
-
57
- assert(run.delete)
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 test_read_permission
62
- server = T2Server::Server.new($uri, $conn_params)
63
-
64
- server.create_run($wkf_pass, $creds) do |run|
65
- assert_nothing_raised(T2Server::AccessForbiddenError) do
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 test_update_permission
100
- server = T2Server::Server.new($uri, $conn_params)
101
-
102
- server.create_run($wkf_pass, $creds) do |run|
103
- assert_nothing_raised(T2Server::AccessForbiddenError) do
104
- run.grant_permission($creds1.username, :update)
105
- end
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
- run_id = run.identifier
86
+ run.grant_permission($creds1.username, :read)
108
87
 
109
- run1 = nil
110
- assert_nothing_raised(T2Server::AccessForbiddenError) do
111
- run1 = server.run(run_id, $creds1)
112
- run1.input_port("IN").value = "Hello, World!"
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
- assert_raise(T2Server::AccessForbiddenError) do
119
- run1.delete
120
- end
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
- assert_nothing_raised(T2Server::AccessForbiddenError) do
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
@@ -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