heroku-api 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ 0.3.2 08/01/2012
2
+ ================
3
+
4
+ don't request v3 apis
5
+ first pass at ssl_endpoints support (no mocks yet)
6
+ bump excon dep
7
+
1
8
  0.3.1 07/20/2012
2
9
  ================
3
10
 
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_runtime_dependency 'excon', '~>0.15.4'
19
+ s.add_runtime_dependency 'excon', '~>0.15.5'
20
20
 
21
21
  s.add_development_dependency 'minitest'
22
22
  s.add_development_dependency 'rake'
@@ -26,6 +26,7 @@ require "heroku/api/login"
26
26
  require "heroku/api/logs"
27
27
  require "heroku/api/processes"
28
28
  require "heroku/api/releases"
29
+ require "heroku/api/ssl_endpoints"
29
30
  require "heroku/api/stacks"
30
31
  require "heroku/api/user"
31
32
 
@@ -48,7 +49,6 @@ module Heroku
48
49
  #'Accept-Language' => 'en-US, en;q=0.8',
49
50
  'Authorization' => "Basic #{Base64.encode64(user_pass).gsub("\n", '')}",
50
51
  'User-Agent' => "heroku-rb/#{Heroku::API::VERSION}",
51
- 'X-Heroku-API-Version' => '3',
52
52
  'X-Ruby-Version' => RUBY_VERSION,
53
53
  'X-Ruby-Platform' => RUBY_PLATFORM
54
54
  }.merge(options[:headers])
@@ -0,0 +1,62 @@
1
+ module Heroku
2
+ class API
3
+
4
+ # DELETE /apps/:app/ssl-endpoint/:cname
5
+ def delete_ssl_endpoint(app, cname)
6
+ request(
7
+ :expects => 200,
8
+ :method => :delete,
9
+ :path => "/apps/#{app}/ssl-endpoints/#{escape(cname)}"
10
+ )
11
+ end
12
+
13
+ # GET /apps/:app/ssl-endpoint/:cname
14
+ def get_ssl_endpoint(app, cname)
15
+ request(
16
+ :expects => 200,
17
+ :method => :get,
18
+ :path => "/apps/#{app}/ssl-endpoints/#{escape(cname)}"
19
+ )
20
+ end
21
+
22
+ # GET /apps/:app/ssl-endpoints
23
+ def get_ssl_endpoints(app)
24
+ request(
25
+ :expects => 200,
26
+ :method => :get,
27
+ :path => "/apps/#{app}/ssl-endpoints"
28
+ )
29
+ end
30
+
31
+ # POST /apps/:app/ssl-endpoints
32
+ def post_ssl_endpoint(app, pem, key)
33
+ request(
34
+ :expects => 200,
35
+ :method => :post,
36
+ :path => "/apps/#{app}/ssl-endpoints",
37
+ :query => { 'key' => key, 'pem' => pem }
38
+ )
39
+ end
40
+
41
+ # POST /apps/:app/ssl-endpoints/:cname/rollback
42
+ def post_ssl_endpoint_rollback(app, cname)
43
+ request(
44
+ :expects => 200,
45
+ :method => :post,
46
+ :path => "/apps/#{app}/ssl-endpoints/#{escape(cname)}/rollback"
47
+ )
48
+ end
49
+
50
+ # PUT /apps/:app/ssl-endpoints/:cname
51
+ def put_ssl_endpoint(app, cname, pem, key)
52
+ request(
53
+ :expects => 200,
54
+ :method => :put,
55
+ :path => "/apps/#{app}/ssl-endpoints/#{escape(cname)}",
56
+ :query => { 'key' => key, 'pem' => pem }
57
+ )
58
+ end
59
+
60
+ end
61
+ end
62
+
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  class API
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDPDCCAiQCCQCh/jTWfdrzuDANBgkqhkiG9w0BAQUFADBgMQswCQYDVQQGEwJV
3
+ UzEPMA0GA1UEChMGSGVyb2t1MR4wHAYDVQQDExVnZWVtdXMgKFdlc2xleSBCZWFy
4
+ eSkxIDAeBgkqhkiG9w0BCQEWEXdlc2xleUBoZXJva3UuY29tMB4XDTEyMDczMDIy
5
+ MTkzMFoXDTEzMDczMDIyMTkzMFowYDELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkhl
6
+ cm9rdTEeMBwGA1UEAxMVZ2Vlb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aaHkrhwOtX9fAv0sYxJS5madw3GBkBAt7tSn6NYgprU0fLR69kZ38hHFjD
20
+ 1SHXaw+9XbjWEpT3GxavX3oMWBsq1kj2FYkvHkjmeTqw+Jumc+Np5nKKWXk9OuHS
21
+ d9YptNlVDiA6FGbJuwhSwQVxAoGAcB0qzbr3b5k+3N3No/AzykbgKMK3v1Jxvlhd
22
+ nwEnWCGBop9kV82sdt5SL23IMrJanP007R5QYvQENicLq/mzj4lYbkBCc1VnPQJu
23
+ 2ASSebXVp8QybiA5CaxizBV2YKB8Bt2wpt+srVXG8E/AbXWTw7Njal3jkOcSSjWB
24
+ FbxiNcMCgYApDMoIJRshdDUbnAmHBiejBxAbyrnhjs5LIklDb3R5OBm2OdgtpDPX
25
+ OEQVS9jHW2rBsLKHTi5bqFfVV1UsIH0nw3aTj4qhEzlVwoGIrrkKN5HG0TK991Y+
26
+ nMZF5DpWRpXGilpBqD3ZYExmDvPW8DkvxCSH7O2tuaAMg9djm/wyzw==
27
+ -----END RSA PRIVATE KEY-----
@@ -5,8 +5,17 @@ gem 'minitest' # ensure we are using the gem version
5
5
  require 'minitest/autorun'
