aspose_slides_cloud 21.4.0 → 21.6.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 +4 -4
- data/README.md +89 -61
- data/TestData/TemplatingCVDataWithBase64.xml +22 -22
- data/lib/aspose_slides_cloud.rb +212 -213
- data/lib/aspose_slides_cloud/api/slides_api.rb +15206 -17689
- data/lib/aspose_slides_cloud/api_client.rb +439 -439
- data/lib/aspose_slides_cloud/models/add_layout_slide.rb +244 -244
- data/lib/aspose_slides_cloud/models/add_master_slide.rb +259 -259
- data/lib/aspose_slides_cloud/models/add_shape.rb +239 -239
- data/lib/aspose_slides_cloud/models/add_slide.rb +269 -269
- data/lib/aspose_slides_cloud/models/api_info.rb +217 -217
- data/lib/aspose_slides_cloud/models/arrow_head_properties.rb +285 -285
- data/lib/aspose_slides_cloud/models/audio_frame.rb +359 -359
- data/lib/aspose_slides_cloud/models/axes.rb +237 -237
- data/lib/aspose_slides_cloud/models/axis.rb +699 -699
- data/lib/aspose_slides_cloud/models/base64_input_file.rb +230 -230
- data/lib/aspose_slides_cloud/models/blur_effect.rb +227 -227
- data/lib/aspose_slides_cloud/models/box_and_whisker_series.rb +299 -299
- data/lib/aspose_slides_cloud/models/bubble_chart_data_point.rb +212 -212
- data/lib/aspose_slides_cloud/models/bubble_series.rb +248 -248
- data/lib/aspose_slides_cloud/models/chart.rb +365 -365
- data/lib/aspose_slides_cloud/models/chart_category.rb +271 -271
- data/lib/aspose_slides_cloud/models/chart_title.rb +222 -222
- data/lib/aspose_slides_cloud/models/chart_wall.rb +281 -281
- data/lib/aspose_slides_cloud/models/color_scheme.rb +317 -317
- data/lib/aspose_slides_cloud/models/common_slide_view_properties.rb +217 -217
- data/lib/aspose_slides_cloud/models/connector.rb +275 -275
- data/lib/aspose_slides_cloud/models/custom_dash_pattern.rb +209 -209
- data/lib/aspose_slides_cloud/models/data_point.rb +197 -197
- data/lib/aspose_slides_cloud/models/disc_usage.rb +227 -227
- data/lib/aspose_slides_cloud/models/document.rb +257 -257
- data/lib/aspose_slides_cloud/models/document_properties.rb +209 -209
- data/lib/aspose_slides_cloud/models/document_property.rb +232 -232
- data/lib/aspose_slides_cloud/models/document_replace_result.rb +218 -218
- data/lib/aspose_slides_cloud/models/effect.rb +424 -424
- data/lib/aspose_slides_cloud/models/effect_format.rb +277 -277
- data/lib/aspose_slides_cloud/models/entity_exists.rb +212 -212
- data/lib/aspose_slides_cloud/models/error.rb +237 -237
- data/lib/aspose_slides_cloud/models/error_details.rb +222 -222
- data/lib/aspose_slides_cloud/models/export_format.rb +60 -60
- data/lib/aspose_slides_cloud/models/export_options.rb +216 -216
- data/lib/aspose_slides_cloud/models/file_version.rb +225 -225
- data/lib/aspose_slides_cloud/models/file_versions.rb +209 -209
- data/lib/aspose_slides_cloud/models/files_list.rb +209 -209
- data/lib/aspose_slides_cloud/models/files_upload_result.rb +221 -221
- data/lib/aspose_slides_cloud/models/fill_format.rb +240 -240
- data/lib/aspose_slides_cloud/models/fill_overlay_effect.rb +246 -246
- data/lib/aspose_slides_cloud/models/font_scheme.rb +227 -227
- data/lib/aspose_slides_cloud/models/font_set.rb +227 -227
- data/lib/aspose_slides_cloud/models/format_scheme.rb +245 -245
- data/lib/aspose_slides_cloud/models/geometry_shape.rb +260 -260
- data/lib/aspose_slides_cloud/models/glow_effect.rb +222 -222
- data/lib/aspose_slides_cloud/models/gradient_fill.rb +342 -342
- data/lib/aspose_slides_cloud/models/gradient_fill_stop.rb +222 -222
- data/lib/aspose_slides_cloud/models/graphical_object.rb +234 -234
- data/lib/aspose_slides_cloud/models/group_shape.rb +234 -234
- data/lib/aspose_slides_cloud/models/header_footer.rb +247 -247
- data/lib/aspose_slides_cloud/models/html_export_options.rb +421 -421
- data/lib/aspose_slides_cloud/models/i_shape_export_options.rb +197 -197
- data/lib/aspose_slides_cloud/models/image.rb +237 -237
- data/lib/aspose_slides_cloud/models/image_export_format.rb +43 -43
- data/lib/aspose_slides_cloud/models/image_export_options.rb +299 -299
- data/lib/aspose_slides_cloud/models/images.rb +209 -209
- data/lib/aspose_slides_cloud/models/inner_shadow_effect.rb +252 -252
- data/lib/aspose_slides_cloud/models/input.rb +227 -227
- data/lib/aspose_slides_cloud/models/input_file.rb +250 -250
- data/lib/aspose_slides_cloud/models/interactive_sequence.rb +224 -224
- data/lib/aspose_slides_cloud/models/layout_slide.rb +278 -278
- data/lib/aspose_slides_cloud/models/layout_slides.rb +209 -209
- data/lib/aspose_slides_cloud/models/legend.rb +321 -321
- data/lib/aspose_slides_cloud/models/line_format.rb +411 -411
- data/lib/aspose_slides_cloud/models/master_slide.rb +231 -231
- data/lib/aspose_slides_cloud/models/master_slides.rb +209 -209
- data/lib/aspose_slides_cloud/models/merge.rb +231 -231
- data/lib/aspose_slides_cloud/models/merging_source.rb +219 -219
- data/lib/aspose_slides_cloud/models/no_fill.rb +219 -219
- data/lib/aspose_slides_cloud/models/normal_view_restored_properties.rb +217 -217
- data/lib/aspose_slides_cloud/models/notes_slide.rb +217 -217
- data/lib/aspose_slides_cloud/models/notes_slide_export_format.rb +43 -43
- data/lib/aspose_slides_cloud/models/notes_slide_header_footer.rb +267 -267
- data/lib/aspose_slides_cloud/models/object_exist.rb +227 -227
- data/lib/aspose_slides_cloud/models/ole_object_frame.rb +259 -259
- data/lib/aspose_slides_cloud/models/one_value_chart_data_point.rb +210 -210
- data/lib/aspose_slides_cloud/models/one_value_series.rb +248 -248
- data/lib/aspose_slides_cloud/models/ordered_merge_request.rb +209 -209
- data/lib/aspose_slides_cloud/models/outer_shadow_effect.rb +252 -252
- data/lib/aspose_slides_cloud/models/output_file.rb +240 -240
- data/lib/aspose_slides_cloud/models/paragraph.rb +517 -517
- data/lib/aspose_slides_cloud/models/paragraphs.rb +209 -209
- data/lib/aspose_slides_cloud/models/path_input_file.rb +240 -240
- data/lib/aspose_slides_cloud/models/path_output_file.rb +239 -239
- data/lib/aspose_slides_cloud/models/pattern_fill.rb +266 -266
- data/lib/aspose_slides_cloud/models/pdf_export_options.rb +547 -547
- data/lib/aspose_slides_cloud/models/picture_fill.rb +351 -351
- data/lib/aspose_slides_cloud/models/picture_frame.rb +245 -245
- data/lib/aspose_slides_cloud/models/pipeline.rb +219 -219
- data/lib/aspose_slides_cloud/models/placeholder.rb +325 -325
- data/lib/aspose_slides_cloud/models/placeholders.rb +209 -209
- data/lib/aspose_slides_cloud/models/plot_area.rb +311 -311
- data/lib/aspose_slides_cloud/models/portion.rb +589 -589
- data/lib/aspose_slides_cloud/models/portions.rb +209 -209
- data/lib/aspose_slides_cloud/models/pptx_export_options.rb +247 -247
- data/lib/aspose_slides_cloud/models/presentation_to_merge.rb +273 -273
- data/lib/aspose_slides_cloud/models/presentations_merge_request.rb +221 -221
- data/lib/aspose_slides_cloud/models/preset_shadow_effect.rb +286 -286
- data/lib/aspose_slides_cloud/models/protection_properties.rb +267 -267
- data/lib/aspose_slides_cloud/models/reflection_effect.rb +441 -441
- data/lib/aspose_slides_cloud/models/remove_shape.rb +229 -229
- data/lib/aspose_slides_cloud/models/remove_slide.rb +234 -234
- data/lib/aspose_slides_cloud/models/reorder_slide.rb +249 -249
- data/lib/aspose_slides_cloud/models/replace_text.rb +269 -269
- data/lib/aspose_slides_cloud/models/request_input_file.rb +235 -235
- data/lib/aspose_slides_cloud/models/reset_slide.rb +234 -234
- data/lib/aspose_slides_cloud/models/resource_base.rb +219 -219
- data/lib/aspose_slides_cloud/models/resource_uri.rb +237 -237
- data/lib/aspose_slides_cloud/models/response_output_file.rb +219 -219
- data/lib/aspose_slides_cloud/models/save.rb +266 -266
- data/lib/aspose_slides_cloud/models/save_shape.rb +276 -276
- data/lib/aspose_slides_cloud/models/save_slide.rb +301 -301
- data/lib/aspose_slides_cloud/models/scatter_chart_data_point.rb +225 -225
- data/lib/aspose_slides_cloud/models/scatter_series.rb +248 -248
- data/lib/aspose_slides_cloud/models/section.rb +234 -234
- data/lib/aspose_slides_cloud/models/sections.rb +209 -209
- data/lib/aspose_slides_cloud/models/series.rb +422 -422
- data/lib/aspose_slides_cloud/models/series_marker.rb +281 -281
- data/lib/aspose_slides_cloud/models/shape.rb +255 -255
- data/lib/aspose_slides_cloud/models/shape_base.rb +375 -375
- data/lib/aspose_slides_cloud/models/shape_export_format.rb +44 -44
- data/lib/aspose_slides_cloud/models/shape_image_export_options.rb +286 -286
- data/lib/aspose_slides_cloud/models/shape_thumbnail_bounds.rb +41 -41
- data/lib/aspose_slides_cloud/models/shapes.rb +209 -209
- data/lib/aspose_slides_cloud/models/shapes_alignment_type.rb +46 -46
- data/lib/aspose_slides_cloud/models/slide.rb +322 -322
- data/lib/aspose_slides_cloud/models/slide_animation.rb +221 -221
- data/lib/aspose_slides_cloud/models/slide_background.rb +266 -266
- data/lib/aspose_slides_cloud/models/slide_comment.rb +239 -239
- data/lib/aspose_slides_cloud/models/slide_comments.rb +209 -209
- data/lib/aspose_slides_cloud/models/slide_export_format.rb +59 -59
- data/lib/aspose_slides_cloud/models/slide_properties.rb +315 -315
- data/lib/aspose_slides_cloud/models/slide_replace_result.rb +223 -223
- data/lib/aspose_slides_cloud/models/slides.rb +209 -209
- data/lib/aspose_slides_cloud/models/smart_art.rb +342 -342
- data/lib/aspose_slides_cloud/models/smart_art_node.rb +293 -293
- data/lib/aspose_slides_cloud/models/smart_art_shape.rb +235 -235
- data/lib/aspose_slides_cloud/models/soft_edge_effect.rb +212 -212
- data/lib/aspose_slides_cloud/models/solid_fill.rb +229 -229
- data/lib/aspose_slides_cloud/models/split_document_result.rb +209 -209
- data/lib/aspose_slides_cloud/models/storage_exist.rb +212 -212
- data/lib/aspose_slides_cloud/models/storage_file.rb +257 -257
- data/lib/aspose_slides_cloud/models/svg_export_options.rb +379 -379
- data/lib/aspose_slides_cloud/models/swf_export_options.rb +529 -529
- data/lib/aspose_slides_cloud/models/table.rb +350 -350
- data/lib/aspose_slides_cloud/models/table_cell.rb +403 -403
- data/lib/aspose_slides_cloud/models/table_column.rb +212 -212
- data/lib/aspose_slides_cloud/models/table_row.rb +239 -239
- data/lib/aspose_slides_cloud/models/task.rb +240 -240
- data/lib/aspose_slides_cloud/models/text_item.rb +217 -217
- data/lib/aspose_slides_cloud/models/text_items.rb +209 -209
- data/lib/aspose_slides_cloud/models/theme.rb +237 -237
- data/lib/aspose_slides_cloud/models/tiff_export_options.rb +423 -423
- data/lib/aspose_slides_cloud/models/update_background.rb +241 -241
- data/lib/aspose_slides_cloud/models/update_shape.rb +239 -239
- data/lib/aspose_slides_cloud/models/video_frame.rb +329 -329
- data/lib/aspose_slides_cloud/models/view_properties.rb +357 -357
- data/lib/aspose_slides_cloud/models/waterfall_chart_data_point.rb +206 -206
- data/lib/aspose_slides_cloud/models/waterfall_series.rb +247 -247
- data/lib/aspose_slides_cloud/models/xps_export_options.rb +243 -243
- data/lib/aspose_slides_cloud/type_registry.rb +323 -323
- data/lib/aspose_slides_cloud/version.rb +25 -25
- data/spec/api/slides_api_spec.rb +40213 -39435
- data/spec/extra/extra_spec.rb +202 -202
- data/spec/spec_utils.rb +182 -182
- data/testConfig.json +7 -7
- data/testRules.json +513 -511
- metadata +2 -3
- data/lib/aspose_slides_cloud/api/slides_api_requests.rb +0 -4742
data/spec/extra/extra_spec.rb
CHANGED
@@ -1,203 +1,203 @@
|
|
1
|
-
=begin
|
2
|
-
Copyright (c) 2019 Aspose Pty Ltd
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
6
|
-
in the Software without restriction, including without limitation the rights
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
9
|
-
furnished to do so, subject to the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
12
|
-
copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
SOFTWARE.
|
21
|
-
=end
|
22
|
-
|
23
|
-
require 'spec_helper'
|
24
|
-
|
25
|
-
describe 'SlidesApiExtra' do
|
26
|
-
describe 'specific cases' do
|
27
|
-
it 'multipart request' do
|
28
|
-
pipeline = AsposeSlidesCloud::Pipeline.new
|
29
|
-
pipeline.input = AsposeSlidesCloud::Input.new
|
30
|
-
pipeline.input.template_data = AsposeSlidesCloud::RequestInputFile.new
|
31
|
-
pipeline.input.template_data.type = "Request"
|
32
|
-
pipeline.input.template_data.index = 0
|
33
|
-
pipeline.input.template = AsposeSlidesCloud::RequestInputFile.new
|
34
|
-
pipeline.input.template.type = "Request"
|
35
|
-
pipeline.input.template.index = 1
|
36
|
-
pipeline.tasks = []
|
37
|
-
pipeline.tasks.push(AsposeSlidesCloud::Save.new)
|
38
|
-
pipeline.tasks[0].type = "Save"
|
39
|
-
pipeline.tasks[0].format = "pptx"
|
40
|
-
pipeline.tasks[0].output = AsposeSlidesCloud::OutputFile.new
|
41
|
-
pipeline.tasks[0].output.type = "Response"
|
42
|
-
files = []
|
43
|
-
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "TemplatingCVDataWithBase64.xml")))
|
44
|
-
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "TemplateCV.pptx")))
|
45
|
-
o, c, _h = AsposeSlidesCloud::SpecUtils.api.pipeline_with_http_info(pipeline, files)
|
46
|
-
expect(c).to eq(200)
|
47
|
-
expect(o).not_to be(nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'base shape' do
|
51
|
-
AsposeSlidesCloud::SpecUtils.initialize('GetSlideShape', nil, nil)
|
52
|
-
o = AsposeSlidesCloud::SpecUtils.api.get_shape("test.pptx", 1, 1, "password", "TempSlidesSDK")
|
53
|
-
expect(o.text).to eq("1")
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'chart' do
|
57
|
-
chart = AsposeSlidesCloud::Chart.new
|
58
|
-
expect(chart.type).to eq("Chart")
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'timeout' do
|
62
|
-
#unstable test
|
63
|
-
#AsposeSlidesCloud::SpecUtils.initialize('post_slide_save_as', nil, nil)
|
64
|
-
|
65
|
-
#config = JSON.parse(File.read('testConfig.json'))
|
66
|
-
#configuration = AsposeSlidesCloud::Configuration.new
|
67
|
-
#configuration.base_url = config["BaseUrl"]
|
68
|
-
#configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
69
|
-
#configuration.app_sid = config["ClientId"]
|
70
|
-
#configuration.app_key = config["ClientSecret"]
|
71
|
-
#configuration.debugging = config["Debug"]
|
72
|
-
#configuration.timeout = 1
|
73
|
-
#api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
74
|
-
|
75
|
-
#api.download_slide("test.pptx", 1, "svg", "password", "TempSlidesSDK")
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'nullable properties' do
|
79
|
-
folderName = "TempSlidesSDK"
|
80
|
-
fileName = "placeholders.pptx"
|
81
|
-
password = "password"
|
82
|
-
min1 = 44.3
|
83
|
-
min2 = 12
|
84
|
-
max1 = 104.3
|
85
|
-
max2 = 87
|
86
|
-
AsposeSlidesCloud::SpecUtils.initialize("no_method", "no_property", nil)
|
87
|
-
AsposeSlidesCloud::SpecUtils.api.copy_file("TempTests/" + fileName, folderName + "/" + fileName)
|
88
|
-
|
89
|
-
dto = AsposeSlidesCloud::Chart.new
|
90
|
-
dto.chart_type = "Line"
|
91
|
-
dto.width = 400.0
|
92
|
-
dto.height = 300.0
|
93
|
-
dto.title = AsposeSlidesCloud::ChartTitle.new
|
94
|
-
dto.title.has_title = true
|
95
|
-
dto.title.text = "MyTitle"
|
96
|
-
dto.series = []
|
97
|
-
dto.series.push(AsposeSlidesCloud::OneValueSeries.new)
|
98
|
-
dto.series[0].type = "ClusteredColumn"
|
99
|
-
dto.series[0].data_point_type = "OneValue"
|
100
|
-
dto.series[0].name = "Series1"
|
101
|
-
dto.series[0].data_points = []
|
102
|
-
dto.series[0].data_points.push(AsposeSlidesCloud::OneValueChartDataPoint.new)
|
103
|
-
dto.series[0].data_points[0].value = 40.0
|
104
|
-
dto.series[0].data_points.push(AsposeSlidesCloud::OneValueChartDataPoint.new)
|
105
|
-
dto.series[0].data_points[1].value = 50.0
|
106
|
-
dto.axes = AsposeSlidesCloud::Axes.new
|
107
|
-
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
108
|
-
dto.axes.horizontal_axis.is_automatic_min_value = false
|
109
|
-
dto.axes.horizontal_axis.min_value = min1
|
110
|
-
dto.axes.horizontal_axis.is_automatic_max_value = false
|
111
|
-
dto.axes.horizontal_axis.max_value = max1
|
112
|
-
AsposeSlidesCloud::SpecUtils.api.create_shape(fileName, 1, dto, nil, nil, password, folderName)
|
113
|
-
|
114
|
-
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
115
|
-
expect(result.axes.horizontal_axis.min_value).to eq(min1)
|
116
|
-
expect(result.axes.horizontal_axis.max_value).to eq(max1)
|
117
|
-
|
118
|
-
dto = AsposeSlidesCloud::Chart.new
|
119
|
-
dto.axes = AsposeSlidesCloud::Axes.new
|
120
|
-
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
121
|
-
dto.axes.horizontal_axis.min_value = min2
|
122
|
-
AsposeSlidesCloud::SpecUtils.api.update_shape(fileName, 1, 4, dto, password, folderName)
|
123
|
-
|
124
|
-
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
125
|
-
expect(result.axes.horizontal_axis.min_value).to eq(min2)
|
126
|
-
expect(result.axes.horizontal_axis.max_value).to eq(max1)
|
127
|
-
|
128
|
-
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
129
|
-
dto.axes.horizontal_axis.max_value = max2
|
130
|
-
AsposeSlidesCloud::SpecUtils.api.update_shape(fileName, 1, 4, dto, password, folderName)
|
131
|
-
|
132
|
-
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
133
|
-
expect(result.axes.horizontal_axis.min_value).to eq(min2)
|
134
|
-
expect(result.axes.horizontal_axis.max_value).to eq(max2)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe 'authentication' do
|
139
|
-
it 'good auth' do
|
140
|
-
config = JSON.parse(File.read('testConfig.json'))
|
141
|
-
configuration = AsposeSlidesCloud::Configuration.new
|
142
|
-
configuration.base_url = config["BaseUrl"]
|
143
|
-
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
144
|
-
configuration.app_sid = config["ClientId"]
|
145
|
-
configuration.app_key = config["ClientSecret"]
|
146
|
-
configuration.debugging = config["Debug"]
|
147
|
-
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
148
|
-
o, c, _h = api.get_api_info_with_http_info
|
149
|
-
expect(c).to eq(200)
|
150
|
-
expect(o).not_to be(nil)
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'bad auth' do
|
154
|
-
config = JSON.parse(File.read('testConfig.json'))
|
155
|
-
configuration = AsposeSlidesCloud::Configuration.new
|
156
|
-
configuration.base_url = config["BaseUrl"]
|
157
|
-
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
158
|
-
configuration.app_sid = "invalid"
|
159
|
-
configuration.app_key = config["ClientSecret"]
|
160
|
-
configuration.debugging = config["Debug"]
|
161
|
-
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
162
|
-
begin
|
163
|
-
o, c, _h = api.get_api_info_with_http_info
|
164
|
-
fail "An exception expected"
|
165
|
-
rescue AsposeSlidesCloud::ApiError => e
|
166
|
-
expect(e.code).to eq(401)
|
167
|
-
expect(e.response_body).to include("invalid_client")
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'good token' do
|
172
|
-
config = JSON.parse(File.read('testConfig.json'))
|
173
|
-
configuration = AsposeSlidesCloud::Configuration.new
|
174
|
-
configuration.base_url = config["BaseUrl"]
|
175
|
-
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
176
|
-
configuration.app_sid = config["ClientId"]
|
177
|
-
configuration.app_key = config["ClientSecret"]
|
178
|
-
configuration.debugging = config["Debug"]
|
179
|
-
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
180
|
-
api.get_api_info_with_http_info
|
181
|
-
configuration.app_sid = "invalid"
|
182
|
-
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
183
|
-
o, c, _h = api.get_api_info_with_http_info
|
184
|
-
expect(c).to eq(200)
|
185
|
-
expect(o).not_to be(nil)
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'bad token' do
|
189
|
-
config = JSON.parse(File.read('testConfig.json'))
|
190
|
-
configuration = AsposeSlidesCloud::Configuration.new
|
191
|
-
configuration.base_url = config["BaseUrl"]
|
192
|
-
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
193
|
-
configuration.app_sid = config["ClientId"]
|
194
|
-
configuration.app_key = config["ClientSecret"]
|
195
|
-
configuration.access_token = "expired.token"
|
196
|
-
configuration.debugging = config["Debug"]
|
197
|
-
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
198
|
-
o, c, _h = api.get_api_info_with_http_info
|
199
|
-
expect(c).to eq(200)
|
200
|
-
expect(o).not_to be(nil)
|
201
|
-
end
|
202
|
-
end
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2019 Aspose Pty Ltd
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
21
|
+
=end
|
22
|
+
|
23
|
+
require 'spec_helper'
|
24
|
+
|
25
|
+
describe 'SlidesApiExtra' do
|
26
|
+
describe 'specific cases' do
|
27
|
+
it 'multipart request' do
|
28
|
+
pipeline = AsposeSlidesCloud::Pipeline.new
|
29
|
+
pipeline.input = AsposeSlidesCloud::Input.new
|
30
|
+
pipeline.input.template_data = AsposeSlidesCloud::RequestInputFile.new
|
31
|
+
pipeline.input.template_data.type = "Request"
|
32
|
+
pipeline.input.template_data.index = 0
|
33
|
+
pipeline.input.template = AsposeSlidesCloud::RequestInputFile.new
|
34
|
+
pipeline.input.template.type = "Request"
|
35
|
+
pipeline.input.template.index = 1
|
36
|
+
pipeline.tasks = []
|
37
|
+
pipeline.tasks.push(AsposeSlidesCloud::Save.new)
|
38
|
+
pipeline.tasks[0].type = "Save"
|
39
|
+
pipeline.tasks[0].format = "pptx"
|
40
|
+
pipeline.tasks[0].output = AsposeSlidesCloud::OutputFile.new
|
41
|
+
pipeline.tasks[0].output.type = "Response"
|
42
|
+
files = []
|
43
|
+
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "TemplatingCVDataWithBase64.xml")))
|
44
|
+
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "TemplateCV.pptx")))
|
45
|
+
o, c, _h = AsposeSlidesCloud::SpecUtils.api.pipeline_with_http_info(pipeline, files)
|
46
|
+
expect(c).to eq(200)
|
47
|
+
expect(o).not_to be(nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'base shape' do
|
51
|
+
AsposeSlidesCloud::SpecUtils.initialize('GetSlideShape', nil, nil)
|
52
|
+
o = AsposeSlidesCloud::SpecUtils.api.get_shape("test.pptx", 1, 1, "password", "TempSlidesSDK")
|
53
|
+
expect(o.text).to eq("1")
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'chart' do
|
57
|
+
chart = AsposeSlidesCloud::Chart.new
|
58
|
+
expect(chart.type).to eq("Chart")
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'timeout' do
|
62
|
+
#unstable test
|
63
|
+
#AsposeSlidesCloud::SpecUtils.initialize('post_slide_save_as', nil, nil)
|
64
|
+
|
65
|
+
#config = JSON.parse(File.read('testConfig.json'))
|
66
|
+
#configuration = AsposeSlidesCloud::Configuration.new
|
67
|
+
#configuration.base_url = config["BaseUrl"]
|
68
|
+
#configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
69
|
+
#configuration.app_sid = config["ClientId"]
|
70
|
+
#configuration.app_key = config["ClientSecret"]
|
71
|
+
#configuration.debugging = config["Debug"]
|
72
|
+
#configuration.timeout = 1
|
73
|
+
#api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
74
|
+
|
75
|
+
#api.download_slide("test.pptx", 1, "svg", "password", "TempSlidesSDK")
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'nullable properties' do
|
79
|
+
folderName = "TempSlidesSDK"
|
80
|
+
fileName = "placeholders.pptx"
|
81
|
+
password = "password"
|
82
|
+
min1 = 44.3
|
83
|
+
min2 = 12
|
84
|
+
max1 = 104.3
|
85
|
+
max2 = 87
|
86
|
+
AsposeSlidesCloud::SpecUtils.initialize("no_method", "no_property", nil)
|
87
|
+
AsposeSlidesCloud::SpecUtils.api.copy_file("TempTests/" + fileName, folderName + "/" + fileName)
|
88
|
+
|
89
|
+
dto = AsposeSlidesCloud::Chart.new
|
90
|
+
dto.chart_type = "Line"
|
91
|
+
dto.width = 400.0
|
92
|
+
dto.height = 300.0
|
93
|
+
dto.title = AsposeSlidesCloud::ChartTitle.new
|
94
|
+
dto.title.has_title = true
|
95
|
+
dto.title.text = "MyTitle"
|
96
|
+
dto.series = []
|
97
|
+
dto.series.push(AsposeSlidesCloud::OneValueSeries.new)
|
98
|
+
dto.series[0].type = "ClusteredColumn"
|
99
|
+
dto.series[0].data_point_type = "OneValue"
|
100
|
+
dto.series[0].name = "Series1"
|
101
|
+
dto.series[0].data_points = []
|
102
|
+
dto.series[0].data_points.push(AsposeSlidesCloud::OneValueChartDataPoint.new)
|
103
|
+
dto.series[0].data_points[0].value = 40.0
|
104
|
+
dto.series[0].data_points.push(AsposeSlidesCloud::OneValueChartDataPoint.new)
|
105
|
+
dto.series[0].data_points[1].value = 50.0
|
106
|
+
dto.axes = AsposeSlidesCloud::Axes.new
|
107
|
+
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
108
|
+
dto.axes.horizontal_axis.is_automatic_min_value = false
|
109
|
+
dto.axes.horizontal_axis.min_value = min1
|
110
|
+
dto.axes.horizontal_axis.is_automatic_max_value = false
|
111
|
+
dto.axes.horizontal_axis.max_value = max1
|
112
|
+
AsposeSlidesCloud::SpecUtils.api.create_shape(fileName, 1, dto, nil, nil, password, folderName)
|
113
|
+
|
114
|
+
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
115
|
+
expect(result.axes.horizontal_axis.min_value).to eq(min1)
|
116
|
+
expect(result.axes.horizontal_axis.max_value).to eq(max1)
|
117
|
+
|
118
|
+
dto = AsposeSlidesCloud::Chart.new
|
119
|
+
dto.axes = AsposeSlidesCloud::Axes.new
|
120
|
+
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
121
|
+
dto.axes.horizontal_axis.min_value = min2
|
122
|
+
AsposeSlidesCloud::SpecUtils.api.update_shape(fileName, 1, 4, dto, password, folderName)
|
123
|
+
|
124
|
+
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
125
|
+
expect(result.axes.horizontal_axis.min_value).to eq(min2)
|
126
|
+
expect(result.axes.horizontal_axis.max_value).to eq(max1)
|
127
|
+
|
128
|
+
dto.axes.horizontal_axis = AsposeSlidesCloud::Axis.new
|
129
|
+
dto.axes.horizontal_axis.max_value = max2
|
130
|
+
AsposeSlidesCloud::SpecUtils.api.update_shape(fileName, 1, 4, dto, password, folderName)
|
131
|
+
|
132
|
+
result = AsposeSlidesCloud::SpecUtils.api.get_shape(fileName, 1, 4, password, folderName)
|
133
|
+
expect(result.axes.horizontal_axis.min_value).to eq(min2)
|
134
|
+
expect(result.axes.horizontal_axis.max_value).to eq(max2)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'authentication' do
|
139
|
+
it 'good auth' do
|
140
|
+
config = JSON.parse(File.read('testConfig.json'))
|
141
|
+
configuration = AsposeSlidesCloud::Configuration.new
|
142
|
+
configuration.base_url = config["BaseUrl"]
|
143
|
+
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
144
|
+
configuration.app_sid = config["ClientId"]
|
145
|
+
configuration.app_key = config["ClientSecret"]
|
146
|
+
configuration.debugging = config["Debug"]
|
147
|
+
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
148
|
+
o, c, _h = api.get_api_info_with_http_info
|
149
|
+
expect(c).to eq(200)
|
150
|
+
expect(o).not_to be(nil)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'bad auth' do
|
154
|
+
config = JSON.parse(File.read('testConfig.json'))
|
155
|
+
configuration = AsposeSlidesCloud::Configuration.new
|
156
|
+
configuration.base_url = config["BaseUrl"]
|
157
|
+
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
158
|
+
configuration.app_sid = "invalid"
|
159
|
+
configuration.app_key = config["ClientSecret"]
|
160
|
+
configuration.debugging = config["Debug"]
|
161
|
+
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
162
|
+
begin
|
163
|
+
o, c, _h = api.get_api_info_with_http_info
|
164
|
+
fail "An exception expected"
|
165
|
+
rescue AsposeSlidesCloud::ApiError => e
|
166
|
+
expect(e.code).to eq(401)
|
167
|
+
expect(e.response_body).to include("invalid_client")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'good token' do
|
172
|
+
config = JSON.parse(File.read('testConfig.json'))
|
173
|
+
configuration = AsposeSlidesCloud::Configuration.new
|
174
|
+
configuration.base_url = config["BaseUrl"]
|
175
|
+
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
176
|
+
configuration.app_sid = config["ClientId"]
|
177
|
+
configuration.app_key = config["ClientSecret"]
|
178
|
+
configuration.debugging = config["Debug"]
|
179
|
+
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
180
|
+
api.get_api_info_with_http_info
|
181
|
+
configuration.app_sid = "invalid"
|
182
|
+
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
183
|
+
o, c, _h = api.get_api_info_with_http_info
|
184
|
+
expect(c).to eq(200)
|
185
|
+
expect(o).not_to be(nil)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'bad token' do
|
189
|
+
config = JSON.parse(File.read('testConfig.json'))
|
190
|
+
configuration = AsposeSlidesCloud::Configuration.new
|
191
|
+
configuration.base_url = config["BaseUrl"]
|
192
|
+
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
193
|
+
configuration.app_sid = config["ClientId"]
|
194
|
+
configuration.app_key = config["ClientSecret"]
|
195
|
+
configuration.access_token = "expired.token"
|
196
|
+
configuration.debugging = config["Debug"]
|
197
|
+
api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
198
|
+
o, c, _h = api.get_api_info_with_http_info
|
199
|
+
expect(c).to eq(200)
|
200
|
+
expect(o).not_to be(nil)
|
201
|
+
end
|
202
|
+
end
|
203
203
|
end
|
data/spec/spec_utils.rb
CHANGED
@@ -1,182 +1,182 @@
|
|
1
|
-
=begin
|
2
|
-
Copyright (c) 2019 Aspose Pty Ltd
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
6
|
-
in the Software without restriction, including without limitation the rights
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
9
|
-
furnished to do so, subject to the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
12
|
-
copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
-
SOFTWARE.
|
21
|
-
=end
|
22
|
-
|
23
|
-
module AsposeSlidesCloud
|
24
|
-
class SpecUtils
|
25
|
-
def self.initialize(method, name, value)
|
26
|
-
if !@@is_initialized
|
27
|
-
version = ""
|
28
|
-
begin
|
29
|
-
version = SpecUtils.api.download_file("TempTests/version.txt")
|
30
|
-
rescue AsposeSlidesCloud::ApiError => e
|
31
|
-
if e.code != 404
|
32
|
-
fail "Could not read from storage"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
if version != EXPECTED_TEST_DATA_VERSION
|
36
|
-
Dir.entries(TEST_DATA_PATH).each { |f|
|
37
|
-
if !File.directory? File.join(TEST_DATA_PATH, f)
|
38
|
-
fd = File.binread(File.join(TEST_DATA_PATH, f))
|
39
|
-
SpecUtils.api.upload_file("TempTests/" + f, fd)
|
40
|
-
end
|
41
|
-
}
|
42
|
-
SpecUtils.api.upload_file("TempTests/version.txt", EXPECTED_TEST_DATA_VERSION)
|
43
|
-
end
|
44
|
-
@@is_initialized = true
|
45
|
-
end
|
46
|
-
files = Hash.new
|
47
|
-
SpecUtils.test_rules["Files"].each do |rule|
|
48
|
-
if SpecUtils.good_rule?(rule, name, method)
|
49
|
-
actual_name = SpecUtils.untemplatize(rule["File"], value)
|
50
|
-
path = "TempSlidesSDK"
|
51
|
-
if rule.key?("Folder")
|
52
|
-
path = SpecUtils.untemplatize(rule["Folder"], value)
|
53
|
-
end
|
54
|
-
path = path + "/" + actual_name
|
55
|
-
files[path] = rule
|
56
|
-
rule["ActualName"] = actual_name
|
57
|
-
end
|
58
|
-
end
|
59
|
-
files.each do |path, rule|
|
60
|
-
if rule["Action"] == "Put"
|
61
|
-
SpecUtils.api.copy_file("TempTests/" + rule['ActualName'], path)
|
62
|
-
elsif rule["Action"] == "Delete"
|
63
|
-
SpecUtils.api.delete_file(path)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.get_param_value(name, method, type)
|
69
|
-
if type == 'File'
|
70
|
-
fileName = "test.pptx"
|
71
|
-
if method.casecmp("
|
72
|
-
fileName = "test.pdf"
|
73
|
-
elsif name.casecmp("Image") == 0
|
74
|
-
fileName = "watermark.png"
|
75
|
-
end
|
76
|
-
return File.binread(File.join(TEST_DATA_PATH, fileName))
|
77
|
-
end
|
78
|
-
if type == 'File[]'
|
79
|
-
files = []
|
80
|
-
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "test.pptx")))
|
81
|
-
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "test-unprotected.pptx")))
|
82
|
-
return files
|
83
|
-
end
|
84
|
-
value = "test" + name
|
85
|
-
SpecUtils.test_rules["Values"].each do |rule|
|
86
|
-
if SpecUtils.good_rule?(rule, name, method) and rule.key?("Value")
|
87
|
-
value = rule["Value"]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
value
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.invalidize_param_value(name, method, value, type)
|
94
|
-
if type == 'File'
|
95
|
-
return nil
|
96
|
-
end
|
97
|
-
invalid_value = nil
|
98
|
-
SpecUtils.test_rules["Values"].each do |rule|
|
99
|
-
if SpecUtils.good_rule?(rule, name, method) and rule.key?("InvalidValue")
|
100
|
-
invalid_value = rule["InvalidValue"]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
SpecUtils.untemplatize(invalid_value, value)
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.get_expected_error(method, name, value)
|
107
|
-
code = 0
|
108
|
-
message = "Unexpeceted message"
|
109
|
-
SpecUtils.test_rules["Results"].each do |rule|
|
110
|
-
if SpecUtils.good_rule?(rule, name, method)
|
111
|
-
if rule.key?("Code")
|
112
|
-
code = rule["Code"]
|
113
|
-
end
|
114
|
-
if rule.key?("Message")
|
115
|
-
message = SpecUtils.untemplatize(rule["Message"], value)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
return code, message
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.no_exception?(method, name)
|
123
|
-
SpecUtils.test_rules["OKToNotFail"].each do |rule|
|
124
|
-
return true
|
125
|
-
end
|
126
|
-
return false
|
127
|
-
end
|
128
|
-
|
129
|
-
def self.good_rule?(rule, name, method)
|
130
|
-
(not rule.key?("Language") or rule["Language"].casecmp("Ruby") == 0) \
|
131
|
-
and (not rule.key?("Invalid") or ((name != nil) == rule["Invalid"])) \
|
132
|
-
and (not rule.key?("Parameter") or (name != nil and rule["Parameter"].casecmp(name) == 0)) \
|
133
|
-
and (not rule.key?("Method") or (method != nil and rule["Method"].casecmp(method) == 0))
|
134
|
-
end
|
135
|
-
|
136
|
-
def self.untemplatize(template, value)
|
137
|
-
if template == nil
|
138
|
-
value
|
139
|
-
else
|
140
|
-
result = template
|
141
|
-
if template.is_a? String and template.match("%v")
|
142
|
-
result = "" + template
|
143
|
-
if value != nil
|
144
|
-
result["%v"] = value.to_s
|
145
|
-
else
|
146
|
-
result["%v"] = ""
|
147
|
-
end
|
148
|
-
end
|
149
|
-
result
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def self.test_rules
|
154
|
-
unless @@test_rules
|
155
|
-
@@test_rules = JSON.parse(File.read('testRules.json'))
|
156
|
-
end
|
157
|
-
@@test_rules
|
158
|
-
end
|
159
|
-
|
160
|
-
@@test_rules = nil
|
161
|
-
|
162
|
-
def self.api
|
163
|
-
unless @@api
|
164
|
-
config = JSON.parse(File.read('testConfig.json'))
|
165
|
-
configuration = AsposeSlidesCloud::Configuration.new
|
166
|
-
configuration.base_url = config["BaseUrl"]
|
167
|
-
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
168
|
-
configuration.app_sid = config["ClientId"]
|
169
|
-
configuration.app_key = config["ClientSecret"]
|
170
|
-
configuration.debugging = config["Debug"]
|
171
|
-
@@api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
172
|
-
end
|
173
|
-
@@api
|
174
|
-
end
|
175
|
-
|
176
|
-
@@api = nil
|
177
|
-
@@is_initialized = false
|
178
|
-
|
179
|
-
TEST_DATA_PATH = "TestData"
|
180
|
-
EXPECTED_TEST_DATA_VERSION = "1"
|
181
|
-
end
|
182
|
-
end
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2019 Aspose Pty Ltd
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
21
|
+
=end
|
22
|
+
|
23
|
+
module AsposeSlidesCloud
|
24
|
+
class SpecUtils
|
25
|
+
def self.initialize(method, name, value)
|
26
|
+
if !@@is_initialized
|
27
|
+
version = ""
|
28
|
+
begin
|
29
|
+
version = SpecUtils.api.download_file("TempTests/version.txt")
|
30
|
+
rescue AsposeSlidesCloud::ApiError => e
|
31
|
+
if e.code != 404
|
32
|
+
fail "Could not read from storage"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if version != EXPECTED_TEST_DATA_VERSION
|
36
|
+
Dir.entries(TEST_DATA_PATH).each { |f|
|
37
|
+
if !File.directory? File.join(TEST_DATA_PATH, f)
|
38
|
+
fd = File.binread(File.join(TEST_DATA_PATH, f))
|
39
|
+
SpecUtils.api.upload_file("TempTests/" + f, fd)
|
40
|
+
end
|
41
|
+
}
|
42
|
+
SpecUtils.api.upload_file("TempTests/version.txt", EXPECTED_TEST_DATA_VERSION)
|
43
|
+
end
|
44
|
+
@@is_initialized = true
|
45
|
+
end
|
46
|
+
files = Hash.new
|
47
|
+
SpecUtils.test_rules["Files"].each do |rule|
|
48
|
+
if SpecUtils.good_rule?(rule, name, method)
|
49
|
+
actual_name = SpecUtils.untemplatize(rule["File"], value)
|
50
|
+
path = "TempSlidesSDK"
|
51
|
+
if rule.key?("Folder")
|
52
|
+
path = SpecUtils.untemplatize(rule["Folder"], value)
|
53
|
+
end
|
54
|
+
path = path + "/" + actual_name
|
55
|
+
files[path] = rule
|
56
|
+
rule["ActualName"] = actual_name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
files.each do |path, rule|
|
60
|
+
if rule["Action"] == "Put"
|
61
|
+
SpecUtils.api.copy_file("TempTests/" + rule['ActualName'], path)
|
62
|
+
elsif rule["Action"] == "Delete"
|
63
|
+
SpecUtils.api.delete_file(path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.get_param_value(name, method, type)
|
69
|
+
if type == 'File'
|
70
|
+
fileName = "test.pptx"
|
71
|
+
if method.casecmp("ImportFromPdf") == 0
|
72
|
+
fileName = "test.pdf"
|
73
|
+
elsif name.casecmp("Image") == 0
|
74
|
+
fileName = "watermark.png"
|
75
|
+
end
|
76
|
+
return File.binread(File.join(TEST_DATA_PATH, fileName))
|
77
|
+
end
|
78
|
+
if type == 'File[]'
|
79
|
+
files = []
|
80
|
+
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "test.pptx")))
|
81
|
+
files.push(File.binread(File.join(AsposeSlidesCloud::SpecUtils::TEST_DATA_PATH, "test-unprotected.pptx")))
|
82
|
+
return files
|
83
|
+
end
|
84
|
+
value = "test" + name
|
85
|
+
SpecUtils.test_rules["Values"].each do |rule|
|
86
|
+
if SpecUtils.good_rule?(rule, name, method) and rule.key?("Value")
|
87
|
+
value = rule["Value"]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
value
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.invalidize_param_value(name, method, value, type)
|
94
|
+
if type == 'File'
|
95
|
+
return nil
|
96
|
+
end
|
97
|
+
invalid_value = nil
|
98
|
+
SpecUtils.test_rules["Values"].each do |rule|
|
99
|
+
if SpecUtils.good_rule?(rule, name, method) and rule.key?("InvalidValue")
|
100
|
+
invalid_value = rule["InvalidValue"]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
SpecUtils.untemplatize(invalid_value, value)
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.get_expected_error(method, name, value)
|
107
|
+
code = 0
|
108
|
+
message = "Unexpeceted message"
|
109
|
+
SpecUtils.test_rules["Results"].each do |rule|
|
110
|
+
if SpecUtils.good_rule?(rule, name, method)
|
111
|
+
if rule.key?("Code")
|
112
|
+
code = rule["Code"]
|
113
|
+
end
|
114
|
+
if rule.key?("Message")
|
115
|
+
message = SpecUtils.untemplatize(rule["Message"], value)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
return code, message
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.no_exception?(method, name)
|
123
|
+
SpecUtils.test_rules["OKToNotFail"].each do |rule|
|
124
|
+
return true
|
125
|
+
end
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.good_rule?(rule, name, method)
|
130
|
+
(not rule.key?("Language") or rule["Language"].casecmp("Ruby") == 0) \
|
131
|
+
and (not rule.key?("Invalid") or ((name != nil) == rule["Invalid"])) \
|
132
|
+
and (not rule.key?("Parameter") or (name != nil and rule["Parameter"].casecmp(name) == 0)) \
|
133
|
+
and (not rule.key?("Method") or (method != nil and rule["Method"].casecmp(method) == 0))
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.untemplatize(template, value)
|
137
|
+
if template == nil
|
138
|
+
value
|
139
|
+
else
|
140
|
+
result = template
|
141
|
+
if template.is_a? String and template.match("%v")
|
142
|
+
result = "" + template
|
143
|
+
if value != nil
|
144
|
+
result["%v"] = value.to_s
|
145
|
+
else
|
146
|
+
result["%v"] = ""
|
147
|
+
end
|
148
|
+
end
|
149
|
+
result
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.test_rules
|
154
|
+
unless @@test_rules
|
155
|
+
@@test_rules = JSON.parse(File.read('testRules.json'))
|
156
|
+
end
|
157
|
+
@@test_rules
|
158
|
+
end
|
159
|
+
|
160
|
+
@@test_rules = nil
|
161
|
+
|
162
|
+
def self.api
|
163
|
+
unless @@api
|
164
|
+
config = JSON.parse(File.read('testConfig.json'))
|
165
|
+
configuration = AsposeSlidesCloud::Configuration.new
|
166
|
+
configuration.base_url = config["BaseUrl"]
|
167
|
+
configuration.auth_base_url = config["AuthBaseUrl"] ? config["AuthBaseUrl"] : config["BaseUrl"]
|
168
|
+
configuration.app_sid = config["ClientId"]
|
169
|
+
configuration.app_key = config["ClientSecret"]
|
170
|
+
configuration.debugging = config["Debug"]
|
171
|
+
@@api = AsposeSlidesCloud::SlidesApi.new(configuration)
|
172
|
+
end
|
173
|
+
@@api
|
174
|
+
end
|
175
|
+
|
176
|
+
@@api = nil
|
177
|
+
@@is_initialized = false
|
178
|
+
|
179
|
+
TEST_DATA_PATH = "TestData"
|
180
|
+
EXPECTED_TEST_DATA_VERSION = "1"
|
181
|
+
end
|
182
|
+
end
|