You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: activesupport/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,9 @@
1
+
* Raise when using key which can't respond to `#to_sym` in `EncryptedConfiguration`.
2
+
3
+
As is the case when trying to use an Integer or Float as a key, which is unsupported.
4
+
5
+
*zzak*
6
+
1
7
* Deprecate addition and since between two `Time` and `ActiveSupport::TimeWithZone`.
2
8
3
9
Previously adding time instances together such as `10.days.ago + 10.days.ago` or `10.days.ago.since(10.days.ago)` produced a nonsensical future date. This behavior is deprecated and will be removed in Rails 8.1.
Copy file name to clipboardExpand all lines: activesupport/test/encrypted_configuration_test.rb
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,42 @@ class EncryptedConfigurationTest < ActiveSupport::TestCase
93
93
end
94
94
end
95
95
96
+
test"raises helpful error when loading invalid content with unsupported keys"do
97
+
@credentials.write("42: value")
98
+
99
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key '42' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
100
+
@credentials.config
101
+
end
102
+
103
+
@credentials.write("42.0: value")
104
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key '42.0' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
105
+
@credentials.config
106
+
end
107
+
108
+
@credentials.write("Off: value")
109
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key 'false' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
110
+
@credentials.config
111
+
end
112
+
end
113
+
114
+
test"raises helpful error when validating invalid content with unsupported keys"do
115
+
@credentials.write("42: value")
116
+
117
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key '42' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
118
+
@credentials.validate!
119
+
end
120
+
121
+
@credentials.write("42.0: value")
122
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key '42.0' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
123
+
@credentials.validate!
124
+
end
125
+
126
+
@credentials.write("Off: value")
127
+
assert_raise(ActiveSupport::EncryptedConfiguration::InvalidKeyError,match: /Key 'false' is invalid, it must respond to '#to_sym' from configuration in '#{@credentials_config_path}'./)do
128
+
@credentials.validate!
129
+
end
130
+
end
131
+
96
132
test"raises key error when accessing config via bang method"do
0 commit comments