imap-backup 2.1.1 → 3.0.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/.rubocop.yml +5 -4
- data/.rubocop_todo.yml +29 -11
- data/.travis.yml +1 -1
- data/README.md +10 -13
- data/bin/imap-backup +5 -2
- data/docs/01-credentials-screen.png +0 -0
- data/docs/02-new-project.png +0 -0
- data/docs/03-initial-credentials-for-project.png +0 -0
- data/docs/04-credential-type-selection.png +0 -0
- data/docs/05-cant-create-without-consent-setup.png +0 -0
- data/docs/06-user-type-selection.png +0 -0
- data/docs/07-consent-screen-form.png +0 -0
- data/docs/08-app-scopes.png +0 -0
- data/docs/09-scope-selection.png +0 -0
- data/docs/10-updated-app-scopes.png +0 -0
- data/docs/11-test-users.png +0 -0
- data/docs/12-add-users.png +0 -0
- data/docs/13-create-oauth-client.png +0 -0
- data/docs/14-application-details.png +0 -0
- data/docs/16-initial-menu.png +0 -0
- data/docs/17-inputting-the-email-address.png +0 -0
- data/docs/18-choose-password.png +0 -0
- data/docs/19-supply-client-info.png +0 -0
- data/docs/20-choose-gmail-account.png +0 -0
- data/docs/21-accept-warnings.png +0 -0
- data/docs/22-grant-access.png +0 -0
- data/docs/24-confirm-choices.png +0 -0
- data/docs/25-success-code.png +0 -0
- data/docs/26-type-code-into-imap-backup.png +0 -0
- data/docs/27-success.png +0 -0
- data/docs/setting-up-gmail.md +166 -0
- data/imap-backup.gemspec +3 -9
- data/lib/email/mboxrd/message.rb +4 -3
- data/lib/email/provider.rb +3 -1
- data/lib/gmail/authenticator.rb +160 -0
- data/lib/google/auth/stores/in_memory_token_store.rb +9 -0
- data/lib/imap/backup.rb +2 -1
- data/lib/imap/backup/account/connection.rb +59 -34
- data/lib/imap/backup/account/folder.rb +10 -1
- data/lib/imap/backup/configuration/account.rb +9 -1
- data/lib/imap/backup/configuration/gmail_oauth2.rb +82 -0
- data/lib/imap/backup/configuration/setup.rb +4 -1
- data/lib/imap/backup/serializer/mbox.rb +4 -0
- data/lib/imap/backup/serializer/mbox_enumerator.rb +1 -1
- data/lib/imap/backup/serializer/mbox_store.rb +20 -4
- data/lib/imap/backup/uploader.rb +10 -2
- data/lib/imap/backup/version.rb +5 -4
- data/spec/features/backup_spec.rb +3 -3
- data/spec/features/helper.rb +1 -1
- data/spec/features/restore_spec.rb +75 -27
- data/spec/features/support/backup_directory.rb +2 -2
- data/spec/features/support/email_server.rb +1 -3
- data/spec/features/support/shared/message_fixtures.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fixtures.rb +1 -1
- data/spec/unit/email/mboxrd/message_spec.rb +2 -8
- data/spec/unit/email/provider_spec.rb +2 -2
- data/spec/unit/gmail/authenticator_spec.rb +138 -0
- data/spec/unit/google/auth/stores/in_memory_token_store_spec.rb +15 -0
- data/spec/unit/imap/backup/account/connection_spec.rb +157 -79
- data/spec/unit/imap/backup/account/folder_spec.rb +30 -20
- data/spec/unit/imap/backup/configuration/account_spec.rb +65 -46
- data/spec/unit/imap/backup/configuration/asker_spec.rb +20 -17
- data/spec/unit/imap/backup/configuration/connection_tester_spec.rb +6 -10
- data/spec/unit/imap/backup/configuration/folder_chooser_spec.rb +16 -10
- data/spec/unit/imap/backup/configuration/gmail_oauth2_spec.rb +84 -0
- data/spec/unit/imap/backup/configuration/list_spec.rb +6 -3
- data/spec/unit/imap/backup/configuration/setup_spec.rb +89 -54
- data/spec/unit/imap/backup/configuration/store_spec.rb +18 -16
- data/spec/unit/imap/backup/downloader_spec.rb +14 -14
- data/spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb +6 -1
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +62 -40
- data/spec/unit/imap/backup/serializer/mbox_store_spec.rb +94 -35
- data/spec/unit/imap/backup/uploader_spec.rb +23 -7
- data/spec/unit/imap/backup/utils_spec.rb +10 -9
- metadata +68 -9
@@ -2,7 +2,9 @@ describe Imap::Backup::Uploader do
|
|
2
2
|
subject { described_class.new(folder, serializer) }
|
3
3
|
|
4
4
|
let(:folder) do
|
5
|
-
instance_double(
|
5
|
+
instance_double(
|
6
|
+
Imap::Backup::Account::Folder, uids: [2, 3], append: 99, name: "foo"
|
7
|
+
)
|
6
8
|
end
|
7
9
|
let(:serializer) do
|
8
10
|
instance_double(
|
@@ -11,27 +13,41 @@ describe Imap::Backup::Uploader do
|
|
11
13
|
update_uid: nil
|
12
14
|
)
|
13
15
|
end
|
16
|
+
let(:missing_message) do
|
17
|
+
instance_double(Email::Mboxrd::Message, supplied_body: "missing message")
|
18
|
+
end
|
19
|
+
let(:existing_message) do
|
20
|
+
instance_double(Email::Mboxrd::Message, supplied_body: "existing message")
|
21
|
+
end
|
22
|
+
|
23
|
+
def message_enumerator
|
24
|
+
yield [1, missing_message]
|
25
|
+
end
|
14
26
|
|
15
27
|
describe "#run" do
|
16
28
|
before do
|
17
|
-
allow(serializer).to receive(:
|
18
|
-
allow(serializer).to receive(:load).with(2) { "existing message" }
|
19
|
-
subject.run
|
29
|
+
allow(serializer).to receive(:each_message).and_return(enum_for(:message_enumerator))
|
20
30
|
end
|
21
31
|
|
22
32
|
context "with messages that are missing" do
|
23
33
|
it "restores them" do
|
24
|
-
expect(folder).to
|
34
|
+
expect(folder).to receive(:append).with(missing_message)
|
35
|
+
|
36
|
+
subject.run
|
25
37
|
end
|
26
38
|
|
27
39
|
it "updates the local message id" do
|
28
|
-
expect(serializer).to
|
40
|
+
expect(serializer).to receive(:update_uid).with(1, 99)
|
41
|
+
|
42
|
+
subject.run
|
29
43
|
end
|
30
44
|
end
|
31
45
|
|
32
46
|
context "with messages that are present on server" do
|
33
47
|
it "does nothing" do
|
34
|
-
expect(folder).to_not
|
48
|
+
expect(folder).to_not receive(:append).with(existing_message)
|
49
|
+
|
50
|
+
subject.run
|
35
51
|
end
|
36
52
|
end
|
37
53
|
end
|
@@ -5,13 +5,14 @@ describe Imap::Backup::Utils do
|
|
5
5
|
let(:exists) { true }
|
6
6
|
|
7
7
|
before do
|
8
|
-
allow(File).to receive(:stat)
|
9
|
-
allow(File).to receive(:exist?).with(filename)
|
8
|
+
allow(File).to receive(:stat) { stat }
|
9
|
+
allow(File).to receive(:exist?).with(filename) { exists }
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".check_permissions" do
|
13
13
|
let(:requested) { 0o345 }
|
14
14
|
|
15
|
+
# rubocop:disable RSpec/EmptyExampleGroup
|
15
16
|
context "with existing files" do
|
16
17
|
[
|
17
18
|
[0o100, "less than the limit", true],
|
@@ -36,6 +37,7 @@ describe Imap::Backup::Utils do
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
40
|
+
# rubocop:enable RSpec/EmptyExampleGroup
|
39
41
|
|
40
42
|
context "with non-existent files" do
|
41
43
|
let(:exists) { false }
|
@@ -72,22 +74,21 @@ describe Imap::Backup::Utils do
|
|
72
74
|
end
|
73
75
|
|
74
76
|
it "does nothing if an empty path is supplied" do
|
75
|
-
|
77
|
+
expect(FileUtils).to_not receive(:mkdir_p)
|
76
78
|
|
77
|
-
|
79
|
+
described_class.make_folder("aaa", "", 0o222)
|
78
80
|
end
|
79
81
|
|
80
82
|
it "creates the path" do
|
81
|
-
|
83
|
+
expect(FileUtils).to receive(:mkdir_p).with("/base/path/new/folder")
|
82
84
|
|
83
|
-
|
85
|
+
described_class.make_folder("/base/path", "new/folder", 0o222)
|
84
86
|
end
|
85
87
|
|
86
88
|
it "sets permissions on the path" do
|
87
|
-
|
89
|
+
expect(FileUtils).to receive(:chmod).with(0o222, "/base/path/new/folder")
|
88
90
|
|
89
|
-
|
90
|
-
to have_received(:chmod).with(0o222, "/base/path/new/folder")
|
91
|
+
described_class.make_folder("/base/path/new", "folder", 0o222)
|
91
92
|
end
|
92
93
|
end
|
93
94
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.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:
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gmail_xoauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: googleauth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: highline
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,10 +170,38 @@ files:
|
|
142
170
|
- Rakefile
|
143
171
|
- bin/imap-backup
|
144
172
|
- docker-compose.yml
|
173
|
+
- docs/01-credentials-screen.png
|
174
|
+
- docs/02-new-project.png
|
175
|
+
- docs/03-initial-credentials-for-project.png
|
176
|
+
- docs/04-credential-type-selection.png
|
177
|
+
- docs/05-cant-create-without-consent-setup.png
|
178
|
+
- docs/06-user-type-selection.png
|
179
|
+
- docs/07-consent-screen-form.png
|
180
|
+
- docs/08-app-scopes.png
|
181
|
+
- docs/09-scope-selection.png
|
182
|
+
- docs/10-updated-app-scopes.png
|
183
|
+
- docs/11-test-users.png
|
184
|
+
- docs/12-add-users.png
|
185
|
+
- docs/13-create-oauth-client.png
|
186
|
+
- docs/14-application-details.png
|
187
|
+
- docs/16-initial-menu.png
|
188
|
+
- docs/17-inputting-the-email-address.png
|
189
|
+
- docs/18-choose-password.png
|
190
|
+
- docs/19-supply-client-info.png
|
191
|
+
- docs/20-choose-gmail-account.png
|
192
|
+
- docs/21-accept-warnings.png
|
193
|
+
- docs/22-grant-access.png
|
194
|
+
- docs/24-confirm-choices.png
|
195
|
+
- docs/25-success-code.png
|
196
|
+
- docs/26-type-code-into-imap-backup.png
|
197
|
+
- docs/27-success.png
|
145
198
|
- docs/docker-imap.md
|
199
|
+
- docs/setting-up-gmail.md
|
146
200
|
- imap-backup.gemspec
|
147
201
|
- lib/email/mboxrd/message.rb
|
148
202
|
- lib/email/provider.rb
|
203
|
+
- lib/gmail/authenticator.rb
|
204
|
+
- lib/google/auth/stores/in_memory_token_store.rb
|
149
205
|
- lib/imap/backup.rb
|
150
206
|
- lib/imap/backup/account/connection.rb
|
151
207
|
- lib/imap/backup/account/folder.rb
|
@@ -153,6 +209,7 @@ files:
|
|
153
209
|
- lib/imap/backup/configuration/asker.rb
|
154
210
|
- lib/imap/backup/configuration/connection_tester.rb
|
155
211
|
- lib/imap/backup/configuration/folder_chooser.rb
|
212
|
+
- lib/imap/backup/configuration/gmail_oauth2.rb
|
156
213
|
- lib/imap/backup/configuration/list.rb
|
157
214
|
- lib/imap/backup/configuration/setup.rb
|
158
215
|
- lib/imap/backup/configuration/store.rb
|
@@ -180,12 +237,15 @@ files:
|
|
180
237
|
- spec/support/silence_logging.rb
|
181
238
|
- spec/unit/email/mboxrd/message_spec.rb
|
182
239
|
- spec/unit/email/provider_spec.rb
|
240
|
+
- spec/unit/gmail/authenticator_spec.rb
|
241
|
+
- spec/unit/google/auth/stores/in_memory_token_store_spec.rb
|
183
242
|
- spec/unit/imap/backup/account/connection_spec.rb
|
184
243
|
- spec/unit/imap/backup/account/folder_spec.rb
|
185
244
|
- spec/unit/imap/backup/configuration/account_spec.rb
|
186
245
|
- spec/unit/imap/backup/configuration/asker_spec.rb
|
187
246
|
- spec/unit/imap/backup/configuration/connection_tester_spec.rb
|
188
247
|
- spec/unit/imap/backup/configuration/folder_chooser_spec.rb
|
248
|
+
- spec/unit/imap/backup/configuration/gmail_oauth2_spec.rb
|
189
249
|
- spec/unit/imap/backup/configuration/list_spec.rb
|
190
250
|
- spec/unit/imap/backup/configuration/setup_spec.rb
|
191
251
|
- spec/unit/imap/backup/configuration/store_spec.rb
|
@@ -200,11 +260,7 @@ files:
|
|
200
260
|
homepage: https://github.com/joeyates/imap-backup
|
201
261
|
licenses: []
|
202
262
|
metadata: {}
|
203
|
-
post_install_message:
|
204
|
-
Note that, when upgrading imap-backup from version 1.x to 2.x,
|
205
|
-
the metadata storage method has changed (from flat file to JSON).
|
206
|
-
As a result, on the first run after an upgrade, old backup folders will be
|
207
|
-
**deleted** and a full new backup created.
|
263
|
+
post_install_message:
|
208
264
|
rdoc_options: []
|
209
265
|
require_paths:
|
210
266
|
- lib
|
@@ -212,14 +268,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
268
|
requirements:
|
213
269
|
- - ">="
|
214
270
|
- !ruby/object:Gem::Version
|
215
|
-
version: 2.
|
271
|
+
version: 2.4.0
|
216
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
273
|
requirements:
|
218
274
|
- - ">="
|
219
275
|
- !ruby/object:Gem::Version
|
220
276
|
version: '0'
|
221
277
|
requirements: []
|
222
|
-
rubygems_version: 3.
|
278
|
+
rubygems_version: 3.1.2
|
223
279
|
signing_key:
|
224
280
|
specification_version: 4
|
225
281
|
summary: Backup GMail (or other IMAP) accounts to disk
|
@@ -240,12 +296,15 @@ test_files:
|
|
240
296
|
- spec/support/silence_logging.rb
|
241
297
|
- spec/unit/email/mboxrd/message_spec.rb
|
242
298
|
- spec/unit/email/provider_spec.rb
|
299
|
+
- spec/unit/gmail/authenticator_spec.rb
|
300
|
+
- spec/unit/google/auth/stores/in_memory_token_store_spec.rb
|
243
301
|
- spec/unit/imap/backup/account/connection_spec.rb
|
244
302
|
- spec/unit/imap/backup/account/folder_spec.rb
|
245
303
|
- spec/unit/imap/backup/configuration/account_spec.rb
|
246
304
|
- spec/unit/imap/backup/configuration/asker_spec.rb
|
247
305
|
- spec/unit/imap/backup/configuration/connection_tester_spec.rb
|
248
306
|
- spec/unit/imap/backup/configuration/folder_chooser_spec.rb
|
307
|
+
- spec/unit/imap/backup/configuration/gmail_oauth2_spec.rb
|
249
308
|
- spec/unit/imap/backup/configuration/list_spec.rb
|
250
309
|
- spec/unit/imap/backup/configuration/setup_spec.rb
|
251
310
|
- spec/unit/imap/backup/configuration/store_spec.rb
|