imap-backup 4.0.0.rc1 → 4.0.0.rc5

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +22 -8
  4. data/imap-backup.gemspec +0 -2
  5. data/lib/imap/backup/account/connection.rb +2 -21
  6. data/lib/imap/backup/cli/local.rb +9 -5
  7. data/lib/imap/backup/cli.rb +77 -73
  8. data/lib/imap/backup/configuration/account.rb +1 -11
  9. data/lib/imap/backup/version.rb +1 -1
  10. data/lib/imap/backup.rb +0 -1
  11. data/spec/unit/imap/backup/account/connection_spec.rb +0 -45
  12. data/spec/unit/imap/backup/configuration/account_spec.rb +0 -43
  13. metadata +2 -65
  14. data/docs/01-credentials-screen.png +0 -0
  15. data/docs/02-new-project.png +0 -0
  16. data/docs/03-initial-credentials-for-project.png +0 -0
  17. data/docs/04-credential-type-selection.png +0 -0
  18. data/docs/05-cant-create-without-consent-setup.png +0 -0
  19. data/docs/06-user-type-selection.png +0 -0
  20. data/docs/07-consent-screen-form.png +0 -0
  21. data/docs/08-app-scopes.png +0 -0
  22. data/docs/09-scope-selection.png +0 -0
  23. data/docs/10-updated-app-scopes.png +0 -0
  24. data/docs/11-test-users.png +0 -0
  25. data/docs/12-add-users.png +0 -0
  26. data/docs/13-create-oauth-client.png +0 -0
  27. data/docs/14-application-details.png +0 -0
  28. data/docs/16-initial-menu.png +0 -0
  29. data/docs/17-inputting-the-email-address.png +0 -0
  30. data/docs/18-choose-password.png +0 -0
  31. data/docs/19-supply-client-info.png +0 -0
  32. data/docs/20-choose-gmail-account.png +0 -0
  33. data/docs/21-accept-warnings.png +0 -0
  34. data/docs/22-grant-access.png +0 -0
  35. data/docs/24-confirm-choices.png +0 -0
  36. data/docs/25-success-code.png +0 -0
  37. data/docs/26-type-code-into-imap-backup.png +0 -0
  38. data/docs/27-success.png +0 -0
  39. data/docs/setting-up-gmail-with-oauth2.md +0 -166
  40. data/lib/gmail/authenticator.rb +0 -160
  41. data/lib/google/auth/stores/in_memory_token_store.rb +0 -9
  42. data/lib/imap/backup/configuration/gmail_oauth2.rb +0 -102
  43. data/spec/unit/gmail/authenticator_spec.rb +0 -138
  44. data/spec/unit/google/auth/stores/in_memory_token_store_spec.rb +0 -15
  45. data/spec/unit/imap/backup/configuration/gmail_oauth2_spec.rb +0 -121
@@ -1,121 +0,0 @@
1
- describe Imap::Backup::Configuration::GmailOauth2 do
2
- include HighLineTestHelpers
3
-
4
- CLIENT_ID = "my_client_id".freeze
5
- CLIENT_SECRET = "my_client_secret".freeze
6
-
7
- subject { described_class.new(account) }
8
-
9
- let(:authorization_url) { "some long authorization_url" }
10
- let(:credentials) { "credentials" }
11
- let(:json_token) { '{"sentinel":"foo"}' }
12
- let!(:highline_streams) { prepare_highline }
13
- let(:highline) { Imap::Backup::Configuration::Setup.highline }
14
- let(:input) { highline_streams[0] }
15
- let(:output) { highline_streams[1] }
16
- let(:account) { {} }
17
- let(:user_input) { %W(my_client_id\n my_secret\n my_code\n) }
18
-
19
- let(:authorizer) do
20
- instance_double(
21
- Google::Auth::UserAuthorizer,
22
- get_authorization_url: authorization_url,
23
- get_and_store_credentials_from_code: credentials
24
- )
25
- end
26
- let(:token_store) do
27
- instance_double(
28
- Google::Auth::Stores::InMemoryTokenStore,
29
- load: json_token
30
- )
31
- end
32
- let(:token) do
33
- instance_double(
34
- Gmail::Authenticator::ImapBackupToken,
35
- valid?: valid,
36
- client_id: CLIENT_ID,
37
- client_secret: CLIENT_SECRET
38
- )
39
- end
40
- let(:valid) { false }
41
-
42
- before do
43
- allow(Google::Auth::UserAuthorizer).
44
- to receive(:new) { authorizer }
45
- allow(Google::Auth::Stores::InMemoryTokenStore).
46
- to receive(:new) { token_store }
47
- allow(Gmail::Authenticator::ImapBackupToken).
48
- to receive(:new) { token }
49
-
50
- allow(highline).to receive(:ask).and_call_original
51
- allow(highline).to receive(:agree).and_call_original
52
-
53
- allow(Kernel).to receive(:system)
54
- allow(Kernel).to receive(:puts)
55
-
56
- allow(input).to receive(:gets).and_return(*user_input)
57
- end
58
-
59
- describe "#run" do
60
- let!(:result) { subject.run }
61
-
62
- it "clears the screen" do
63
- expect(Kernel).to have_received(:system).with("clear")
64
- end
65
-
66
- it "requests client_id" do
67
- expect(highline).to have_received(:ask).with("client_id: ")
68
- end
69
-
70
- it "requests client_secret" do
71
- expect(highline).to have_received(:ask).with("client_secret: ")
72
- end
73
-
74
- it "displays the authorization URL" do
75
- expect(Kernel).
76
- to have_received(:puts).
77
- with(/#{authorization_url}/)
78
- end
79
-
80
- it "requests the success code" do
81
- expect(highline).to have_received(:ask).with("success code: ")
82
- end
83
-
84
- it "requests an access_token via the code" do
85
- expect(authorizer).to have_received(:get_and_store_credentials_from_code)
86
- end
87
-
88
- it "returns the credentials" do
89
- expect(result).to match('"sentinel":"foo"')
90
- end
91
-
92
- it "includes the client_secret in the credentials" do
93
- expect(result).to match('"client_secret":"my_secret"')
94
- end
95
-
96
- context "when the account already has client info" do
97
- let(:valid) { true }
98
- let(:user_input) { %W(yes\n) }
99
-
100
- it "requests confirmation of client info" do
101
- expect(highline).to have_received(:agree).with("Use existing client info?")
102
- end
103
-
104
- context "when yhe user says 'no'" do
105
- let(:user_input) { %W(no\n) }
106
-
107
- it "requests client_id" do
108
- expect(highline).to have_received(:ask).with("client_id: ")
109
- end
110
-
111
- it "requests client_secret" do
112
- expect(highline).to have_received(:ask).with("client_secret: ")
113
- end
114
-
115
- it "requests the success code" do
116
- expect(highline).to have_received(:ask).with("success code: ")
117
- end
118
- end
119
- end
120
- end
121
- end