zendesk_apps_support 3.3.6 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b12d11bc57f62df776a651d8d9c06292815c41b
4
- data.tar.gz: 5e2e1ec2503c0364e4bbc5b4288e8684a70bdd3b
3
+ metadata.gz: 911488fbf5c3bbe10e98b1696e6b0915f6894b35
4
+ data.tar.gz: b383f7790f4ac3a8bc34a0e50b4d6d47e4f79af9
5
5
  SHA512:
6
- metadata.gz: 51b9342a9ab4d031e565bf9a482ff18f1bc77110148e3a298a805bd7a8d64fc158eb33c899c65a04501ad7312a588d89d584a49f3e5cc16fe5ae214030260826
7
- data.tar.gz: 1e11c048c19ea123bce3f012fe07e2866b2e0ddbfa12ea38ff600066680cd9bec364deebe97d007ce27aa259bcd0e316a3c241d11d0cee2db8dbd957001a4dc7
6
+ metadata.gz: f1ab63b2557319672569094b3561bd63edb21b708091475eacc02833c9be8185b26b693850021436a494ecaea13cc1ce4f670533d99381e83133ba15df217fab
7
+ data.tar.gz: 9e6a726beb6676c1dafaea5e0f3e1d6ab7d5d271a6f05be4dc0d8ffe56fc7f58b5a2e8494b6d8982a531425aa4b24df18203cea846252be1bca2a7f603712828
@@ -26,6 +26,12 @@ en:
26
26
  symlink_in_zip: Symlinks are not allowed in the zip file
27
27
  invalid_experiment: 'Manifest specifies unknown or unavailable experiment:
28
28
  %{experiment}'
29
+ unacceptable_hash: The manifest field %{field} needs to be key-value pairs
30
+ with string keys, but it was %{value}
31
+ unacceptable_array: The manifest field %{field} needs to be an array,
32
+ but it was %{value}
33
+ unacceptable_array_of_strings: The manifest field %{field} need to be
34
+ an array containing strings
29
35
  missing_requirements: Could not find requirements.json
30
36
  requirements_not_supported: App requirements are not supported for marketing-only
31
37
  apps
@@ -89,6 +95,7 @@ en:
89
95
  one: "%{invalid_types} is an invalid parameter type."
90
96
  other: "%{invalid_types} are invalid parameter types."
91
97
  unacceptable_boolean: '%{field} must be a boolean value, got "%{value}".'
98
+ unacceptable_string: '%{field} must be a string, got "%{value}".'
92
99
  invalid_no_template: noTemplate must be set to true, false, or an array
93
100
  of valid locations.
94
101
  duplicate_reference: 'Duplicate reference in manifest: "%{key}".'
@@ -56,6 +56,18 @@ parts:
56
56
  key: "txt.apps.admin.error.app_build.invalid_experiment"
57
57
  title: "App builder job: an experiment has been specifed that is not publically available or otherwise invalid. https://en.wikipedia.org/wiki/Manifest_file"
58
58
  value: "Manifest specifies unknown or unavailable experiment: %{experiment}"
59
+ - translation:
60
+ key: "txt.apps.admin.error.app_build.unacceptable_hash"
61
+ title: "App builder job: the value for a field needs to be key-value pairs, but it was something else. https://en.wikipedia.org/wiki/Manifest_file"
62
+ value: "The manifest field %{field} needs to be key-value pairs with string keys, but it was %{value}"
63
+ - translation:
64
+ key: "txt.apps.admin.error.app_build.unacceptable_array"
65
+ title: "App builder job: the value for a field needs to be an array, but it was something else. https://en.wikipedia.org/wiki/Manifest_file"
66
+ value: "The manifest field %{field} needs to be an array, but it was %{value}"
67
+ - translation:
68
+ key: "txt.apps.admin.error.app_build.unacceptable_array_of_strings"
69
+ title: "App builder job: the value for domainWhitelist needs to be an array of strings, but it was something else. https://en.wikipedia.org/wiki/Manifest_file"
70
+ value: "The manifest field %{field} need to be an array containing strings"
59
71
  - translation:
60
72
  key: "txt.apps.admin.error.app_build.missing_requirements"
61
73
  title: "App builder job: missing requirements error"
@@ -234,6 +246,10 @@ parts:
234
246
  key: "txt.apps.admin.error.app_build.unacceptable_boolean"
235
247
  title: "App builder job: this value needs to be either true or false, but something else was passed in. placeholder value is taken from user input. You can translate as: The value %{field} must be a Boolean... to avoid any gender issues."
236
248
  value: "%{field} must be a boolean value, got \"%{value}\"."
249
+ - translation:
250
+ key: "txt.apps.admin.error.app_build.unacceptable_string"
251
+ title: "App builder job: this value needs to be a text string, but something else was passed in. placeholder value is taken from user input. You can translate as: The value %{field} must be a string... to avoid any gender issues."
252
+ value: "%{field} must be a string, got \"%{value}\"."
237
253
  - translation:
238
254
  key: "txt.apps.admin.error.app_build.invalid_no_template"
239
255
  title: "App builder job: `noTemplate` needs to be true, false or a valid array, but something else was passed in. noTemplate, true, and false should not be translated."
