cloudpassage 0.0.6 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloudpassage/base.rb +5 -1
- data/lib/cloudpassage/policies.rb +2 -1
- data/lib/cloudpassage/pry.rb +2 -2
- data/lib/cloudpassage/servers.rb +28 -8
- data/lib/cloudpassage/version.rb +1 -1
- data/spec/api_spec.rb +21 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3727dfd86efb6d3d5cef5c602aa690e7d553a605
|
4
|
+
data.tar.gz: 628dfedd3fd24a5aa4ed1a6527e0a0716e059dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302bc95abceca07d03495259b28b7a6605e2e204ee081ce8a208df80e89f306a5d14084d029b4fd904d88456c8bcf3da37cd9369aebe2b14a4d5bca0553ab7c6
|
7
|
+
data.tar.gz: aa443e757687fa058a044ed5ec2e746d8adb3d1bd7dcec14b9fe8c27b382620a1997ebd9a9aed6c69928ee0f2100b66037577fe95601d50105736b12b80ed059
|
data/lib/cloudpassage/base.rb
CHANGED
@@ -59,6 +59,10 @@ module Cloudpassage
|
|
59
59
|
JSON.parse(@base_resource.post payload.to_json, headers)
|
60
60
|
end
|
61
61
|
|
62
|
+
def put(payload)
|
63
|
+
JSON.parse(@base_resource.put payload.to_json, headers)
|
64
|
+
end
|
65
|
+
|
62
66
|
# Convert class name to symbol.
|
63
67
|
# eg: CloudPassage::Users --> :users
|
64
68
|
def object_symbol
|
@@ -77,4 +81,4 @@ module Cloudpassage
|
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
80
|
-
end
|
84
|
+
end
|
data/lib/cloudpassage/pry.rb
CHANGED
@@ -3,7 +3,7 @@ require 'cloudpassage'
|
|
3
3
|
|
4
4
|
# Module to make it easy to use stuff from pry (or any sort of interactive debugger)
|
5
5
|
module Cloudpassage::Pry
|
6
|
-
def cloudpassage(type)
|
6
|
+
def self.cloudpassage(type)
|
7
7
|
type_section = Cloudpassage::Pry::section(type)
|
8
8
|
Cloudpassage::Api.new(Cloudpassage.token(type_section['id'], type_section['secret']))
|
9
9
|
end
|
@@ -19,4 +19,4 @@ module Cloudpassage::Pry
|
|
19
19
|
def self.config_file
|
20
20
|
ENV.fetch('CLOUDPASSAGE_CONFIG_FILE', "#{ENV['HOME']}/.cloudpassagerc")
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
data/lib/cloudpassage/servers.rb
CHANGED
@@ -3,8 +3,8 @@ module Cloudpassage
|
|
3
3
|
include Collection
|
4
4
|
|
5
5
|
def filter(options={})
|
6
|
-
|
7
|
-
|
6
|
+
servers = JSON.parse(@base_resource.get(headers.merge(:params=>options)), :symbolize_names=>true)[:servers]
|
7
|
+
servers.map { |i| get(i[:id], i) }
|
8
8
|
end
|
9
9
|
|
10
10
|
def singleton_class
|
@@ -68,16 +68,29 @@ module Cloudpassage
|
|
68
68
|
# Creates username, in the given group.
|
69
69
|
# If opts[:password] is specified, that password will be used.
|
70
70
|
# Otherwise, password will be generated.
|
71
|
+
# If opts
|
71
72
|
def create(username, groups = '', opts = {})
|
72
|
-
payload = {
|
73
|
-
:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
payload = {
|
74
|
+
:account => {
|
75
|
+
:username => username,
|
76
|
+
:comment => '',
|
77
|
+
:groups => groups,
|
78
|
+
:password => password_opts.merge(opts.fetch(:password, {}))
|
79
|
+
}
|
80
|
+
}
|
78
81
|
@server.commands.get(post(payload)['command']['id'])
|
79
82
|
end
|
80
83
|
|
84
|
+
def set_ssh_keys(username, *keys)
|
85
|
+
keys = *keys
|
86
|
+
payload = {
|
87
|
+
:account => {
|
88
|
+
:ssh_authorized_keys => keys.map{|k|{:key=>k}}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
@server.commands.get(JSON.parse(@base_resource[username].put(payload.to_json, headers))['command']['id'])
|
92
|
+
end
|
93
|
+
|
81
94
|
def reset(username, opts = {})
|
82
95
|
payload = {'password' => password_opts.merge(opts)}
|
83
96
|
JSON.parse @base_resource[username]['password'].put(payload.to_json, headers)
|
@@ -100,6 +113,12 @@ module Cloudpassage
|
|
100
113
|
:include_uppercase => true
|
101
114
|
}
|
102
115
|
end
|
116
|
+
|
117
|
+
def ssh_keys_opts(opts)
|
118
|
+
keys = opts.fetch(:keys, [])
|
119
|
+
keys.map{|k|{:key=>k}}
|
120
|
+
end
|
121
|
+
|
103
122
|
end
|
104
123
|
|
105
124
|
class Issues < Base
|
@@ -127,4 +146,5 @@ module Cloudpassage
|
|
127
146
|
|
128
147
|
class Issue < Single;end
|
129
148
|
class Account < Single;end
|
149
|
+
|
130
150
|
end
|
data/lib/cloudpassage/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require'cloudpassage/pry'
|
3
4
|
require 'rspec'
|
4
5
|
|
5
6
|
module Cloudpassage
|
@@ -7,20 +8,23 @@ module Cloudpassage
|
|
7
8
|
attr_reader :api
|
8
9
|
|
9
10
|
before :each do
|
10
|
-
|
11
|
+
Cloudpassage.stub(:token){ 'token' }
|
12
|
+
Cloudpassage::Pry.stub(:yaml){({'test'=>{'id'=>'id', 'secret'=>'secret'}})}
|
13
|
+
@api = Cloudpassage::Pry.cloudpassage(:test)
|
14
|
+
RestClient::Resource.stub(:new){resource}
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.collections
|
14
18
|
[
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
:configuration_policies,
|
20
|
+
:events,
|
21
|
+
:file_integrity_policies,
|
22
|
+
:firewall_interfaces,
|
23
|
+
:firewall_policies,
|
24
|
+
:firewall_services,
|
25
|
+
:firewall_zones,
|
26
|
+
:server_groups,
|
27
|
+
:users
|
24
28
|
]
|
25
29
|
end
|
26
30
|
|
@@ -28,14 +32,12 @@ module Cloudpassage
|
|
28
32
|
it "should retrieve data for #{type}" do
|
29
33
|
api.send(type).data
|
30
34
|
end
|
35
|
+
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# Reload a single instance of each object type.
|
37
|
-
collection.all[0].reload.data
|
37
|
+
def resource
|
38
|
+
@resource ||= double('resource').tap do |r|
|
39
|
+
r.stub(:get=>'{}')
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
|
-
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudpassage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mshea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.2.2
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Cloudpassage
|