lita-digitalocean 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +178 -6
- data/lib/lita-digitalocean.rb +18 -0
- data/lib/lita/handlers/digitalocean.rb +0 -147
- data/lib/lita/handlers/digitalocean/base.rb +62 -0
- data/lib/lita/handlers/digitalocean/domain.rb +61 -0
- data/lib/lita/handlers/digitalocean/domain_record.rb +99 -0
- data/lib/lita/handlers/digitalocean/droplet.rb +236 -0
- data/lib/lita/handlers/digitalocean/image.rb +68 -0
- data/lib/lita/handlers/digitalocean/region.rb +23 -0
- data/lib/lita/handlers/digitalocean/size.rb +23 -0
- data/lib/lita/handlers/digitalocean/ssh_key.rb +94 -0
- data/lita-digitalocean.gemspec +4 -3
- data/locales/en.yml +142 -5
- data/spec/lita/handlers/digitalocean/base_spec.rb +39 -0
- data/spec/lita/handlers/digitalocean/domain_record_spec.rb +118 -0
- data/spec/lita/handlers/digitalocean/domain_spec.rb +85 -0
- data/spec/lita/handlers/digitalocean/droplet_spec.rb +238 -0
- data/spec/lita/handlers/digitalocean/image_spec.rb +121 -0
- data/spec/lita/handlers/digitalocean/region_spec.rb +44 -0
- data/spec/lita/handlers/digitalocean/size_spec.rb +44 -0
- data/spec/lita/handlers/digitalocean/ssh_key_spec.rb +119 -0
- metadata +44 -8
- data/spec/lita/handlers/digitalocean_spec.rb +0 -130
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::Size, lita_handler: true do
|
4
|
+
it { routes_command("do sizes list").to(:list) }
|
5
|
+
|
6
|
+
let(:client) { instance_double( "::DigitalOcean::API", sizes: client_sizes) }
|
7
|
+
let(:client_sizes) { instance_double("::DigitalOcean::Resource::Size") }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
11
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
12
|
+
config.client_id = "CLIENT_ID"
|
13
|
+
config.api_key = "API_KEY"
|
14
|
+
end
|
15
|
+
|
16
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
17
|
+
user,
|
18
|
+
:digitalocean_admins
|
19
|
+
).and_return(true)
|
20
|
+
|
21
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:do_sizes) do
|
25
|
+
{
|
26
|
+
status: "OK",
|
27
|
+
sizes: [
|
28
|
+
{ id: 33, name: "512MB", slug: "512mb" },
|
29
|
+
{ id: 34, name: "1GB", slug: "1gb" }
|
30
|
+
]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#list" do
|
35
|
+
it "responds with a list of all sizes" do
|
36
|
+
allow(client_sizes).to receive(:list).and_return(do_sizes)
|
37
|
+
send_command("do sizes list")
|
38
|
+
expect(replies).to eq([
|
39
|
+
'ID: 33, Name: 512MB, Slug: 512mb',
|
40
|
+
'ID: 34, Name: 1GB, Slug: 1gb'
|
41
|
+
])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::SSHKey, lita_handler: true do
|
4
|
+
it { routes_command("do ssh keys add 'foo bar' 'ssh-rsa abcdefg'").to(:add) }
|
5
|
+
it { routes_command("do ssh keys delete 123").to(:delete) }
|
6
|
+
it do
|
7
|
+
routes_command(
|
8
|
+
"do ssh keys edit 123 --name foo --public-key 'ssh-rsa changed'"
|
9
|
+
).to(:edit)
|
10
|
+
end
|
11
|
+
it { routes_command("do ssh keys list").to(:list) }
|
12
|
+
it { routes_command("do ssh keys show 123").to(:show) }
|
13
|
+
|
14
|
+
let(:client) { instance_double("::DigitalOcean::API", ssh_keys: client_ssh_keys) }
|
15
|
+
let(:client_ssh_keys) { instance_double("::DigitalOcean::Resource::SSHKey") }
|
16
|
+
|
17
|
+
before do
|
18
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
19
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
20
|
+
config.client_id = "CLIENT_ID"
|
21
|
+
config.api_key = "API_KEY"
|
22
|
+
end
|
23
|
+
|
24
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
25
|
+
user,
|
26
|
+
:digitalocean_admins
|
27
|
+
).and_return(true)
|
28
|
+
|
29
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:do_list) do
|
33
|
+
{
|
34
|
+
status: "OK",
|
35
|
+
ssh_keys: [
|
36
|
+
{ id: 123, name: "My Key" },
|
37
|
+
{ id: 456, name: "Your Key" }
|
38
|
+
]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:do_list_empty) do
|
43
|
+
{
|
44
|
+
status: "OK",
|
45
|
+
ssh_keys: []
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:do_key) do
|
50
|
+
{
|
51
|
+
status: "OK",
|
52
|
+
ssh_key: {
|
53
|
+
id: 123,
|
54
|
+
name: "My Key",
|
55
|
+
ssh_pub_key: "ssh-rsa abcdefg"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#add" do
|
61
|
+
it "responds with the details of the new key" do
|
62
|
+
allow(client_ssh_keys).to receive(:add).with(
|
63
|
+
name: "My Key",
|
64
|
+
ssh_pub_key: "ssh-rsa abcdefg"
|
65
|
+
).and_return(do_key)
|
66
|
+
send_command("do ssh keys add 'My Key' 'ssh-rsa abcdefg'")
|
67
|
+
expect(replies.last).to eq("Created new SSH key: 123 (My Key): ssh-rsa abcdefg")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "responds with an error message if name or public key is missing" do
|
71
|
+
send_command("do ssh keys add foo")
|
72
|
+
expect(replies.last).to eq("Format: do ssh keys add NAME PUBLIC_KEY")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#delete" do
|
77
|
+
let(:do_delete) { { status: "OK" } }
|
78
|
+
|
79
|
+
it "responds with a success message" do
|
80
|
+
allow(client_ssh_keys).to receive(:delete).with("123").and_return(do_delete)
|
81
|
+
send_command("do ssh keys delete 123")
|
82
|
+
expect(replies.last).to eq("Deleted SSH key: 123")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#edit" do
|
87
|
+
it "responds with the edited key's values" do
|
88
|
+
allow(client_ssh_keys).to receive(:edit).with(
|
89
|
+
"123",
|
90
|
+
name: "My Key",
|
91
|
+
ssh_pub_key: "ssh-rsa abcdefg"
|
92
|
+
).and_return(do_key)
|
93
|
+
send_command(%{do ssh keys edit 123 --name 'My Key' --public-key "ssh-rsa abcdefg"})
|
94
|
+
expect(replies.last).to eq("Updated SSH key: 123 (My Key): ssh-rsa abcdefg")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#list" do
|
99
|
+
it "returns a list of key IDs and names" do
|
100
|
+
allow(client_ssh_keys).to receive(:list).and_return(do_list)
|
101
|
+
send_command("do ssh keys list")
|
102
|
+
expect(replies).to eq(["123 (My Key)", "456 (Your Key)"])
|
103
|
+
end
|
104
|
+
|
105
|
+
it "returns an empty state message if there are no SSH keys" do
|
106
|
+
allow(client_ssh_keys).to receive(:list).and_return(do_list_empty)
|
107
|
+
send_command("do ssh keys list")
|
108
|
+
expect(replies.last).to eq("No SSH keys have been added yet.")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#show" do
|
113
|
+
it "responds with the public key" do
|
114
|
+
allow(client_ssh_keys).to receive(:show).with("123").and_return(do_key)
|
115
|
+
send_command("do ssh keys show 123")
|
116
|
+
expect(replies.last).to eq("123 (My Key): ssh-rsa abcdefg")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lita-keyword-arguments
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: digital_ocean
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
47
|
+
version: 1.5.0
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
54
|
+
version: 1.5.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,9 +137,24 @@ files:
|
|
123
137
|
- Rakefile
|
124
138
|
- lib/lita-digitalocean.rb
|
125
139
|
- lib/lita/handlers/digitalocean.rb
|
140
|
+
- lib/lita/handlers/digitalocean/base.rb
|
141
|
+
- lib/lita/handlers/digitalocean/domain.rb
|
142
|
+
- lib/lita/handlers/digitalocean/domain_record.rb
|
143
|
+
- lib/lita/handlers/digitalocean/droplet.rb
|
144
|
+
- lib/lita/handlers/digitalocean/image.rb
|
145
|
+
- lib/lita/handlers/digitalocean/region.rb
|
146
|
+
- lib/lita/handlers/digitalocean/size.rb
|
147
|
+
- lib/lita/handlers/digitalocean/ssh_key.rb
|
126
148
|
- lita-digitalocean.gemspec
|
127
149
|
- locales/en.yml
|
128
|
-
- spec/lita/handlers/
|
150
|
+
- spec/lita/handlers/digitalocean/base_spec.rb
|
151
|
+
- spec/lita/handlers/digitalocean/domain_record_spec.rb
|
152
|
+
- spec/lita/handlers/digitalocean/domain_spec.rb
|
153
|
+
- spec/lita/handlers/digitalocean/droplet_spec.rb
|
154
|
+
- spec/lita/handlers/digitalocean/image_spec.rb
|
155
|
+
- spec/lita/handlers/digitalocean/region_spec.rb
|
156
|
+
- spec/lita/handlers/digitalocean/size_spec.rb
|
157
|
+
- spec/lita/handlers/digitalocean/ssh_key_spec.rb
|
129
158
|
- spec/spec_helper.rb
|
130
159
|
homepage: https://github.com/jimmycuadra/lita-digitalocean
|
131
160
|
licenses:
|
@@ -153,5 +182,12 @@ signing_key:
|
|
153
182
|
specification_version: 4
|
154
183
|
summary: A Lita handler for managing DigitalOcean services.
|
155
184
|
test_files:
|
156
|
-
- spec/lita/handlers/
|
185
|
+
- spec/lita/handlers/digitalocean/base_spec.rb
|
186
|
+
- spec/lita/handlers/digitalocean/domain_record_spec.rb
|
187
|
+
- spec/lita/handlers/digitalocean/domain_spec.rb
|
188
|
+
- spec/lita/handlers/digitalocean/droplet_spec.rb
|
189
|
+
- spec/lita/handlers/digitalocean/image_spec.rb
|
190
|
+
- spec/lita/handlers/digitalocean/region_spec.rb
|
191
|
+
- spec/lita/handlers/digitalocean/size_spec.rb
|
192
|
+
- spec/lita/handlers/digitalocean/ssh_key_spec.rb
|
157
193
|
- spec/spec_helper.rb
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Lita::Handlers::Digitalocean, lita_handler: true do
|
4
|
-
it { routes_command("do ssh keys add 'foo bar' 'ssh-rsa abcdefg'").to(:ssh_keys_add) }
|
5
|
-
it { routes_command("do ssh keys delete 123").to(:ssh_keys_delete) }
|
6
|
-
it do
|
7
|
-
routes_command(
|
8
|
-
"do ssh keys edit 123 name=foo public_key='ssh-rsa changed'"
|
9
|
-
).to(:ssh_keys_edit)
|
10
|
-
end
|
11
|
-
it { routes_command("do ssh keys list").to(:ssh_keys_list) }
|
12
|
-
it { routes_command("do ssh keys show 123").to(:ssh_keys_show) }
|
13
|
-
|
14
|
-
let(:client) do
|
15
|
-
instance_double(
|
16
|
-
"::DigitalOcean::API",
|
17
|
-
ssh_keys: client_ssh_keys
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:client_ssh_keys) { instance_double("::DigitalOcean::Resource::SSHKey") }
|
22
|
-
|
23
|
-
before do
|
24
|
-
Lita.config.handlers.digitalocean.tap do |config|
|
25
|
-
config.client_id = "CLIENT_ID"
|
26
|
-
config.api_key = "API_KEY"
|
27
|
-
end
|
28
|
-
|
29
|
-
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
30
|
-
user,
|
31
|
-
:digitalocean_admins
|
32
|
-
).and_return(true)
|
33
|
-
|
34
|
-
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "ssh key commands" do
|
38
|
-
let(:do_list) do
|
39
|
-
instance_double(
|
40
|
-
"Hashie::Rash",
|
41
|
-
status: "OK",
|
42
|
-
ssh_keys: [
|
43
|
-
instance_double("Hashie::Rash", id: 123, name: "My Key"),
|
44
|
-
instance_double("Hashie::Rash", id: 456, name: "Your Key"),
|
45
|
-
]
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
let(:do_list_empty) do
|
50
|
-
instance_double(
|
51
|
-
"Hashie::Rash",
|
52
|
-
status: "OK",
|
53
|
-
ssh_keys: []
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
let(:do_key) do
|
58
|
-
instance_double(
|
59
|
-
"Hashie::Rash",
|
60
|
-
status: "OK",
|
61
|
-
ssh_key: instance_double(
|
62
|
-
"Hashie::Rash",
|
63
|
-
id: 123,
|
64
|
-
name: "My Key",
|
65
|
-
ssh_pub_key: "ssh-rsa abcdefg"
|
66
|
-
)
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
let(:do_delete) { instance_double("Hashie::Rash", status: "OK") }
|
71
|
-
|
72
|
-
describe "#ssh_keys_add" do
|
73
|
-
it "responds with the details of the new key" do
|
74
|
-
allow(client_ssh_keys).to receive(:add).with(
|
75
|
-
name: "My Key",
|
76
|
-
ssh_pub_key: "ssh-rsa abcdefg"
|
77
|
-
).and_return(do_key)
|
78
|
-
send_command("do ssh keys add 'My Key' 'ssh-rsa abcdefg'")
|
79
|
-
expect(replies.last).to eq("Created new SSH key: 123 (My Key): ssh-rsa abcdefg")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "responds with an error message if name or public key is missing" do
|
83
|
-
send_command("do ssh keys add foo")
|
84
|
-
expect(replies.last).to eq("Format: do ssh keys add NAME PUBLIC_KEY")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#ssh_keys_delete" do
|
89
|
-
it "responds with a success message" do
|
90
|
-
allow(client_ssh_keys).to receive(:delete).with("123").and_return(do_delete)
|
91
|
-
send_command("do ssh keys delete 123")
|
92
|
-
expect(replies.last).to eq("Deleted SSH key: 123")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "#ssh_keys_edit" do
|
97
|
-
it "responds with the edited key's values" do
|
98
|
-
allow(client_ssh_keys).to receive(:edit).with(
|
99
|
-
"123",
|
100
|
-
name: "My Key",
|
101
|
-
ssh_pub_key: "ssh-rsa abcdefg"
|
102
|
-
).and_return(do_key)
|
103
|
-
send_command(%{do ssh keys edit 123 name='My Key' public_key="ssh-rsa abcdefg"})
|
104
|
-
expect(replies.last).to eq("Updated SSH key: 123 (My Key): ssh-rsa abcdefg")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#ssh_keys_list" do
|
109
|
-
it "returns a list of key IDs and names" do
|
110
|
-
allow(client_ssh_keys).to receive(:list).and_return(do_list)
|
111
|
-
send_command("do ssh keys list")
|
112
|
-
expect(replies).to eq(["123 (My Key)", "456 (Your Key)"])
|
113
|
-
end
|
114
|
-
|
115
|
-
it "returns an empty state message if there are no SSH keys" do
|
116
|
-
allow(client_ssh_keys).to receive(:list).and_return(do_list_empty)
|
117
|
-
send_command("do ssh keys list")
|
118
|
-
expect(replies.last).to eq("No SSH keys have been added yet.")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#ssh_keys_show" do
|
123
|
-
it "responds with the public key" do
|
124
|
-
allow(client_ssh_keys).to receive(:show).with("123").and_return(do_key)
|
125
|
-
send_command("do ssh keys show 123")
|
126
|
-
expect(replies.last).to eq("123 (My Key): ssh-rsa abcdefg")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|