mailroute 0.0.2 → 0.0.3

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mailroute (0.0.2)
4
+ mailroute (0.0.3)
5
5
  activeresource
6
6
  json_pure
7
7
  rest-client
@@ -29,6 +29,11 @@ module Mailroute
29
29
  self
30
30
  end
31
31
 
32
+ def regenerate_api_key
33
+ response = connection.post(element_path(prefix_options) + 'regenerate_api_key/', nil, self.class.headers)
34
+ self.class.format.decode(response.body)['api_key']
35
+ end
36
+
32
37
  class << self
33
38
  alias_method :get_by_id, :get
34
39
  def get(*args)
@@ -1,3 +1,3 @@
1
1
  module Mailroute
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -63,6 +63,24 @@ describe Mailroute::EmailAccount, :vcr => true do
63
63
  end
64
64
  end
65
65
 
66
+ describe '#regenerate_api_key' do
67
+ context 'an email account' do
68
+ let(:email_account) { Mailroute::EmailAccount.get(7718) }
69
+
70
+ context 'regenerating api key' do
71
+ subject(:new_key) { email_account.regenerate_api_key }
72
+
73
+ it { should match /\A[0-9a-f]{40}\Z/ }
74
+
75
+ context 'regenerating api key once again' do
76
+ let(:another_key) { email_account.regenerate_api_key }
77
+
78
+ it { should_not == another_key }
79
+ end
80
+ end
81
+ end
82
+ end
83
+
66
84
  it 'should be possible to create, read, update and delete email accounts' do
67
85
  domain = Mailroute::Domain.get(4555)