@@ -261,4 +277,4 @@ parts:
261
277
  - translation:
262
278
  key: "txt.apps.admin.error.app_build.invalid_v1_location.other"
263
279
  title: "The locations listed are not available in framework v1."
264
- value: "%{invalid_locations} are invalid locations in framework v1."
280
+ value: "%{invalid_locations} are invalid locations in framework v1."
@@ -107,7 +107,7 @@ module ZendeskAppsSupport
107
107
  end
108
108
 
109
109
  def enabled_experiments
110
- (experiments || {}).select { |_k, v| v }.keys
110
+ experiments.select { |_k, v| v }.keys
111
111
  end
112
112
 
113
113
  def initialize(manifest_text)
@@ -3,7 +3,8 @@ module ZendeskAppsSupport
3
3
  class Manifest
4
4
  class Parameter
5
5
  TYPES = %w(text password checkbox url number multiline hidden).freeze
6
- attr_reader :name, :type, :required, :secure, :default
6
+ ATTRIBUTES = %i(name type required secure default).freeze
7
+ attr_reader(*ATTRIBUTES)
7
8
  def default?
8
9
  @has_default
9
10
  end
@@ -22,14 +22,13 @@ module ZendeskAppsSupport
22
22
 
23
23
  private
24
24
 
25
- # rubocop:disable Metrics/AbcSize
26
25
  def collate_manifest_errors(package)
27
26
  manifest = package.manifest
28
27
 
29
28
  errors = []
30
29
  errors << missing_keys_error(manifest)
30
+ errors << type_checks(manifest)
31
31
  errors << oauth_error(manifest)
32
- errors << boolean_error(manifest)
33
32
  errors << default_locale_error(manifest, package)
34
33
 
35
34
  if manifest.marketing_only?
@@ -40,7 +39,6 @@ module ZendeskAppsSupport
40
39
  errors << invalid_hidden_parameter_error(manifest)
41
40
  errors << invalid_type_error(manifest)
42
41
  errors << name_as_parameter_name_error(manifest)
43
- errors << no_template_format_error(manifest)
44
42
  end
45
43
 
46
44
  if manifest.requirements_only? || manifest.marketing_only?
@@ -59,7 +57,55 @@ module ZendeskAppsSupport
59
57
 
60
58
  errors.flatten.compact
61
59
  end
62
- # rubocop:enable Metrics/AbcSize
60
+
61
+ def type_checks(manifest)
62
+ errors = []
63
+ errors << boolean_error(manifest)
64
+ errors << string_error(manifest)
65
+ errors << no_template_format_error(manifest)
66
+ unless manifest.experiments.is_a?(Hash)
67
+ errors << ValidationError.new(
68
+ :unacceptable_hash,
69
+ field: 'experiments',
70
+ value: manifest.experiments.class.to_s
71
+ )
72
+ end
73
+ whitelist = manifest.domain_whitelist
74
+ unless whitelist.nil? || whitelist.is_a?(Array) && whitelist.all? { |dom| dom.is_a? String }
75
+ errors << ValidationError.new(:unacceptable_array_of_strings, field: 'domainWhitelist')
76
+ end
77
+ parameters = manifest.original_parameters
78
+ unless parameters.nil? || parameters.is_a?(Array)
79
+ errors << ValidationError.new(
80
+ :unacceptable_array,
81
+ field: 'parameters',
82
+ value: parameters.class.to_s
83
+ )
84
+ end
85
+ errors
86
+ end
87
+
88
+ def string_error(manifest)
89
+ manifest_strings = %i(
90
+ default_locale
91
+ version
92
+ framework_version
93
+ remote_installation_url
94
+ terms_conditions_url
95
+ google_analytics_code
96
+ )
97
+ errors = manifest_strings.map do |field|
98
+ validate_string(manifest.public_send(field), field)
99
+ end
100
+
101
+ if manifest.author
102
+ author_strings = %w(name email url)
103
+ errors << (author_strings.map do |field|
104
+ validate_string(manifest.author[field], "author #{field}")
105
+ end)
106
+ end
107
+ errors
108
+ end
63
109
 
64
110
  def boolean_error(manifest)
65
111
  booleans = %i(requirements_only marketing_only single_install signed_urls private)
@@ -72,6 +118,12 @@ module ZendeskAppsSupport
72
118
  errors.compact
73
119
  end
74
120
 
121
+ def validate_string(value, label_for_error)
122
+ unless value.is_a?(String) || value.nil?
123
+ ValidationError.new(:unacceptable_string, field: label_for_error, value: value)
124
+ end
125
+ end
126
+
75
127
  def validate_boolean(value, label_for_error)
76
128
  unless [true, false].include? value
77
129
  ValidationError.new(:unacceptable_boolean, field: label_for_error, value: value)
@@ -294,8 +346,7 @@ module ZendeskAppsSupport
294
346
  end
295
347
  end
296
348
 
297
- # TODO: support the new location format in the no_template array and check the app actually runs in
298
- # included locations
349
+ # TODO: check the app actually runs in included locations
299
350
  def no_template_format_error(manifest)
300
351
  no_template = manifest.no_template
301
352
  return if [false, true].include? no_template
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.6
4
+ version: 3.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen