kpm 0.7.1 → 0.9.0
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 +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +138 -0
- data/Gemfile +2 -0
- data/README.adoc +126 -109
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +10 -8
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +269 -337
- data/lib/kpm/base_artifact.rb +40 -36
- data/lib/kpm/base_installer.rb +71 -84
- data/lib/kpm/blob.rb +29 -0
- data/lib/kpm/cli.rb +3 -1
- data/lib/kpm/coordinates.rb +10 -12
- data/lib/kpm/database.rb +93 -103
- data/lib/kpm/diagnostic_file.rb +126 -146
- data/lib/kpm/formatter.rb +76 -48
- data/lib/kpm/inspector.rb +24 -34
- data/lib/kpm/installer.rb +53 -46
- data/lib/kpm/kaui_artifact.rb +4 -3
- data/lib/kpm/killbill_plugin_artifact.rb +10 -7
- data/lib/kpm/killbill_server_artifact.rb +24 -10
- data/lib/kpm/migrations.rb +26 -11
- data/lib/kpm/nexus_helper/actions.rb +45 -9
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
- data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
- data/lib/kpm/plugins_directory.rb +14 -9
- data/lib/kpm/plugins_directory.yml +16 -175
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +56 -15
- data/lib/kpm/system.rb +104 -135
- data/lib/kpm/system_helpers/cpu_information.rb +56 -55
- data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
- data/lib/kpm/system_helpers/entropy_available.rb +37 -39
- data/lib/kpm/system_helpers/memory_information.rb +52 -51
- data/lib/kpm/system_helpers/os_information.rb +45 -47
- data/lib/kpm/system_helpers/system_proxy.rb +10 -10
- data/lib/kpm/tasks.rb +370 -443
- data/lib/kpm/tenant_config.rb +68 -83
- data/lib/kpm/tomcat_manager.rb +10 -8
- data/lib/kpm/trace_logger.rb +18 -16
- data/lib/kpm/uninstaller.rb +81 -14
- data/lib/kpm/utils.rb +13 -14
- data/lib/kpm/version.rb +3 -1
- data/packaging/Gemfile +2 -0
- data/pom.xml +1 -1
- data/spec/kpm/remote/base_artifact_spec.rb +33 -17
- data/spec/kpm/remote/base_installer_spec.rb +35 -34
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +80 -78
- data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +30 -13
- data/spec/kpm/remote/migrations_spec.rb +12 -11
- data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
- data/spec/kpm/remote/tenant_config_spec.rb +30 -29
- data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
- data/spec/kpm/unit/actions_spec.rb +52 -0
- data/spec/kpm/unit/base_artifact_spec.rb +19 -18
- data/spec/kpm/unit/cpu_information_spec.rb +67 -0
- data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
- data/spec/kpm/unit/entropy_information_spec.rb +36 -0
- data/spec/kpm/unit/formatter_spec.rb +163 -0
- data/spec/kpm/unit/inspector_spec.rb +34 -42
- data/spec/kpm/unit/installer_spec.rb +7 -6
- data/spec/kpm/unit/memory_information_spec.rb +102 -0
- data/spec/kpm/unit/os_information_spec.rb +38 -0
- data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
- data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
- data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
- data/spec/kpm/unit/uninstaller_spec.rb +118 -72
- data/spec/kpm/unit_mysql/account_spec.rb +144 -143
- data/spec/spec_helper.rb +20 -18
- data/tasks/package.rake +18 -18
- metadata +26 -22
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillPluginArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -16,15 +17,15 @@ describe KPM::KillbillPluginArtifact do
|
|
16
17
|
KPM::BaseArtifact::KAUI_CLASSIFIER,
|
17
18
|
'LATEST',
|
18
19
|
dir)
|
19
|
-
info[:file_name].
|
20
|
-
info[:size].
|
20
|
+
expect(info[:file_name]).to eq "kaui-standalone-#{info[:version]}.war"
|
21
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'should be able to list versions' do
|
25
26
|
versions = KPM::KauiArtifact.versions.to_a
|
26
|
-
versions.size.
|
27
|
-
versions[0].
|
28
|
-
versions[1].
|
27
|
+
expect(versions.size).to be >= 2
|
28
|
+
expect(versions[0]).to eq '0.0.1'
|
29
|
+
expect(versions[1]).to eq '0.0.2'
|
29
30
|
end
|
30
31
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillPluginArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -19,15 +20,15 @@ describe KPM::KillbillPluginArtifact do
|
|
19
20
|
|
20
21
|
Dir.mktmpdir do |dir|
|
21
22
|
info = KPM::KillbillPluginArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, plugin_name, dir)
|
22
|
-
info[:file_name].
|
23
|
+
expect(info[:file_name]).to be_nil
|
23
24
|
|
24
25
|
files_in_dir = Dir[info[:file_path] + '/*']
|
25
|
-
files_in_dir.size.
|
26
|
-
files_in_dir[0].
|
26
|
+
expect(files_in_dir.size).to eq 1
|
27
|
+
expect(files_in_dir[0]).to eq info[:file_path] + '/killbill-payment-test'
|
27
28
|
|
28
|
-
File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').
|
29
|
+
expect(File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties')).to eq "mainClass=PaymentTest::PaymentPlugin\nrequire=payment_test\npluginType=PAYMENT\n"
|
29
30
|
|
30
|
-
info[:bundle_dir].
|
31
|
+
expect(info[:bundle_dir]).to eq info[:file_path] + '/killbill-payment-test/1.8.7'
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -43,8 +44,8 @@ describe KPM::KillbillPluginArtifact do
|
|
43
44
|
'killbill-analytics',
|
44
45
|
dir,
|
45
46
|
sha1_file)
|
46
|
-
info[:file_name].
|
47
|
-
info[:size].
|
47
|
+
expect(info[:file_name]).to eq "analytics-plugin-#{info[:version]}.jar"
|
48
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
48
49
|
|
49
50
|
check_yaml_for_resolved_latest_version(sha1_file, 'org.kill-bill.billing.plugin.java:analytics-plugin:jar', '3.0.0')
|
50
51
|
end
|
@@ -62,31 +63,28 @@ describe KPM::KillbillPluginArtifact do
|
|
62
63
|
sha1_file)
|
63
64
|
|
64
65
|
# No file name - since we untar'ed it
|
65
|
-
info[:file_name].
|
66
|
+
expect(info[:file_name]).to be_nil
|
66
67
|
|
67
68
|
check_yaml_for_resolved_latest_version(sha1_file, 'org.kill-bill.billing.plugin.ruby:logging-plugin:tar.gz', '3.0.0')
|
68
69
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
70
|
end
|
73
71
|
|
74
72
|
it 'should be able to list versions' do
|
75
73
|
versions = KPM::KillbillPluginArtifact.versions
|
76
74
|
|
77
|
-
versions[:java].
|
78
|
-
versions[:java]['analytics-plugin'].
|
75
|
+
expect(versions[:java]).not_to be_nil
|
76
|
+
expect(versions[:java]['analytics-plugin']).not_to be_nil
|
79
77
|
logging_plugin_versions = versions[:java]['analytics-plugin'].to_a
|
80
|
-
logging_plugin_versions.size.
|
81
|
-
logging_plugin_versions[0].
|
82
|
-
logging_plugin_versions[1].
|
83
|
-
logging_plugin_versions[2].
|
78
|
+
expect(logging_plugin_versions.size).to be >= 3
|
79
|
+
expect(logging_plugin_versions[0]).to eq '0.6.0'
|
80
|
+
expect(logging_plugin_versions[1]).to eq '0.7.0'
|
81
|
+
expect(logging_plugin_versions[2]).to eq '0.7.1'
|
84
82
|
|
85
|
-
versions[:ruby].
|
86
|
-
versions[:ruby]['logging-plugin'].
|
83
|
+
expect(versions[:ruby]).not_to be_nil
|
84
|
+
expect(versions[:ruby]['logging-plugin']).not_to be_nil
|
87
85
|
logging_plugin_versions = versions[:ruby]['logging-plugin'].to_a
|
88
|
-
logging_plugin_versions.size.
|
89
|
-
logging_plugin_versions[0].
|
86
|
+
expect(logging_plugin_versions.size).to be >= 1
|
87
|
+
expect(logging_plugin_versions[0]).to eq '1.7.0'
|
90
88
|
end
|
91
89
|
|
92
90
|
private
|
@@ -95,17 +93,14 @@ describe KPM::KillbillPluginArtifact do
|
|
95
93
|
# (we can't check against actual version because as we keep releasing those increment,
|
96
94
|
# so the best we can do it check this is *not* LATEST and greater than current version at the time the test was written )
|
97
95
|
def check_yaml_for_resolved_latest_version(sha1_file, key_prefix, minimum_version)
|
98
|
-
|
99
96
|
sha1_checker = KPM::Sha1Checker.from_file(sha1_file)
|
100
97
|
|
101
|
-
keys = sha1_checker.all_sha1.keys.select { |k| k.start_with? key_prefix}
|
102
|
-
keys.size.
|
98
|
+
keys = sha1_checker.all_sha1.keys.select { |k| k.start_with? key_prefix }
|
99
|
+
expect(keys.size).to eq 1
|
103
100
|
|
104
101
|
parts = keys[0].split(':')
|
105
|
-
parts.size.
|
106
|
-
parts[3].
|
107
|
-
parts[3].
|
102
|
+
expect(parts.size).to eq 4
|
103
|
+
expect(parts[3]).not_to eq 'LATEST'
|
104
|
+
expect(parts[3]).to be >= minimum_version
|
108
105
|
end
|
109
|
-
|
110
|
-
|
111
106
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillServerArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -17,25 +18,41 @@ describe KPM::KillbillServerArtifact do
|
|
17
18
|
KPM::BaseArtifact::KILLBILL_CLASSIFIER,
|
18
19
|
'LATEST',
|
19
20
|
dir)
|
20
|
-
info[:file_name].
|
21
|
-
info[:size].
|
21
|
+
expect(info[:file_name]).to eq "killbill-profiles-killbill-#{info[:version]}.war"
|
22
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'should be able to list versions' do
|
26
27
|
versions = KPM::KillbillServerArtifact.versions(KPM::BaseArtifact::KILLBILL_ARTIFACT_ID).to_a
|
27
|
-
versions.size.
|
28
|
-
versions[0].
|
29
|
-
versions[1].
|
28
|
+
expect(versions.size).to be >= 2
|
29
|
+
expect(versions[0]).to eq '0.11.10'
|
30
|
+
expect(versions[1]).to eq '0.11.11'
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'should get dependencies information' do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
nexus_down = { url: 'https://does.not.exist' }
|
35
|
+
|
36
|
+
Dir.mktmpdir do |dir|
|
37
|
+
sha1_file = "#{dir}/sha1.yml"
|
38
|
+
info = KPM::KillbillServerArtifact.info('0.15.9', sha1_file)
|
39
|
+
expect(info['killbill']).to eq '0.15.9'
|
40
|
+
expect(info['killbill-oss-parent']).to eq '0.62'
|
41
|
+
expect(info['killbill-api']).to eq '0.27'
|
42
|
+
expect(info['killbill-plugin-api']).to eq '0.16'
|
43
|
+
expect(info['killbill-commons']).to eq '0.10'
|
44
|
+
expect(info['killbill-platform']).to eq '0.13'
|
45
|
+
expect(KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9')).to eq info
|
46
|
+
|
47
|
+
# Verify the download is skipped gracefully when Nexus isn't reachable
|
48
|
+
KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down)
|
49
|
+
|
50
|
+
# Verify the download fails when Nexus isn't reachable and force_download is set
|
51
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
52
|
+
|
53
|
+
# Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
|
54
|
+
KPM::Sha1Checker.from_file(sha1_file).cache_killbill_info('0.15.9', nil)
|
55
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
56
|
+
end
|
40
57
|
end
|
41
58
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
4
|
|
5
|
+
describe KPM::Migrations, skip_me_if_nil: ENV['TOKEN'].nil? do
|
5
6
|
context 'plugins' do
|
6
7
|
it 'should be able to find migrations for a java plugin' do
|
7
8
|
migrations = KPM::Migrations.new('analytics-plugin-3.0.2', nil, 'killbill/killbill-analytics-plugin', ENV['TOKEN']).migrations
|
8
9
|
# No migration yet
|
9
|
-
migrations.size.
|
10
|
+
expect(migrations.size).to eq 0
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'should be able to find migrations for a ruby plugin' do
|
13
14
|
migrations = KPM::Migrations.new('master', nil, 'killbill/killbill-cybersource-plugin', ENV['TOKEN']).migrations
|
14
15
|
# No migration yet
|
15
|
-
migrations.size.
|
16
|
+
expect(migrations.size).to eq 1
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -20,19 +21,19 @@ describe KPM::Migrations, :skip_me_if_nil => ENV['TOKEN'].nil? do
|
|
20
21
|
it 'should be able to find migrations between two versions' do
|
21
22
|
migrations = KPM::Migrations.new('killbill-0.16.3', 'killbill-0.16.4', 'killbill/killbill', ENV['TOKEN']).migrations
|
22
23
|
|
23
|
-
migrations.size.
|
24
|
-
migrations.first[:name].
|
25
|
-
migrations.first[:sql].
|
24
|
+
expect(migrations.size).to eq 1
|
25
|
+
expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
26
|
+
expect(migrations.first[:sql]).to eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
26
27
|
|
27
|
-
KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size.
|
28
|
+
expect(KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size).to eq 0
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'should be able to find migrations for a given version' do
|
31
32
|
migrations = KPM::Migrations.new('killbill-0.16.4', nil, 'killbill/killbill', ENV['TOKEN']).migrations
|
32
33
|
|
33
|
-
migrations.size.
|
34
|
-
migrations.first[:name].
|
35
|
-
migrations.first[:sql].
|
34
|
+
expect(migrations.size).to eq 1
|
35
|
+
expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
36
|
+
expect(migrations.first[:sql]).to eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -1,60 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'rexml/document'
|
3
5
|
|
4
6
|
describe KPM::NexusFacade do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
let(:coordinates_map) do
|
8
|
+
{ version: '0.1.4',
|
9
|
+
group_id: 'org.kill-bill.billing',
|
10
|
+
artifact_id: 'killbill-platform-osgi-api',
|
11
|
+
packaging: 'jar',
|
12
|
+
classifier: nil }
|
13
|
+
end
|
14
|
+
let(:coordinates_with_classifier_map) do
|
15
|
+
{ version: '0.1.1',
|
16
|
+
group_id: 'org.kill-bill.billing',
|
17
|
+
artifact_id: 'killbill-platform-osgi-bundles-jruby',
|
18
|
+
packaging: 'jar',
|
19
|
+
classifier: 'javadoc' }
|
20
|
+
end
|
21
|
+
let(:coordinates) { KPM::Coordinates.build_coordinates(coordinates_map) }
|
22
|
+
let(:coordinates_with_classifier) { KPM::Coordinates.build_coordinates(coordinates_with_classifier_map) }
|
23
|
+
let(:nexus_remote) { described_class::RemoteFactory.create(nil, true) }
|
19
24
|
|
20
25
|
it 'when searching for artifacts' do
|
21
26
|
response = nil
|
22
|
-
expect{
|
23
|
-
expect(REXML::Document.new(response).elements[
|
27
|
+
expect { response = nexus_remote.search_for_artifacts(coordinates) }.not_to raise_exception
|
28
|
+
expect(REXML::Document.new(response).elements['//artifactId'].text).to eq(coordinates_map[:artifact_id])
|
24
29
|
end
|
25
30
|
|
26
31
|
it 'when searching for artifact with classifier' do
|
27
32
|
response = nil
|
28
|
-
expect{
|
29
|
-
expect(REXML::Document.new(response).elements[
|
33
|
+
expect { response = nexus_remote.search_for_artifacts(coordinates_with_classifier) }.not_to raise_exception
|
34
|
+
expect(REXML::Document.new(response).elements['//artifactId'].text).to eq(coordinates_with_classifier_map[:artifact_id])
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'when getting artifact info' do
|
33
38
|
response = nil
|
34
|
-
expect{
|
35
|
-
expect(REXML::Document.new(response).elements[
|
39
|
+
expect { response = nexus_remote.get_artifact_info(coordinates) }.not_to raise_exception
|
40
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_map[:version])
|
36
41
|
end
|
37
42
|
|
38
43
|
it 'when getting artifact info with classifier' do
|
39
44
|
response = nil
|
40
|
-
expect{
|
41
|
-
expect(REXML::Document.new(response).elements[
|
45
|
+
expect { response = nexus_remote.get_artifact_info(coordinates_with_classifier) }.not_to raise_exception
|
46
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_with_classifier_map[:version])
|
42
47
|
end
|
43
48
|
|
44
49
|
it 'when pull artifact' do
|
45
50
|
response = nil
|
46
51
|
destination = Dir.mktmpdir('artifact')
|
47
|
-
expect{
|
52
|
+
expect { response = nexus_remote.pull_artifact(coordinates, destination) }.not_to raise_exception
|
48
53
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
49
|
-
expect(File.exist?(destination)).to
|
54
|
+
expect(File.exist?(destination)).to be_truthy
|
50
55
|
end
|
51
56
|
|
52
57
|
it 'when pull artifact with classifier' do
|
53
58
|
response = nil
|
54
59
|
destination = Dir.mktmpdir('artifact')
|
55
|
-
expect{
|
60
|
+
expect { response = nexus_remote.pull_artifact(coordinates_with_classifier, destination) }.not_to raise_exception
|
56
61
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
57
|
-
expect(File.exist?(destination)).to
|
62
|
+
expect(File.exist?(destination)).to be_truthy
|
58
63
|
end
|
59
|
-
|
60
|
-
end
|
64
|
+
end
|
@@ -1,58 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::TenantConfig do
|
4
6
|
include_context 'connection_setup'
|
5
7
|
|
6
|
-
let(:value) {"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<catalog>\n <effectiveDate>2017-04-25T15:57:43Z</effectiveDate>\n <catalogName>DEFAULT</catalogName>\n <recurringBillingMode>IN_ADVANCE</recurringBillingMode>\n <currencies/>\n <units/>\n <products/>\n <rules>\n <changePolicy>\n <changePolicyCase>\n <policy>IMMEDIATE</policy>\n </changePolicyCase>\n </changePolicy>\n <changeAlignment>\n <changeAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </changeAlignmentCase>\n </changeAlignment>\n <cancelPolicy>\n <cancelPolicyCase>\n <policy>IMMEDIATE</policy>\n </cancelPolicyCase>\n </cancelPolicy>\n <createAlignment>\n <createAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </createAlignmentCase>\n </createAlignment>\n <billingAlignment>\n <billingAlignmentCase>\n <alignment>ACCOUNT</alignment>\n </billingAlignmentCase>\n </billingAlignment>\n <priceList>\n <priceListCase>\n <toPriceList>DEFAULT</toPriceList>\n </priceListCase>\n </priceList>\n </rules>\n <plans/>\n <priceLists>\n <defaultPriceList name=\"DEFAULT\">\n <plans/>\n </defaultPriceList>\n </priceLists>\n</catalog>\n"}
|
7
|
-
let(:key) {'CATALOG_RSPEC'}
|
8
|
-
|
9
|
-
let(:user) {'KPM Tenant Spec'}
|
10
|
-
let(:tenant_config_class)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
let(:value) { "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<catalog>\n <effectiveDate>2017-04-25T15:57:43Z</effectiveDate>\n <catalogName>DEFAULT</catalogName>\n <recurringBillingMode>IN_ADVANCE</recurringBillingMode>\n <currencies/>\n <units/>\n <products/>\n <rules>\n <changePolicy>\n <changePolicyCase>\n <policy>IMMEDIATE</policy>\n </changePolicyCase>\n </changePolicy>\n <changeAlignment>\n <changeAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </changeAlignmentCase>\n </changeAlignment>\n <cancelPolicy>\n <cancelPolicyCase>\n <policy>IMMEDIATE</policy>\n </cancelPolicyCase>\n </cancelPolicy>\n <createAlignment>\n <createAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </createAlignmentCase>\n </createAlignment>\n <billingAlignment>\n <billingAlignmentCase>\n <alignment>ACCOUNT</alignment>\n </billingAlignmentCase>\n </billingAlignment>\n <priceList>\n <priceListCase>\n <toPriceList>DEFAULT</toPriceList>\n </priceListCase>\n </priceList>\n </rules>\n <plans/>\n <priceLists>\n <defaultPriceList name=\"DEFAULT\">\n <plans/>\n </defaultPriceList>\n </priceLists>\n</catalog>\n" }
|
9
|
+
let(:key) { 'CATALOG_RSPEC' }
|
10
|
+
|
11
|
+
let(:user) { 'KPM Tenant Spec' }
|
12
|
+
let(:tenant_config_class) do
|
13
|
+
described_class.new([killbill_api_key, killbill_api_secret],
|
14
|
+
[killbill_user, killbill_password], url, logger)
|
15
|
+
end
|
16
|
+
let(:options) do
|
17
|
+
{
|
18
|
+
username: killbill_user,
|
19
|
+
password: killbill_password,
|
20
|
+
api_key: killbill_api_key,
|
21
|
+
api_secret: killbill_api_secret
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
19
25
|
describe '#initialize' do
|
20
26
|
context 'when creating an instance of tenant config class' do
|
21
|
-
|
22
27
|
it 'when initialized with defaults' do
|
23
28
|
expect(described_class.new).to be_an_instance_of(KPM::TenantConfig)
|
24
29
|
end
|
25
30
|
|
26
31
|
it 'when initialized with options' do
|
27
|
-
tenant_config_class.
|
32
|
+
expect(tenant_config_class).to be_an_instance_of(KPM::TenantConfig)
|
28
33
|
expect(tenant_config_class.instance_variable_get(:@killbill_api_key)).to eq(killbill_api_key)
|
29
|
-
expect(tenant_config_class.instance_variable_get(:@
|
34
|
+
expect(tenant_config_class.instance_variable_get(:@killbill_api_secret)).to eq(killbill_api_secret)
|
30
35
|
expect(tenant_config_class.instance_variable_get(:@killbill_user)).to eq(killbill_user)
|
31
36
|
expect(tenant_config_class.instance_variable_get(:@killbill_password)).to eq(killbill_password)
|
32
37
|
expect(tenant_config_class.instance_variable_get(:@killbill_url)).to eq(url)
|
33
|
-
|
34
38
|
end
|
35
|
-
|
36
39
|
end
|
40
|
+
end
|
37
41
|
|
38
|
-
end
|
39
|
-
|
40
42
|
describe '#export' do
|
41
43
|
it 'when retrieving tenant configuration' do
|
42
44
|
KillBillClient.url = url
|
43
45
|
|
44
|
-
#Add a new tenant config
|
46
|
+
# Add a new tenant config
|
45
47
|
tenant_config = KillBillClient::Model::Tenant.upload_tenant_user_key_value(key, value, user, nil, nil, options)
|
46
48
|
expect(tenant_config.key).to eq(key)
|
47
|
-
|
48
|
-
#get created tenant config
|
49
|
+
|
50
|
+
# get created tenant config
|
49
51
|
export_file = tenant_config_class.export(key)
|
50
|
-
expect(File.exist?(export_file)).to
|
51
|
-
expect(File.readlines(export_file).grep(/#{key}/)).to
|
52
|
-
|
53
|
-
#remove created tenant config
|
52
|
+
expect(File.exist?(export_file)).to be_truthy
|
53
|
+
expect(File.readlines(export_file).grep(/#{key}/)).to be_truthy
|
54
|
+
|
55
|
+
# remove created tenant config
|
54
56
|
KillBillClient::Model::Tenant.delete_tenant_user_key_value(key, user, nil, nil, options)
|
55
|
-
|
56
57
|
end
|
57
58
|
end
|
58
|
-
end
|
59
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::TomcatManager do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -12,10 +13,10 @@ describe KPM::TomcatManager do
|
|
12
13
|
manager = KPM::TomcatManager.new(dir, @logger)
|
13
14
|
|
14
15
|
tomcat_path = manager.download
|
15
|
-
tomcat_path.
|
16
|
+
expect(tomcat_path).not_to be_nil
|
16
17
|
|
17
18
|
root_war_path = manager.setup
|
18
|
-
root_war_path.
|
19
|
+
expect(root_war_path).not_to be_nil
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|