imap-backup 6.0.0.rc2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imap-backup.gemspec +5 -1
- data/lib/cli_coverage.rb +11 -11
- data/lib/email/provider/base.rb +2 -0
- data/lib/email/provider/unknown.rb +2 -0
- data/lib/email/provider.rb +2 -0
- data/lib/imap/backup/account/connection/backup_folders.rb +27 -0
- data/lib/imap/backup/account/connection/client_factory.rb +54 -0
- data/lib/imap/backup/account/connection/folder_names.rb +26 -0
- data/lib/imap/backup/account/connection.rb +11 -95
- data/lib/imap/backup/account/folder.rb +9 -6
- data/lib/imap/backup/account.rb +3 -5
- data/lib/imap/backup/cli/backup.rb +1 -3
- data/lib/imap/backup/cli/helpers.rb +24 -22
- data/lib/imap/backup/cli/local.rb +20 -13
- data/lib/imap/backup/cli/migrate.rb +4 -10
- data/lib/imap/backup/cli/restore.rb +8 -7
- data/lib/imap/backup/cli/setup.rb +10 -8
- data/lib/imap/backup/cli/stats.rb +78 -0
- data/lib/imap/backup/cli/status.rb +2 -2
- data/lib/imap/backup/cli/utils.rb +4 -6
- data/lib/imap/backup/cli.rb +24 -3
- data/lib/imap/backup/configuration.rb +9 -11
- data/lib/imap/backup/downloader.rb +48 -30
- data/lib/imap/backup/migrator.rb +5 -5
- data/lib/imap/backup/sanitizer.rb +3 -2
- data/lib/imap/backup/serializer/appender.rb +49 -0
- data/lib/imap/backup/serializer/message_enumerator.rb +29 -0
- data/lib/imap/backup/serializer/unused_name_finder.rb +27 -0
- data/lib/imap/backup/serializer.rb +24 -78
- data/lib/imap/backup/setup/account/header.rb +75 -0
- data/lib/imap/backup/setup/account.rb +14 -91
- data/lib/imap/backup/setup/asker.rb +4 -15
- data/lib/imap/backup/setup/backup_path.rb +41 -0
- data/lib/imap/backup/setup/email.rb +45 -0
- data/lib/imap/backup/setup/folder_chooser.rb +3 -3
- data/lib/imap/backup/setup/helpers.rb +1 -1
- data/lib/imap/backup/setup.rb +5 -4
- data/lib/imap/backup/thunderbird/mailbox_exporter.rb +39 -20
- data/lib/imap/backup/uploader.rb +46 -8
- data/lib/imap/backup/utils.rb +1 -1
- data/lib/imap/backup/version.rb +1 -1
- data/lib/imap/backup.rb +0 -1
- metadata +31 -134
- data/spec/features/backup_spec.rb +0 -100
- data/spec/features/configuration/minimal_configuration.rb +0 -15
- data/spec/features/configuration/missing_configuration.rb +0 -14
- data/spec/features/folders_spec.rb +0 -36
- data/spec/features/helper.rb +0 -2
- data/spec/features/local/list_accounts_spec.rb +0 -12
- data/spec/features/local/list_emails_spec.rb +0 -21
- data/spec/features/local/list_folders_spec.rb +0 -21
- data/spec/features/local/show_an_email_spec.rb +0 -34
- data/spec/features/migrate_spec.rb +0 -35
- data/spec/features/remote/list_account_folders_spec.rb +0 -16
- data/spec/features/restore_spec.rb +0 -162
- data/spec/features/status_spec.rb +0 -43
- data/spec/features/support/aruba.rb +0 -78
- data/spec/features/support/backup_directory.rb +0 -43
- data/spec/features/support/email_server.rb +0 -110
- data/spec/features/support/shared/connection_context.rb +0 -14
- data/spec/features/support/shared/message_fixtures.rb +0 -16
- data/spec/fixtures/connection.yml +0 -7
- data/spec/spec_helper.rb +0 -15
- data/spec/support/fixtures.rb +0 -11
- data/spec/support/higline_test_helpers.rb +0 -8
- data/spec/support/silence_logging.rb +0 -7
- data/spec/unit/email/mboxrd/message_spec.rb +0 -177
- data/spec/unit/email/provider/apple_mail_spec.rb +0 -7
- data/spec/unit/email/provider/base_spec.rb +0 -11
- data/spec/unit/email/provider/fastmail_spec.rb +0 -7
- data/spec/unit/email/provider/gmail_spec.rb +0 -7
- data/spec/unit/email/provider_spec.rb +0 -27
- data/spec/unit/imap/backup/account/connection_spec.rb +0 -433
- data/spec/unit/imap/backup/account/folder_spec.rb +0 -261
- data/spec/unit/imap/backup/account_spec.rb +0 -246
- data/spec/unit/imap/backup/cli/accounts_spec.rb +0 -58
- data/spec/unit/imap/backup/cli/backup_spec.rb +0 -19
- data/spec/unit/imap/backup/cli/folders_spec.rb +0 -39
- data/spec/unit/imap/backup/cli/helpers_spec.rb +0 -87
- data/spec/unit/imap/backup/cli/local_spec.rb +0 -100
- data/spec/unit/imap/backup/cli/migrate_spec.rb +0 -80
- data/spec/unit/imap/backup/cli/restore_spec.rb +0 -67
- data/spec/unit/imap/backup/cli/setup_spec.rb +0 -17
- data/spec/unit/imap/backup/cli/utils_spec.rb +0 -125
- data/spec/unit/imap/backup/cli_spec.rb +0 -93
- data/spec/unit/imap/backup/client/apple_mail_spec.rb +0 -9
- data/spec/unit/imap/backup/client/default_spec.rb +0 -22
- data/spec/unit/imap/backup/configuration_spec.rb +0 -238
- data/spec/unit/imap/backup/downloader_spec.rb +0 -96
- data/spec/unit/imap/backup/logger_spec.rb +0 -48
- data/spec/unit/imap/backup/migrator_spec.rb +0 -58
- data/spec/unit/imap/backup/sanitizer_spec.rb +0 -42
- data/spec/unit/imap/backup/serializer/directory_spec.rb +0 -37
- data/spec/unit/imap/backup/serializer/imap_spec.rb +0 -218
- data/spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb +0 -45
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +0 -101
- data/spec/unit/imap/backup/serializer_spec.rb +0 -296
- data/spec/unit/imap/backup/setup/account_spec.rb +0 -461
- data/spec/unit/imap/backup/setup/asker_spec.rb +0 -137
- data/spec/unit/imap/backup/setup/connection_tester_spec.rb +0 -51
- data/spec/unit/imap/backup/setup/folder_chooser_spec.rb +0 -146
- data/spec/unit/imap/backup/setup/helpers_spec.rb +0 -15
- data/spec/unit/imap/backup/setup_spec.rb +0 -301
- data/spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb +0 -116
- data/spec/unit/imap/backup/uploader_spec.rb +0 -54
- data/spec/unit/imap/backup/utils_spec.rb +0 -92
- data/spec/unit/retry_on_error_spec.rb +0 -34
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: Backup GMail, or any other IMAP email service, to disk.
|
168
182
|
email:
|
169
183
|
- joe.g.yates@gmail.com
|
@@ -190,6 +204,9 @@ files:
|
|
190
204
|
- lib/imap/backup.rb
|
191
205
|
- lib/imap/backup/account.rb
|
192
206
|
- lib/imap/backup/account/connection.rb
|
207
|
+
- lib/imap/backup/account/connection/backup_folders.rb
|
208
|
+
- lib/imap/backup/account/connection/client_factory.rb
|
209
|
+
- lib/imap/backup/account/connection/folder_names.rb
|
193
210
|
- lib/imap/backup/account/folder.rb
|
194
211
|
- lib/imap/backup/cli.rb
|
195
212
|
- lib/imap/backup/cli/accounts.rb
|
@@ -201,6 +218,7 @@ files:
|
|
201
218
|
- lib/imap/backup/cli/remote.rb
|
202
219
|
- lib/imap/backup/cli/restore.rb
|
203
220
|
- lib/imap/backup/cli/setup.rb
|
221
|
+
- lib/imap/backup/cli/stats.rb
|
204
222
|
- lib/imap/backup/cli/status.rb
|
205
223
|
- lib/imap/backup/cli/utils.rb
|
206
224
|
- lib/imap/backup/client/apple_mail.rb
|
@@ -211,14 +229,20 @@ files:
|
|
211
229
|
- lib/imap/backup/migrator.rb
|
212
230
|
- lib/imap/backup/sanitizer.rb
|
213
231
|
- lib/imap/backup/serializer.rb
|
232
|
+
- lib/imap/backup/serializer/appender.rb
|
214
233
|
- lib/imap/backup/serializer/directory.rb
|
215
234
|
- lib/imap/backup/serializer/imap.rb
|
216
235
|
- lib/imap/backup/serializer/mbox.rb
|
217
236
|
- lib/imap/backup/serializer/mbox_enumerator.rb
|
237
|
+
- lib/imap/backup/serializer/message_enumerator.rb
|
238
|
+
- lib/imap/backup/serializer/unused_name_finder.rb
|
218
239
|
- lib/imap/backup/setup.rb
|
219
240
|
- lib/imap/backup/setup/account.rb
|
241
|
+
- lib/imap/backup/setup/account/header.rb
|
220
242
|
- lib/imap/backup/setup/asker.rb
|
243
|
+
- lib/imap/backup/setup/backup_path.rb
|
221
244
|
- lib/imap/backup/setup/connection_tester.rb
|
245
|
+
- lib/imap/backup/setup/email.rb
|
222
246
|
- lib/imap/backup/setup/folder_chooser.rb
|
223
247
|
- lib/imap/backup/setup/helpers.rb
|
224
248
|
- lib/imap/backup/thunderbird/mailbox_exporter.rb
|
@@ -226,74 +250,11 @@ files:
|
|
226
250
|
- lib/imap/backup/utils.rb
|
227
251
|
- lib/imap/backup/version.rb
|
228
252
|
- lib/retry_on_error.rb
|
229
|
-
- spec/features/backup_spec.rb
|
230
|
-
- spec/features/configuration/minimal_configuration.rb
|
231
|
-
- spec/features/configuration/missing_configuration.rb
|
232
|
-
- spec/features/folders_spec.rb
|
233
|
-
- spec/features/helper.rb
|
234
|
-
- spec/features/local/list_accounts_spec.rb
|
235
|
-
- spec/features/local/list_emails_spec.rb
|
236
|
-
- spec/features/local/list_folders_spec.rb
|
237
|
-
- spec/features/local/show_an_email_spec.rb
|
238
|
-
- spec/features/migrate_spec.rb
|
239
|
-
- spec/features/remote/list_account_folders_spec.rb
|
240
|
-
- spec/features/restore_spec.rb
|
241
|
-
- spec/features/status_spec.rb
|
242
|
-
- spec/features/support/aruba.rb
|
243
|
-
- spec/features/support/backup_directory.rb
|
244
|
-
- spec/features/support/email_server.rb
|
245
|
-
- spec/features/support/shared/connection_context.rb
|
246
|
-
- spec/features/support/shared/message_fixtures.rb
|
247
|
-
- spec/fixtures/connection.yml
|
248
|
-
- spec/spec_helper.rb
|
249
|
-
- spec/support/fixtures.rb
|
250
|
-
- spec/support/higline_test_helpers.rb
|
251
|
-
- spec/support/silence_logging.rb
|
252
|
-
- spec/unit/email/mboxrd/message_spec.rb
|
253
|
-
- spec/unit/email/provider/apple_mail_spec.rb
|
254
|
-
- spec/unit/email/provider/base_spec.rb
|
255
|
-
- spec/unit/email/provider/fastmail_spec.rb
|
256
|
-
- spec/unit/email/provider/gmail_spec.rb
|
257
|
-
- spec/unit/email/provider_spec.rb
|
258
|
-
- spec/unit/imap/backup/account/connection_spec.rb
|
259
|
-
- spec/unit/imap/backup/account/folder_spec.rb
|
260
|
-
- spec/unit/imap/backup/account_spec.rb
|
261
|
-
- spec/unit/imap/backup/cli/accounts_spec.rb
|
262
|
-
- spec/unit/imap/backup/cli/backup_spec.rb
|
263
|
-
- spec/unit/imap/backup/cli/folders_spec.rb
|
264
|
-
- spec/unit/imap/backup/cli/helpers_spec.rb
|
265
|
-
- spec/unit/imap/backup/cli/local_spec.rb
|
266
|
-
- spec/unit/imap/backup/cli/migrate_spec.rb
|
267
|
-
- spec/unit/imap/backup/cli/restore_spec.rb
|
268
|
-
- spec/unit/imap/backup/cli/setup_spec.rb
|
269
|
-
- spec/unit/imap/backup/cli/utils_spec.rb
|
270
|
-
- spec/unit/imap/backup/cli_spec.rb
|
271
|
-
- spec/unit/imap/backup/client/apple_mail_spec.rb
|
272
|
-
- spec/unit/imap/backup/client/default_spec.rb
|
273
|
-
- spec/unit/imap/backup/configuration_spec.rb
|
274
|
-
- spec/unit/imap/backup/downloader_spec.rb
|
275
|
-
- spec/unit/imap/backup/logger_spec.rb
|
276
|
-
- spec/unit/imap/backup/migrator_spec.rb
|
277
|
-
- spec/unit/imap/backup/sanitizer_spec.rb
|
278
|
-
- spec/unit/imap/backup/serializer/directory_spec.rb
|
279
|
-
- spec/unit/imap/backup/serializer/imap_spec.rb
|
280
|
-
- spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
|
281
|
-
- spec/unit/imap/backup/serializer/mbox_spec.rb
|
282
|
-
- spec/unit/imap/backup/serializer_spec.rb
|
283
|
-
- spec/unit/imap/backup/setup/account_spec.rb
|
284
|
-
- spec/unit/imap/backup/setup/asker_spec.rb
|
285
|
-
- spec/unit/imap/backup/setup/connection_tester_spec.rb
|
286
|
-
- spec/unit/imap/backup/setup/folder_chooser_spec.rb
|
287
|
-
- spec/unit/imap/backup/setup/helpers_spec.rb
|
288
|
-
- spec/unit/imap/backup/setup_spec.rb
|
289
|
-
- spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb
|
290
|
-
- spec/unit/imap/backup/uploader_spec.rb
|
291
|
-
- spec/unit/imap/backup/utils_spec.rb
|
292
|
-
- spec/unit/retry_on_error_spec.rb
|
293
253
|
homepage: https://github.com/joeyates/imap-backup
|
294
254
|
licenses:
|
295
255
|
- MIT
|
296
|
-
metadata:
|
256
|
+
metadata:
|
257
|
+
rubygems_mfa_required: 'true'
|
297
258
|
post_install_message:
|
298
259
|
rdoc_options: []
|
299
260
|
require_paths:
|
@@ -305,76 +266,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
266
|
version: '2.5'
|
306
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
268
|
requirements:
|
308
|
-
- - "
|
269
|
+
- - ">="
|
309
270
|
- !ruby/object:Gem::Version
|
310
|
-
version:
|
271
|
+
version: '0'
|
311
272
|
requirements: []
|
312
273
|
rubygems_version: 3.1.6
|
313
274
|
signing_key:
|
314
275
|
specification_version: 4
|
315
276
|
summary: Backup GMail (or other IMAP) accounts to disk
|
316
|
-
test_files:
|
317
|
-
- spec/spec_helper.rb
|
318
|
-
- spec/unit/imap/backup/account_spec.rb
|
319
|
-
- spec/unit/imap/backup/serializer/imap_spec.rb
|
320
|
-
- spec/unit/imap/backup/serializer/directory_spec.rb
|
321
|
-
- spec/unit/imap/backup/serializer/mbox_spec.rb
|
322
|
-
- spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
|
323
|
-
- spec/unit/imap/backup/cli_spec.rb
|
324
|
-
- spec/unit/imap/backup/setup_spec.rb
|
325
|
-
- spec/unit/imap/backup/logger_spec.rb
|
326
|
-
- spec/unit/imap/backup/configuration_spec.rb
|
327
|
-
- spec/unit/imap/backup/setup/account_spec.rb
|
328
|
-
- spec/unit/imap/backup/setup/connection_tester_spec.rb
|
329
|
-
- spec/unit/imap/backup/setup/asker_spec.rb
|
330
|
-
- spec/unit/imap/backup/setup/helpers_spec.rb
|
331
|
-
- spec/unit/imap/backup/setup/folder_chooser_spec.rb
|
332
|
-
- spec/unit/imap/backup/cli/folders_spec.rb
|
333
|
-
- spec/unit/imap/backup/cli/setup_spec.rb
|
334
|
-
- spec/unit/imap/backup/cli/backup_spec.rb
|
335
|
-
- spec/unit/imap/backup/cli/restore_spec.rb
|
336
|
-
- spec/unit/imap/backup/cli/helpers_spec.rb
|
337
|
-
- spec/unit/imap/backup/cli/accounts_spec.rb
|
338
|
-
- spec/unit/imap/backup/cli/migrate_spec.rb
|
339
|
-
- spec/unit/imap/backup/cli/utils_spec.rb
|
340
|
-
- spec/unit/imap/backup/cli/local_spec.rb
|
341
|
-
- spec/unit/imap/backup/downloader_spec.rb
|
342
|
-
- spec/unit/imap/backup/migrator_spec.rb
|
343
|
-
- spec/unit/imap/backup/uploader_spec.rb
|
344
|
-
- spec/unit/imap/backup/account/folder_spec.rb
|
345
|
-
- spec/unit/imap/backup/account/connection_spec.rb
|
346
|
-
- spec/unit/imap/backup/utils_spec.rb
|
347
|
-
- spec/unit/imap/backup/serializer_spec.rb
|
348
|
-
- spec/unit/imap/backup/client/default_spec.rb
|
349
|
-
- spec/unit/imap/backup/client/apple_mail_spec.rb
|
350
|
-
- spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb
|
351
|
-
- spec/unit/imap/backup/sanitizer_spec.rb
|
352
|
-
- spec/unit/retry_on_error_spec.rb
|
353
|
-
- spec/unit/email/mboxrd/message_spec.rb
|
354
|
-
- spec/unit/email/provider/gmail_spec.rb
|
355
|
-
- spec/unit/email/provider/apple_mail_spec.rb
|
356
|
-
- spec/unit/email/provider/fastmail_spec.rb
|
357
|
-
- spec/unit/email/provider/base_spec.rb
|
358
|
-
- spec/unit/email/provider_spec.rb
|
359
|
-
- spec/features/folders_spec.rb
|
360
|
-
- spec/features/configuration/missing_configuration.rb
|
361
|
-
- spec/features/configuration/minimal_configuration.rb
|
362
|
-
- spec/features/backup_spec.rb
|
363
|
-
- spec/features/helper.rb
|
364
|
-
- spec/features/restore_spec.rb
|
365
|
-
- spec/features/local/list_emails_spec.rb
|
366
|
-
- spec/features/local/list_accounts_spec.rb
|
367
|
-
- spec/features/local/show_an_email_spec.rb
|
368
|
-
- spec/features/local/list_folders_spec.rb
|
369
|
-
- spec/features/status_spec.rb
|
370
|
-
- spec/features/support/email_server.rb
|
371
|
-
- spec/features/support/backup_directory.rb
|
372
|
-
- spec/features/support/aruba.rb
|
373
|
-
- spec/features/support/shared/connection_context.rb
|
374
|
-
- spec/features/support/shared/message_fixtures.rb
|
375
|
-
- spec/features/migrate_spec.rb
|
376
|
-
- spec/features/remote/list_account_folders_spec.rb
|
377
|
-
- spec/support/fixtures.rb
|
378
|
-
- spec/support/silence_logging.rb
|
379
|
-
- spec/support/higline_test_helpers.rb
|
380
|
-
- spec/fixtures/connection.yml
|
277
|
+
test_files: []
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "backup", type: :aruba, docker: true do
|
4
|
-
include_context "imap-backup connection"
|
5
|
-
include_context "message-fixtures"
|
6
|
-
|
7
|
-
let(:local_backup_path) { File.expand_path("~/backup") }
|
8
|
-
let(:backup_folders) { [{name: folder}] }
|
9
|
-
let(:folder) { "my-stuff" }
|
10
|
-
let(:messages_as_mbox) do
|
11
|
-
message_as_mbox_entry(msg1) + message_as_mbox_entry(msg2)
|
12
|
-
end
|
13
|
-
|
14
|
-
let!(:pre) {}
|
15
|
-
let!(:setup) do
|
16
|
-
server_create_folder folder
|
17
|
-
send_email folder, msg1
|
18
|
-
send_email folder, msg2
|
19
|
-
create_config(accounts: [account.to_h])
|
20
|
-
|
21
|
-
run_command_and_stop("imap-backup backup")
|
22
|
-
end
|
23
|
-
|
24
|
-
after do
|
25
|
-
server_delete_folder folder
|
26
|
-
end
|
27
|
-
|
28
|
-
it "downloads messages" do
|
29
|
-
expect(mbox_content(folder)).to eq(messages_as_mbox)
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "IMAP metadata" do
|
33
|
-
let(:imap_metadata) { imap_parsed(folder) }
|
34
|
-
let(:folder_uids) { server_uids(folder) }
|
35
|
-
|
36
|
-
it "saves IMAP metadata in a JSON file" do
|
37
|
-
expect { imap_metadata }.to_not raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it "saves a file version" do
|
41
|
-
expect(imap_metadata[:version].to_s).to match(/^[0-9.]$/)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "records IMAP ids" do
|
45
|
-
expect(imap_metadata[:uids]).to eq(folder_uids)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "records uid_validity" do
|
49
|
-
expect(imap_metadata[:uid_validity]).to eq(server_uid_validity(folder))
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when uid_validity does not match" do
|
53
|
-
let(:new_name) { "NEWNAME" }
|
54
|
-
let(:original_folder_uid_validity) { server_uid_validity(folder) }
|
55
|
-
let!(:pre) do
|
56
|
-
server_create_folder folder
|
57
|
-
send_email folder, msg3
|
58
|
-
original_folder_uid_validity
|
59
|
-
connection.run_backup
|
60
|
-
connection.disconnect
|
61
|
-
server_rename_folder folder, new_name
|
62
|
-
end
|
63
|
-
let(:renamed_folder) { "#{folder}-#{original_folder_uid_validity}" }
|
64
|
-
|
65
|
-
after do
|
66
|
-
server_delete_folder new_name
|
67
|
-
end
|
68
|
-
|
69
|
-
it "renames the old backup" do
|
70
|
-
expect(mbox_content(renamed_folder)).to eq(message_as_mbox_entry(msg3))
|
71
|
-
end
|
72
|
-
|
73
|
-
it "renames the old metadata file" do
|
74
|
-
expect(imap_parsed(renamed_folder)).to be_a Hash
|
75
|
-
end
|
76
|
-
|
77
|
-
it "downloads messages" do
|
78
|
-
expect(mbox_content(folder)).to eq(messages_as_mbox)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "creates a metadata file" do
|
82
|
-
expect(imap_parsed(folder)).to be_a Hash
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when a renamed local backup exists" do
|
86
|
-
let!(:pre) do
|
87
|
-
super()
|
88
|
-
create_directory local_backup_path
|
89
|
-
File.write(imap_path(renamed_folder), "existing imap")
|
90
|
-
File.write(mbox_path(renamed_folder), "existing mbox")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "moves the old backup to a uniquely named directory" do
|
94
|
-
renamed = "#{folder}-#{original_folder_uid_validity}-1"
|
95
|
-
expect(mbox_content(renamed)).to eq(message_as_mbox_entry(msg3))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Running commands", type: :aruba do
|
4
|
-
before do
|
5
|
-
create_config(accounts: [])
|
6
|
-
run_command("imap-backup local accounts")
|
7
|
-
last_command_started.stop
|
8
|
-
end
|
9
|
-
|
10
|
-
context "when no accounts are configured" do
|
11
|
-
it "succeeds" do
|
12
|
-
expect(last_command_started).to have_exit_status(0)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Running commands", type: :aruba do
|
4
|
-
before do
|
5
|
-
run_command("imap-backup")
|
6
|
-
last_command_started.stop
|
7
|
-
end
|
8
|
-
|
9
|
-
context "when the configuration file is missing" do
|
10
|
-
it "fails" do
|
11
|
-
expect(last_command_started).not_to have_exit_status(0)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
require "imap/backup/cli/folders"
|
3
|
-
|
4
|
-
RSpec.describe "folders", type: :feature, docker: true do
|
5
|
-
include_context "imap-backup connection"
|
6
|
-
|
7
|
-
let(:options) do
|
8
|
-
{accounts: "address@example.org"}
|
9
|
-
end
|
10
|
-
let(:folder) { "my-stuff" }
|
11
|
-
let(:output) { StringIO.new }
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(Imap::Backup::CLI::Accounts).to receive(:new) { [account] }
|
15
|
-
server_create_folder folder
|
16
|
-
end
|
17
|
-
|
18
|
-
around do |example|
|
19
|
-
stdout = $stdout
|
20
|
-
$stdout = output
|
21
|
-
example.run
|
22
|
-
$stdout = stdout
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
FileUtils.rm_rf local_backup_path
|
27
|
-
server_delete_folder folder
|
28
|
-
connection.disconnect
|
29
|
-
end
|
30
|
-
|
31
|
-
it "lists account folders" do
|
32
|
-
Imap::Backup::CLI::Folders.new(options).run
|
33
|
-
|
34
|
-
expect(output.string).to match(/^\tmy-stuff\n/)
|
35
|
-
end
|
36
|
-
end
|
data/spec/features/helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Listing accounts", type: :aruba do
|
4
|
-
before do
|
5
|
-
create_config(accounts: [{"username": "me@example.com"}])
|
6
|
-
run_command_and_stop("imap-backup local accounts")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "lists accounts" do
|
10
|
-
expect(last_command_started).to have_output("me@example.com")
|
11
|
-
end
|
12
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Listing emails", type: :aruba do
|
4
|
-
let(:email) { "me@example.com" }
|
5
|
-
let(:account) do
|
6
|
-
{
|
7
|
-
username: email,
|
8
|
-
local_path: File.join(config_path, email.gsub("@", "_"))
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
create_config(accounts: [account])
|
14
|
-
store_email(email: email, folder: "my_folder", subject: "Ciao")
|
15
|
-
run_command_and_stop("imap-backup local list #{email} my_folder")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "lists emails" do
|
19
|
-
expect(last_command_started).to have_output(/1: Ciao/)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Listing account folders", type: :aruba do
|
4
|
-
let(:email) { "me@example.com" }
|
5
|
-
let(:account) do
|
6
|
-
{
|
7
|
-
username: email,
|
8
|
-
local_path: File.join(config_path, email.gsub("@", "_"))
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
create_config(accounts: [account])
|
14
|
-
store_email(email: email, folder: "my_folder", body: "Hi")
|
15
|
-
run_command_and_stop("imap-backup local folders #{email}")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "lists folders that have been backed up" do
|
19
|
-
expect(last_command_started).to have_output(%q("my_folder"))
|
20
|
-
end
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Show an email", type: :aruba do
|
4
|
-
let(:email) { "me@example.com" }
|
5
|
-
let(:account) do
|
6
|
-
{
|
7
|
-
username: email,
|
8
|
-
local_path: File.join(config_path, email.gsub("@", "_"))
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
create_config(accounts: [account])
|
14
|
-
store_email(
|
15
|
-
email: email,
|
16
|
-
folder: "my_folder",
|
17
|
-
uid: 99,
|
18
|
-
from: "me@example.com",
|
19
|
-
subject: "Hello",
|
20
|
-
body: "How're things?"
|
21
|
-
)
|
22
|
-
run_command_and_stop("imap-backup local show #{email} my_folder 99")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "shows the email" do
|
26
|
-
expected = <<~BODY
|
27
|
-
From: me@example.com
|
28
|
-
Subject: Hello
|
29
|
-
|
30
|
-
How're things?
|
31
|
-
BODY
|
32
|
-
expect(last_command_started).to have_output(expected)
|
33
|
-
end
|
34
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Migration", type: :aruba, docker: true do
|
4
|
-
let(:email) { "me@example.com" }
|
5
|
-
let(:folder) { "my_folder" }
|
6
|
-
let(:source_account) do
|
7
|
-
{
|
8
|
-
username: email,
|
9
|
-
local_path: File.join(config_path, email.gsub("@", "_"))
|
10
|
-
}
|
11
|
-
end
|
12
|
-
let(:destination_account) { fixture("connection") }
|
13
|
-
|
14
|
-
before do
|
15
|
-
create_config(accounts: [source_account, destination_account])
|
16
|
-
store_email(email: email, folder: folder, subject: "Ciao")
|
17
|
-
run_command_and_stop("imap-backup migrate #{email} #{destination_account[:username]}")
|
18
|
-
end
|
19
|
-
|
20
|
-
after do
|
21
|
-
delete_emails(folder)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "copies email to the destination account" do
|
25
|
-
messages = server_messages(folder)
|
26
|
-
expected = <<~MESSAGE.gsub("\n", "\r\n")
|
27
|
-
From: sender@example.com
|
28
|
-
Subject: Ciao
|
29
|
-
|
30
|
-
body
|
31
|
-
|
32
|
-
MESSAGE
|
33
|
-
expect(messages[0]["BODY[]"]).to eq(expected)
|
34
|
-
end
|
35
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "List account folders", type: :aruba do
|
4
|
-
let(:account) do
|
5
|
-
fixture("connection")
|
6
|
-
end
|
7
|
-
|
8
|
-
before do
|
9
|
-
create_config(accounts: [account])
|
10
|
-
run_command_and_stop("imap-backup remote folders #{account[:username]}")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "lists folders" do
|
14
|
-
expect(last_command_started).to have_output(/"INBOX"/)
|
15
|
-
end
|
16
|
-
end
|