rumm 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +11 -3
- data/app.rb +13 -0
- data/app/controllers/authentication_controller.rb +12 -11
- data/app/controllers/railsifications_controller.rb +24 -21
- data/app/controllers/servers_controller.rb +14 -4
- data/app/controllers/users_controller.rb +15 -0
- data/app/forms/servers/update_form.rb +7 -0
- data/app/forms/volumes/create_form.rb +1 -2
- data/app/help/create_container.txt +0 -1
- data/app/help/create_dbinstance.txt +1 -1
- data/app/help/create_server.txt +1 -1
- data/app/help/destroy_node_on_loadbalancer.txt +1 -1
- data/app/help/railsify_server.txt +1 -1
- data/app/help/show_attachment_on_server.txt +4 -4
- data/app/help/show_server.txt +1 -1
- data/app/help/update_server.txt +19 -0
- data/app/providers/configuration_provider.rb +118 -0
- data/app/providers/credentials_provider.rb +4 -4
- data/app/providers/login_information_provider.rb +34 -0
- data/app/providers/users_provider.rb +13 -0
- data/app/routes.rb +1 -0
- data/app/views/authentication/login.txt.erb +1 -1
- data/app/views/help/show.txt.erb +1 -1
- data/app/views/servers/update.txt.erb +1 -0
- data/app/views/users/create.txt.erb +1 -1
- data/app/views/users/destroy.txt.erb +1 -0
- data/app/views/users/show.txt.erb +1 -0
- data/lib/rumm/exceptions.rb +5 -0
- data/lib/rumm/version.rb +1 -1
- data/rumm.gemspec +1 -2
- data/spec/features/attachments_spec.rb +1 -1
- data/spec/features/configuration_spec.rb +143 -0
- data/spec/features/containers_spec.rb +1 -1
- data/spec/features/databases_spec.rb +1 -1
- data/spec/features/dbinstances_spec.rb +1 -1
- data/spec/features/files_spec.rb +1 -1
- data/spec/features/help_spec.rb +1 -1
- data/spec/features/loadbalancers_spec.rb +1 -1
- data/spec/features/login_spec.rb +47 -33
- data/spec/features/nodes_spec.rb +1 -1
- data/spec/features/servers_spec.rb +1 -1
- data/spec/features/users_spec.rb +28 -0
- data/spec/features/volumes_spec.rb +1 -1
- data/spec/fixtures/cassettes/authentication/successful-login.yml +9 -5
- data/spec/fixtures/cassettes/authentication/unsuccessful-login.yml +5 -3
- data/spec/fixtures/cassettes/users/create.yml +122 -0
- data/spec/fixtures/cassettes/users/destroy.yml +200 -0
- data/spec/fixtures/cassettes/users/show-all.yml +122 -0
- data/spec/fixtures/cassettes/users/show.yml +165 -0
- data/spec/spec_helper.rb +19 -11
- metadata +25 -19
- data/app/providers/user_provider.rb +0 -23
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'netrc'
|
2
|
-
|
3
1
|
class CredentialsProvider
|
2
|
+
|
3
|
+
requires :configuration
|
4
4
|
|
5
5
|
def value
|
6
|
-
if
|
7
|
-
Map(username:
|
6
|
+
if configuration.username
|
7
|
+
Map(username: configuration.username, api_key: configuration.api_key, rackspace_region: configuration.region)
|
8
8
|
else
|
9
9
|
fail Rumm::LoginRequired, "login required"
|
10
10
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
|
3
|
+
class LoginInformationProvider
|
4
|
+
requires :command
|
5
|
+
requires :configuration
|
6
|
+
|
7
|
+
def value
|
8
|
+
name = get_name
|
9
|
+
password = get_password
|
10
|
+
region = get_default_region
|
11
|
+
Map name: name, password: password, region: region
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_name
|
17
|
+
command.output.print "Username: "
|
18
|
+
command.input.gets.chomp
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_password
|
22
|
+
command.output.print "Password: "
|
23
|
+
password = command.input.noecho(&:gets).chomp
|
24
|
+
command.output.print "\n"
|
25
|
+
password
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_default_region
|
29
|
+
command.output.print "Default Region (Enter for #{configuration.region}): "
|
30
|
+
region = command.input.gets.chomp
|
31
|
+
region.empty? ? configuration.region : region
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fog'
|
2
|
+
class UsersProvider
|
3
|
+
requires :credentials
|
4
|
+
|
5
|
+
def value
|
6
|
+
options = {
|
7
|
+
:rackspace_username => credentials.username,
|
8
|
+
:rackspace_api_key => credentials.api_key,
|
9
|
+
:rackspace_region => credentials.rackspace_region
|
10
|
+
}
|
11
|
+
Fog::Rackspace::Databases.new(options).users
|
12
|
+
end
|
13
|
+
end
|
data/app/routes.rb
CHANGED
@@ -44,6 +44,7 @@ match 'destroy database :id on dbinstance :instance_id' => 'databases#destroy'
|
|
44
44
|
match 'show users on dbinstance :dbinstance_id' => 'users#index'
|
45
45
|
match 'show user :id on dbinstance :dbinstance_id' => 'users#show'
|
46
46
|
match 'create user on dbinstance :dbinstance_id' => 'users#create'
|
47
|
+
match 'destroy user :id on dbinstance :dbinstance_id' => 'users#destroy'
|
47
48
|
|
48
49
|
match 'ssh :id' => 'servers#ssh'
|
49
50
|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
logged in as <%= this.access.user.name %>, credentials written to ~/.
|
2
|
+
logged in as <%= this.access.user.name %>, credentials written to ~/.rummrc
|
data/app/views/help/show.txt.erb
CHANGED
@@ -6,7 +6,7 @@ Rumm: A tasty tool for hackers and pirates
|
|
6
6
|
rumm login
|
7
7
|
Username: rsteveson
|
8
8
|
Password: ******
|
9
|
-
logged in as rstevenson, credentials written to ~/.
|
9
|
+
logged in as rstevenson, credentials written to ~/.rummrc
|
10
10
|
|
11
11
|
And you're good to go! For a list of all commands, run:
|
12
12
|
|
@@ -0,0 +1 @@
|
|
1
|
+
Sent update request to server.
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Created user <%= this.name %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Requested destruction of user
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= this.name %>, databases: <% this.databases.each do |database| %> <%= database["name"] %> <% end %>
|
data/lib/rumm/version.rb
CHANGED
data/rumm.gemspec
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe "using the attachments api" do
|
4
4
|
context "with credentials are present" do
|
5
5
|
|
6
|
-
include_context "
|
6
|
+
include_context "rummrc"
|
7
7
|
|
8
8
|
context "to create" do
|
9
9
|
When { VCR.use_cassette('attachments/create') { run "rumm create attachment on server silly-saffron --volume jumping-jellybean" }}
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "configuration_provider"
|
3
|
+
|
4
|
+
describe "configuration" do
|
5
|
+
|
6
|
+
describe "defaults" do
|
7
|
+
context "should be initialized with defaults" do
|
8
|
+
include_context "set fake home"
|
9
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
10
|
+
Then { configuration.region.should == 'ord' }
|
11
|
+
And { configuration.username.should == nil }
|
12
|
+
And { configuration.api_key.should == nil}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Configuration file present" do
|
17
|
+
include_context "set home"
|
18
|
+
When do
|
19
|
+
File.open("#{home}/.rummrc", 'w') do |f|
|
20
|
+
f.puts "{\"environments\":{\"default\":{\"region\":\"dfw\",\"username\":\"racker\",\"api_key\":\"1234\"}}}"
|
21
|
+
end
|
22
|
+
configuration.reload
|
23
|
+
end
|
24
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
25
|
+
context "should be initialized with .rummrc file if present" do
|
26
|
+
Then { configuration.region.should == "dfw" }
|
27
|
+
And { configuration.username.should == 'racker' }
|
28
|
+
And { configuration.api_key.should == '1234' }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Cleanup
|
32
|
+
# File.delete "#{@rumm_dir}/.rummrc" if File.exists? "#{@rumm_dir}/.rummrc"
|
33
|
+
describe "region" do
|
34
|
+
When { ENV['REGION'] = "SYD" }
|
35
|
+
context "should be overridable with REGION environment var" do
|
36
|
+
Then { configuration.region.should == "syd" }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#Clean up
|
41
|
+
|
42
|
+
describe "lon_region?" do
|
43
|
+
When { ENV['REGION'] = nil }
|
44
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
45
|
+
When { configuration.region = region }
|
46
|
+
|
47
|
+
context "when set with lon" do
|
48
|
+
Given (:region) { "lon" }
|
49
|
+
Then { configuration.lon_region? }
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when set with LON" do
|
53
|
+
Given (:region) { "LON" }
|
54
|
+
Then { configuration.lon_region? }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when set with :lon" do
|
58
|
+
Given (:region) { :lon }
|
59
|
+
Then { configuration.lon_region? }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when set as nil" do
|
63
|
+
Given (:region) { "nil" }
|
64
|
+
Then { !configuration.lon_region? }
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when set as dfw" do
|
68
|
+
Given (:region) { "nil" }
|
69
|
+
Then { !configuration.lon_region? }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "auth_endpoint" do
|
74
|
+
Given (:configuration) { ConfigurationProvider.new.value }
|
75
|
+
When { configuration.region = region }
|
76
|
+
|
77
|
+
context "when set as :lon" do
|
78
|
+
Given (:region) { :lon }
|
79
|
+
Then { configuration.auth_endpoint.should == Fog::Rackspace::UK_AUTH_ENDPOINT }
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when set as :syd" do
|
83
|
+
Given (:region) { :syd }
|
84
|
+
Then { configuration.auth_endpoint.should == Fog::Rackspace::US_AUTH_ENDPOINT }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "reload" do
|
89
|
+
context "should reload configuration if config file is present" do
|
90
|
+
Given(:configuration) do
|
91
|
+
ConfigurationProvider.new.value
|
92
|
+
end
|
93
|
+
Given { ENV['REGION'] = nil }
|
94
|
+
|
95
|
+
When do
|
96
|
+
configuration.username = "unclebob"
|
97
|
+
configuration.reload.should be_true
|
98
|
+
end
|
99
|
+
Then { configuration.username.should == "racker" }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
describe "delete" do
|
103
|
+
context "should delete file if it exists and revert to default configuration" do
|
104
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
105
|
+
Given { File.should_receive(:delete).with "#{File.expand_path(current_dir)}/.rummrc" }
|
106
|
+
When { configuration.delete }
|
107
|
+
Then { configuration.region.should == 'ord' }
|
108
|
+
And { configuration.username.should == nil }
|
109
|
+
And { configuration.api_key.should == nil }
|
110
|
+
end
|
111
|
+
context "should not delete file if it does not exist" do
|
112
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
113
|
+
Given { File.stub(:exists?).with("#{File.expand_path(current_dir)}/.rummrc").and_return(false)}
|
114
|
+
Given { File.stub(:delete).never }
|
115
|
+
When { configuration.delete.should be_true }
|
116
|
+
Then { configuration.region.should == 'ord' }
|
117
|
+
And { configuration.username.should == nil }
|
118
|
+
And { configuration.api_key.should == nil }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
describe "save" do
|
122
|
+
context "should save the configuration" do
|
123
|
+
Given(:configuration) { ConfigurationProvider.new.value }
|
124
|
+
Given { JSON.stub :dump }
|
125
|
+
Then { configuration.save.should be_true }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "should not reload values if configuration file does not exist" do
|
131
|
+
include_context "set fake home"
|
132
|
+
|
133
|
+
Given(:configuration) do
|
134
|
+
ConfigurationProvider.new.value
|
135
|
+
end
|
136
|
+
When do
|
137
|
+
configuration.username = "unclebob"
|
138
|
+
configuration.reload.should be_false
|
139
|
+
end
|
140
|
+
|
141
|
+
Then { configuration.username.should == "unclebob" }
|
142
|
+
end
|
143
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "using the databases api" do
|
4
|
-
include_context "
|
4
|
+
include_context "rummrc"
|
5
5
|
|
6
6
|
context "to create" do
|
7
7
|
When { VCR.use_cassette('databases/create') { run "rumm create database on dbinstance decided-irony --name dancing-bear" }}
|
data/spec/features/files_spec.rb
CHANGED
data/spec/features/help_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe "interactive learning" do
|
|
14
14
|
# rumm login
|
15
15
|
# Username: rsteveson
|
16
16
|
# Password: ******
|
17
|
-
# logged in as rstevenson, credentials written to ~/.
|
17
|
+
# logged in as rstevenson, credentials written to ~/.rummrc
|
18
18
|
#
|
19
19
|
# And you're good to go! The following commands are available in your Rumm
|
20
20
|
# environment:
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "using the load balancers api" do
|
4
4
|
|
5
|
-
include_context "
|
5
|
+
include_context "rummrc"
|
6
6
|
|
7
7
|
context "to create" do
|
8
8
|
When { VCR.use_cassette('loadbalancers/create') { run "rumm create loadbalancer --name likable-bear --node 166.78.114.25:80" }}
|
data/spec/features/login_spec.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "netrc"
|
3
2
|
require 'io/console'
|
4
3
|
|
5
4
|
describe "logging in" do
|
6
|
-
include_context "netrc"
|
7
5
|
before do
|
8
6
|
run "rumm logout"
|
9
7
|
end
|
10
|
-
|
8
|
+
|
9
|
+
context "with valid credentials" do
|
10
|
+
Given(:region) { "ord"}
|
11
|
+
|
11
12
|
When do
|
13
|
+
run "rumm logout"
|
12
14
|
VCR.use_cassette('authentication/successful-login') do
|
13
15
|
if VCR.current_cassette.recording?
|
14
16
|
print "\nUsername: "
|
@@ -16,46 +18,58 @@ describe "logging in" do
|
|
16
18
|
print "Password: "
|
17
19
|
password = $stdin.noecho(&:gets).chomp
|
18
20
|
end
|
19
|
-
|
20
|
-
will_type
|
21
|
+
@username = username || "<username>"
|
22
|
+
will_type(@username)
|
23
|
+
will_type(password || "<password>")
|
24
|
+
will_type region
|
21
25
|
run_interactive "rumm login"
|
22
26
|
stop_process @interactive
|
23
27
|
end
|
24
28
|
end
|
25
|
-
Then {last_exit_status == 0}
|
26
29
|
|
27
|
-
|
28
|
-
Given(:netrc) { Netrc.read["api.rackspace.com"] }
|
29
|
-
Given(:user) {netrc.first}
|
30
|
-
Given(:password) {netrc.last}
|
30
|
+
Then { last_exit_status == 0 }
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
32
|
+
Given(:config_file_path) {
|
33
|
+
File.expand_path("~/.rummrc")
|
34
|
+
}
|
36
35
|
|
37
|
-
|
38
|
-
When {run "rumm logout"}
|
39
|
-
Then {last_exit_status == 0}
|
36
|
+
Then { File.exists?(config_file_path) }
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
user, pass = n["api.rackspace.com"]
|
45
|
-
user == nil and pass == nil
|
38
|
+
Given(:json) {
|
39
|
+
File.open(config_file_path) do |f|
|
40
|
+
JSON.load(f)["environments"]["default"]
|
46
41
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
}
|
43
|
+
|
44
|
+
Then { @username == json["username"] }
|
45
|
+
Then { json["api_key"] }
|
46
|
+
Then { region == json["region"] }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with invalid credentials" do
|
50
|
+
When do
|
51
|
+
VCR.use_cassette('authentication/unsuccessful-login') do
|
52
|
+
will_type "nil"
|
53
|
+
will_type "nil"
|
54
|
+
will_type "nil"
|
55
|
+
run_interactive "rumm login"
|
56
|
+
stop_process @interactive
|
56
57
|
end
|
57
|
-
Then {last_exit_status != 0}
|
58
|
-
And {all_stderr =~ /User could not be authenticated/}
|
59
58
|
end
|
59
|
+
Then {last_exit_status != 0}
|
60
|
+
And {all_stderr =~ /User could not be authenticated/}
|
61
|
+
end
|
62
|
+
|
63
|
+
context "after previous successful login"
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
describe "logging out" do
|
69
|
+
|
70
|
+
When { run "rumm logout" }
|
71
|
+
Then { last_exit_status == 0 }
|
72
|
+
context "deletes .rummrc" do
|
73
|
+
Then { !File.exists? "#{File.expand_path('~')}/.rummrc" }
|
60
74
|
end
|
61
75
|
end
|
data/spec/features/nodes_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "using the nodes api" do
|
4
4
|
$id = "test"
|
5
|
-
include_context "
|
5
|
+
include_context "rummrc"
|
6
6
|
|
7
7
|
context "to create" do
|
8
8
|
When { VCR.use_cassette('nodes/create') { run "rumm create node on loadbalancer laughing-barrel --address 198.61.221.220 --condition ENABLED --port: 80" }}
|