6
6
  require 'time'
7
7
 
8
+ DATA_PATH = File.expand_path("#{File.dirname(__FILE__)}/data")
8
9
  MOCK = ENV['MOCK'] != 'false'
9
10
 
11
+ def data_server_crt
12
+ @data_server_crt ||= File.read(File.join(DATA_PATH, 'server.crt'))
13
+ end
14
+
15
+ def data_server_key
16
+ @data_server_key ||= File.read(File.join(DATA_PATH, 'server.key'))
17
+ end
18
+
10
19
  def heroku
11
20
  # ENV['HEROKU_API_KEY'] used for :api_key
12
21
  Heroku::API.new(:mock => MOCK)
@@ -0,0 +1,125 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestSslEndpoints < MiniTest::Unit::TestCase
4
+
5
+ def test_delete_ssl_endpoint
6
+ skip if MOCK
7
+ with_app do |app_data|
8
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
9
+ ssl_endpoint_data = heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key).body
10
+
11
+ response = heroku.delete_ssl_endpoint(app_data['name'], ssl_endpoint_data['cname'])
12
+
13
+ assert_equal(' ', response.body)
14
+ assert_equal(200, response.status)
15
+ end
16
+ end
17
+
18
+ def test_delete_ssl_endpoint_app_not_found
19
+ skip if MOCK
20
+ assert_raises(Heroku::API::Errors::NotFound) do
21
+ heroku.delete_ssl_endpoint(random_name, 'key')
22
+ end
23
+ end
24
+
25
+ def test_get_ssl_endpoint
26
+ skip if MOCK
27
+ with_app do |app_data|
28
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
29
+ ssl_endpoint_data = heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key).body
30
+
31
+ response = heroku.get_ssl_endpoint(app_data['name'], ssl_endpoint_data['cname'])
32
+
33
+ data = response.body['ssl_cert']
34
+ assert_equal(false, data['ca_signed?'])
35
+ assert_equal(true, data['self_signed?'])
36
+ assert_equal(['geemus (wesley beary)'], data['cert_domains'])
37
+ assert_equal('2013/07/30 15:19:30 -0700', data['expires_at'])
38
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['issuer'])
39
+ assert_equal('2012/07/30 15:19:30 -0700', data['starts_at'])
40
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['subject'])
41
+ assert_equal(200, response.status)
42
+ end
43
+ end
44
+
45
+ def test_get_ssl_endpoints
46
+ skip if MOCK
47
+ with_app do |app_data|
48
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
49
+ heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key)
50
+
51
+ response = heroku.get_ssl_endpoints(app_data['name'])
52
+
53
+ data = response.body.first['ssl_cert']
54
+ assert_equal(false, data['ca_signed?'])
55
+ assert_equal(true, data['self_signed?'])
56
+ assert_equal(['geemus (wesley beary)'], data['cert_domains'])
57
+ assert_equal('2013/07/30 15:19:30 -0700', data['expires_at'])
58
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['issuer'])
59
+ assert_equal('2012/07/30 15:19:30 -0700', data['starts_at'])
60
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['subject'])
61
+ assert_equal(200, response.status)
62
+ end
63
+ end
64
+
65
+ def test_post_ssl_endpoint
66
+ skip if MOCK
67
+ with_app do |app_data|
68
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
69
+
70
+ response = heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key)
71
+
72
+ data = response.body['ssl_cert']
73
+ assert_equal(false, data['ca_signed?'])
74
+ assert_equal(true, data['self_signed?'])
75
+ assert_equal(['geemus (wesley beary)'], data['cert_domains'])
76
+ assert_equal('2013/07/30 15:19:30 -0700', data['expires_at'])
77
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['issuer'])
78
+ assert_equal('2012/07/30 15:19:30 -0700', data['starts_at'])
79
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['subject'])
80
+ assert_equal(200, response.status)
81
+ end
82
+ end
83
+
84
+ def test_post_ssl_endpoint_rollback
85
+ skip if MOCK
86
+ with_app do |app_data|
87
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
88
+ ssl_endpoint_data = heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key).body
89
+ heroku.put_ssl_endpoint(app_data['name'], ssl_endpoint_data['cname'], data_server_crt, data_server_key)
90
+
91
+ response = heroku.post_ssl_endpoint_rollback(app_data['name'], ssl_endpoint_data['cname'])
92
+
93
+ data = response.body['ssl_cert']
94
+ assert_equal(false, data['ca_signed?'])
95
+ assert_equal(true, data['self_signed?'])
96
+ assert_equal(['geemus (wesley beary)'], data['cert_domains'])
97
+ assert_equal('2013/07/30 15:19:30 -0700', data['expires_at'])
98
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['issuer'])
99
+ assert_equal('2012/07/30 15:19:30 -0700', data['starts_at'])
100
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['subject'])
101
+ assert_equal(200, response.status)
102
+ end
103
+ end
104
+
105
+ def test_put_ssl_endpoint
106
+ skip if MOCK
107
+ with_app do |app_data|
108
+ heroku.post_addon(app_data['name'], 'ssl:endpoint')
109
+ ssl_endpoint_data = heroku.post_ssl_endpoint(app_data['name'], data_server_crt, data_server_key).body
110
+
111
+ response = heroku.put_ssl_endpoint(app_data['name'], ssl_endpoint_data['cname'], data_server_crt, data_server_key)
112
+
113
+ data = response.body['ssl_cert']
114
+ assert_equal(false, data['ca_signed?'])
115
+ assert_equal(true, data['self_signed?'])
116
+ assert_equal(['geemus (wesley beary)'], data['cert_domains'])
117
+ assert_equal('2013/07/30 15:19:30 -0700', data['expires_at'])
118
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['issuer'])
119
+ assert_equal('2012/07/30 15:19:30 -0700', data['starts_at'])
120
+ assert_equal('/C=US/O=Heroku/CN=geemus (Wesley Beary)/emailAddress=wesley@heroku.com', data['subject'])
121
+ assert_equal(200, response.status)
122
+ end
123
+ end
124
+
125
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
16
- requirement: &70353003020620 !ruby/object:Gem::Requirement
16
+ requirement: &70119193362320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.15.4
21
+ version: 0.15.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70353003020620
24
+ version_requirements: *70119193362320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70353003019420 !ruby/object:Gem::Requirement
27
+ requirement: &70119193360480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70353003019420
35
+ version_requirements: *70119193360480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70353003016440 !ruby/object:Gem::Requirement
38
+ requirement: &70119193355000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70353003016440
46
+ version_requirements: *70119193355000
47
47
  description: Ruby Client for the Heroku API
