prefab-cloud-ruby 1.2.0 → 1.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/CHANGELOG.md +12 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +21 -0
- data/LICENSE.txt +1 -1
- data/VERSION +1 -1
- data/lib/prefab/client.rb +4 -0
- data/lib/prefab/config_client.rb +20 -1
- data/lib/prefab/config_loader.rb +2 -0
- data/lib/prefab/config_value_unwrapper.rb +93 -15
- data/lib/prefab/config_value_wrapper.rb +6 -6
- data/lib/prefab/criteria_evaluator.rb +4 -3
- data/lib/prefab/encryption.rb +65 -0
- data/lib/prefab/errors/env_var_parse_error.rb +11 -0
- data/lib/prefab/evaluation.rb +8 -4
- data/lib/prefab/internal_logger.rb +6 -23
- data/lib/prefab/local_config_parser.rb +58 -2
- data/lib/prefab/log_subscribers/action_controller_subscriber.rb +54 -0
- data/lib/prefab/logger_client.rb +0 -7
- data/lib/prefab/options.rb +11 -1
- data/lib/prefab/resolved_config_presenter.rb +2 -2
- data/lib/prefab/sse_logger.rb +4 -20
- data/lib/prefab/static_logger.rb +29 -0
- data/lib/prefab-cloud-ruby.rb +6 -0
- data/lib/prefab_pb.rb +5 -1
- data/prefab-cloud-ruby.gemspec +11 -3
- data/test/test_action_controller.rb +52 -0
- data/test/test_config_value_unwrapper.rb +167 -20
- data/test/test_context_shape.rb +3 -4
- data/test/test_encryption.rb +16 -0
- data/test/test_local_config_parser.rb +73 -2
- data/test/test_logger.rb +5 -5
- metadata +22 -2
@@ -3,72 +3,219 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class TestConfigValueUnwrapper < Minitest::Test
|
6
|
-
|
6
|
+
CONFIG = PrefabProto::Config.new(
|
7
|
+
key: 'config_key'
|
8
|
+
)
|
7
9
|
EMPTY_CONTEXT = Prefab::Context.new()
|
10
|
+
DECRYPTION_KEY_NAME = "decryption.key"
|
11
|
+
DECRYPTION_KEY_VALUE = Prefab::Encryption.generate_new_hex_key
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@mock_resolver = MockResolver.new
|
16
|
+
end
|
8
17
|
|
9
18
|
def test_unwrapping_int
|
10
19
|
config_value = PrefabProto::ConfigValue.new(int: 123)
|
11
|
-
assert_equal 123, unwrap(config_value,
|
20
|
+
assert_equal 123, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
12
21
|
end
|
13
22
|
|
14
23
|
def test_unwrapping_string
|
15
24
|
config_value = PrefabProto::ConfigValue.new(string: 'abc')
|
16
|
-
assert_equal 'abc', unwrap(config_value,
|
25
|
+
assert_equal 'abc', unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
26
|
+
assert_equal 'abc', reportable_value(config_value, CONFIG, EMPTY_CONTEXT)
|
17
27
|
end
|
18
28
|
|
19
29
|
def test_unwrapping_double
|
20
30
|
config_value = PrefabProto::ConfigValue.new(double: 1.23)
|
21
|
-
assert_equal 1.23, unwrap(config_value,
|
31
|
+
assert_equal 1.23, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
22
32
|
end
|
23
33
|
|
24
34
|
def test_unwrapping_bool
|
25
35
|
config_value = PrefabProto::ConfigValue.new(bool: true)
|
26
|
-
assert_equal true, unwrap(config_value,
|
36
|
+
assert_equal true, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
27
37
|
|
28
38
|
config_value = PrefabProto::ConfigValue.new(bool: false)
|
29
|
-
assert_equal false, unwrap(config_value,
|
39
|
+
assert_equal false, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
30
40
|
end
|
31
41
|
|
32
42
|
def test_unwrapping_log_level
|
33
43
|
config_value = PrefabProto::ConfigValue.new(log_level: :INFO)
|
34
|
-
assert_equal :INFO, unwrap(config_value,
|
44
|
+
assert_equal :INFO, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
35
45
|
end
|
36
46
|
|
37
47
|
def test_unwrapping_string_list
|
38
48
|
config_value = PrefabProto::ConfigValue.new(string_list: PrefabProto::StringList.new(values: %w[a b c]))
|
39
|
-
assert_equal %w[a b c], unwrap(config_value,
|
49
|
+
assert_equal %w[a b c], unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
40
50
|
end
|
41
51
|
|
42
52
|
def test_unwrapping_weighted_values
|
43
53
|
# single value
|
44
54
|
config_value = PrefabProto::ConfigValue.new(weighted_values: weighted_values([['abc', 1]]))
|
45
55
|
|
46
|
-
assert_equal 'abc', unwrap(config_value,
|
56
|
+
assert_equal 'abc', unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
47
57
|
|
48
58
|
# multiple values, evenly distributed
|
49
59
|
config_value = PrefabProto::ConfigValue.new(weighted_values: weighted_values([['abc', 1], ['def', 1], ['ghi', 1]]))
|
50
|
-
assert_equal 'def', unwrap(config_value,
|
51
|
-
assert_equal 'ghi', unwrap(config_value,
|
52
|
-
assert_equal 'abc', unwrap(config_value,
|
53
|
-
assert_equal 'ghi', unwrap(config_value,
|
60
|
+
assert_equal 'def', unwrap(config_value, CONFIG, context_with_key('user:000'))
|
61
|
+
assert_equal 'ghi', unwrap(config_value, CONFIG, context_with_key('user:456'))
|
62
|
+
assert_equal 'abc', unwrap(config_value, CONFIG, context_with_key('user:789'))
|
63
|
+
assert_equal 'ghi', unwrap(config_value, CONFIG, context_with_key('user:888'))
|
54
64
|
|
55
65
|
# multiple values, unevenly distributed
|
56
66
|
config_value = PrefabProto::ConfigValue.new(weighted_values: weighted_values([['abc', 1], ['def', 99], ['ghi', 1]]))
|
57
|
-
assert_equal 'def', unwrap(config_value,
|
58
|
-
assert_equal 'def', unwrap(config_value,
|
59
|
-
assert_equal 'def', unwrap(config_value,
|
60
|
-
assert_equal 'def', unwrap(config_value,
|
61
|
-
assert_equal 'ghi', unwrap(config_value,
|
62
|
-
assert_equal 'abc', unwrap(config_value,
|
67
|
+
assert_equal 'def', unwrap(config_value, CONFIG, context_with_key('user:123'))
|
68
|
+
assert_equal 'def', unwrap(config_value, CONFIG, context_with_key('user:456'))
|
69
|
+
assert_equal 'def', unwrap(config_value, CONFIG, context_with_key('user:789'))
|
70
|
+
assert_equal 'def', unwrap(config_value, CONFIG, context_with_key('user:012'))
|
71
|
+
assert_equal 'ghi', unwrap(config_value, CONFIG, context_with_key('user:428'))
|
72
|
+
assert_equal 'abc', unwrap(config_value, CONFIG, context_with_key('user:548'))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_unwrapping_provided_values
|
76
|
+
with_env('ENV_VAR_NAME', 'unit test value')do
|
77
|
+
value = PrefabProto::Provided.new(
|
78
|
+
source: :ENV_VAR,
|
79
|
+
lookup: "ENV_VAR_NAME"
|
80
|
+
)
|
81
|
+
config_value = PrefabProto::ConfigValue.new(provided: value)
|
82
|
+
assert_equal 'unit test value', unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_unwrapping_provided_values_of_type_string_list
|
87
|
+
with_env('ENV_VAR_NAME', '["bob","cary"]')do
|
88
|
+
value = PrefabProto::Provided.new(
|
89
|
+
source: :ENV_VAR,
|
90
|
+
lookup: "ENV_VAR_NAME"
|
91
|
+
)
|
92
|
+
config_value = PrefabProto::ConfigValue.new(provided: value)
|
93
|
+
assert_equal ["bob", "cary"], unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_unwrapping_provided_values_coerces_to_int
|
98
|
+
with_env('ENV_VAR_NAME', '42')do
|
99
|
+
value = PrefabProto::Provided.new(
|
100
|
+
source: :ENV_VAR,
|
101
|
+
lookup: "ENV_VAR_NAME"
|
102
|
+
)
|
103
|
+
config_value = PrefabProto::ConfigValue.new(provided: value)
|
104
|
+
assert_equal 42, unwrap(config_value, config_of(PrefabProto::Config::ValueType::INT), EMPTY_CONTEXT)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_unwrapping_provided_values_when_value_type_mismatch
|
109
|
+
with_env('ENV_VAR_NAME', 'not an int')do
|
110
|
+
value = PrefabProto::Provided.new(
|
111
|
+
source: :ENV_VAR,
|
112
|
+
lookup: "ENV_VAR_NAME"
|
113
|
+
)
|
114
|
+
config_value = PrefabProto::ConfigValue.new(provided: value)
|
115
|
+
|
116
|
+
assert_raises Prefab::Errors::EnvVarParseError do
|
117
|
+
unwrap(config_value, config_of(PrefabProto::Config::ValueType::INT), EMPTY_CONTEXT)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_coerce
|
123
|
+
assert_equal "string", Prefab::ConfigValueUnwrapper.coerce_into_type("string", CONFIG, "ENV")
|
124
|
+
assert_equal 42, Prefab::ConfigValueUnwrapper.coerce_into_type("42", CONFIG, "ENV")
|
125
|
+
assert_equal false, Prefab::ConfigValueUnwrapper.coerce_into_type("false", CONFIG, "ENV")
|
126
|
+
assert_equal 42.42, Prefab::ConfigValueUnwrapper.coerce_into_type("42.42", CONFIG, "ENV")
|
127
|
+
assert_equal ["a","b"], Prefab::ConfigValueUnwrapper.coerce_into_type("['a','b']", CONFIG, "ENV")
|
128
|
+
|
129
|
+
assert_equal "string", Prefab::ConfigValueUnwrapper.coerce_into_type("string", config_of(PrefabProto::Config::ValueType::STRING),"ENV")
|
130
|
+
assert_equal "42", Prefab::ConfigValueUnwrapper.coerce_into_type("42", config_of(PrefabProto::Config::ValueType::STRING),"ENV")
|
131
|
+
assert_equal "42.42", Prefab::ConfigValueUnwrapper.coerce_into_type("42.42", config_of(PrefabProto::Config::ValueType::STRING),"ENV")
|
132
|
+
assert_equal 42, Prefab::ConfigValueUnwrapper.coerce_into_type("42", config_of(PrefabProto::Config::ValueType::INT),"ENV")
|
133
|
+
assert_equal false, Prefab::ConfigValueUnwrapper.coerce_into_type("false", config_of(PrefabProto::Config::ValueType::BOOL),"ENV")
|
134
|
+
assert_equal 42.42, Prefab::ConfigValueUnwrapper.coerce_into_type("42.42", config_of(PrefabProto::Config::ValueType::DOUBLE),"ENV")
|
135
|
+
assert_equal ["a","b"], Prefab::ConfigValueUnwrapper.coerce_into_type("['a','b']", config_of(PrefabProto::Config::ValueType::STRING_LIST),"ENV")
|
136
|
+
|
137
|
+
assert_raises Prefab::Errors::EnvVarParseError do
|
138
|
+
Prefab::ConfigValueUnwrapper.coerce_into_type("not an int", config_of(PrefabProto::Config::ValueType::INT), "ENV")
|
139
|
+
end
|
140
|
+
assert_raises Prefab::Errors::EnvVarParseError do
|
141
|
+
Prefab::ConfigValueUnwrapper.coerce_into_type("not bool", config_of(PrefabProto::Config::ValueType::BOOL), "ENV")
|
142
|
+
end
|
143
|
+
assert_raises Prefab::Errors::EnvVarParseError do
|
144
|
+
Prefab::ConfigValueUnwrapper.coerce_into_type("not a double", config_of(PrefabProto::Config::ValueType::DOUBLE), "ENV")
|
145
|
+
end
|
146
|
+
assert_raises Prefab::Errors::EnvVarParseError do
|
147
|
+
Prefab::ConfigValueUnwrapper.coerce_into_type("not a list", config_of(PrefabProto::Config::ValueType::STRING_LIST), "ENV")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_unwrapping_provided_values_with_missing_env_var
|
152
|
+
value = PrefabProto::Provided.new(
|
153
|
+
source: :ENV_VAR,
|
154
|
+
lookup: "NON_EXISTENT_ENV_VAR_NAME"
|
155
|
+
)
|
156
|
+
config_value = PrefabProto::ConfigValue.new(provided: value)
|
157
|
+
assert_equal '', unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_unwrapping_encrypted_values_decrypts
|
161
|
+
clear_text = "very secret stuff"
|
162
|
+
encrypted = Prefab::Encryption.new(DECRYPTION_KEY_VALUE).encrypt(clear_text)
|
163
|
+
config_value = PrefabProto::ConfigValue.new(string: encrypted, decrypt_with: "decryption.key")
|
164
|
+
assert_equal clear_text, unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_confidential
|
168
|
+
config_value = PrefabProto::ConfigValue.new(confidential: true, string: "something confidential")
|
169
|
+
assert reportable_value(config_value, CONFIG, EMPTY_CONTEXT).start_with? Prefab::ConfigValueUnwrapper::CONFIDENTIAL_PREFIX
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_unwrap_confiential_provided
|
173
|
+
with_env('PAAS_PASSWORD', "the password")do
|
174
|
+
value = PrefabProto::Provided.new(
|
175
|
+
source: :ENV_VAR,
|
176
|
+
lookup: "PAAS_PASSWORD"
|
177
|
+
)
|
178
|
+
config_value = PrefabProto::ConfigValue.new(provided: value, confidential: true)
|
179
|
+
assert_equal "the password", unwrap(config_value, CONFIG, EMPTY_CONTEXT)
|
180
|
+
assert reportable_value(config_value, CONFIG, EMPTY_CONTEXT).start_with? Prefab::ConfigValueUnwrapper::CONFIDENTIAL_PREFIX
|
181
|
+
end
|
63
182
|
end
|
64
183
|
|
65
184
|
private
|
66
185
|
|
186
|
+
def config_of(value_type)
|
187
|
+
PrefabProto::Config.new(
|
188
|
+
key: 'config-key',
|
189
|
+
value_type: value_type
|
190
|
+
)
|
191
|
+
end
|
192
|
+
|
67
193
|
def context_with_key(key)
|
68
194
|
Prefab::Context.new(user: { key: key })
|
69
195
|
end
|
70
196
|
|
71
197
|
def unwrap(config_value, config_key, context)
|
72
|
-
Prefab::ConfigValueUnwrapper.deepest_value(config_value, config_key, context).unwrap
|
198
|
+
Prefab::ConfigValueUnwrapper.deepest_value(config_value, config_key, context, @mock_resolver).unwrap
|
199
|
+
end
|
200
|
+
|
201
|
+
def reportable_value(config_value, config_key, context)
|
202
|
+
Prefab::ConfigValueUnwrapper.deepest_value(config_value, config_key, context, @mock_resolver).reportable_value
|
203
|
+
end
|
204
|
+
|
205
|
+
class MockResolver
|
206
|
+
def get(key)
|
207
|
+
if DECRYPTION_KEY_NAME == key
|
208
|
+
Prefab::Evaluation.new(config: PrefabProto::Config.new(key: key),
|
209
|
+
value: PrefabProto::ConfigValue.new(string: DECRYPTION_KEY_VALUE),
|
210
|
+
value_index: 0,
|
211
|
+
config_row_index: 0,
|
212
|
+
context: Prefab::Context.new,
|
213
|
+
resolver: self
|
214
|
+
)
|
215
|
+
|
216
|
+
else
|
217
|
+
raise "unexpected key"
|
218
|
+
end
|
219
|
+
end
|
73
220
|
end
|
74
221
|
end
|
data/test/test_context_shape.rb
CHANGED
@@ -36,12 +36,11 @@ class TestContextShape < Minitest::Test
|
|
36
36
|
|
37
37
|
# If this test fails, it means that we've added a new type to the ConfigValue
|
38
38
|
def test_mapping_is_exhaustive
|
39
|
-
unsupported = [:bytes, :limit_definition, :log_level, :weighted_values, :int_range]
|
40
|
-
|
41
|
-
supported =
|
39
|
+
unsupported = [:bytes, :limit_definition, :log_level, :weighted_values, :int_range, :provided]
|
40
|
+
type_fields = PrefabProto::ConfigValue.descriptor.lookup_oneof("type").entries
|
41
|
+
supported = type_fields.entries.reject do |entry|
|
42
42
|
unsupported.include?(entry.name.to_sym)
|
43
43
|
end.map(&:number)
|
44
|
-
|
45
44
|
mapped = Prefab::ContextShape::MAPPING.values.uniq
|
46
45
|
|
47
46
|
unless mapped == supported
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class TestEncryption < Minitest::Test
|
6
|
+
def test_encryption
|
7
|
+
secret = Prefab::Encryption.generate_new_hex_key
|
8
|
+
|
9
|
+
enc = Prefab::Encryption.new(secret)
|
10
|
+
|
11
|
+
clear_text = "hello world"
|
12
|
+
encrypted = enc.encrypt(clear_text)
|
13
|
+
decrypted = enc.decrypt(encrypted)
|
14
|
+
assert_equal clear_text, decrypted
|
15
|
+
end
|
16
|
+
end
|
@@ -6,6 +6,11 @@ class TestLocalConfigParser < Minitest::Test
|
|
6
6
|
FILE_NAME = 'example-config.yaml'
|
7
7
|
DEFAULT_MATCH = 'default'
|
8
8
|
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
@mock_resolver = MockResolver.new
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_parse_int_config
|
10
15
|
key = :sample_int
|
11
16
|
parsed = Prefab::LocalConfigParser.parse(key, 123, {}, FILE_NAME)[key]
|
@@ -34,7 +39,7 @@ class TestLocalConfigParser < Minitest::Test
|
|
34
39
|
assert_equal 1, config.rows[0].values.size
|
35
40
|
|
36
41
|
value_row = config.rows[0].values[0]
|
37
|
-
assert_equal 'all-features', Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, key, {}).unwrap
|
42
|
+
assert_equal 'all-features', Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, key, {}, @mock_resolver).unwrap
|
38
43
|
end
|
39
44
|
|
40
45
|
def test_flag_in_user_key
|
@@ -53,13 +58,73 @@ class TestLocalConfigParser < Minitest::Test
|
|
53
58
|
assert_equal 1, config.rows[0].values[0].criteria.size
|
54
59
|
|
55
60
|
value_row = config.rows[0].values[0]
|
56
|
-
assert_equal true, Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, key, {}).unwrap
|
61
|
+
assert_equal true, Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, key, {}, @mock_resolver).unwrap
|
57
62
|
|
58
63
|
assert_equal 'user.key', value_row.criteria[0].property_name
|
59
64
|
assert_equal :PROP_IS_ONE_OF, value_row.criteria[0].operator
|
60
65
|
assert_equal %w[abc123 xyz987], value_row.criteria[0].value_to_match.string_list.values
|
61
66
|
end
|
62
67
|
|
68
|
+
def test_provided_values
|
69
|
+
with_env('LOOKUP_ENV', 'from env') do
|
70
|
+
key = :test_provided
|
71
|
+
value = stringify_keys({type: 'provided', source: 'ENV_VAR', lookup: 'LOOKUP_ENV'})
|
72
|
+
parsed = Prefab::LocalConfigParser.parse(key, value, {}, FILE_NAME)[key]
|
73
|
+
config = parsed[:config]
|
74
|
+
|
75
|
+
assert_equal FILE_NAME, parsed[:source]
|
76
|
+
assert_equal 'LOOKUP_ENV', parsed[:match]
|
77
|
+
assert_equal :CONFIG, config.config_type
|
78
|
+
assert_equal key.to_s, config.key
|
79
|
+
assert_equal 1, config.rows.size
|
80
|
+
assert_equal 1, config.rows[0].values.size
|
81
|
+
|
82
|
+
value_row = config.rows[0].values[0]
|
83
|
+
provided = value_row.value.provided
|
84
|
+
assert_equal :ENV_VAR, provided.source
|
85
|
+
assert_equal 'LOOKUP_ENV', provided.lookup
|
86
|
+
assert_equal 'from env', Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, config, {}, @mock_resolver).unwrap
|
87
|
+
reportable_value = Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, config, {}, @mock_resolver).reportable_value
|
88
|
+
assert_equal 'from env', reportable_value
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_confidential_provided_values
|
93
|
+
with_env('LOOKUP_ENV', 'from env') do
|
94
|
+
key = :test_provided
|
95
|
+
value = stringify_keys({type: 'provided', source: 'ENV_VAR', lookup: 'LOOKUP_ENV', confidential: true})
|
96
|
+
parsed = Prefab::LocalConfigParser.parse(key, value, {}, FILE_NAME)[key]
|
97
|
+
config = parsed[:config]
|
98
|
+
|
99
|
+
value_row = config.rows[0].values[0]
|
100
|
+
provided = value_row.value.provided
|
101
|
+
assert_equal :ENV_VAR, provided.source
|
102
|
+
assert_equal 'LOOKUP_ENV', provided.lookup
|
103
|
+
assert_equal 'from env', Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, config, {}, @mock_resolver).unwrap
|
104
|
+
reportable_value = Prefab::ConfigValueUnwrapper.deepest_value(value_row.value, config, {}, @mock_resolver).reportable_value
|
105
|
+
assert reportable_value.start_with? Prefab::ConfigValueUnwrapper::CONFIDENTIAL_PREFIX
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_confidential_values
|
110
|
+
key = :test_confidential
|
111
|
+
value = stringify_keys({value: 'a confidential string', confidential: true})
|
112
|
+
parsed = Prefab::LocalConfigParser.parse(key, value, {}, FILE_NAME)[key]
|
113
|
+
config = parsed[:config]
|
114
|
+
|
115
|
+
assert_equal FILE_NAME, parsed[:source]
|
116
|
+
assert_equal :CONFIG, config.config_type
|
117
|
+
assert_equal key.to_s, config.key
|
118
|
+
assert_equal 1, config.rows.size
|
119
|
+
assert_equal 1, config.rows[0].values.size
|
120
|
+
|
121
|
+
value_row = config.rows[0].values[0]
|
122
|
+
config_value = value_row.value
|
123
|
+
assert_equal 'a confidential string', Prefab::ConfigValueUnwrapper.deepest_value(config_value, key, {}, @mock_resolver).unwrap
|
124
|
+
reportable_value = Prefab::ConfigValueUnwrapper.deepest_value(config_value, key, {}, @mock_resolver).reportable_value
|
125
|
+
assert reportable_value.start_with? Prefab::ConfigValueUnwrapper::CONFIDENTIAL_PREFIX
|
126
|
+
end
|
127
|
+
|
63
128
|
private
|
64
129
|
|
65
130
|
def stringify_keys(hash)
|
@@ -73,4 +138,10 @@ class TestLocalConfigParser < Minitest::Test
|
|
73
138
|
end
|
74
139
|
result
|
75
140
|
end
|
141
|
+
|
142
|
+
class MockResolver
|
143
|
+
def get(key)
|
144
|
+
raise "unexpected key"
|
145
|
+
end
|
146
|
+
end
|
76
147
|
end
|
data/test/test_logger.rb
CHANGED
@@ -87,22 +87,22 @@ class TestLogger < Minitest::Test
|
|
87
87
|
|
88
88
|
def test_log_internal
|
89
89
|
prefab, io = captured_logger
|
90
|
-
prefab.log.log_internal(::Logger::WARN, 'test message', 'test.path')
|
90
|
+
prefab.log.log_internal(::Logger::WARN, 'test message', 'cloud.prefab.client.test.path')
|
91
91
|
assert_logged io, 'WARN', "cloud.prefab.client.test.path", "test message"
|
92
92
|
end
|
93
93
|
|
94
94
|
def test_log_internal_unknown
|
95
95
|
prefab, io = captured_logger
|
96
|
-
prefab.log.log_internal(::Logger::UNKNOWN, 'test message', 'test.path')
|
96
|
+
prefab.log.log_internal(::Logger::UNKNOWN, 'test message', 'cloud.prefab.client.test.path')
|
97
97
|
assert_logged io, 'ANY', "cloud.prefab.client.test.path", "test message"
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_log_internal_silencing
|
101
101
|
prefab, io = captured_logger
|
102
102
|
prefab.log.silence do
|
103
|
-
prefab.log.log_internal(::Logger::WARN, 'should not log', 'test.path')
|
103
|
+
prefab.log.log_internal(::Logger::WARN, 'should not log', 'cloud.prefab.client.test.path')
|
104
104
|
end
|
105
|
-
prefab.log.log_internal(::Logger::WARN, 'should log', 'test.path')
|
105
|
+
prefab.log.log_internal(::Logger::WARN, 'should log', 'cloud.prefab.client.test.path')
|
106
106
|
assert_logged io, 'WARN', "cloud.prefab.client.test.path", "should log"
|
107
107
|
refute_logged io, 'should not log'
|
108
108
|
end
|
@@ -457,7 +457,7 @@ class TestLogger < Minitest::Test
|
|
457
457
|
def test_structured_internal_logging
|
458
458
|
prefab, io = captured_logger
|
459
459
|
|
460
|
-
prefab.log.log_internal(::Logger::WARN, 'test', 'test.path', user: "michael")
|
460
|
+
prefab.log.log_internal(::Logger::WARN, 'test', 'cloud.prefab.client.test.path', user: "michael")
|
461
461
|
|
462
462
|
assert_logged io, 'WARN', 'cloud.prefab.client.test.path', "test user=michael"
|
463
463
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prefab-cloud-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dwyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: activesupport
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '4'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '4'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: benchmark-ips
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +221,9 @@ files:
|
|
207
221
|
- lib/prefab/context_shape.rb
|
208
222
|
- lib/prefab/context_shape_aggregator.rb
|
209
223
|
- lib/prefab/criteria_evaluator.rb
|
224
|
+
- lib/prefab/encryption.rb
|
210
225
|
- lib/prefab/error.rb
|
226
|
+
- lib/prefab/errors/env_var_parse_error.rb
|
211
227
|
- lib/prefab/errors/initialization_timeout_error.rb
|
212
228
|
- lib/prefab/errors/invalid_api_key_error.rb
|
213
229
|
- lib/prefab/errors/missing_default_error.rb
|
@@ -220,6 +236,7 @@ files:
|
|
220
236
|
- lib/prefab/internal_logger.rb
|
221
237
|
- lib/prefab/local_config_parser.rb
|
222
238
|
- lib/prefab/log_path_aggregator.rb
|
239
|
+
- lib/prefab/log_subscribers/action_controller_subscriber.rb
|
223
240
|
- lib/prefab/logger_client.rb
|
224
241
|
- lib/prefab/murmer3.rb
|
225
242
|
- lib/prefab/options.rb
|
@@ -228,6 +245,7 @@ files:
|
|
228
245
|
- lib/prefab/rate_limit_cache.rb
|
229
246
|
- lib/prefab/resolved_config_presenter.rb
|
230
247
|
- lib/prefab/sse_logger.rb
|
248
|
+
- lib/prefab/static_logger.rb
|
231
249
|
- lib/prefab/time_helpers.rb
|
232
250
|
- lib/prefab/weighted_value_resolver.rb
|
233
251
|
- lib/prefab/yaml_config_parser.rb
|
@@ -241,6 +259,7 @@ files:
|
|
241
259
|
- test/support/mock_base_client.rb
|
242
260
|
- test/support/mock_config_client.rb
|
243
261
|
- test/support/mock_config_loader.rb
|
262
|
+
- test/test_action_controller.rb
|
244
263
|
- test/test_client.rb
|
245
264
|
- test/test_config_client.rb
|
246
265
|
- test/test_config_loader.rb
|
@@ -251,6 +270,7 @@ files:
|
|
251
270
|
- test/test_context_shape.rb
|
252
271
|
- test/test_context_shape_aggregator.rb
|
253
272
|
- test/test_criteria_evaluator.rb
|
273
|
+
- test/test_encryption.rb
|
254
274
|
- test/test_evaluation_summary_aggregator.rb
|
255
275
|
- test/test_example_contexts_aggregator.rb
|
256
276
|
- test/test_exponential_backoff.rb
|