dpl-connect 1.8.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +36 -0
- data/Gemfile +100 -0
- data/LICENSE +22 -0
- data/README.md +934 -0
- data/Rakefile +1 -0
- data/TESTING.md +29 -0
- data/bin/dpl +5 -0
- data/dpl.gemspec +32 -0
- data/lib/dpl/cli.rb +66 -0
- data/lib/dpl/error.rb +3 -0
- data/lib/dpl/provider.rb +264 -0
- data/lib/dpl/provider/anynines.rb +13 -0
- data/lib/dpl/provider/appfog.rb +21 -0
- data/lib/dpl/provider/atlas.rb +108 -0
- data/lib/dpl/provider/azure_webapps.rb +48 -0
- data/lib/dpl/provider/bintray.rb +509 -0
- data/lib/dpl/provider/bitballoon.rb +22 -0
- data/lib/dpl/provider/bluemix_cloud_foundry.rb +23 -0
- data/lib/dpl/provider/boxfuse.rb +57 -0
- data/lib/dpl/provider/catalyze.rb +49 -0
- data/lib/dpl/provider/chef_supermarket.rb +85 -0
- data/lib/dpl/provider/cloud66.rb +38 -0
- data/lib/dpl/provider/cloud_files.rb +38 -0
- data/lib/dpl/provider/cloud_foundry.rb +43 -0
- data/lib/dpl/provider/code_deploy.rb +123 -0
- data/lib/dpl/provider/deis.rb +119 -0
- data/lib/dpl/provider/divshot.rb +23 -0
- data/lib/dpl/provider/elastic_beanstalk.rb +195 -0
- data/lib/dpl/provider/engine_yard.rb +90 -0
- data/lib/dpl/provider/firebase.rb +27 -0
- data/lib/dpl/provider/gae.rb +97 -0
- data/lib/dpl/provider/gcs.rb +59 -0
- data/lib/dpl/provider/hackage.rb +29 -0
- data/lib/dpl/provider/heroku.rb +18 -0
- data/lib/dpl/provider/heroku/api.rb +98 -0
- data/lib/dpl/provider/heroku/generic.rb +94 -0
- data/lib/dpl/provider/heroku/git.rb +28 -0
- data/lib/dpl/provider/lambda.rb +236 -0
- data/lib/dpl/provider/launchpad.rb +48 -0
- data/lib/dpl/provider/modulus.rb +23 -0
- data/lib/dpl/provider/npm.rb +64 -0
- data/lib/dpl/provider/openshift.rb +59 -0
- data/lib/dpl/provider/ops_works.rb +132 -0
- data/lib/dpl/provider/packagecloud.rb +144 -0
- data/lib/dpl/provider/pages.rb +79 -0
- data/lib/dpl/provider/puppet_forge.rb +43 -0
- data/lib/dpl/provider/pypi.rb +111 -0
- data/lib/dpl/provider/releases.rb +139 -0
- data/lib/dpl/provider/rubygems.rb +51 -0
- data/lib/dpl/provider/s3.rb +123 -0
- data/lib/dpl/provider/scalingo.rb +97 -0
- data/lib/dpl/provider/script.rb +29 -0
- data/lib/dpl/provider/surge.rb +33 -0
- data/lib/dpl/provider/testfairy.rb +190 -0
- data/lib/dpl/provider/transifex.rb +45 -0
- data/lib/dpl/version.rb +3 -0
- data/notes/engine_yard.md +1 -0
- data/notes/heroku.md +3 -0
- data/spec/cli_spec.rb +36 -0
- data/spec/provider/anynines_spec.rb +20 -0
- data/spec/provider/appfog_spec.rb +35 -0
- data/spec/provider/atlas_spec.rb +99 -0
- data/spec/provider/azure_webapps_spec.rb +95 -0
- data/spec/provider/bintray_spec.rb +259 -0
- data/spec/provider/bitballoon_spec.rb +32 -0
- data/spec/provider/bluemixcloudfoundry_spec.rb +23 -0
- data/spec/provider/boxfuse_spec.rb +16 -0
- data/spec/provider/catalyze_spec.rb +39 -0
- data/spec/provider/chef_supermarket_spec.rb +51 -0
- data/spec/provider/cloud66_spec.rb +44 -0
- data/spec/provider/cloud_files_spec.rb +88 -0
- data/spec/provider/cloudfoundry_spec.rb +71 -0
- data/spec/provider/code_deploy_spec.rb +360 -0
- data/spec/provider/deis_spec.rb +116 -0
- data/spec/provider/divshot_spec.rb +28 -0
- data/spec/provider/elastic_beanstalk_spec.rb +209 -0
- data/spec/provider/firebase_spec.rb +40 -0
- data/spec/provider/gae_spec.rb +26 -0
- data/spec/provider/gcs_spec.rb +115 -0
- data/spec/provider/hackage_spec.rb +47 -0
- data/spec/provider/heroku_spec.rb +357 -0
- data/spec/provider/lambda_spec.rb +432 -0
- data/spec/provider/launchpad_spec.rb +33 -0
- data/spec/provider/modulus_spec.rb +29 -0
- data/spec/provider/npm_spec.rb +95 -0
- data/spec/provider/openshift_spec.rb +91 -0
- data/spec/provider/ops_works_spec.rb +127 -0
- data/spec/provider/packagecloud_spec.rb +56 -0
- data/spec/provider/puppet_forge_spec.rb +60 -0
- data/spec/provider/pypi_spec.rb +103 -0
- data/spec/provider/releases_spec.rb +303 -0
- data/spec/provider/rubygems_spec.rb +106 -0
- data/spec/provider/s3_spec.rb +174 -0
- data/spec/provider/scalingo_spec.rb +64 -0
- data/spec/provider/script_spec.rb +26 -0
- data/spec/provider/surge_spec.rb +15 -0
- data/spec/provider/testfairy_spec.rb +86 -0
- data/spec/provider/transifex_spec.rb +110 -0
- data/spec/provider_spec.rb +210 -0
- data/spec/spec_helper.rb +20 -0
- metadata +279 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dpl/provider/launchpad'
|
3
|
+
|
4
|
+
describe DPL::Provider::Launchpad do
|
5
|
+
subject :provider do
|
6
|
+
described_class.new(DummyContext.new, :slug => '~user/repo/branch', :oauth_token => 'uezinoosinmxkewhochq', :oauth_token_secret => 'dinb6fao4jh0kfdn5mich31cbikdkpjplkmadhi80h93kbbaableeeg41mm0jab9jif8ch7i2k9a80n5')
|
7
|
+
end
|
8
|
+
|
9
|
+
its(:needs_key?) { should be false }
|
10
|
+
|
11
|
+
describe '#push_app' do
|
12
|
+
it 'on api success' do
|
13
|
+
expect(provider).to receive(:api_call).with('/1.0/~user/repo/branch/+code-import', {'ws.op' => 'requestImport'}).and_return Net::HTTPSuccess.new("HTTP/1.1", 200, "Ok")
|
14
|
+
provider.push_app
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'on api failure' do
|
18
|
+
expect(provider).to receive(:api_call).with('/1.0/~user/repo/branch/+code-import', {'ws.op' => 'requestImport'}).and_return double("Net::HTTPUnauthorized", code: 401, body: "", class: Net::HTTPUnauthorized)
|
19
|
+
expect { provider.push_app }.to raise_error(DPL::Error)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'private method' do
|
24
|
+
describe '#authorization' do
|
25
|
+
it 'should return correct oauth' do
|
26
|
+
result = provider.instance_eval { authorization }
|
27
|
+
expect(result).to include('oauth_token="uezinoosinmxkewhochq",')
|
28
|
+
expect(result).to include('oauth_signature="%26dinb6fao4jh0kfdn5mich31cbikdkpjplkmadhi80h93kbbaableeeg41mm0jab9jif8ch7i2k9a80n5",')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dpl/provider/modulus'
|
3
|
+
|
4
|
+
describe DPL::Provider::Modulus do
|
5
|
+
subject :provider do
|
6
|
+
described_class.new(DummyContext.new, :api_key => 'test-token', :project_name => 'test-project')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#check_auth" do
|
10
|
+
it 'should require an api key' do
|
11
|
+
provider.options.update(:api_key => nil)
|
12
|
+
expect{ provider.check_auth }.to raise_error("must supply an api key")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#check_app" do
|
17
|
+
it 'should require a project name' do
|
18
|
+
provider.options.update(:project_name => nil)
|
19
|
+
expect{ provider.check_app }.to raise_error("must supply a project name")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#push_app" do
|
24
|
+
it 'should include the api key and project name specified' do
|
25
|
+
expect(provider.context).to receive(:shell).with("env MODULUS_TOKEN=test-token modulus deploy -p test-project")
|
26
|
+
provider.push_app
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dpl/provider/npm'
|
3
|
+
|
4
|
+
describe DPL::Provider::NPM do
|
5
|
+
before :each do
|
6
|
+
allow(subject).to receive(:npm_version).and_return('2.11.3')
|
7
|
+
end
|
8
|
+
|
9
|
+
subject :provider do
|
10
|
+
described_class.new(DummyContext.new, :email => 'foo@blah.com', :api_key => 'test')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#check_auth" do
|
14
|
+
example do
|
15
|
+
expect(provider).to receive(:setup_auth)
|
16
|
+
expect(provider).to receive(:log).with("Authenticated with email foo@blah.com")
|
17
|
+
provider.check_auth
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#push_app" do
|
22
|
+
example do
|
23
|
+
expect(provider.context).to receive(:shell).with("env NPM_API_KEY=test npm publish")
|
24
|
+
expect(FileUtils).to receive(:rm).with(File.expand_path(DPL::Provider::NPM::NPMRC_FILE))
|
25
|
+
provider.setup_auth
|
26
|
+
provider.push_app
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#setup_auth" do
|
31
|
+
example do
|
32
|
+
test_setup_auth
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when NPM is version 1.x' do
|
37
|
+
before :each do
|
38
|
+
allow(subject).to receive(:npm_version).and_return('1.4.28')
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#setup_auth" do
|
42
|
+
example do
|
43
|
+
test_setup_auth(DPL::Provider::NPM::DEFAULT_NPM_REGISTRY, "_auth = ${NPM_API_KEY}\nemail = foo@blah.com")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when package.json exists' do
|
49
|
+
let(:host) { 'npm.example.com' }
|
50
|
+
let(:custom_rpm_registry) { 'https://' + host }
|
51
|
+
before :each do
|
52
|
+
expect(File).to receive(:exists?).with('package.json').and_return(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'and it defines custom RPM registry' do
|
56
|
+
before { expect(File).to receive(:read).with('package.json').and_return("{\"publishConfig\":{\"registry\":\"#{custom_rpm_registry}\"}}") }
|
57
|
+
|
58
|
+
describe '#setup_auth' do
|
59
|
+
example do
|
60
|
+
test_setup_auth(host)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'and it defines custom RPM registry with trailing slash' do
|
66
|
+
let(:host) { 'npm.example.com' }
|
67
|
+
let(:custom_rpm_registry) { 'https://' + host + '/' }
|
68
|
+
before { expect(File).to receive(:read).with('package.json').and_return("{\"publishConfig\":{\"registry\":\"#{custom_rpm_registry}\"}}") }
|
69
|
+
|
70
|
+
describe '#setup_auth' do
|
71
|
+
example do
|
72
|
+
test_setup_auth(host)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'and it does not define custom RPM registry' do
|
78
|
+
before { expect(File).to receive(:read).with('package.json').and_return("{}") }
|
79
|
+
|
80
|
+
describe '#setup_auth' do
|
81
|
+
example do
|
82
|
+
test_setup_auth
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_setup_auth(registry = DPL::Provider::NPM::DEFAULT_NPM_REGISTRY, content = "//#{registry}/:_authToken=${NPM_API_KEY}")
|
90
|
+
f = double(:npmrc)
|
91
|
+
expect(File).to receive(:open).with(File.expand_path(DPL::Provider::NPM::NPMRC_FILE), 'w').and_return(f)
|
92
|
+
expect(f).to receive(:puts).with(content)
|
93
|
+
allow(f).to receive(:flush)
|
94
|
+
provider.setup_auth
|
95
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rhc'
|
3
|
+
require 'dpl/provider/openshift'
|
4
|
+
|
5
|
+
describe DPL::Provider::Openshift do
|
6
|
+
subject :provider do
|
7
|
+
described_class.new(DummyContext.new, :user => 'foo', :password => 'foo', :domain => 'foo', :app => 'example', :key_name => 'key')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#api" do
|
11
|
+
it 'accepts a user and a password' do
|
12
|
+
api = double(:api)
|
13
|
+
provider.options.update(:user => "foo", :password => "bar")
|
14
|
+
expect(::RHC::Rest::Client).to receive(:new).with(:user => "foo", :password => "bar", :server => "openshift.redhat.com").and_return(api)
|
15
|
+
expect(provider.api).to eq(api)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with api" do
|
20
|
+
let :api do
|
21
|
+
double "api",
|
22
|
+
:user => double(:login => "foo@bar.com"),
|
23
|
+
:find_application => double(:name => "example", :git_url => "git://something"),
|
24
|
+
:add_key => double
|
25
|
+
end
|
26
|
+
let :app do
|
27
|
+
double "app",
|
28
|
+
:restart => double
|
29
|
+
end
|
30
|
+
|
31
|
+
before do
|
32
|
+
expect(::RHC::Rest::Client).to receive(:new).at_most(:once).and_return(api)
|
33
|
+
provider.api
|
34
|
+
end
|
35
|
+
|
36
|
+
its(:api) {should be == api}
|
37
|
+
|
38
|
+
describe "#check_auth" do
|
39
|
+
example do
|
40
|
+
expect(provider).to receive(:log).with("authenticated as foo@bar.com")
|
41
|
+
provider.check_auth
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#check_app" do
|
46
|
+
example do
|
47
|
+
expect(provider).to receive(:log).with("found app example")
|
48
|
+
provider.check_app
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#setup_key" do
|
53
|
+
example do
|
54
|
+
expect(File).to receive(:read).with("the file").and_return("ssh-rsa\nfoo")
|
55
|
+
expect(api).to receive(:add_key).with("key", "foo", "ssh-rsa")
|
56
|
+
provider.setup_key("the file")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#remove_key" do
|
61
|
+
example do
|
62
|
+
expect(api).to receive(:delete_key).with("key")
|
63
|
+
provider.remove_key
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#push_app" do
|
68
|
+
example "when app.deployment_branch is not set" do
|
69
|
+
expect(provider.context).to receive(:shell).with("git push git://something -f")
|
70
|
+
provider.push_app
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "when app.deployment_branch is set" do
|
75
|
+
subject :provider do
|
76
|
+
described_class.new(DummyContext.new, :user => 'foo', :password => 'foo', :domain => 'foo', :app => 'example', :key_name => 'key', :deployment_branch => 'test-branch')
|
77
|
+
|
78
|
+
expect(provider.app).to receive(:deployment_branch=).with("test-branch")
|
79
|
+
expect(provider.context).to receive(:shell).with("git push git://something -f test-branch")
|
80
|
+
provider.push_app
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#restart" do
|
85
|
+
example do
|
86
|
+
expect(provider.app).to receive(:restart)
|
87
|
+
provider.restart
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'aws-sdk'
|
3
|
+
require 'dpl/provider'
|
4
|
+
require 'dpl/provider/ops_works'
|
5
|
+
|
6
|
+
describe DPL::Provider::OpsWorks do
|
7
|
+
|
8
|
+
subject :provider do
|
9
|
+
described_class.new(DummyContext.new, :access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#opsworks_options' do
|
13
|
+
context 'without region' do
|
14
|
+
example do
|
15
|
+
options = provider.opsworks_options
|
16
|
+
expect(options[:region]).to eq('us-east-1')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with region' do
|
21
|
+
example do
|
22
|
+
region = 'us-west-1'
|
23
|
+
provider.options.update(:region => region)
|
24
|
+
options = provider.opsworks_options
|
25
|
+
expect(options[:region]).to eq(region)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#check_auth" do
|
31
|
+
example do
|
32
|
+
expect(provider).to receive(:log).with('Logging in with Access Key: ****************jklz')
|
33
|
+
provider.check_auth
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#needs_key?" do
|
38
|
+
example do
|
39
|
+
expect(provider.needs_key?).to eq(false)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe DPL::Provider::OpsWorks do
|
44
|
+
access_key_id = 'someaccesskey'
|
45
|
+
secret_access_key = 'somesecretaccesskey'
|
46
|
+
region = 'us-east-1'
|
47
|
+
|
48
|
+
client_options = {
|
49
|
+
stub_responses: true,
|
50
|
+
region: region,
|
51
|
+
credentials: Aws::Credentials.new(access_key_id, secret_access_key)
|
52
|
+
}
|
53
|
+
|
54
|
+
subject :provider do
|
55
|
+
described_class.new(DummyContext.new, {
|
56
|
+
access_key_id: access_key_id,
|
57
|
+
secret_access_key: secret_access_key
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
before :each do
|
62
|
+
expect(provider).to receive(:opsworks_options).and_return(client_options)
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#opsworks' do
|
66
|
+
example do
|
67
|
+
expect(Aws::OpsWorks::Client).to receive(:new).with(client_options).once
|
68
|
+
provider.opsworks
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#push_app" do
|
73
|
+
let(:client) { provider.opsworks }
|
74
|
+
let(:ops_works_app) { {shortname: 'app', stack_id: 'stack-id'} }
|
75
|
+
before do
|
76
|
+
expect(provider).to receive(:current_sha).and_return('sha')
|
77
|
+
expect(provider.context.env).to receive(:[]).with('TRAVIS_BUILD_NUMBER').and_return('123')
|
78
|
+
end
|
79
|
+
|
80
|
+
let(:custom_json) { "{\"deploy\":{\"app\":{\"migrate\":false,\"scm\":{\"revision\":\"sha\"}}}}" }
|
81
|
+
example 'without :migrate option' do
|
82
|
+
provider.options.update(app_id: 'app-id')
|
83
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
84
|
+
expect(client).to receive(:create_deployment).with(
|
85
|
+
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
86
|
+
).and_return({})
|
87
|
+
provider.push_app
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:custom_json_with_migrate) { "{\"deploy\":{\"app\":{\"migrate\":true,\"scm\":{\"revision\":\"sha\"}}}}" }
|
91
|
+
example 'with :migrate option' do
|
92
|
+
provider.options.update(app_id: 'app-id', migrate: true)
|
93
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
94
|
+
expect(client).to receive(:create_deployment).with(
|
95
|
+
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json_with_migrate
|
96
|
+
).and_return({})
|
97
|
+
provider.push_app
|
98
|
+
end
|
99
|
+
|
100
|
+
example 'with :wait_until_deployed' do
|
101
|
+
provider.options.update(app_id: 'app-id', wait_until_deployed: true)
|
102
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
103
|
+
expect(client).to receive(:create_deployment).and_return({deployment_id: 'deployment_id'})
|
104
|
+
expect(client).to receive(:describe_deployments).with({deployment_ids: ['deployment_id']}).and_return({deployments: [status: 'running']}, {deployments: [status: 'successful']})
|
105
|
+
provider.push_app
|
106
|
+
end
|
107
|
+
|
108
|
+
example 'with :instance-ids' do
|
109
|
+
provider.options.update(app_id: 'app-id', instance_ids: ['instance-id'])
|
110
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
111
|
+
expect(client).to receive(:create_deployment).with(
|
112
|
+
stack_id: 'stack-id', app_id: 'app-id', instance_ids:['instance-id'], command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
113
|
+
).and_return({})
|
114
|
+
provider.push_app
|
115
|
+
end
|
116
|
+
|
117
|
+
example 'with :layer-ids' do
|
118
|
+
provider.options.update(app_id: 'app-id', layer_ids: ['layer-id'])
|
119
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
120
|
+
expect(client).to receive(:create_deployment).with(
|
121
|
+
stack_id: 'stack-id', app_id: 'app-id', layer_ids:['layer-id'], command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
122
|
+
).and_return({})
|
123
|
+
provider.push_app
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'gems'
|
4
|
+
require 'dpl/provider/packagecloud'
|
5
|
+
|
6
|
+
describe DPL::Provider::Packagecloud do
|
7
|
+
|
8
|
+
subject :provider do
|
9
|
+
described_class.new(DummyContext.new, :username => 'joedamato', :repository => 'test_repo', :token => 'test_token')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#setup_auth" do
|
13
|
+
it 'should get username and token' do
|
14
|
+
expect(provider).to receive(:log).with("Logging into https://packagecloud.io with joedamato:****************oken")
|
15
|
+
provider.setup_auth
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should require username' do
|
19
|
+
new_provider = described_class.new(DummyContext.new, {:token => 'test_token'})
|
20
|
+
expect{ new_provider.setup_auth }.to raise_error("missing username")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should require token' do
|
24
|
+
new_provider = described_class.new(DummyContext.new, {:username => 'test_token'})
|
25
|
+
expect{ new_provider.setup_auth }.to raise_error("missing token")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should require repository' do
|
29
|
+
new_provider = described_class.new(DummyContext.new, {:username => 'joedamato', :token => 'test_token'})
|
30
|
+
expect{ new_provider.setup_auth }.to raise_error("missing repository")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#push_app" do
|
36
|
+
it 'defaults to searching everywhere' do
|
37
|
+
expect(Dir).to receive(:glob).with('**/*')
|
38
|
+
expect { provider.push_app }.to raise_error(DPL::Error)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'accepts and uses a string glob' do
|
42
|
+
provider.options.update(:package_glob => 'foo*.gem')
|
43
|
+
|
44
|
+
expect(Dir).to receive(:glob).with('foo*.gem')
|
45
|
+
expect { provider.push_app }.to raise_error(DPL::Error)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'accepts and uses an array of globs' do
|
49
|
+
provider.options.update(:package_glob => ['*.rpm', '**/*.deb'])
|
50
|
+
|
51
|
+
expect(Dir).to receive(:glob).with('*.rpm', '**/*.deb')
|
52
|
+
expect { provider.push_app }.to raise_error(DPL::Error)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dpl/provider/puppet_forge'
|
3
|
+
require 'puppet/face'
|
4
|
+
require 'puppet_blacksmith'
|
5
|
+
|
6
|
+
describe DPL::Provider::PuppetForge do
|
7
|
+
subject :provider do
|
8
|
+
described_class.new(DummyContext.new, :user => 'puppetlabs', :password => 's3cr3t')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "forge" do
|
12
|
+
it 'should include the user and password specified' do
|
13
|
+
expect(provider.forge.username).to eq(provider.options[:user])
|
14
|
+
expect(provider.forge.password).to eq(provider.options[:password])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "build" do
|
19
|
+
it 'should use Puppet module tool to build the module' do
|
20
|
+
pmt = double('pmt')
|
21
|
+
expect(::Puppet::Face).to receive(:[]).and_return(pmt)
|
22
|
+
expect(pmt).to receive(:build).with('./')
|
23
|
+
provider.build
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#check_auth" do
|
28
|
+
it 'should require a user' do
|
29
|
+
provider.options.update(:user => nil)
|
30
|
+
expect{ provider.check_auth }.to raise_error("must supply a user")
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should require a password' do
|
34
|
+
provider.options.update(:password => nil)
|
35
|
+
expect{ provider.check_auth }.to raise_error("must supply a password")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#check_app" do
|
40
|
+
it 'should load module metadata using Blacksmith' do
|
41
|
+
modulefile = double('modulefile')
|
42
|
+
expect(::Blacksmith::Modulefile).to receive(:new).and_return(modulefile)
|
43
|
+
expect(modulefile).to receive(:metadata) { true }
|
44
|
+
provider.check_app
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#push_app" do
|
49
|
+
it 'should use Blacksmith to push to the Forge' do
|
50
|
+
forge = double('forge')
|
51
|
+
expect(provider).to receive(:build).and_return(true)
|
52
|
+
expect(provider).to receive(:modulefile).at_least(:once).and_return(double('modulefile', :name => 'test'))
|
53
|
+
expect(provider).to receive(:log).and_return(true)
|
54
|
+
expect(::Blacksmith::Forge).to receive(:new).and_return(forge)
|
55
|
+
expect(forge).to receive(:push!) { true }
|
56
|
+
expect(forge).to receive(:username) { provider.options[:user] }
|
57
|
+
provider.push_app
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|