scooter 0.0.0 → 3.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.env +5 -0
- data/.gitignore +47 -19
- data/Gemfile +3 -0
- data/HISTORY.md +1539 -0
- data/README.md +69 -10
- data/Rakefile +7 -0
- data/docs/http_dispatchers.md +79 -0
- data/lib/scooter.rb +11 -3
- data/lib/scooter/httpdispatchers.rb +12 -0
- data/lib/scooter/httpdispatchers/activity.rb +46 -0
- data/lib/scooter/httpdispatchers/activity/v1/v1.rb +50 -0
- data/lib/scooter/httpdispatchers/classifier.rb +376 -0
- data/lib/scooter/httpdispatchers/classifier/v1/v1.rb +99 -0
- data/lib/scooter/httpdispatchers/code_manager.rb +31 -0
- data/lib/scooter/httpdispatchers/code_manager/v1/v1.rb +17 -0
- data/lib/scooter/httpdispatchers/consoledispatcher.rb +132 -0
- data/lib/scooter/httpdispatchers/httpdispatcher.rb +168 -0
- data/lib/scooter/httpdispatchers/orchestrator/v1/v1.rb +87 -0
- data/lib/scooter/httpdispatchers/orchestratordispatcher.rb +83 -0
- data/lib/scooter/httpdispatchers/puppetdb/v4/v4.rb +51 -0
- data/lib/scooter/httpdispatchers/puppetdbdispatcher.rb +390 -0
- data/lib/scooter/httpdispatchers/rbac.rb +231 -0
- data/lib/scooter/httpdispatchers/rbac/v1/directory_service.rb +68 -0
- data/lib/scooter/httpdispatchers/rbac/v1/v1.rb +116 -0
- data/lib/scooter/ldap.rb +349 -0
- data/lib/scooter/ldap/ldap_fixtures.rb +60 -0
- data/lib/scooter/middleware/rbac_auth_token.rb +35 -0
- data/lib/scooter/utilities.rb +9 -0
- data/lib/scooter/utilities/beaker_utilities.rb +41 -0
- data/lib/scooter/utilities/string_utilities.rb +32 -0
- data/lib/scooter/version.rb +3 -1
- data/scooter.gemspec +23 -6
- data/spec/scooter/beaker_utilities_spec.rb +53 -0
- data/spec/scooter/httpdispatchers/activity/activity_spec.rb +218 -0
- data/spec/scooter/httpdispatchers/classifier/classifier_spec.rb +542 -0
- data/spec/scooter/httpdispatchers/code_manager/code-manager_spec.rb +67 -0
- data/spec/scooter/httpdispatchers/consoledispatcher_spec.rb +80 -0
- data/spec/scooter/httpdispatchers/httpdispatcher_spec.rb +91 -0
- data/spec/scooter/httpdispatchers/middleware/rbac_auth_token_spec.rb +58 -0
- data/spec/scooter/httpdispatchers/orchestratordispatcher_spec.rb +195 -0
- data/spec/scooter/httpdispatchers/puppetdbdispatcher_spec.rb +246 -0
- data/spec/scooter/httpdispatchers/rbac/rbac_spec.rb +387 -0
- data/spec/scooter/string_utilities_spec.rb +83 -0
- data/spec/spec_helper.rb +8 -0
- metadata +270 -18
- data/LICENSE.txt +0 -15
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Scooter::HttpDispatchers::CodeManager do
|
|
4
|
+
|
|
5
|
+
let(:api) {
|
|
6
|
+
class DummyClass
|
|
7
|
+
attr_accessor :connection
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
dummy = DummyClass.new.extend(Scooter::HttpDispatchers::CodeManager)
|
|
11
|
+
dummy.connection = double(Faraday::Connection)
|
|
12
|
+
dummy
|
|
13
|
+
}
|
|
14
|
+
let(:array) { ['environment one', 'environment two'] }
|
|
15
|
+
|
|
16
|
+
describe '.deploy_environments' do
|
|
17
|
+
|
|
18
|
+
it 'works when passing in an array' do
|
|
19
|
+
expect(api.connection).to receive_message_chain('url_prefix.port=').with(8170)
|
|
20
|
+
expect(api.connection).to receive(:post).with('/code-manager/v1/deploys')
|
|
21
|
+
expect{api.deploy_environments(array)}.not_to raise_error
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'works when passed a value for wait' do
|
|
25
|
+
expect(api.connection).to receive_message_chain('url_prefix.port=').with(8170)
|
|
26
|
+
expect(api.connection).to receive(:post).with('/code-manager/v1/deploys')
|
|
27
|
+
expect{api.deploy_environments(array, true)}.not_to raise_error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'negative cases' do
|
|
31
|
+
|
|
32
|
+
it 'should fail with no arguements' do
|
|
33
|
+
expect{api.deploy_environments}.to raise_error(ArgumentError)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should fail if wait is not a boolean' do
|
|
37
|
+
expect{api.deploy_environments(array, 'true')}.to raise_error(ArgumentError)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '.deploy_all_environments' do
|
|
43
|
+
|
|
44
|
+
it 'works with no arguments' do
|
|
45
|
+
expect(api.connection).to receive_message_chain('url_prefix.port=').with(8170)
|
|
46
|
+
expect(api.connection).to receive(:post).with('/code-manager/v1/deploys')
|
|
47
|
+
expect{api.deploy_all_environments}.not_to raise_error
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should work with wait value' do
|
|
51
|
+
expect(api.connection).to receive_message_chain('url_prefix.port=').with(8170)
|
|
52
|
+
expect(api.connection).to receive(:post).with('/code-manager/v1/deploys')
|
|
53
|
+
expect{api.deploy_all_environments(true)}.not_to raise_error
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'negative cases' do
|
|
57
|
+
|
|
58
|
+
it 'fails if supplied two arguments' do
|
|
59
|
+
expect{api.deploy_all_environments(true, 'foo bar')}.to raise_error(ArgumentError)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should fail if wait is not a boolean' do
|
|
63
|
+
expect{api.deploy_all_environments('true')}.to raise_error(ArgumentError)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Scooter
|
|
4
|
+
|
|
5
|
+
describe HttpDispatchers::ConsoleDispatcher do
|
|
6
|
+
|
|
7
|
+
let(:host) {double('host')}
|
|
8
|
+
let(:credentials) { { login: username, password: password} }
|
|
9
|
+
let(:username) {'Ziggy'}
|
|
10
|
+
let(:password) {'Stardust'}
|
|
11
|
+
let(:mock_page) {double('mock_page')}
|
|
12
|
+
|
|
13
|
+
subject { HttpDispatchers::ConsoleDispatcher.new(host, credentials) }
|
|
14
|
+
|
|
15
|
+
context 'with a beaker host passed in' do
|
|
16
|
+
unixhost = { roles: ['test_role'],
|
|
17
|
+
'platform' => 'debian-7-x86_64' }
|
|
18
|
+
let(:host) { Beaker::Host.create('test.com', unixhost, {}) }
|
|
19
|
+
before do
|
|
20
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:pe_ca_cert_file).and_return('cert file')
|
|
21
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:get_public_ip).and_return('public_ip')
|
|
22
|
+
expect(subject).not_to be_nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context '.signin with a page that returns an xcsrf token' do
|
|
26
|
+
let(:mock_page) { <<-XCSRF_PAGE
|
|
27
|
+
<!doctype html>
|
|
28
|
+
<head>
|
|
29
|
+
<meta name="__anti-forgery-token" content="xcsrf-token" />
|
|
30
|
+
</head>
|
|
31
|
+
</html>
|
|
32
|
+
XCSRF_PAGE
|
|
33
|
+
}
|
|
34
|
+
before do
|
|
35
|
+
index = subject.connection.builder.handlers.index(Faraday::Adapter::NetHttp)
|
|
36
|
+
subject.connection.builder.swap(index, Faraday::Adapter::Test) do |stub|
|
|
37
|
+
stub.post('/auth/login', "username=#{username}&password=#{password}") {[200, {}, '']}
|
|
38
|
+
stub.get('/') {[200, {}, mock_page]}
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'sends the credentials' do
|
|
43
|
+
expect{subject.signin}.to_not raise_error
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'sets the xcsrf token in the header' do
|
|
47
|
+
subject.signin
|
|
48
|
+
expect(subject.connection.headers['X-CSRF-Token']).to eq('xcsrf-token')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context '.signin with a page that has no xcsrf token' do
|
|
53
|
+
let(:mock_page) { <<-XCSRF_PAGE
|
|
54
|
+
<!doctype html>
|
|
55
|
+
<head>
|
|
56
|
+
</head>
|
|
57
|
+
</html>
|
|
58
|
+
XCSRF_PAGE
|
|
59
|
+
}
|
|
60
|
+
before do
|
|
61
|
+
index = subject.connection.builder.handlers.index(Faraday::Adapter::NetHttp)
|
|
62
|
+
subject.connection.builder.swap(index, Faraday::Adapter::Test) do |stub|
|
|
63
|
+
stub.post('/auth/login', "username=#{username}&password=#{password}") {[200, {}, '']}
|
|
64
|
+
stub.get('/') {[200, {}, mock_page]}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'does not raise an error' do
|
|
69
|
+
expect{subject.signin}.to_not raise_error
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'There is no xcsrf token set' do
|
|
73
|
+
subject.signin
|
|
74
|
+
expect(subject.connection.headers['X-CSRF-Token']).to eq(nil)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Scooter
|
|
4
|
+
|
|
5
|
+
describe HttpDispatchers::HttpDispatcher do
|
|
6
|
+
|
|
7
|
+
let(:host) {double('host')}
|
|
8
|
+
|
|
9
|
+
subject { HttpDispatchers::HttpDispatcher.new(host) }
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
context 'with a beaker host passed in' do
|
|
13
|
+
unixhost = { roles: ['test_role'],
|
|
14
|
+
'platform' => 'debian-7-x86_64' }
|
|
15
|
+
let(:host) { Beaker::Host.create('test.com', unixhost, {}) }
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:pe_ca_cert_file).and_return('cert file')
|
|
19
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:pe_private_key).and_return('key file')
|
|
20
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:pe_hostcert).and_return('host cert')
|
|
21
|
+
expect(OpenSSL::PKey).to receive(:read).and_return('Pkey')
|
|
22
|
+
expect(OpenSSL::X509::Certificate).to receive(:new).and_return('client_cert')
|
|
23
|
+
expect(Scooter::Utilities::BeakerUtilities).to receive(:get_public_ip).and_return('public_ip')
|
|
24
|
+
expect(subject).not_to be_nil
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'sets the hostname correctly' do
|
|
29
|
+
expect(subject.connection.url_prefix.hostname).to eq('test.com')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'automatically has been configured for https' do
|
|
33
|
+
expect(subject.connection.url_prefix.scheme).to eq('https')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'automatically has a defined CA file' do
|
|
37
|
+
expect(subject.connection.ssl['ca_file']).to eq('cert file')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'automatically has a defined client key' do
|
|
41
|
+
expect(subject.connection.ssl['client_key']).to eq('Pkey')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'automatically has a defined client cert' do
|
|
45
|
+
expect(subject.connection.ssl['client_cert']).to eq('client_cert')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'has a URI::HTTPS object for a url_prefix' do
|
|
49
|
+
expect(subject.connection.url_prefix).to be_an_instance_of(URI::HTTPS)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'when it receives a 500 error' do
|
|
53
|
+
before do
|
|
54
|
+
index = subject.connection.builder.handlers.index(Faraday::Adapter::NetHttp)
|
|
55
|
+
subject.connection.builder.swap(index, Faraday::Adapter::Test) do |stub|
|
|
56
|
+
stub.get('/test/route') {[500,
|
|
57
|
+
{'content-type' => 'application/json;charset=UTF-8'},
|
|
58
|
+
"{ \"key\" : \"value\" }"]}
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
it 'has a correctly parsed body in the error' do
|
|
62
|
+
expect{subject.connection.get('/test/route')}.to raise_error do |error|
|
|
63
|
+
expect(error.response[:body]).to be_a(Hash)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'with a string passed in for initialization' do
|
|
71
|
+
let(:host) {'test.com'}
|
|
72
|
+
before do
|
|
73
|
+
expect(subject).not_to be_nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'sets the hostname correctly for the dispatcher object' do
|
|
77
|
+
expect(subject.connection.url_prefix.host).to eq('test.com')
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'does not set ssl when there are no ssl components to add' do
|
|
82
|
+
expect(subject.add_ssl_components_to_connection).to eq(nil)
|
|
83
|
+
expect(subject.connection.url_prefix.scheme).to eq('http')
|
|
84
|
+
expect(subject.connection.ssl['client_key']).to eq(nil)
|
|
85
|
+
expect(subject.connection.ssl['client_cert']).to eq(nil)
|
|
86
|
+
expect(subject.connection.ssl['ca_file']).to eq(nil)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Faraday::RbacAuthToken do
|
|
4
|
+
|
|
5
|
+
let(:conn) { Faraday.new(:url => 'http://test.com/path') }
|
|
6
|
+
let(:dispatcher) { double('dispatcher') }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
conn.builder.insert(0, Faraday::RbacAuthToken, dispatcher)
|
|
10
|
+
conn.adapter :test do |stub|
|
|
11
|
+
stub.get('/path') {[200, {}, 'success']}
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'a dispatcher with no token' do
|
|
16
|
+
before do
|
|
17
|
+
allow(dispatcher).to receive(:token) { nil }
|
|
18
|
+
allow(dispatcher).to receive(:send_auth_token_as_query_param) { nil }
|
|
19
|
+
end
|
|
20
|
+
it 'sends the request without a token' do
|
|
21
|
+
expect(conn.get.env.url.query).to eq(nil)
|
|
22
|
+
expect(conn.get.env.request_headers['X-Authentication']).to eq(nil)
|
|
23
|
+
expect{conn.get}.not_to raise_error
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'a dispatcher with a token' do
|
|
28
|
+
before do
|
|
29
|
+
allow(dispatcher).to receive(:token) {'testingtoken'}
|
|
30
|
+
allow(dispatcher).to receive(:send_auth_token_as_query_param) { nil }
|
|
31
|
+
end
|
|
32
|
+
it 'sends the request with the token in an X-Authentication header' do
|
|
33
|
+
expect(conn.get.env.request_headers['X-Authentication']).to eq('testingtoken')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe 'a dispatcher with a token as a query param' do
|
|
38
|
+
before do
|
|
39
|
+
allow(dispatcher).to receive(:token) { 'testingtoken' }
|
|
40
|
+
allow(dispatcher).to receive(:send_auth_token_as_query_param) { true }
|
|
41
|
+
end
|
|
42
|
+
it 'sends the request with the token as a query param' do
|
|
43
|
+
expect(conn.get.env.url.query).to eq('token=testingtoken')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe 'a dispatcher with a token to be sent as a query param does not overwrite other params' do
|
|
48
|
+
before do
|
|
49
|
+
allow(dispatcher).to receive(:token) { 'testingtoken' }
|
|
50
|
+
allow(dispatcher).to receive(:send_auth_token_as_query_param) { true }
|
|
51
|
+
end
|
|
52
|
+
it 'sends the request with the token and other parameters' do
|
|
53
|
+
response = conn.get {|req| req.params[:extra_param] = 'extra_value'}
|
|
54
|
+
hashed_query = CGI.parse(response.env.url.query)
|
|
55
|
+
expect(hashed_query).to eq('token'=> ['testingtoken'], 'extra_param' => ['extra_value'])
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Scooter::HttpDispatchers::OrchestratorDispatcher do
|
|
4
|
+
|
|
5
|
+
let(:host) {'host'}
|
|
6
|
+
let(:orchestrator_api) { Scooter::HttpDispatchers::OrchestratorDispatcher.new(host) }
|
|
7
|
+
let(:job_id) { random_string }
|
|
8
|
+
let(:environment) {random_string}
|
|
9
|
+
|
|
10
|
+
subject { orchestrator_api }
|
|
11
|
+
|
|
12
|
+
it 'should make requests on the correct port' do
|
|
13
|
+
expect(orchestrator_api.connection.url_prefix.port).to be(8143)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should use the correct path prefix' do
|
|
17
|
+
expect(orchestrator_api.connection.url_prefix.path).to eq('/orchestrator')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '.list_jobs' do
|
|
21
|
+
|
|
22
|
+
it { is_expected.to respond_to(:list_jobs).with(0).arguments }
|
|
23
|
+
it { is_expected.to respond_to(:list_jobs).with(1).arguments }
|
|
24
|
+
it { is_expected.not_to respond_to(:list_jobs).with(2).arguments }
|
|
25
|
+
|
|
26
|
+
it 'should take a job_id' do
|
|
27
|
+
expect(orchestrator_api.connection).to receive(:get).with('v1/jobs')
|
|
28
|
+
expect{ orchestrator_api.list_jobs }.not_to raise_error
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '.list_job_details' do
|
|
33
|
+
|
|
34
|
+
it { is_expected.not_to respond_to(:list_job_details).with(0).arguments }
|
|
35
|
+
it { is_expected.to respond_to(:list_job_details).with(1).arguments }
|
|
36
|
+
|
|
37
|
+
it 'should take a job_id' do
|
|
38
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/jobs/#{job_id}")
|
|
39
|
+
expect{ orchestrator_api.list_job_details(job_id) }.not_to raise_error
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '.list_nodes_associated_with_job' do
|
|
44
|
+
|
|
45
|
+
it { is_expected.not_to respond_to(:list_nodes_associated_with_job).with(0).arguments }
|
|
46
|
+
it { is_expected.to respond_to(:list_nodes_associated_with_job).with(1).arguments }
|
|
47
|
+
|
|
48
|
+
it 'should take a job_id' do
|
|
49
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/jobs/#{job_id}/nodes")
|
|
50
|
+
expect{ orchestrator_api.list_nodes_associated_with_job(job_id) }.not_to raise_error
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '.get_job_report' do
|
|
55
|
+
|
|
56
|
+
it { is_expected.not_to respond_to(:get_job_report).with(0).arguments }
|
|
57
|
+
it { is_expected.to respond_to(:get_job_report).with(1).arguments }
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
it 'should take a job_id' do
|
|
61
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/jobs/#{job_id}/report")
|
|
62
|
+
expect{ orchestrator_api.get_job_report(job_id) }.not_to raise_error
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '.get_job_events' do
|
|
67
|
+
|
|
68
|
+
it { is_expected.not_to respond_to(:get_job_events).with(0).arguments }
|
|
69
|
+
it { is_expected.to respond_to(:get_job_events).with(1).arguments }
|
|
70
|
+
|
|
71
|
+
it 'should take a job_id' do
|
|
72
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/jobs/#{job_id}/events")
|
|
73
|
+
expect{ orchestrator_api.get_job_events(job_id) }.not_to raise_error
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe '.environment' do
|
|
78
|
+
it { is_expected.not_to respond_to(:environment).with(0).arguments }
|
|
79
|
+
it { is_expected.to respond_to(:environment).with(1).arguments }
|
|
80
|
+
|
|
81
|
+
it 'should take a environment name' do
|
|
82
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/environments/#{environment}")
|
|
83
|
+
expect{ orchestrator_api.environment(environment) }.not_to raise_error
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe '.list_applications' do
|
|
88
|
+
it { is_expected.not_to respond_to(:list_applications).with(0).arguments }
|
|
89
|
+
it { is_expected.to respond_to(:list_applications).with(1).arguments }
|
|
90
|
+
|
|
91
|
+
it 'should take a environment name' do
|
|
92
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/environments/#{environment}/applications")
|
|
93
|
+
expect{ orchestrator_api.list_applications(environment) }.not_to raise_error
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe '.list_app_instances' do
|
|
98
|
+
it { is_expected.not_to respond_to(:list_app_instances).with(0).arguments }
|
|
99
|
+
it { is_expected.to respond_to(:list_app_instances).with(1).arguments }
|
|
100
|
+
|
|
101
|
+
it 'should take a environment name' do
|
|
102
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/environments/#{environment}/instances")
|
|
103
|
+
expect{ orchestrator_api.list_app_instances(environment) }.not_to raise_error
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
describe '.deploy_environment' do
|
|
108
|
+
it { is_expected.not_to respond_to(:deploy_environment).with(0).arguments }
|
|
109
|
+
it { is_expected.to respond_to(:deploy_environment).with(1).arguments }
|
|
110
|
+
it { is_expected.to respond_to(:deploy_environment).with(2).arguments }
|
|
111
|
+
|
|
112
|
+
it 'should take an environment name' do
|
|
113
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/command/deploy")
|
|
114
|
+
expect{ orchestrator_api.deploy_environment(environment) }.not_to raise_error
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'should take an environment and a opts hash' do
|
|
118
|
+
opts = {'noop' => true, 'concurency' => 5}
|
|
119
|
+
|
|
120
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/command/deploy")
|
|
121
|
+
expect{ orchestrator_api.deploy_environment(environment, opts) }.not_to raise_error
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
describe '.stop_job' do
|
|
126
|
+
it { is_expected.not_to respond_to(:stop_job).with(0).arguments }
|
|
127
|
+
it { is_expected.to respond_to(:stop_job).with(1).arguments }
|
|
128
|
+
it { is_expected.not_to respond_to(:stop_job).with(2).arguments }
|
|
129
|
+
|
|
130
|
+
it 'should take a job id' do
|
|
131
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/command/stop")
|
|
132
|
+
expect{ orchestrator_api.stop_job(job_id) }.not_to raise_error
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe '.plan_job' do
|
|
137
|
+
it { is_expected.not_to respond_to(:plan_job).with(0).arguments }
|
|
138
|
+
it { is_expected.to respond_to(:plan_job).with(1).arguments }
|
|
139
|
+
it { is_expected.to respond_to(:plan_job).with(2).arguments }
|
|
140
|
+
|
|
141
|
+
it 'should take an environment name' do
|
|
142
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/command/plan")
|
|
143
|
+
expect{ orchestrator_api.plan_job(environment) }.not_to raise_error
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'should take an environment and a opts hash' do
|
|
147
|
+
opts = {'noop' => true, 'concurency' => 5}
|
|
148
|
+
|
|
149
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/command/plan")
|
|
150
|
+
expect{ orchestrator_api.plan_job(environment, opts) }.not_to raise_error
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '.get_inventory' do
|
|
155
|
+
let(:certname) {'thisismycertname'}
|
|
156
|
+
|
|
157
|
+
it {is_expected.to respond_to(:get_inventory).with(0).arguments }
|
|
158
|
+
it {is_expected.to respond_to(:get_inventory).with(1).arguments }
|
|
159
|
+
it {is_expected.not_to respond_to(:get_inventory).with(2).arguments }
|
|
160
|
+
|
|
161
|
+
it 'should take a single certname' do
|
|
162
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/inventory/#{certname}")
|
|
163
|
+
expect{ orchestrator_api.get_inventory(certname) }.not_to raise_error
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'should take no argument' do
|
|
167
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/inventory")
|
|
168
|
+
expect{ orchestrator_api.get_inventory }.not_to raise_error
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
describe '.nodes_connected_to_broker' do
|
|
173
|
+
let(:certnames) {['certnameone', 'certnametwo', 'certnamethree']}
|
|
174
|
+
|
|
175
|
+
it {is_expected.not_to respond_to(:nodes_connected_to_broker).with(0).arguments }
|
|
176
|
+
it {is_expected.to respond_to(:nodes_connected_to_broker).with(1).arguments }
|
|
177
|
+
it {is_expected.not_to respond_to(:nodes_connected_to_broker).with(2).arguments }
|
|
178
|
+
|
|
179
|
+
it 'should take an array of certnames' do
|
|
180
|
+
expect(orchestrator_api.connection).to receive(:post).with("v1/inventory")
|
|
181
|
+
expect{ orchestrator_api.nodes_connected_to_broker(certnames) }.not_to raise_error
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
describe '.get_status' do
|
|
186
|
+
|
|
187
|
+
it {is_expected.to respond_to(:get_status).with(0).arguments }
|
|
188
|
+
it {is_expected.not_to respond_to(:get_status).with(1).arguments }
|
|
189
|
+
|
|
190
|
+
it 'should take no argument' do
|
|
191
|
+
expect(orchestrator_api.connection).to receive(:get).with("v1/status")
|
|
192
|
+
expect{ orchestrator_api.get_status }.not_to raise_error
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|