48
48
  email:
49
49
  - wesley@heroku.com
@@ -89,10 +89,13 @@ files:
89
89
  - lib/heroku/api/mock/user.rb
90
90
  - lib/heroku/api/processes.rb
91
91
  - lib/heroku/api/releases.rb
92
+ - lib/heroku/api/ssl_endpoints.rb
92
93
  - lib/heroku/api/stacks.rb
93
94
  - lib/heroku/api/user.rb
94
95
  - lib/heroku/api/vendor/okjson.rb
95
96
  - lib/heroku/api/version.rb
97
+ - test/data/server.crt
98
+ - test/data/server.key
96
99
  - test/test_addons.rb
97
100
  - test/test_apps.rb
98
101
  - test/test_collaborators.rb
@@ -105,6 +108,7 @@ files:
105
108
  - test/test_logs.rb
106
109
  - test/test_processes.rb
107
110
  - test/test_releases.rb
111
+ - test/test_ssl_endpoints.rb
108
112
  - test/test_stacks.rb
109
113
  - test/test_user.rb
110
114
  homepage: http://github.com/heroku/heroku.rb
@@ -121,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
125
  version: '0'
122
126
  segments:
123
127
  - 0
124
- hash: -2286072111782090869
128
+ hash: -2298175570851415714
125
129
  required_rubygems_version: !ruby/object:Gem::Requirement
126
130
  none: false
127
131
  requirements:
@@ -130,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
134
  version: '0'
131
135
  segments:
132
136
  - 0
133
- hash: -2286072111782090869
137
+ hash: -2298175570851415714
134
138
  requirements: []
135
139
  rubyforge_project:
136
140
  rubygems_version: 1.8.15
@@ -138,6 +142,8 @@ signing_key:
138
142
  specification_version: 3
139
143
  summary: Ruby Client for the Heroku API
140
144
  test_files:
145
+ - test/data/server.crt
146
+ - test/data/server.key
141
147
  - test/test_addons.rb
142
148
  - test/test_apps.rb
143
149
  - test/test_collaborators.rb
@@ -150,5 +156,6 @@ test_files:
150
156
  - test/test_logs.rb
151
157
  - test/test_processes.rb
152
158
  - test/test_releases.rb
159
+ - test/test_ssl_endpoints.rb
153
160
  - test/test_stacks.rb
154
161
  - test/test_user.rb