webbynode 1.0.5.3 → 1.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of webbynode might be problematic. Click here for more details.
- data/.autotest +1 -0
- data/.bundle/config +2 -0
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +1 -20
- data/Gemfile.lock +43 -50
- data/Manifest +0 -1
- data/Rakefile +1 -45
- data/bin/webbynode +0 -0
- data/bin/wn +0 -0
- data/lib/webbynode/api_client.rb +35 -63
- data/lib/webbynode/command.rb +2 -1
- data/lib/webbynode/commands/accounts.rb +11 -8
- data/lib/webbynode/commands/change_dns.rb +1 -1
- data/lib/webbynode/commands/database.rb +7 -7
- data/lib/webbynode/commands/dns_aliases.rb +6 -6
- data/lib/webbynode/commands/{guides.rb → docs.rb} +3 -2
- data/lib/webbynode/commands/help.rb +3 -3
- data/lib/webbynode/commands/init.rb +16 -16
- data/lib/webbynode/commands/push.rb +7 -7
- data/lib/webbynode/commands/remote.rb +1 -1
- data/lib/webbynode/commands/settings.rb +1 -1
- data/lib/webbynode/commands/tasks.rb +3 -3
- data/lib/webbynode/commands/user.rb +5 -5
- data/lib/webbynode/commands/version.rb +1 -1
- data/lib/webbynode/commands/webbies.rb +17 -22
- data/lib/webbynode/manager2_api_client.rb +94 -0
- data/lib/webbynode/manager_api_client.rb +94 -0
- data/lib/webbynode/models/webby.rb +3 -0
- data/lib/webbynode/notify.rb +1 -1
- data/lib/webbynode/server.rb +1 -1
- data/lib/webbynode/updater.rb +28 -8
- data/lib/webbynode/version.rb +8 -0
- data/lib/webbynode.rb +5 -5
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/fixtures/manager2/webbies +11 -0
- data/spec/fixtures/manager2/webbies_unauthorized +10 -0
- data/spec/fixtures/manager2/zones +11 -0
- data/spec/fixtures/manager2/zones_a_record +11 -0
- data/spec/fixtures/manager2/zones_a_record_error +10 -0
- data/spec/fixtures/manager2/zones_new_zone +11 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/webbynode/api_client_spec.rb +15 -128
- data/spec/webbynode/command_spec.rb +6 -0
- data/spec/webbynode/commands/accounts_spec.rb +10 -4
- data/spec/webbynode/commands/apps_spec.rb +1 -0
- data/spec/webbynode/commands/database_spec.rb +4 -1
- data/spec/webbynode/commands/{guides_spec.rb → docs_spec.rb} +2 -2
- data/spec/webbynode/commands/init_spec.rb +27 -64
- data/spec/webbynode/commands/push_spec.rb +29 -15
- data/spec/webbynode/commands/remote_spec.rb +2 -0
- data/spec/webbynode/commands/version_spec.rb +1 -1
- data/spec/webbynode/commands/webbies_spec.rb +17 -2
- data/spec/webbynode/manager2_api_client_spec.rb +127 -0
- data/spec/webbynode/manager_api_client_spec.rb +136 -0
- data/webbynode.gemspec +30 -49
- metadata +297 -127
- data/PostInstall.txt +0 -45
- data/changelog.rdoc +0 -437
- data/cucumber.yml.old +0 -1
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 401 Unauthorized
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
Cache-Control: no-cache
|
5
|
+
Set-Cookie: _manager2_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTZlMmIzMmU2YjU0ZWFkYTAzMzEzNzExNzdiNTZkMjgxBjsAVA%3D%3D--c63c0ee5af07938f9c01ea6f879cec2667a67fae; path=/; HttpOnly
|
6
|
+
X-Request-Id: ff212d338f2fe110fb7498c67804e488
|
7
|
+
X-Runtime: 0.009122
|
8
|
+
Transfer-Encoding: chunked
|
9
|
+
|
10
|
+
{"error":"Invalid authentication token"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
ETag: "008c38dc8bf529335cf627ec2f9116e7"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
Set-Cookie: _manager2_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTNiZDM1NDc1OTJhYjc1ZGYxYTBkYzlhZGQ4ZTEwNGIyBjsAVEkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIJVXNlcgY7AEZbBmkCpRMw--26cedef41c3bfe0db351c6a0d9d75481bbe41f05; path=/; HttpOnly
|
7
|
+
X-Request-Id: bb9dcb0d5162114f44a121537a9cb066
|
8
|
+
X-Runtime: 0.237234
|
9
|
+
Transfer-Encoding: chunked
|
10
|
+
|
11
|
+
[{"id":18,"name":"developer.com"},{"id":20,"name":"rubyista.info"},{"id":21,"name":"webbyapp.com"}]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
ETag: "894d43b42f734d4b3cd3a49665d50340"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
Set-Cookie: _manager2_session=BAh7B0kiGXdhcmRlbi51c2VyLnVzZXIua2V5BjoGRVRbCEkiCVVzZXIGOwBGWwZpAqUTMEkiD3Nlc3Npb25faWQGOwBGSSIlZDU1ZmNiYjU0ZWUxNDdjNjM0Yjg5NDhkM2MxMTA4YjAGOwBU--6d20062fe58981c5c9ba2e9f5b72dac8052fc457; path=/; HttpOnly
|
7
|
+
X-Request-Id: 5dd616dacff6bafdd1f7adb6318fc8be
|
8
|
+
X-Runtime: 0.623106
|
9
|
+
Transfer-Encoding: chunked
|
10
|
+
|
11
|
+
{"id":32,"name":"ww3","type":"A","content":"102.10.87.111","ttl":3600,"aux":0}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 404 Not Found
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
Cache-Control: no-cache
|
5
|
+
Set-Cookie: _manager2_session=BAh7B0kiGXdhcmRlbi51c2VyLnVzZXIua2V5BjoGRVRbCEkiCVVzZXIGOwBGWwZpAqUTMEkiD3Nlc3Npb25faWQGOwBGSSIlZTRiZGVjYmM5YTk4NDUxNzMxNGYxM2I3YTFmMzNiNTIGOwBU--a889bbab4b1fd9fd4c2887e871ca5e6739760f2c; path=/; HttpOnly
|
6
|
+
X-Request-Id: 4878cb8eeca3a4395ff86ebffb30be2e
|
7
|
+
X-Runtime: 0.569462
|
8
|
+
Transfer-Encoding: chunked
|
9
|
+
|
10
|
+
{"message":"not found"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-UA-Compatible: IE=Edge
|
4
|
+
ETag: "c2f2bd693271cea091c60e9d46ccfb4b"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
Set-Cookie: _manager2_session=BAh7B0kiGXdhcmRlbi51c2VyLnVzZXIua2V5BjoGRVRbCEkiCVVzZXIGOwBGWwZpAqUTMEkiD3Nlc3Npb25faWQGOwBGSSIlYmYxYzExZDU1OWRiMjgwMWJlYjAxNzAzMDJmMTlmYTIGOwBU--a6bc9a95f4359db2c22f1a86fbb68db4445818cf; path=/; HttpOnly
|
7
|
+
X-Request-Id: 07e9ed44c58cafdd3c77b6cee1da0061
|
8
|
+
X-Runtime: 0.080832
|
9
|
+
Transfer-Encoding: chunked
|
10
|
+
|
11
|
+
{"id":22,"name":"newzone.com"}
|
data/spec/spec_helper.rb
CHANGED
@@ -4,149 +4,31 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
|
|
4
4
|
describe Webbynode::ApiClient do
|
5
5
|
let(:base_uri) { Webbynode::ApiClient.base_uri }
|
6
6
|
let(:api) { Webbynode::ApiClient.new }
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
FakeWeb.clean_registry
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#create_record" do
|
13
|
-
it "should raise an exception if the domain is inactive" do
|
14
|
-
api.should_receive(:zones).and_return({"another.com." => {:id => 21, :status => "Inactive"}})
|
15
|
-
api.should_receive(:create_zone).never
|
16
|
-
api.should_receive(:create_a_record).never
|
17
|
-
|
18
|
-
lambda { api.create_record("yes.another.com", "10.0.0.0") }.should raise_error(Webbynode::ApiClient::InactiveZone, "another.com.")
|
19
|
-
end
|
20
7
|
|
21
|
-
|
22
|
-
|
23
|
-
api.should_receive(:create_zone).with("newdomain.com.").and_return({:id => 20, :status => 'Active'})
|
24
|
-
api.should_receive(:create_a_record).with(20, "new", "212.10.20.10", "new.newdomain.com")
|
25
|
-
|
26
|
-
api.create_record("new.newdomain.com", "212.10.20.10")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should retrieve the domains, when inexistent" do
|
30
|
-
api.should_receive(:zones).and_return({"mydomain.com.br." => {:id => 21, :status => 'Active'}})
|
31
|
-
api.should_receive(:create_a_record).with(21, "new", "212.10.20.10", "new.mydomain.com.br")
|
32
|
-
|
33
|
-
api.create_record("new.mydomain.com.br", "212.10.20.10")
|
34
|
-
end
|
8
|
+
before(:all) do
|
9
|
+
Webbynode::ApiClient.send(:base_uri, "https://manager.webbynode.com/api/yaml")
|
35
10
|
end
|
36
11
|
|
37
|
-
|
38
|
-
|
39
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/dns",
|
40
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns"))
|
41
|
-
|
42
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
43
|
-
api.zones["rubyista.info."][:domain].should == "rubyista.info."
|
44
|
-
api.zones["webbyapp.com."][:domain].should == "webbyapp.com."
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#create_zone" do
|
49
|
-
it "should create a new zone and a new A record" do
|
50
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/dns",
|
51
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns"))
|
52
|
-
|
53
|
-
FakeWeb.register_uri(:post,
|
54
|
-
"#{Webbynode::ApiClient.base_uri}/dns/new?zone[ttl]=86400&zone[domain]=newzone.com.",
|
55
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns_new_zone"))
|
56
|
-
|
57
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
58
|
-
api.create_zone("newzone.com.")[:id].should == 1045
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#create_a_record" do
|
63
|
-
it "should create a new A record" do
|
64
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/dns",
|
65
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns"))
|
66
|
-
|
67
|
-
FakeWeb.register_uri(:post,
|
68
|
-
"#{Webbynode::ApiClient.base_uri}/dns/14/records/new?record[data]=200.100.200.100&record[type]=A&record[name]=xyz",
|
69
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns_a_record"))
|
70
|
-
|
71
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
72
|
-
api.create_a_record(14, "xyz", "200.100.200.100", "xyz.rubyista.info")[:id].should == 7360
|
73
|
-
end
|
74
|
-
|
75
|
-
it "raise an exception upon errors" do
|
76
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/dns",
|
77
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns"))
|
78
|
-
|
79
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/dns/14/records/new?record[data]=200.100.200.100&record[type]=A&record[name]=xyz",
|
80
|
-
:email => "fcoury@me.com", :response => read_fixture("api/dns_a_record_error"))
|
81
|
-
|
82
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
83
|
-
lambda {
|
84
|
-
api.create_a_record(14, "xyz", "200.100.200.100", "xyz.rubyista.info")
|
85
|
-
}.should raise_error(Webbynode::ApiClient::ApiError, "No DNS entry for id 99999")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "#ip_for" do
|
90
|
-
describe "when file ~/.webbynode is absent" do
|
91
|
-
it "should call init_credentials email address and API token" do
|
92
|
-
FakeWeb.register_uri(:post, "#{base_uri}/webbies",
|
93
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies"))
|
94
|
-
|
95
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
96
|
-
api.ip_for("webby3067").should == "61.21.71.31"
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should return the correct ip" do
|
100
|
-
FakeWeb.register_uri(:post, "#{base_uri}/webbies",
|
101
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies"))
|
102
|
-
|
103
|
-
api.should_receive(:init_credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
104
|
-
api.ip_for("sandbox").should == "201.81.121.201"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "when file ~/.webbynode is present" do
|
109
|
-
before do
|
110
|
-
FakeWeb.register_uri(:post, "#{base_uri}/webbies",
|
111
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies"))
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should return the IP for existing Webby hostname" do
|
115
|
-
api.should_receive(:credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
116
|
-
api.ip_for("sandbox").should == "201.81.121.201"
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should show an error message if the Webby does not exist for the user" do
|
120
|
-
api.should_receive(:credentials).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
121
|
-
api.ip_for("this_doesnt_exist").nil?.should == true
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "when unauthorized" do
|
127
|
-
it "should raise an error" do
|
128
|
-
FakeWeb.register_uri(:post, "#{base_uri}/webbies",
|
129
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies_unauthorized"))
|
130
|
-
|
131
|
-
api = Webbynode::ApiClient.new
|
132
|
-
api.should_receive(:credentials).and_return({:email => "fcoury@me.com"})
|
133
|
-
lambda { api.ip_for("sandbox") }.should raise_error(Webbynode::ApiClient::Unauthorized, "You have provided the wrong credentials")
|
134
|
-
end
|
12
|
+
before(:each) do
|
13
|
+
FakeWeb.clean_registry
|
135
14
|
end
|
136
15
|
|
137
16
|
describe "#init_credentials" do
|
138
17
|
let(:io) { double("Io") }
|
18
|
+
let(:post_result) { stub(:post_result).as_null_object }
|
139
19
|
|
140
20
|
before(:each) do
|
141
21
|
api.should_receive(:io).any_number_of_times.and_return(io)
|
22
|
+
# Webbynode::ApiClient.stub(:post => post_result)
|
142
23
|
end
|
143
24
|
|
144
25
|
context "when credentials file exists" do
|
145
26
|
it "should read the credentials" do
|
146
27
|
io.should_receive(:file_exists?).with("#{ENV['HOME']}/.webbynode").and_return(true)
|
147
|
-
api.should_receive(:properties).and_return({:email => "fcoury@me.com", :token => "apitoken"})
|
28
|
+
api.should_receive(:properties).and_return({:email => "fcoury@me.com", :token => "apitoken", :system => 'manager'})
|
148
29
|
|
149
30
|
creds = api.init_credentials
|
31
|
+
creds[:system].should == "manager"
|
150
32
|
creds[:email].should == "fcoury@me.com"
|
151
33
|
creds[:token].should == "apitoken"
|
152
34
|
end
|
@@ -162,12 +44,14 @@ describe Webbynode::ApiClient do
|
|
162
44
|
io.should_receive(:read_from_template)
|
163
45
|
api.should_receive(:properties).any_number_of_times.and_return(properties)
|
164
46
|
|
47
|
+
api.should_receive(:ask).once.ordered.and_return("manager")
|
165
48
|
api.should_receive(:ask).with("Login email: ").once.ordered.and_return("login@email.com")
|
166
49
|
api.should_receive(:ask).with("API token: ").once.ordered.and_return("apitoken")
|
167
50
|
|
168
51
|
io.stub(:log)
|
169
52
|
|
170
53
|
creds = api.init_credentials(true)
|
54
|
+
creds[:system].should == "manager"
|
171
55
|
creds[:email].should == "login@email.com"
|
172
56
|
creds[:token].should == "apitoken"
|
173
57
|
end
|
@@ -184,7 +68,8 @@ describe Webbynode::ApiClient do
|
|
184
68
|
|
185
69
|
api.should_receive(:ask).never
|
186
70
|
|
187
|
-
creds = api.init_credentials({ :email => 'login@email.com', :token => 'apitoken' })
|
71
|
+
creds = api.init_credentials({ :email => 'login@email.com', :token => 'apitoken', :system => 'manager' })
|
72
|
+
creds[:system].should == "manager"
|
188
73
|
creds[:email].should == "login@email.com"
|
189
74
|
creds[:token].should == "apitoken"
|
190
75
|
end
|
@@ -202,6 +87,7 @@ describe Webbynode::ApiClient do
|
|
202
87
|
io.should_receive(:read_from_template)
|
203
88
|
api.should_receive(:properties).any_number_of_times.and_return(properties)
|
204
89
|
|
90
|
+
api.should_receive(:ask).once.ordered.and_return("manager")
|
205
91
|
api.should_receive(:ask).with("Login email: ").once.ordered.and_return("login@email.com")
|
206
92
|
api.should_receive(:ask).with("API token: ").once.ordered.and_return("apitoken")
|
207
93
|
|
@@ -221,11 +107,12 @@ describe Webbynode::ApiClient do
|
|
221
107
|
io.should_receive(:read_from_template)
|
222
108
|
api.should_receive(:properties).any_number_of_times.and_return(properties)
|
223
109
|
|
110
|
+
api.should_receive(:ask).once.ordered.and_return("manager")
|
224
111
|
api.should_receive(:ask).with("Login email: ").once.ordered.and_return("login@email.com")
|
225
112
|
api.should_receive(:ask).with("API token: ").once.ordered.and_return("apitoken")
|
226
113
|
|
227
114
|
io.stub(:log)
|
228
|
-
|
115
|
+
|
229
116
|
lambda { api.init_credentials }.should raise_error(Webbynode::ApiClient::Unauthorized, "You have provided the wrong credentials")
|
230
117
|
end
|
231
118
|
end
|
@@ -53,6 +53,10 @@ describe Webbynode::Command do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
context "when git is missing" do
|
56
|
+
before do
|
57
|
+
Webbynode::ApiClient.stub(:instance)
|
58
|
+
end
|
59
|
+
|
56
60
|
it "should provide a friendly error" do
|
57
61
|
git.should_receive(:present?).and_return(false)
|
58
62
|
|
@@ -214,6 +218,8 @@ describe Webbynode::Command do
|
|
214
218
|
raise Webbynode::ApiClient::Unauthorized
|
215
219
|
end
|
216
220
|
end
|
221
|
+
|
222
|
+
before { Webbynode::ApiClient.stub(:instance) }
|
217
223
|
|
218
224
|
it "should output a friendly message" do
|
219
225
|
cmd = UnauthorizedCommand.new
|
@@ -17,12 +17,18 @@ describe Webbynode::Commands::Accounts do
|
|
17
17
|
subject { prepare "list" }
|
18
18
|
|
19
19
|
it "shows all available accounts" do
|
20
|
-
api.
|
21
|
-
io.
|
22
|
-
io.
|
23
|
-
io.
|
20
|
+
api.stub(:credentials => {"email" => "fcoury@me.com", "token" => "apitoken", "system" => "manager"})
|
21
|
+
io.stub(:list_files).with("#{dir}/.webbynode_*").and_return(["#{dir}/.webbynode_personal", "#{dir}/.webbynode_biz", "#{dir}/.webbynode_other"])
|
22
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_personal", /email=fcoury@me.com/).and_return(true)
|
23
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_personal", /system=manager$/).and_return(true)
|
24
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_other", /email=fcoury@me.com/).and_return(true)
|
25
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_other", /system=manager$/).and_return(false)
|
26
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_biz", /email=fcoury@me.com/).and_return(false)
|
27
|
+
io.stub(:file_matches).with("#{dir}/.webbynode_biz", /system=manager$/).and_return(false)
|
28
|
+
|
24
29
|
io.should_receive(:log).with("* personal")
|
25
30
|
io.should_receive(:log).with(" biz")
|
31
|
+
io.should_receive(:log).with(" other")
|
26
32
|
subject.execute
|
27
33
|
end
|
28
34
|
|
@@ -99,6 +99,7 @@ describe Webbynode::Commands::Database do
|
|
99
99
|
|
100
100
|
it "asks the local database credentials and name" do
|
101
101
|
io.should_receive(:load_setting).with("database_name").and_return(nil)
|
102
|
+
io.should_receive(:load_setting).with("database_user").and_return(nil)
|
102
103
|
io.should_receive(:load_setting).with("database_password").and_return(nil)
|
103
104
|
|
104
105
|
io.should_receive(:db_name).any_number_of_times.and_return("myapp")
|
@@ -114,6 +115,7 @@ describe Webbynode::Commands::Database do
|
|
114
115
|
context "when user doesn't authorize" do
|
115
116
|
it "stores all data but password" do
|
116
117
|
io.should_receive(:load_setting).with("database_name").and_return(nil)
|
118
|
+
io.should_receive(:load_setting).with("database_user").and_return(nil)
|
117
119
|
io.should_receive(:load_setting).with("database_password").and_return(nil)
|
118
120
|
|
119
121
|
io.should_receive(:db_name).any_number_of_times.and_return("myapp")
|
@@ -134,9 +136,10 @@ describe Webbynode::Commands::Database do
|
|
134
136
|
context "when user authorizes" do
|
135
137
|
it "stores the password" do
|
136
138
|
io.should_receive(:load_setting).with("database_name").and_return(nil)
|
139
|
+
io.should_receive(:load_setting).with("database_user").and_return(nil)
|
137
140
|
io.should_receive(:load_setting).with("database_password").and_return(nil)
|
138
141
|
|
139
|
-
io.
|
142
|
+
io.stub(:db_name).any_number_of_times.and_return("myapp")
|
140
143
|
|
141
144
|
subject.should_receive(:ask).with("Database name [myapp]: ").and_return("")
|
142
145
|
subject.should_receive(:ask).with(" User name [myapp]: ").and_return("user")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Load Spec Helper
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
3
|
|
4
|
-
describe Webbynode::Commands::
|
5
|
-
it "opens
|
4
|
+
describe Webbynode::Commands::Docs do
|
5
|
+
it "opens docs in browser" do
|
6
6
|
Launchy.should_receive(:open).with('http://wbno.de/rapp')
|
7
7
|
subject.execute
|
8
8
|
end
|
@@ -7,6 +7,7 @@ describe Webbynode::Commands::Init do
|
|
7
7
|
let(:gemfile) { double("gemfile").as_null_object.tap { |g| g.stub!(:present?).and_return(false) } }
|
8
8
|
let(:api) { double("api").as_null_object }
|
9
9
|
let(:pushand) { stub.as_null_object }
|
10
|
+
let(:instance) { stub(:instance).as_null_object }
|
10
11
|
|
11
12
|
def create_init(ip="4.3.2.1", host=nil, extra=[])
|
12
13
|
host = "--dns=#{host}" if host
|
@@ -24,20 +25,27 @@ describe Webbynode::Commands::Init do
|
|
24
25
|
FakeWeb.clean_registry
|
25
26
|
create_init
|
26
27
|
git_handler.stub!(:remote_exists?).and_return(false)
|
28
|
+
Webbynode::ApiClient.stub(:system => "manager")
|
29
|
+
Webbynode::ApiClient.stub(:instance => instance)
|
30
|
+
end
|
31
|
+
|
32
|
+
def make_webby(hash)
|
33
|
+
webby = Webbynode::Webby.new
|
34
|
+
hash.each_pair { |k,v| webby.send("#{k}=", v) }
|
35
|
+
webby
|
27
36
|
end
|
28
37
|
|
29
38
|
subject do
|
30
39
|
Webbynode::Commands::Init.new.tap do |cmd|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
40
|
+
webby = Webbynode::Webby.new
|
41
|
+
webby.ip = "201.81.121.201"
|
42
|
+
webby.status = "on"
|
43
|
+
webby.name = "sandbox"
|
44
|
+
webby.plan = "Webbybeta"
|
45
|
+
webby.node = "miami-b15"
|
46
|
+
|
47
|
+
webbies = { 'sandbox' => webby }
|
48
|
+
|
41
49
|
api.stub!(:webbies).and_return(webbies)
|
42
50
|
|
43
51
|
cmd.stub!(:git).and_return(git_handler)
|
@@ -82,7 +90,7 @@ describe Webbynode::Commands::Init do
|
|
82
90
|
it "asks for trial username when not found" do
|
83
91
|
io_handler.should_receive(:general_settings).and_return({})
|
84
92
|
io_handler.should_receive(:app_name).and_return('trial_app')
|
85
|
-
subject.should_receive(:ask).with('Enter your
|
93
|
+
subject.should_receive(:ask).with('Enter your Webbynode trial user: ').and_return('user')
|
86
94
|
io_handler.should_receive(:add_general_setting).with('rapp_username', 'user')
|
87
95
|
git_handler.should_receive(:add_remote).with('user', 'webbynode', 'trial.webbyapp.com', 'trial_app', :home => '/home/user')
|
88
96
|
|
@@ -238,14 +246,13 @@ describe Webbynode::Commands::Init do
|
|
238
246
|
subject do
|
239
247
|
Webbynode::Commands::Init.new("--engine=php").tap do |cmd|
|
240
248
|
webbies = {
|
241
|
-
'sandbox' => {
|
249
|
+
'sandbox' => make_webby({
|
242
250
|
"ip" => "201.81.121.201",
|
243
251
|
"status" => "on",
|
244
252
|
"name" => "sandbox",
|
245
|
-
"notes" => "",
|
246
253
|
"plan" => "Webbybeta",
|
247
254
|
"node" => "miami-b15"
|
248
|
-
}
|
255
|
+
})
|
249
256
|
}
|
250
257
|
api.stub!(:webbies).and_return(webbies)
|
251
258
|
|
@@ -319,30 +326,27 @@ describe Webbynode::Commands::Init do
|
|
319
326
|
|
320
327
|
it "complains if missing and user has > 1 webby" do
|
321
328
|
webbies = {
|
322
|
-
'webby3' => {
|
329
|
+
'webby3' => make_webby({
|
323
330
|
"ip" => "67.53.31.3",
|
324
331
|
"status" => "on",
|
325
332
|
"name" => "webby3",
|
326
|
-
"notes" => "",
|
327
333
|
"plan" => "Webbybeta",
|
328
334
|
"node" => "miami-b11"
|
329
|
-
},
|
330
|
-
'sandbox' => {
|
335
|
+
}),
|
336
|
+
'sandbox' => make_webby({
|
331
337
|
"ip" => "201.81.121.201",
|
332
338
|
"status" => "on",
|
333
339
|
"name" => "sandbox",
|
334
|
-
"notes" => "",
|
335
340
|
"plan" => "Webbybeta",
|
336
341
|
"node" => "miami-b15"
|
337
|
-
},
|
338
|
-
'webby2' => {
|
342
|
+
}),
|
343
|
+
'webby2' => make_webby({
|
339
344
|
"ip" => "67.53.31.2",
|
340
345
|
"status" => "on",
|
341
346
|
"name" => "webby2",
|
342
|
-
"notes" => "",
|
343
347
|
"plan" => "Webbybeta",
|
344
348
|
"node" => "miami-b11"
|
345
|
-
}
|
349
|
+
})
|
346
350
|
}
|
347
351
|
api.should_receive(:webbies).and_return(webbies)
|
348
352
|
io_handler.should_receive(:log).with("Current Webbies in your account:")
|
@@ -519,47 +523,6 @@ describe Webbynode::Commands::Init do
|
|
519
523
|
end
|
520
524
|
end
|
521
525
|
|
522
|
-
it "should ask for user's login email if no credentials" do
|
523
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/webbies",
|
524
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies"))
|
525
|
-
|
526
|
-
io_handler.should_receive(:file_exists?).with(Webbynode::ApiClient::CREDENTIALS_FILE).and_return(false)
|
527
|
-
io_handler.should_receive(:app_name).any_number_of_times.and_return("my_app")
|
528
|
-
|
529
|
-
props = {}
|
530
|
-
props.stub(:save)
|
531
|
-
|
532
|
-
create_init("my_webby_name")
|
533
|
-
@command.stub!(:detect_engine).and_return(Webbynode::Engines::Rails)
|
534
|
-
@command.api.should_receive(:io).any_number_of_times.and_return(io_handler)
|
535
|
-
@command.api.should_receive(:ask).with("API token: ").and_return("234def")
|
536
|
-
@command.api.should_receive(:ask).with("Login email: ").and_return("abc123")
|
537
|
-
@command.api.should_receive(:properties).any_number_of_times.and_return(props)
|
538
|
-
api.stub(:puts)
|
539
|
-
@command.run
|
540
|
-
|
541
|
-
stdout.should =~ /Couldn't find Webby 'my_webby_name' on your account. Your Webbies are/
|
542
|
-
stdout.should =~ /'webby3067'/
|
543
|
-
stdout.should =~ /' and '/
|
544
|
-
stdout.should =~ /'sandbox'/
|
545
|
-
end
|
546
|
-
|
547
|
-
it "should report the error if user provides wrong credentials" do
|
548
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/webbies",
|
549
|
-
:email => "fcoury@me.com", :response => read_fixture("api/webbies_unauthorized"))
|
550
|
-
|
551
|
-
io_handler.should_receive(:app_name).any_number_of_times.and_return("my_app")
|
552
|
-
io_handler.should_receive(:create_file).never
|
553
|
-
|
554
|
-
create_init("my_webby_name")
|
555
|
-
|
556
|
-
@command.api.should_receive(:ip_for).and_raise(Webbynode::ApiClient::Unauthorized)
|
557
|
-
@command.stub!(:detect_engine).and_return(Webbynode::Engines::Rails)
|
558
|
-
@command.run
|
559
|
-
|
560
|
-
stdout.should =~ /Your credentials didn't match any Webbynode account./
|
561
|
-
end
|
562
|
-
|
563
526
|
it "should report Webby doesn't exist" do
|
564
527
|
api = double("ApiClient")
|
565
528
|
api.should_receive(:ip_for).with("my_webby_name").and_return(nil)
|
@@ -16,6 +16,7 @@ describe Webbynode::Commands::Push do
|
|
16
16
|
push.should_receive(:git).any_number_of_times.and_return(git)
|
17
17
|
push.before_tasks.stub!(:read_tasks)
|
18
18
|
push.after_tasks.stub!(:read_tasks)
|
19
|
+
Webbynode::ApiClient.stub(:system => "manager")
|
19
20
|
end
|
20
21
|
|
21
22
|
subject do
|
@@ -30,22 +31,35 @@ describe Webbynode::Commands::Push do
|
|
30
31
|
end
|
31
32
|
|
32
33
|
context "before pushing" do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
context "with manager 2" do
|
35
|
+
it "doesn't check for updates" do
|
36
|
+
Webbynode::ApiClient.stub(:system => "manager2")
|
37
|
+
re.should_receive(:exec).with(/update_rapp/).never
|
38
|
+
subject.before_tasks.should_receive(:ensure_tasks_folder)
|
39
|
+
subject.before_tasks.should_receive(:read_tasks)
|
40
|
+
subject.execute
|
41
|
+
end
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
context "with manager" do
|
45
|
+
it "checks for update_rapp script remotely" do
|
46
|
+
Webbynode::ApiClient.stub(:system => "manager")
|
47
|
+
re.should_receive(:exec).with(<<-EOS, false, true)
|
48
|
+
if [ ! -f /var/webbynode/update_rapp ]; then
|
49
|
+
cd /var/webbynode
|
50
|
+
wget http://repo.webbynode.com/rapidapps/update_rapp
|
51
|
+
chmod +x update_rapp
|
52
|
+
ln -s -f /var/webbynode/update_rapp /usr/bin/update_rapp
|
53
|
+
fi
|
54
|
+
|
55
|
+
/var/webbynode/update_rapp
|
56
|
+
if [ $? -eq 1 ]; then exit 1; fi
|
57
|
+
EOS
|
58
|
+
|
59
|
+
subject.before_tasks.should_receive(:ensure_tasks_folder)
|
60
|
+
subject.before_tasks.should_receive(:read_tasks)
|
61
|
+
subject.execute
|
62
|
+
end
|
49
63
|
end
|
50
64
|
end
|
51
65
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
3
|
|
4
4
|
describe Webbynode::Commands::Remote do
|
5
|
+
let(:instance) { stub(:instance) }
|
5
6
|
|
6
7
|
def load_all_mocks(rem=remote)
|
7
8
|
rem.should_receive(:remote_executor).any_number_of_times.and_return(re)
|
@@ -9,6 +10,7 @@ describe Webbynode::Commands::Remote do
|
|
9
10
|
rem.should_receive(:io).any_number_of_times.and_return(io)
|
10
11
|
rem.should_receive(:pushand).any_number_of_times.and_return(pushand)
|
11
12
|
rem.should_receive(:server).any_number_of_times.and_return(server)
|
13
|
+
Webbynode::ApiClient.stub(:instance => instance)
|
12
14
|
end
|
13
15
|
|
14
16
|
let(:re) { double("RemoteExecutor").as_null_object }
|
@@ -11,7 +11,7 @@ describe Webbynode::Commands::Version do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return the version of the gem" do
|
14
|
-
io.should_receive(:log).with("Rapid Deployment Gem v#{Webbynode::
|
14
|
+
io.should_receive(:log).with("Rapid Deployment Gem v#{Webbynode::Version::STRING}")
|
15
15
|
version.execute
|
16
16
|
end
|
17
17
|
|
@@ -7,12 +7,27 @@ describe Webbynode::Commands::Webbies do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should provide a list with all the Webbies and its status" do
|
10
|
-
FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/webbies",
|
11
|
-
|
10
|
+
# FakeWeb.register_uri(:post, "#{Webbynode::ApiClient.base_uri}/webbies",
|
11
|
+
# :email => "fcoury@me.com", :response => read_fixture("api/webbies"))
|
12
12
|
|
13
|
+
webby1 = Webbynode::Webby.new
|
14
|
+
webby1.name = "sandbox"
|
15
|
+
webby1.ip = "201.81.121.201"
|
16
|
+
webby1.node = "miami-b15"
|
17
|
+
webby1.plan = "plan1"
|
18
|
+
webby1.status = "on"
|
19
|
+
|
20
|
+
webby2 = Webbynode::Webby.new
|
21
|
+
webby2.name = "webby3067"
|
22
|
+
webby2.ip = "61.21.71.31"
|
23
|
+
webby2.node = "miami-b02"
|
24
|
+
webby2.plan = "plan2"
|
25
|
+
webby2.status = "off"
|
26
|
+
|
13
27
|
api = Webbynode::ApiClient.new
|
14
28
|
api.stub(:properties)
|
15
29
|
api.stub(:credentials)
|
30
|
+
api.stub(:webbies => { "sandbox" => webby1, "webby3067" => webby2 })
|
16
31
|
|
17
32
|
cmd = Webbynode::Commands::Webbies.new
|
18
33
|
cmd.should_receive(:api).and_return(api)
|