68
86
  new_account = nil
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://admin-dev.mailroute.net/api/v1/email_account/7718/
6
+ body:
7
+ string: ""
8
+ headers:
9
+ Authorization:
10
+ - ApiKey test_ruby:93ec480a01deb532ffb592ba711013e14422c4f1
11
+ Accept:
12
+ - application/json
13
+ response:
14
+ status:
15
+ code: 200
16
+ message: OK
17
+ headers:
18
+ Connection:
19
+ - keep-alive
20
+ Transfer-Encoding:
21
+ - chunked
22
+ Date:
23
+ - Wed, 01 May 2013 19:40:05 GMT
24
+ Cache-Control:
25
+ - no-cache
26
+ Server:
27
+ - nginx/1.2.6
28
+ Vary:
29
+ - Accept, Cookie
30
+ - Accept-Encoding
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ body:
34
+ string: "{\"absolute_url\": \"/user/7718/\", \"aliases\": \"\", \"change_pwd\": null, \"contact\": null, \"create_opt\": null, \"created_at\": \"Wed, 1 May 2013 12:03:04 -0700\", \"domain\": \"/api/v1/domain/8372/\", \"domain_name\": \"example.com\", \"id\": 7718, \"localpart\": \"admin\", \"notification_tasks\": [\"/api/v1/notification_account_task/16924/\"], \"policy\": \"/api/v1/policy_user/16395/\", \"priority\": 8, \"resource_uri\": \"/api/v1/email_account/7718/\", \"updated_at\": \"Wed, 1 May 2013 12:03:04 -0700\", \"use_domain_notifications\": true}"
35
+ http_version:
36
+ recorded_at: Wed, 01 May 2013 19:40:05 GMT
37
+ - request:
38
+ method: post
39
+ uri: https://admin-dev.mailroute.net/api/v1/email_account/7718/regenerate_api_key/
40
+ body:
41
+ string: ""
42
+ headers:
43
+ Authorization:
44
+ - ApiKey test_ruby:93ec480a01deb532ffb592ba711013e14422c4f1
45
+ Accept:
46
+ - "*/*"
47
+ Content-Type:
48
+ - application/json
49
+ response:
50
+ status:
51
+ code: 202
52
+ message: ACCEPTED
53
+ headers:
54
+ Connection:
55
+ - keep-alive
56
+ Transfer-Encoding:
57
+ - chunked
58
+ Date:
59
+ - Wed, 01 May 2013 19:40:06 GMT
60
+ Server:
61
+ - nginx/1.2.6
62
+ Vary:
63
+ - Accept, Cookie
64
+ Content-Type:
65
+ - application/json
66
+ body:
67
+ string: "{\"api_key\": \"8e5c26f459ffaccd2acb18adb5b3c3030cbe55d7\"}"
68
+ http_version:
69
+ recorded_at: Wed, 01 May 2013 19:40:06 GMT
70
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,103 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://admin-dev.mailroute.net/api/v1/email_account/7718/
6
+ body:
7
+ string: ""
8
+ headers:
9
+ Authorization:
10
+ - ApiKey test_ruby:93ec480a01deb532ffb592ba711013e14422c4f1
11
+ Accept:
12
+ - application/json
13
+ response:
14
+ status:
15
+ code: 200
16
+ message: OK
17
+ headers:
18
+ Connection:
19
+ - keep-alive
20
+ Transfer-Encoding:
21
+ - chunked
22
+ Date:
23
+ - Wed, 01 May 2013 19:40:07 GMT
24
+ Cache-Control:
25
+ - no-cache
26
+ Server:
27
+ - nginx/1.2.6
28
+ Vary:
29
+ - Accept, Cookie
30
+ - Accept-Encoding
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ body:
34
+ string: "{\"absolute_url\": \"/user/7718/\", \"aliases\": \"\", \"change_pwd\": null, \"contact\": null, \"create_opt\": null, \"created_at\": \"Wed, 1 May 2013 12:03:04 -0700\", \"domain\": \"/api/v1/domain/8372/\", \"domain_name\": \"example.com\", \"id\": 7718, \"localpart\": \"admin\", \"notification_tasks\": [\"/api/v1/notification_account_task/16924/\"], \"policy\": \"/api/v1/policy_user/16395/\", \"priority\": 8, \"resource_uri\": \"/api/v1/email_account/7718/\", \"updated_at\": \"Wed, 1 May 2013 12:03:04 -0700\", \"use_domain_notifications\": true}"
35
+ http_version:
36
+ recorded_at: Wed, 01 May 2013 19:40:07 GMT
37
+ - request:
38
+ method: post
39
+ uri: https://admin-dev.mailroute.net/api/v1/email_account/7718/regenerate_api_key/
40
+ body:
41
+ string: ""
42
+ headers:
43
+ Authorization:
44
+ - ApiKey test_ruby:93ec480a01deb532ffb592ba711013e14422c4f1
45
+ Accept:
46
+ - "*/*"
47
+ Content-Type:
48
+ - application/json
49
+ response:
50
+ status:
51
+ code: 202
52
+ message: ACCEPTED
53
+ headers:
54
+ Connection:
55
+ - keep-alive
56
+ Transfer-Encoding:
57
+ - chunked
58
+ Date:
59
+ - Wed, 01 May 2013 19:40:08 GMT
60
+ Server:
61
+ - nginx/1.2.6
62
+ Vary:
63
+ - Accept, Cookie
64
+ Content-Type:
65
+ - application/json
66
+ body:
67
+ string: "{\"api_key\": \"f346c9faf3052b3d6da3f59fbb19af63817d785f\"}"
68
+ http_version:
69
+ recorded_at: Wed, 01 May 2013 19:40:08 GMT
70
+ - request:
71
+ method: post
72
+ uri: https://admin-dev.mailroute.net/api/v1/email_account/7718/regenerate_api_key/
73
+ body:
74
+ string: ""
75
+ headers:
76
+ Authorization:
77
+ - ApiKey test_ruby:93ec480a01deb532ffb592ba711013e14422c4f1
78
+ Accept:
79
+ - "*/*"
80
+ Content-Type:
81
+ - application/json
82
+ response:
83
+ status:
84
+ code: 202
85
+ message: ACCEPTED
86
+ headers:
87
+ Connection:
88
+ - keep-alive
89
+ Transfer-Encoding:
90
+ - chunked
91
+ Date:
92
+ - Wed, 01 May 2013 19:40:09 GMT
93
+ Server:
94
+ - nginx/1.2.6
95
+ Vary:
96
+ - Accept, Cookie
97
+ Content-Type:
98
+ - application/json
99
+ body:
100
+ string: "{\"api_key\": \"ad021767061c051fa2465d17b13966bb82b87f65\"}"
101
+ http_version:
102
+ recorded_at: Wed, 01 May 2013 19:40:09 GMT
103
+ recorded_with: VCR 2.4.0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailroute
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Viktar Basharymau
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-30 00:00:00 Z
18
+ date: 2013-05-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client
@@ -305,6 +305,8 @@ files:
305
305
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain/should_return_an_account.yml
306
306
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain_id/should_return_an_account.yml
307
307
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain_name/should_return_an_account.yml
308
+ - spec/vcr_cassettes/Mailroute_EmailAccount/_regenerate_api_key/an_email_account/regenerating_api_key/.yml
309
+ - spec/vcr_cassettes/Mailroute_EmailAccount/_regenerate_api_key/an_email_account/regenerating_api_key/regenerating_api_key_once_again/.yml
308
310
  - spec/vcr_cassettes/Mailroute_EmailAccount/_set_password/should_set_the_password.yml
309
311
  - spec/vcr_cassettes/Mailroute_EmailAccount/black_white_list/should_blacklist_and_whitelist_emails.yml
310
312
  - spec/vcr_cassettes/Mailroute_EmailAccount/has_contact/should_have_contact.yml
@@ -490,6 +492,8 @@ test_files:
490
492
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain/should_return_an_account.yml
491
493
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain_id/should_return_an_account.yml
492
494
  - spec/vcr_cassettes/Mailroute_EmailAccount/_get/by_localpart_and_domain_name/should_return_an_account.yml
495
+ - spec/vcr_cassettes/Mailroute_EmailAccount/_regenerate_api_key/an_email_account/regenerating_api_key/.yml
496
+ - spec/vcr_cassettes/Mailroute_EmailAccount/_regenerate_api_key/an_email_account/regenerating_api_key/regenerating_api_key_once_again/.yml
493
497
  - spec/vcr_cassettes/Mailroute_EmailAccount/_set_password/should_set_the_password.yml
494
498
  - spec/vcr_cassettes/Mailroute_EmailAccount/black_white_list/should_blacklist_and_whitelist_emails.yml
495
499
  - spec/vcr_cassettes/Mailroute_EmailAccount/has_contact/should_have_contact.yml