pogo 2.31.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/README.md +73 -0
  2. data/bin/pogo +22 -0
  3. data/data/cacert.pem +3988 -0
  4. data/lib/heroku.rb +22 -0
  5. data/lib/heroku/auth.rb +320 -0
  6. data/lib/heroku/cli.rb +38 -0
  7. data/lib/heroku/client.rb +764 -0
  8. data/lib/heroku/client/heroku_postgresql.rb +111 -0
  9. data/lib/heroku/client/pgbackups.rb +113 -0
  10. data/lib/heroku/client/rendezvous.rb +105 -0
  11. data/lib/heroku/client/ssl_endpoint.rb +25 -0
  12. data/lib/heroku/command.rb +273 -0
  13. data/lib/heroku/command/account.rb +23 -0
  14. data/lib/heroku/command/accounts.rb +34 -0
  15. data/lib/heroku/command/addons.rb +305 -0
  16. data/lib/heroku/command/apps.rb +311 -0
  17. data/lib/heroku/command/auth.rb +86 -0
  18. data/lib/heroku/command/base.rb +230 -0
  19. data/lib/heroku/command/certs.rb +148 -0
  20. data/lib/heroku/command/config.rb +137 -0
  21. data/lib/heroku/command/db.rb +218 -0
  22. data/lib/heroku/command/domains.rb +85 -0
  23. data/lib/heroku/command/drains.rb +46 -0
  24. data/lib/heroku/command/git.rb +65 -0
  25. data/lib/heroku/command/help.rb +163 -0
  26. data/lib/heroku/command/keys.rb +115 -0
  27. data/lib/heroku/command/labs.rb +161 -0
  28. data/lib/heroku/command/logs.rb +98 -0
  29. data/lib/heroku/command/maintenance.rb +61 -0
  30. data/lib/heroku/command/pg.rb +277 -0
  31. data/lib/heroku/command/pgbackups.rb +289 -0
  32. data/lib/heroku/command/plugins.rb +110 -0
  33. data/lib/heroku/command/ps.rb +232 -0
  34. data/lib/heroku/command/releases.rb +124 -0
  35. data/lib/heroku/command/run.rb +179 -0
  36. data/lib/heroku/command/sharing.rb +89 -0
  37. data/lib/heroku/command/ssl.rb +61 -0
  38. data/lib/heroku/command/stack.rb +62 -0
  39. data/lib/heroku/command/status.rb +51 -0
  40. data/lib/heroku/command/update.rb +47 -0
  41. data/lib/heroku/command/version.rb +23 -0
  42. data/lib/heroku/deprecated.rb +5 -0
  43. data/lib/heroku/deprecated/help.rb +38 -0
  44. data/lib/heroku/distribution.rb +9 -0
  45. data/lib/heroku/helpers.rb +517 -0
  46. data/lib/heroku/helpers/heroku_postgresql.rb +104 -0
  47. data/lib/heroku/plugin.rb +161 -0
  48. data/lib/heroku/updater.rb +158 -0
  49. data/lib/heroku/version.rb +3 -0
  50. data/lib/vendor/heroku/okjson.rb +598 -0
  51. data/spec/helper/legacy_help.rb +16 -0
  52. data/spec/heroku/auth_spec.rb +246 -0
  53. data/spec/heroku/client/heroku_postgresql_spec.rb +34 -0
  54. data/spec/heroku/client/pgbackups_spec.rb +43 -0
  55. data/spec/heroku/client/rendezvous_spec.rb +62 -0
  56. data/spec/heroku/client/ssl_endpoint_spec.rb +48 -0
  57. data/spec/heroku/client_spec.rb +564 -0
  58. data/spec/heroku/command/addons_spec.rb +585 -0
  59. data/spec/heroku/command/apps_spec.rb +351 -0
  60. data/spec/heroku/command/auth_spec.rb +38 -0
  61. data/spec/heroku/command/base_spec.rb +109 -0
  62. data/spec/heroku/command/certs_spec.rb +178 -0
  63. data/spec/heroku/command/config_spec.rb +144 -0
  64. data/spec/heroku/command/db_spec.rb +110 -0
  65. data/spec/heroku/command/domains_spec.rb +87 -0
  66. data/spec/heroku/command/drains_spec.rb +34 -0
  67. data/spec/heroku/command/git_spec.rb +116 -0
  68. data/spec/heroku/command/help_spec.rb +93 -0
  69. data/spec/heroku/command/keys_spec.rb +120 -0
  70. data/spec/heroku/command/labs_spec.rb +99 -0
  71. data/spec/heroku/command/logs_spec.rb +60 -0
  72. data/spec/heroku/command/maintenance_spec.rb +51 -0
  73. data/spec/heroku/command/pg_spec.rb +223 -0
  74. data/spec/heroku/command/pgbackups_spec.rb +280 -0
  75. data/spec/heroku/command/plugins_spec.rb +104 -0
  76. data/spec/heroku/command/ps_spec.rb +195 -0
  77. data/spec/heroku/command/releases_spec.rb +130 -0
  78. data/spec/heroku/command/run_spec.rb +86 -0
  79. data/spec/heroku/command/sharing_spec.rb +59 -0
  80. data/spec/heroku/command/ssl_spec.rb +32 -0
  81. data/spec/heroku/command/stack_spec.rb +46 -0
  82. data/spec/heroku/command/status_spec.rb +48 -0
  83. data/spec/heroku/command/version_spec.rb +16 -0
  84. data/spec/heroku/command_spec.rb +211 -0
  85. data/spec/heroku/helpers/heroku_postgresql_spec.rb +109 -0
  86. data/spec/heroku/helpers_spec.rb +48 -0
  87. data/spec/heroku/plugin_spec.rb +172 -0
  88. data/spec/heroku/updater_spec.rb +44 -0
  89. data/spec/spec.opts +1 -0
  90. data/spec/spec_helper.rb +209 -0
  91. data/spec/support/display_message_matcher.rb +49 -0
  92. data/spec/support/openssl_mock_helper.rb +8 -0
  93. metadata +220 -0
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+ require "heroku/command/drains"
3
+
4
+ describe Heroku::Command::Drains do
5
+
6
+ describe "drains" do
7
+ it "can list drains" do
8
+ stub_core.list_drains("myapp").returns("drains")
9
+ stderr, stdout = execute("drains")
10
+ stderr.should == ""
11
+ stdout.should == <<-STDOUT
12
+ drains
13
+ STDOUT
14
+ end
15
+
16
+ it "can add drains" do
17
+ stub_core.add_drain("myapp", "syslog://localhost/add").returns("added")
18
+ stderr, stdout = execute("drains:add syslog://localhost/add")
19
+ stderr.should == ""
20
+ stdout.should == <<-STDOUT
21
+ added
22
+ STDOUT
23
+ end
24
+
25
+ it "can remove drains" do
26
+ stub_core.remove_drain("myapp", "syslog://localhost/remove").returns("removed")
27
+ stderr, stdout = execute("drains:remove syslog://localhost/remove")
28
+ stderr.should == ""
29
+ stdout.should == <<-STDOUT
30
+ removed
31
+ STDOUT
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+ require 'heroku/command/git'
3
+
4
+ module Heroku::Command
5
+ describe Git do
6
+
7
+ before(:each) do
8
+ stub_core
9
+ end
10
+
11
+ context("clone") do
12
+
13
+ before(:each) do
14
+ api.post_app("name" => "myapp", "stack" => "cedar")
15
+ FileUtils.mkdir('myapp')
16
+ FileUtils.chdir('myapp') { `git init` }
17
+ end
18
+
19
+ after(:each) do
20
+ api.delete_app("myapp")
21
+ FileUtils.rm_rf('myapp')
22
+ end
23
+
24
+ it "clones and adds remote" do
25
+ any_instance_of(Heroku::Command::Git) do |git|
26
+ stub(git).git('clone git@heroku.com:myapp.git ').returns("Cloning into 'myapp'...")
27
+ stub(git).git('remote').returns("origin")
28
+ stub(git).git('remote add heroku git@heroku.com:myapp.git')
29
+ end
30
+ stderr, stdout = execute("git:clone")
31
+ stderr.should == ""
32
+ stdout.should == <<-STDOUT
33
+ Cloning into 'myapp'...
34
+ Git remote heroku added
35
+ STDOUT
36
+ end
37
+
38
+ it "clones and sets -r remote" do
39
+ any_instance_of(Heroku::Command::Git) do |git|
40
+ stub(git).git('clone git@heroku.com:myapp.git ').returns("Cloning into 'myapp'...")
41
+ stub(git).git('remote').returns("origin")
42
+ stub(git).git('remote add other git@heroku.com:myapp.git')
43
+ end
44
+ stderr, stdout = execute("git:clone -r other")
45
+ stderr.should == ""
46
+ stdout.should == <<-STDOUT
47
+ Cloning into 'myapp'...
48
+ Git remote other added
49
+ STDOUT
50
+ end
51
+
52
+ it "clones and skips remote with no-remote" do
53
+ any_instance_of(Heroku::Command::Git) do |git|
54
+ stub(git).git('clone git@heroku.com:myapp.git ').returns("Cloning into 'myapp'...")
55
+ end
56
+ stderr, stdout = execute("git:clone --no-remote")
57
+ stderr.should == ""
58
+ stdout.should == <<-STDOUT
59
+ Cloning into 'myapp'...
60
+ STDOUT
61
+ end
62
+
63
+ end
64
+
65
+ context("remote") do
66
+
67
+ before(:each) do
68
+ api.post_app("name" => "myapp", "stack" => "cedar")
69
+ FileUtils.mkdir('myapp')
70
+ FileUtils.chdir('myapp') { `git init` }
71
+ end
72
+
73
+ after(:each) do
74
+ api.delete_app("myapp")
75
+ FileUtils.rm_rf('myapp')
76
+ end
77
+
78
+ it "adds remote" do
79
+ any_instance_of(Heroku::Command::Git) do |git|
80
+ stub(git).git('remote').returns("origin")
81
+ stub(git).git('remote add heroku git@heroku.com:myapp.git')
82
+ end
83
+ stderr, stdout = execute("git:remote")
84
+ stderr.should == ""
85
+ stdout.should == <<-STDOUT
86
+ Git remote heroku added
87
+ STDOUT
88
+ end
89
+
90
+ it "adds -r remote" do
91
+ any_instance_of(Heroku::Command::Git) do |git|
92
+ stub(git).git('remote').returns("origin")
93
+ stub(git).git('remote add other git@heroku.com:myapp.git')
94
+ end
95
+ stderr, stdout = execute("git:remote -r other")
96
+ stderr.should == ""
97
+ stdout.should == <<-STDOUT
98
+ Git remote other added
99
+ STDOUT
100
+ end
101
+
102
+ it "skips remote when it already exists" do
103
+ any_instance_of(Heroku::Command::Git) do |git|
104
+ stub(git).git('remote').returns("heroku")
105
+ end
106
+ stderr, stdout = execute("git:remote")
107
+ stderr.should == <<-STDERR
108
+ ! Git remote heroku already exists
109
+ STDERR
110
+ stdout.should == ""
111
+ end
112
+
113
+ end
114
+
115
+ end
116
+ end
@@ -0,0 +1,93 @@
1
+ require "spec_helper"
2
+ require "heroku/command/apps"
3
+ require "heroku/command/help"
4
+
5
+ describe Heroku::Command::Help do
6
+
7
+ describe "help" do
8
+ it "should show root help with no args" do
9
+ stderr, stdout = execute("help")
10
+ stderr.should == ""
11
+ stdout.should include "Usage: heroku COMMAND [--app APP] [command-specific-options]"
12
+ stdout.should include "apps"
13
+ stdout.should include "help"
14
+ end
15
+
16
+ it "should show command help and namespace help when ambigious" do
17
+ stderr, stdout = execute("help apps")
18
+ stderr.should == ""
19
+ stdout.should include "heroku apps"
20
+ stdout.should include "list your apps"
21
+ stdout.should include "Additional commands"
22
+ stdout.should include "apps:create"
23
+ end
24
+
25
+ it "should show only command help when not ambiguous" do
26
+ stderr, stdout = execute("help apps:create")
27
+ stderr.should == ""
28
+ stdout.should include "heroku apps:create"
29
+ stdout.should include "create a new app"
30
+ stdout.should_not include "Additional commands"
31
+ end
32
+
33
+ it "should show command help with --help" do
34
+ stderr, stdout = execute("apps:create --help")
35
+ stderr.should == ""
36
+ stdout.should include "Usage: heroku apps:create"
37
+ stdout.should include "create a new app"
38
+ stdout.should_not include "Additional commands"
39
+ end
40
+
41
+ it "should redirect if the command is an alias" do
42
+ stderr, stdout = execute("help create")
43
+ stderr.should == ""
44
+ stdout.should include "Alias: create redirects to apps:create"
45
+ stdout.should include "Usage: heroku apps:create"
46
+ stdout.should include "create a new app"
47
+ stdout.should_not include "Additional commands"
48
+ end
49
+
50
+ it "should show if the command does not exist" do
51
+ stderr, stdout = execute("help sudo:sandwich")
52
+ stderr.should == <<-STDERR
53
+ ! sudo:sandwich is not a heroku command. See `heroku help`.
54
+ STDERR
55
+ stdout.should == ""
56
+ end
57
+
58
+ it "should show help with naked -h" do
59
+ stderr, stdout = execute("-h")
60
+ stderr.should == ""
61
+ stdout.should include "Usage: heroku COMMAND"
62
+ end
63
+
64
+ it "should show help with naked --help" do
65
+ stderr, stdout = execute("--help")
66
+ stderr.should == ""
67
+ stdout.should include "Usage: heroku COMMAND"
68
+ end
69
+
70
+ describe "with legacy help" do
71
+ require "helper/legacy_help"
72
+
73
+ it "displays the legacy group in the namespace list" do
74
+ stderr, stdout = execute("help")
75
+ stderr.should == ""
76
+ stdout.should include "Foo Group"
77
+ end
78
+
79
+ it "displays group help" do
80
+ stderr, stdout = execute("help foo")
81
+ stderr.should == ""
82
+ stdout.should include "do a bar to foo"
83
+ stdout.should include "do a baz to foo"
84
+ end
85
+
86
+ it "displays legacy command-specific help" do
87
+ stderr, stdout = execute("help foo:bar")
88
+ stderr.should == ""
89
+ stdout.should include "do a bar to foo"
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,120 @@
1
+ require "spec_helper"
2
+ require "heroku/command/keys"
3
+
4
+ module Heroku::Command
5
+ describe Keys do
6
+ KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp9AJD5QABmOcrkHm6SINuQkDefaR0MUrfgZ1Pxir3a4fM1fwa00dsUwbUaRuR7FEFD8n1E9WwDf8SwQTHtyZsJg09G9myNqUzkYXCmydN7oGr5IdVhRyv5ixcdiE0hj7dRnOJg2poSQ3Qi+Ka8SVJzF7nIw1YhuicHPSbNIFKi5s0D5a+nZb/E6MNGvhxoFCQX2IcNxaJMqhzy1ESwlixz45aT72mXYq0LIxTTpoTqma1HuKdRY8HxoREiivjmMQulYP+CxXFcMyV9kxTKIUZ/FXqlC6G5vSm3J4YScSatPOj9ID5HowpdlIx8F6y4p1/28r2tTl4CY40FFyoke4MQ== pedro@heroku"
7
+
8
+ before(:each) do
9
+ stub_core
10
+ end
11
+
12
+ context("add") do
13
+
14
+ after(:each) do
15
+ api.delete_key("pedro@heroku")
16
+ end
17
+
18
+ it "tries to find a key if no key filename is supplied" do
19
+ Heroku::Auth.should_receive(:ask).and_return("y")
20
+ Heroku::Auth.should_receive(:generate_ssh_key)
21
+ File.should_receive(:exists?).with('.git').and_return(false)
22
+ File.should_receive(:exists?).with('/.ssh/id_rsa.pub').and_return(true)
23
+ File.should_receive(:read).with('/.ssh/id_rsa.pub').and_return(KEY)
24
+ stderr, stdout = execute("keys:add")
25
+ stderr.should == ""
26
+ stdout.should == <<-STDOUT
27
+ Could not find an existing public key.
28
+ Would you like to generate one? [Yn] Generating new SSH public key.
29
+ Uploading SSH public key /.ssh/id_rsa.pub... done
30
+ STDOUT
31
+ end
32
+
33
+ it "adds a key from a specified keyfile path" do
34
+ File.should_receive(:exists?).with('.git').and_return(false)
35
+ File.should_receive(:exists?).with('/my/key.pub').and_return(true)
36
+ File.should_receive(:read).with('/my/key.pub').and_return(KEY)
37
+ stderr, stdout = execute("keys:add /my/key.pub")
38
+ stderr.should == ""
39
+ stdout.should == <<-STDOUT
40
+ Uploading SSH public key /my/key.pub... done
41
+ STDOUT
42
+ end
43
+
44
+ end
45
+
46
+ context("index") do
47
+
48
+ before do
49
+ api.post_key(KEY)
50
+ end
51
+
52
+ after do
53
+ api.delete_key("pedro@heroku")
54
+ end
55
+
56
+ it "list keys, trimming the hex code for better display" do
57
+ stderr, stdout = execute("keys")
58
+ stderr.should == ""
59
+ stdout.should == <<-STDOUT
60
+ === email@example.com Keys
61
+ ssh-rsa AAAAB3NzaC...Fyoke4MQ== pedro@heroku
62
+
63
+ STDOUT
64
+ end
65
+
66
+ it "list keys showing the whole key hex with --long" do
67
+ stderr, stdout = execute("keys --long")
68
+ stderr.should == ""
69
+ stdout.should == <<-STDOUT
70
+ === email@example.com Keys
71
+ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp9AJD5QABmOcrkHm6SINuQkDefaR0MUrfgZ1Pxir3a4fM1fwa00dsUwbUaRuR7FEFD8n1E9WwDf8SwQTHtyZsJg09G9myNqUzkYXCmydN7oGr5IdVhRyv5ixcdiE0hj7dRnOJg2poSQ3Qi+Ka8SVJzF7nIw1YhuicHPSbNIFKi5s0D5a+nZb/E6MNGvhxoFCQX2IcNxaJMqhzy1ESwlixz45aT72mXYq0LIxTTpoTqma1HuKdRY8HxoREiivjmMQulYP+CxXFcMyV9kxTKIUZ/FXqlC6G5vSm3J4YScSatPOj9ID5HowpdlIx8F6y4p1/28r2tTl4CY40FFyoke4MQ== pedro@heroku
72
+
73
+ STDOUT
74
+ end
75
+
76
+ end
77
+
78
+ context("remove") do
79
+
80
+ context("success") do
81
+
82
+ before(:each) do
83
+ api.post_key(KEY)
84
+ end
85
+
86
+ it "succeeds" do
87
+ stderr, stdout = execute("keys:remove pedro@heroku")
88
+ stderr.should == ""
89
+ stdout.should == <<-STDOUT
90
+ Removing pedro@heroku SSH key... done
91
+ STDOUT
92
+ end
93
+
94
+ end
95
+
96
+ it "displays an error if no key is specified" do
97
+ stderr, stdout = execute("keys:remove")
98
+ stderr.should == <<-STDERR
99
+ ! Usage: heroku keys:remove KEY
100
+ ! Must specify KEY to remove.
101
+ STDERR
102
+ stdout.should == ""
103
+ end
104
+
105
+ end
106
+
107
+ context("clear") do
108
+
109
+ it "succeeds" do
110
+ stderr, stdout = execute("keys:clear")
111
+ stderr.should == ""
112
+ stdout.should == <<-STDOUT
113
+ Removing all SSH keys... done
114
+ STDOUT
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+ end
@@ -0,0 +1,99 @@
1
+ require "spec_helper"
2
+
3
+ require "heroku/command/labs"
4
+
5
+ module Heroku::Command
6
+ describe Labs do
7
+
8
+ before(:each) do
9
+ stub_core
10
+ api.post_app("name" => "myapp", "stack" => "cedar")
11
+ end
12
+
13
+ after(:each) do
14
+ api.delete_app("myapp")
15
+ end
16
+
17
+ it "lists available features" do
18
+ stderr, stdout = execute("labs:list")
19
+ stderr.should == ""
20
+ stdout.should == <<-STDOUT
21
+ === App Available Features
22
+ sigterm-all: When stopping a dyno, send SIGTERM to all processes rather than only to the root process.
23
+ user_env_compile: Add user config vars to the environment during slug compilation
24
+
25
+ === User Available Features
26
+ sumo-rankings: Heroku Sumo ranks and visualizes the scale of your app, and suggests the optimum combination of dynos and add-ons to take it to the next level.
27
+
28
+ STDOUT
29
+ end
30
+
31
+ it "lists enabled features" do
32
+ stub_core.list_features("myapp").returns([])
33
+ stderr, stdout = execute("labs")
34
+ stderr.should == ""
35
+ stdout.should == <<-STDOUT
36
+ === myapp Enabled Features
37
+ sigterm-all: When stopping a dyno, send SIGTERM to all processes rather than only to the root process.
38
+
39
+ email@example.com has no enabled features.
40
+ STDOUT
41
+ end
42
+
43
+ it "displays details of a feature" do
44
+ stderr, stdout = execute("labs:info user_env_compile")
45
+ stderr.should == ""
46
+ stdout.should == <<-STDOUT
47
+ === user_env_compile
48
+ Docs: http://devcenter.heroku.com/articles/labs-user-env-compile
49
+ Summary: Add user config vars to the environment during slug compilation
50
+ STDOUT
51
+ end
52
+
53
+ it "shows usage if no feature name is specified for info" do
54
+ stderr, stdout = execute("labs:info")
55
+ stderr.should == <<-STDERR
56
+ ! Usage: heroku labs:info FEATURE
57
+ ! Must specify FEATURE for info.
58
+ STDERR
59
+ stdout.should == ""
60
+ end
61
+
62
+ it "enables a feature" do
63
+ stderr, stdout = execute("labs:enable user_env_compile")
64
+ stderr.should == ""
65
+ stdout.should == <<-STDOUT
66
+ Enabling user_env_compile for myapp... done
67
+ WARNING: This feature is experimental and may change or be removed without notice.
68
+ For more information see: http://devcenter.heroku.com/articles/labs-user-env-compile
69
+ STDOUT
70
+ end
71
+
72
+ it "shows usage if no feature name is specified for enable" do
73
+ stderr, stdout = execute("labs:enable")
74
+ stderr.should == <<-STDERR
75
+ ! Usage: heroku labs:enable FEATURE
76
+ ! Must specify FEATURE to enable.
77
+ STDERR
78
+ stdout.should == ""
79
+ end
80
+
81
+ it "disables a feature" do
82
+ api.post_feature('user_env_compile', 'myapp')
83
+ stderr, stdout = execute("labs:disable user_env_compile")
84
+ stderr.should == ""
85
+ stdout.should == <<-STDOUT
86
+ Disabling user_env_compile for myapp... done
87
+ STDOUT
88
+ end
89
+
90
+ it "shows usage if no feature name is specified for disable" do
91
+ stderr, stdout = execute("labs:disable")
92
+ stderr.should == <<-STDERR
93
+ ! Usage: heroku labs:disable FEATURE
94
+ ! Must specify FEATURE to disable.
95
+ STDERR
96
+ stdout.should == ""
97
+ end
98
+ end
99
+ end