lws 7.2.1 → 7.3.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/bin/lwsconsole +2 -1
- data/lib/lws.rb +2 -3
- data/lib/lws/apps/auth.rb +5 -7
- data/lib/lws/apps/corporate_website.rb +5 -6
- data/lib/lws/apps/digital_signage.rb +15 -8
- data/lib/lws/apps/generic.rb +25 -4
- data/lib/lws/apps/maps.rb +5 -6
- data/lib/lws/apps/presence.rb +21 -18
- data/lib/lws/apps/resource.rb +5 -6
- data/lib/lws/apps/ticket.rb +5 -6
- data/lib/lws/config.rb +43 -11
- data/lib/lws/version.rb +1 -1
- data/test/config/full.yml +1 -0
- data/test/digital_signage_test.rb +2 -2
- data/test/http_caching_test.rb +1 -0
- data/test/setup_test.rb +47 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adfefa3011145091ec6c1bbcf5c729159e25785e6ed08a4d0a2016b3fee39da
|
4
|
+
data.tar.gz: 7a36e1b6055974e4694c90305a92780b53083070f7f4d68f4b60c3e0415d80b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a678afd13b84a45b5806fe6b23cd62cd6fb168f9bb6ea3847a920e0f0ede050cf39ba2af2c19ec07adaeeeca8d67058fc74f786c20ba7a08a1a44207cc3cfa
|
7
|
+
data.tar.gz: 3326e671e49b61f88e12a98881c8339d3e0f13a2c76079cf957910b197af85078a35d065130694d73b91f295b2ae61c137878450ce05f71549ab48629605ffb1
|
data/bin/lwsconsole
CHANGED
@@ -36,7 +36,7 @@ EOB
|
|
36
36
|
@options[:debug] = debug
|
37
37
|
end
|
38
38
|
opts.on("-e", "--environment=ENV", "select the LWS environment (default: production)") do |env|
|
39
|
-
@options[:environment] = env
|
39
|
+
@options[:environment] = env
|
40
40
|
end
|
41
41
|
opts.on("-t", "--token=TOKEN", "the LWS API token necessary to gain access") do |token|
|
42
42
|
@options[:token] = token
|
@@ -80,6 +80,7 @@ begin
|
|
80
80
|
LWS.setup do |config|
|
81
81
|
config.api_token = @options[:token] if @options[:token]
|
82
82
|
config.endpoints = @endpoints
|
83
|
+
config.http_caching = true
|
83
84
|
config.http_debug = @options[:debug]
|
84
85
|
config.json_debug = @options[:debug]
|
85
86
|
config.logger = logger
|
data/lib/lws.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
require "faraday_middleware"
|
13
12
|
require "faraday/http_cache"
|
14
13
|
require "hashie"
|
@@ -81,7 +80,7 @@ module LWS
|
|
81
80
|
|
82
81
|
# Override the environment if needed
|
83
82
|
if ENV["LC_LWS_ENV"].present?
|
84
|
-
@@config.environment = ENV["LC_LWS_ENV"]
|
83
|
+
@@config.environment = ENV["LC_LWS_ENV"]
|
85
84
|
end
|
86
85
|
|
87
86
|
# Override the API token if needed (and no custom API token middleware
|
@@ -112,7 +111,7 @@ module LWS
|
|
112
111
|
# @param api_url [String] The endpoint URL of the API
|
113
112
|
# @return [Faraday::Connection] A Faraday connection that makes requests to the API
|
114
113
|
def self.setup_api(api_url)
|
115
|
-
api = Faraday.new(url: api_url) do |c|
|
114
|
+
api = Faraday.new(url: api_url, proxy: config.proxy) do |c|
|
116
115
|
# Request
|
117
116
|
if config.caching_object
|
118
117
|
c.use FaradayMiddleware::Caching, config.caching_object
|
data/lib/lws/apps/auth.rb
CHANGED
@@ -14,18 +14,16 @@ module LWS::Auth
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Auth app
|
18
21
|
ENDPOINT = { production: "https://leftclick.cloud/" ,
|
19
22
|
development: "https://dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
class << self
|
25
|
-
attr_accessor :api
|
26
|
-
end
|
27
|
-
@api = LWS.setup_api(LWS.config.endpoints[:auth] ||
|
28
|
-
ENDPOINT[LWS.config.environment])
|
26
|
+
include LWS::Generic
|
29
27
|
|
30
28
|
### Generic classes
|
31
29
|
|
@@ -14,17 +14,16 @@ module LWS::CorporateWebsite
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Corporate Website app
|
18
21
|
ENDPOINT = { production: "https://www.leftclick.cloud/",
|
19
22
|
development: "https://www-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:corporate_website] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
@@ -14,17 +14,16 @@ module LWS::DigitalSignage
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Digital Signage app
|
18
21
|
ENDPOINT = { production: "https://cm.leftclick.cloud/" ,
|
19
22
|
development: "https://cm-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:digital_signage] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
@@ -653,6 +652,12 @@ module LWS::DigitalSignage
|
|
653
652
|
# of the layout element
|
654
653
|
has_many :customizables, class_name: "LWS::DigitalSignage::Layout::Element::Customizable"
|
655
654
|
|
655
|
+
# @!attribute definition
|
656
|
+
# @note This attribute is only available if the token is of an account
|
657
|
+
# with sysadmin permissions
|
658
|
+
# @return [Hash] the (plugin) component definition of the layout element
|
659
|
+
attribute :definition
|
660
|
+
|
656
661
|
# @!attribute index
|
657
662
|
# @return [Integer, nil] the index of the element within the list of
|
658
663
|
# layout elements of the associated layout version
|
@@ -768,8 +773,10 @@ module LWS::DigitalSignage
|
|
768
773
|
|
769
774
|
# @!attribute archive_url
|
770
775
|
# @note
|
771
|
-
# To be able retrieve
|
772
|
-
# in the HTTP request headers!
|
776
|
+
# To be able retrieve the archive, the token needs to be passed via
|
777
|
+
# +X-Token+ in the HTTP request headers!
|
778
|
+
# @note This attribute is only available if the token is of an account
|
779
|
+
# with sysadmin permissions
|
773
780
|
# @return [String, nil] the URL of the archive/layout pack of the layout
|
774
781
|
# version (if accessible)
|
775
782
|
attribute :archive_url
|
data/lib/lws/apps/generic.rb
CHANGED
@@ -14,6 +14,25 @@
|
|
14
14
|
# This module contains classes that are present in all applications.
|
15
15
|
module LWS::Generic
|
16
16
|
|
17
|
+
def self.included(app_mod)
|
18
|
+
app_mod.module_eval do |mod|
|
19
|
+
# Set up the API using the configured or default endpoint for the current
|
20
|
+
# environment.
|
21
|
+
endpoints = mod.const_get(:ENDPOINT)
|
22
|
+
app_name = mod.name.demodulize.underscore.to_sym
|
23
|
+
@api = LWS.setup_api(LWS.config.endpoints[app_name] ||
|
24
|
+
endpoints[LWS.config.environment])
|
25
|
+
|
26
|
+
def self.api
|
27
|
+
@api
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.endpoint
|
31
|
+
@api.url_prefix.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
17
36
|
# = The generic model class
|
18
37
|
#
|
19
38
|
# This model forms the base for all LWS models.
|
@@ -203,11 +222,13 @@ module LWS::Generic
|
|
203
222
|
def self.use_api(api)
|
204
223
|
config = LWS.config
|
205
224
|
|
206
|
-
#
|
207
|
-
#
|
208
|
-
@as_connection = Faraday.new(url: api.url_prefix) do |c|
|
225
|
+
# An API connection to Active Storage (with JSON request/response, but
|
226
|
+
# without caching).
|
227
|
+
@as_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
209
228
|
# Request
|
210
229
|
c.request :json
|
230
|
+
c.use LWS::Middleware::RequestHeaders, config.api_token
|
231
|
+
c.use config.api_token_middleware if config.api_token_middleware.present?
|
211
232
|
|
212
233
|
# Response
|
213
234
|
c.use LWS::JSONLogger, config.logger if config.json_debug
|
@@ -223,7 +244,7 @@ module LWS::Generic
|
|
223
244
|
|
224
245
|
# A plain file connection to LWS (with token autnentication and caching but without
|
225
246
|
# JSON request/response).
|
226
|
-
@lws_connection = Faraday.new(url: api.url_prefix) do |c|
|
247
|
+
@lws_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
227
248
|
# Request
|
228
249
|
if config.caching_object
|
229
250
|
c.use FaradayMiddleware::Caching, config.caching_object
|
data/lib/lws/apps/maps.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Maps
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Maps app
|
18
21
|
ENDPOINT = { production: "https://maps.leftclick.cloud/",
|
19
22
|
development: "https://maps-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:maps] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/presence.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Presence
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Presence app
|
18
21
|
ENDPOINT = { production: "https://presence.leftclick.cloud/",
|
19
22
|
development: "https://presence-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:presence] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
@@ -84,7 +83,7 @@ module LWS::Presence
|
|
84
83
|
attribute :title
|
85
84
|
|
86
85
|
# @!attribute uuid
|
87
|
-
# @return [String] the UUID of the
|
86
|
+
# @return [String] the UUID of the appointment
|
88
87
|
attribute :uuid
|
89
88
|
end
|
90
89
|
|
@@ -174,11 +173,11 @@ module LWS::Presence
|
|
174
173
|
attribute :checkin_status
|
175
174
|
|
176
175
|
# @!attribute checkout_alter_status
|
177
|
-
# @return ["available", "
|
178
|
-
# "
|
179
|
-
# "
|
180
|
-
# "
|
181
|
-
# location to when someone checks out
|
176
|
+
# @return ["available", "maintenance_cleaning", "maintenance_technical",
|
177
|
+
# "reserved", "unavailable", "permanent_available",
|
178
|
+
# "permanent_maintenance_cleaning", "permanent_maintenance_technical",
|
179
|
+
# "permanent_reserved", "permanent_unavailable", nil] the status to set
|
180
|
+
# the location to when someone checks out
|
182
181
|
attribute :checkout_alter_status
|
183
182
|
|
184
183
|
# @!attribute checkout_location
|
@@ -216,6 +215,10 @@ module LWS::Presence
|
|
216
215
|
# @return [String, nil] the URL of the image of the location
|
217
216
|
attribute :image_url
|
218
217
|
|
218
|
+
# @!attribute import_ref
|
219
|
+
# @return [String, nil] reference of the location in the remote database
|
220
|
+
attribute :import_ref
|
221
|
+
|
219
222
|
# @!attribute journals
|
220
223
|
# @return [Array<Journal>] the journal (entries) associated with the location
|
221
224
|
has_many :journals, class: "LWS::Presence::Journal"
|
@@ -285,10 +288,11 @@ module LWS::Presence
|
|
285
288
|
has_many :readers
|
286
289
|
|
287
290
|
# @!attribute status
|
288
|
-
# @return ["available", "
|
289
|
-
# "maintenance_technical", "
|
290
|
-
# "
|
291
|
-
# "permanent_maintenance_technical"
|
291
|
+
# @return ["available", "maintenance_cleaning",
|
292
|
+
# "maintenance_technical", "reserved", "unavailable",
|
293
|
+
# "permanent_available", "permanent_maintenance_cleaning",
|
294
|
+
# "permanent_maintenance_technical", "permanent_reserved",
|
295
|
+
# "permanent_unavailable" ] the status of the location
|
292
296
|
attribute :status
|
293
297
|
|
294
298
|
# @!attribute time_zone
|
@@ -503,8 +507,7 @@ module LWS::Presence
|
|
503
507
|
attribute :extra_info
|
504
508
|
|
505
509
|
# @!attribute import_ref
|
506
|
-
# @return [String, nil] reference
|
507
|
-
# database
|
510
|
+
# @return [String, nil] reference of the person in the remote database
|
508
511
|
attribute :import_ref
|
509
512
|
|
510
513
|
# @!attribute kind
|
data/lib/lws/apps/resource.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Resource
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Resource app
|
18
21
|
ENDPOINT = { production: "https://resource.leftclick.cloud/",
|
19
22
|
development: "https://resource-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:resource] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/apps/ticket.rb
CHANGED
@@ -14,17 +14,16 @@ module LWS::Ticket
|
|
14
14
|
|
15
15
|
# :nocov:
|
16
16
|
unless defined? ENDPOINT
|
17
|
-
#
|
17
|
+
# @!method self.endpoint
|
18
|
+
# @return [String] the actual API endpoint used to reach the app
|
19
|
+
|
20
|
+
# The API endpoint environment mapping for the Ticket app
|
18
21
|
ENDPOINT = { production: "https://ticket.leftclick.cloud/",
|
19
22
|
development: "https://ticket-dev.leftclick.cloud/" }
|
20
23
|
end
|
21
24
|
# :nocov:
|
22
25
|
|
23
|
-
|
24
|
-
def self.api
|
25
|
-
LWS.setup_api(LWS.config.endpoints[:ticket] ||
|
26
|
-
ENDPOINT[LWS.config.environment])
|
27
|
-
end
|
26
|
+
include LWS::Generic
|
28
27
|
|
29
28
|
### Generic classes
|
30
29
|
|
data/lib/lws/config.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
module LWS
|
13
12
|
|
14
13
|
# = The LWS API configuration class
|
@@ -20,7 +19,9 @@ module LWS
|
|
20
19
|
# configured for the library to work properly!
|
21
20
|
class Config < Hashie::Dash
|
22
21
|
# The list of properties that can be set using a config file.
|
23
|
-
VALID_FILE_PROPERTIES =
|
22
|
+
VALID_FILE_PROPERTIES =
|
23
|
+
[:api_token, :endpoints, :environment, :http_debug, :http_debug_headers,
|
24
|
+
:json_debug, :proxy]
|
24
25
|
|
25
26
|
#@!attribute api_token
|
26
27
|
# @return [String, nil] the API token necessary to gain access
|
@@ -47,7 +48,7 @@ module LWS
|
|
47
48
|
|
48
49
|
#@!attribute http_caching
|
49
50
|
# @return [Boolean] whether HTTP caching is enabled
|
50
|
-
property :http_caching, default:
|
51
|
+
property :http_caching, default: false
|
51
52
|
|
52
53
|
#@!attribute http_caching_object
|
53
54
|
# @return [#read, #write, #delete] an object that caches results
|
@@ -76,13 +77,42 @@ module LWS
|
|
76
77
|
# (Rails logger, Logger, etc.)
|
77
78
|
property :logger
|
78
79
|
|
80
|
+
#@!attribute proxy
|
81
|
+
# When passing a Hash, it should at least contain +:uri+ as key with
|
82
|
+
# a String or URI as value and optionally the +:user+ and +:password+
|
83
|
+
# keys with appropriate values.
|
84
|
+
# @return [Hash, String, URI] the proxy configuration, either as URL or
|
85
|
+
# as a Hash
|
86
|
+
property :proxy
|
87
|
+
|
79
88
|
#@!attribute stubbing
|
80
89
|
# @return [String] the path to a directory with stubbing fixtures
|
81
90
|
# (setting this enables the default stubs)
|
82
91
|
property :stubbing
|
83
92
|
|
84
|
-
#
|
93
|
+
# Sets the environment for the config.
|
94
|
+
#
|
95
|
+
# The provided environment can be a string in short and long format as well
|
96
|
+
# as a symbol.
|
97
|
+
#
|
98
|
+
# @param new_env [Symbol, String] the new environment to use
|
99
|
+
# @return [Symbol] the new environment
|
100
|
+
# @raise when an invalid environment is provided
|
101
|
+
def environment=(new_env)
|
102
|
+
real_env =
|
103
|
+
case new_env
|
104
|
+
when "prod", "production", :prod, :production
|
105
|
+
:production
|
106
|
+
when "dev", "development", :dev, :development
|
107
|
+
:development
|
108
|
+
else
|
109
|
+
raise "unsupported environment: #{new_env}"
|
110
|
+
end
|
111
|
+
self[:environment] = real_env
|
112
|
+
end
|
85
113
|
|
114
|
+
# Supplements the configuration with settings from a config file.
|
115
|
+
#
|
86
116
|
# The configuration file has a section per environment that indicates
|
87
117
|
# per property what to use if it is unset.
|
88
118
|
#
|
@@ -100,9 +130,10 @@ module LWS
|
|
100
130
|
# an environment key that selects the default environment (unless
|
101
131
|
# overriden by the +LC_LWS_ENV+ environment variable).
|
102
132
|
#
|
103
|
-
# @example A elaborate configuration that sets the development environment as default, enables debugging and overrides an endpoint
|
133
|
+
# @example A elaborate configuration that sets the proxy and the development environment as default, enables debugging and overrides an endpoint
|
104
134
|
# default:
|
105
135
|
# environment: "development"
|
136
|
+
# proxy: "http://proxyserver:8080"
|
106
137
|
#
|
107
138
|
# production:
|
108
139
|
# api_token: "my-prod-api-token"
|
@@ -123,12 +154,13 @@ module LWS
|
|
123
154
|
def load_config_file(config_file, force_environment = nil)
|
124
155
|
return false unless File.exist? config_file
|
125
156
|
config_data = YAML.load_file(config_file)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
157
|
+
default_config = config_data["default"] || {}
|
158
|
+
|
159
|
+
self.environment = force_environment ||
|
160
|
+
ENV["LC_LWS_ENV"] ||
|
161
|
+
config_data.dig("default", "environment") ||
|
162
|
+
self.environment
|
163
|
+
config = default_config.merge(config_data[self.environment.to_s] || {})
|
132
164
|
|
133
165
|
config.each_pair do |key, value|
|
134
166
|
unless VALID_FILE_PROPERTIES.include? key.to_sym
|
data/lib/lws/version.rb
CHANGED
data/test/config/full.yml
CHANGED
@@ -116,7 +116,7 @@ class TestDigitalSignageChannelTimeSchedule < MiniTest::Test
|
|
116
116
|
include LWS::DigitalSignage
|
117
117
|
|
118
118
|
def setup
|
119
|
-
@channel_time_schedule = Channel::TimeSchedule.
|
119
|
+
@channel_time_schedule = Channel::TimeSchedule.find(1)
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_valid
|
@@ -137,7 +137,7 @@ class TestDigitalSignageChannelTimeScheduleDay < MiniTest::Test
|
|
137
137
|
include LWS::DigitalSignage
|
138
138
|
|
139
139
|
def setup
|
140
|
-
@channel_time_schedule = Channel::TimeSchedule.
|
140
|
+
@channel_time_schedule = Channel::TimeSchedule.find(1)
|
141
141
|
# Time schedule days only exist as child objects of a time schedule
|
142
142
|
@channel_time_schedule_day = @channel_time_schedule.days.first
|
143
143
|
end
|
data/test/http_caching_test.rb
CHANGED
@@ -44,6 +44,7 @@ class TestHTTPCaching < MiniTest::Test
|
|
44
44
|
# Redo the LWS setup with an HTTP caching object
|
45
45
|
LWS.setup do |config|
|
46
46
|
config.api_token = ENV["LC_LWS_TEST_TOKEN"]
|
47
|
+
config.http_caching = true
|
47
48
|
config.http_caching_object = @cache_mock
|
48
49
|
if ENV["LC_LWS_TEST_DEBUG"].present?
|
49
50
|
config.http_debug = true
|
data/test/setup_test.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# contact LeftClick B.V. at: Schootense Dreef 20A, 5708 HZ Helmond, The
|
9
9
|
# Netherlands, info@leftclick.eu, +3185-4444-004.
|
10
10
|
|
11
|
-
|
12
11
|
require "test_helper"
|
13
12
|
|
14
13
|
class TestSetup < MiniTest::Test
|
@@ -24,7 +23,7 @@ class TestSetup < MiniTest::Test
|
|
24
23
|
|
25
24
|
def test_cannot_leave_out_api_token
|
26
25
|
assert_raises do
|
27
|
-
LWS.setup {
|
26
|
+
LWS.setup {}
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
@@ -47,6 +46,26 @@ class TestSetup < MiniTest::Test
|
|
47
46
|
assert_equal("test-token", LWS.config.api_token)
|
48
47
|
end
|
49
48
|
|
49
|
+
def test_environment_writer
|
50
|
+
LWS.config.environment = "prod"
|
51
|
+
assert_equal(:production, LWS.config.environment)
|
52
|
+
LWS.config.environment = "production"
|
53
|
+
assert_equal(:production, LWS.config.environment)
|
54
|
+
LWS.config.environment = :production
|
55
|
+
assert_equal(:production, LWS.config.environment)
|
56
|
+
|
57
|
+
LWS.config.environment = "dev"
|
58
|
+
assert_equal(:development, LWS.config.environment)
|
59
|
+
LWS.config.environment = "development"
|
60
|
+
assert_equal(:development, LWS.config.environment)
|
61
|
+
LWS.config.environment = :development
|
62
|
+
assert_equal(:development, LWS.config.environment)
|
63
|
+
|
64
|
+
assert_raises do
|
65
|
+
LWS.config.environment = "doesnotexist"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
50
69
|
def test_http_logging_without_logger
|
51
70
|
reconfigure(logger: nil,
|
52
71
|
http_debug: true,
|
@@ -112,6 +131,7 @@ class TestSetup < MiniTest::Test
|
|
112
131
|
assert_equal(true, LWS.config.http_debug)
|
113
132
|
assert_equal(true, LWS.config.http_debug_headers)
|
114
133
|
assert_equal(true, LWS.config.json_debug)
|
134
|
+
assert_equal("http://user:password@proxyserver:8080", LWS.config.proxy)
|
115
135
|
|
116
136
|
with_env("LC_LWS_ENV" => "production") do
|
117
137
|
reconfigure do |config|
|
@@ -128,4 +148,29 @@ class TestSetup < MiniTest::Test
|
|
128
148
|
assert_equal(:development, LWS.config.environment)
|
129
149
|
end
|
130
150
|
|
151
|
+
def test_proxy
|
152
|
+
proxy_url = "http://user:password@proxyserver:8080"
|
153
|
+
reconfigure do |config|
|
154
|
+
config.proxy = proxy_url
|
155
|
+
end
|
156
|
+
|
157
|
+
assert_equal(proxy_url, LWS.config.proxy)
|
158
|
+
assert_equal("http://user:password@proxyserver:8080", LWS::Auth.api.proxy.uri.to_s)
|
159
|
+
assert_equal("user", LWS::Auth.api.proxy.user)
|
160
|
+
assert_equal("password", LWS::Auth.api.proxy.password)
|
161
|
+
|
162
|
+
proxy_options =
|
163
|
+
{ uri: Addressable::URI.parse("http://proxyserver:8080"),
|
164
|
+
user: "user",
|
165
|
+
password: "password" }
|
166
|
+
reconfigure do |config|
|
167
|
+
config.proxy = proxy_options
|
168
|
+
end
|
169
|
+
|
170
|
+
assert_equal(proxy_options, LWS.config.proxy)
|
171
|
+
assert_equal("http://proxyserver:8080", LWS::Auth.api.proxy.uri.to_s)
|
172
|
+
assert_equal("user", LWS::Auth.api.proxy.user)
|
173
|
+
assert_equal("password", LWS::Auth.api.proxy.password)
|
174
|
+
end
|
175
|
+
|
131
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeftClick B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday-http-cache
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.10.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '2.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.10.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '2.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,14 +140,14 @@ dependencies:
|
|
140
140
|
requirements:
|
141
141
|
- - "~>"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: '1
|
143
|
+
version: '2.1'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
146
|
version_requirements: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
148
|
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: '1
|
150
|
+
version: '2.1'
|
151
151
|
- !ruby/object:Gem::Dependency
|
152
152
|
name: minitest
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|