@@ -217,6 +217,77 @@ func TestNewGSReplicaFromConfig(t *testing.T) {
217217 }
218218}
219219
220+ // TestNewReplicaFromConfig_AgeEncryption verifies that age encryption configuration is rejected.
221+ // Age encryption is currently non-functional and would silently write plaintext data.
222+ // See: https://github.com/benbjohnson/litestream/issues/790
223+ func TestNewReplicaFromConfig_AgeEncryption (t * testing.T ) {
224+ t .Run ("RejectIdentities" , func (t * testing.T ) {
225+ config := & main.ReplicaConfig {
226+ URL : "s3://foo/bar" ,
227+ }
228+ config .Age .Identities = []string {"AGE-SECRET-KEY-1EXAMPLE" }
229+
230+ _ , err := main .NewReplicaFromConfig (config , nil )
231+ if err == nil {
232+ t .Fatal ("expected error when age identities are configured" )
233+ }
234+ if ! strings .Contains (err .Error (), "age encryption is not currently supported" ) {
235+ t .Errorf ("expected age encryption error, got: %v" , err )
236+ }
237+ if ! strings .Contains (err .Error (), "revert back to Litestream v0.3.x" ) {
238+ t .Errorf ("expected error to reference v0.3.x, got: %v" , err )
239+ }
240+ })
241+
242+ t .Run ("RejectRecipients" , func (t * testing.T ) {
243+ config := & main.ReplicaConfig {
244+ URL : "s3://foo/bar" ,
245+ }
246+ config .Age .Recipients = []string {"age1example" }
247+
248+ _ , err := main .NewReplicaFromConfig (config , nil )
249+ if err == nil {
250+ t .Fatal ("expected error when age recipients are configured" )
251+ }
252+ if ! strings .Contains (err .Error (), "age encryption is not currently supported" ) {
253+ t .Errorf ("expected age encryption error, got: %v" , err )
254+ }
255+ if ! strings .Contains (err .Error (), "revert back to Litestream v0.3.x" ) {
256+ t .Errorf ("expected error to reference v0.3.x, got: %v" , err )
257+ }
258+ })
259+
260+ t .Run ("RejectBoth" , func (t * testing.T ) {
261+ config := & main.ReplicaConfig {
262+ URL : "s3://foo/bar" ,
263+ }
264+ config .Age .Identities = []string {"AGE-SECRET-KEY-1EXAMPLE" }
265+ config .Age .Recipients = []string {"age1example" }
266+
267+ _ , err := main .NewReplicaFromConfig (config , nil )
268+ if err == nil {
269+ t .Fatal ("expected error when both age identities and recipients are configured" )
270+ }
271+ if ! strings .Contains (err .Error (), "age encryption is not currently supported" ) {
272+ t .Errorf ("expected age encryption error, got: %v" , err )
273+ }
274+ if ! strings .Contains (err .Error (), "revert back to Litestream v0.3.x" ) {
275+ t .Errorf ("expected error to reference v0.3.x, got: %v" , err )
276+ }
277+ })
278+
279+ t .Run ("AllowEmpty" , func (t * testing.T ) {
280+ config := & main.ReplicaConfig {
281+ URL : "s3://foo/bar" ,
282+ }
283+
284+ _ , err := main .NewReplicaFromConfig (config , nil )
285+ if err != nil {
286+ t .Fatalf ("unexpected error when age configuration is not present: %v" , err )
287+ }
288+ })
289+ }
290+
220291// TestConfig_Validate_SnapshotIntervals tests validation of snapshot intervals
221292func TestConfig_Validate_SnapshotIntervals (t * testing.T ) {
222293 t .Run ("ValidInterval" , func (t * testing.T ) {
0 commit comments