foreman_puppet 0.1.0 → 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb +28 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +1 -1
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/{base_controller.rb → puppet_base_controller.rb} +2 -3
- data/app/controllers/foreman_puppet/api/v2/{lookups_common_controller.rb → puppet_lookups_common_controller.rb} +6 -2
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +1 -2
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +9 -2
- data/app/graphgl/concerns/foreman_puppet/mutations/hosts/create_extensions.rb +29 -0
- data/app/graphgl/concerns/foreman_puppet/types/host_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/hostgroup_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/location_extensions.rb +14 -0
- data/app/graphgl/concerns/foreman_puppet/types/organization_extensions.rb +14 -0
- data/app/graphgl/foreman_puppet/types/environment.rb +20 -0
- data/app/graphgl/foreman_puppet/types/puppetclass.rb +20 -0
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +2 -2
- data/app/models/concerns/foreman_puppet/extensions/host.rb +6 -4
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +6 -2
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +16 -10
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
- data/app/models/foreman_puppet/environment.rb +2 -0
- data/app/models/foreman_puppet/host_puppet_facet.rb +1 -1
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +1 -1
- data/app/models/{concerns/foreman_puppet/host_common.rb → foreman_puppet/puppet_facet_common.rb} +1 -1
- data/app/models/foreman_puppet/puppetclass.rb +2 -0
- data/app/{views/api/v2/template_combinations/base.json.erb → prepend_views/api/v2/template_combinations/base.json.rabl} +0 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +3 -4
- data/app/views/foreman_puppet/config_groups/index.html.erb +2 -2
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -11
- data/app/views/foreman_puppet/environments/welcome.html.erb +3 -15
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +10 -8
- data/config/initializers/api_reroute.rb +13 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +16 -10
- data/lib/foreman_puppet.rb +1 -1
- data/lib/foreman_puppet/engine.rb +48 -16
- data/lib/foreman_puppet/register.rb +5 -0
- data/lib/foreman_puppet/version.rb +1 -1
- data/locale/en/foreman_puppet.edit.po +927 -0
- data/locale/en/foreman_puppet.po.time_stamp +0 -0
- data/locale/en/foreman_puppet.pox +0 -0
- data/locale/messages.mo +0 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +17 -15
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +2 -1
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +3 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +7 -1
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/environments_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +5 -6
- data/test/factories/host_puppet_enhancements.rb +6 -6
- data/test/graphql/mutations/hosts/create_mutation_test.rb +66 -0
- data/test/graphql/queries/environment_query_test.rb +54 -0
- data/test/graphql/queries/environments_query_test.rb +43 -0
- data/test/{qraphql → graphql}/queries/host_puppet_query_test.rb +3 -8
- data/test/{qraphql → graphql}/queries/hostgroup_puppet_query_test.rb +1 -6
- data/test/graphql/queries/location_query_test.rb +52 -0
- data/test/graphql/queries/organization_query_test.rb +52 -0
- data/test/graphql/queries/puppetclass_query_test.rb +68 -0
- data/test/graphql/queries/puppetclasses_query_test.rb +43 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +4 -1
- data/test/integration/foreman_puppet/host_js_test.rb +1 -1
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +1 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +3 -1
- data/test/models/foreman_puppet/environment_test.rb +2 -0
- data/test/models/foreman_puppet/host_test.rb +3 -2
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
- data/test/models/foreman_puppet/provisioning_template_test.rb +23 -23
- data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +13 -5
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +0 -36
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +3 -1
- data/webpack/index.js +3 -4
- data/webpack/src/Components/Environments/Welcome.js +37 -0
- metadata +78 -50
@@ -12,9 +12,6 @@ module Queries
|
|
12
12
|
environment {
|
13
13
|
id
|
14
14
|
}
|
15
|
-
puppetProxy {
|
16
|
-
id
|
17
|
-
}
|
18
15
|
}
|
19
16
|
}
|
20
17
|
GRAPHQL
|
@@ -23,14 +20,12 @@ module Queries
|
|
23
20
|
let(:host) { FactoryBot.create(:host, :with_puppet_enc) }
|
24
21
|
let(:global_id) { Foreman::GlobalId.encode('Host', host.id) }
|
25
22
|
let(:variables) { { id: global_id } }
|
23
|
+
let(:data) { result['data']['host'] }
|
26
24
|
|
27
25
|
test 'fetching host attributes' do
|
28
|
-
skip 'GraphQL is TODO'
|
29
|
-
host_data = result['data']['host']
|
30
26
|
assert_empty result['errors']
|
31
|
-
assert_equal global_id,
|
32
|
-
assert_record host.environment,
|
33
|
-
assert_record host.puppet_proxy, host_data['puppetProxy']
|
27
|
+
assert_equal global_id, data['id']
|
28
|
+
assert_record host.environment, data['environment']
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
@@ -12,25 +12,20 @@ module Queries
|
|
12
12
|
environment {
|
13
13
|
id
|
14
14
|
}
|
15
|
-
puppetProxy {
|
16
|
-
id
|
17
|
-
}
|
18
15
|
}
|
19
16
|
}
|
20
17
|
GRAPHQL
|
21
18
|
end
|
22
19
|
|
23
|
-
let(:hostgroup) { FactoryBot.create(:hostgroup, :with_puppet_enc) }
|
20
|
+
let(:hostgroup) { FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass) }
|
24
21
|
let(:global_id) { Foreman::GlobalId.encode('Hostgroup', hostgroup.id) }
|
25
22
|
let(:variables) { { id: global_id } }
|
26
23
|
|
27
24
|
test 'fetching host attributes' do
|
28
|
-
skip 'GraphQL is TODO'
|
29
25
|
hostgroup_data = result['data']['hostgroup']
|
30
26
|
assert_empty result['errors']
|
31
27
|
assert_equal global_id, hostgroup_data['id']
|
32
28
|
assert_record hostgroup.puppet.environment, hostgroup_data['environment']
|
33
|
-
assert_record hostgroup.puppet_proxy, hostgroup_data['puppetProxy']
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module Queries
|
4
|
+
class LocationQueryTest < GraphQLQueryTestCase
|
5
|
+
let(:query) do
|
6
|
+
<<-GRAPHQL
|
7
|
+
query (
|
8
|
+
$id: String!
|
9
|
+
) {
|
10
|
+
location(id: $id) {
|
11
|
+
id
|
12
|
+
environments {
|
13
|
+
totalCount
|
14
|
+
edges {
|
15
|
+
node {
|
16
|
+
id
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
puppetclasses {
|
21
|
+
totalCount
|
22
|
+
edges {
|
23
|
+
node {
|
24
|
+
id
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
GRAPHQL
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:environment) { FactoryBot.create(:environment) }
|
34
|
+
let(:location_object) { FactoryBot.create(:location, environments: [environment]) }
|
35
|
+
|
36
|
+
let(:global_id) { Foreman::GlobalId.for(location_object) }
|
37
|
+
let(:variables) { { id: global_id } }
|
38
|
+
let(:data) { result['data']['location'] }
|
39
|
+
|
40
|
+
setup do
|
41
|
+
FactoryBot.create(:puppetclass, environments: [environment])
|
42
|
+
end
|
43
|
+
|
44
|
+
test 'fetching location attributes' do
|
45
|
+
assert_empty result['errors']
|
46
|
+
|
47
|
+
assert_equal global_id, data['id']
|
48
|
+
assert_collection location_object.environments, data['environments']
|
49
|
+
assert_collection location_object.puppetclasses, data['puppetclasses']
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module Queries
|
4
|
+
class OrganizationQueryTest < GraphQLQueryTestCase
|
5
|
+
let(:query) do
|
6
|
+
<<-GRAPHQL
|
7
|
+
query (
|
8
|
+
$id: String!
|
9
|
+
) {
|
10
|
+
organization(id: $id) {
|
11
|
+
id
|
12
|
+
environments {
|
13
|
+
totalCount
|
14
|
+
edges {
|
15
|
+
node {
|
16
|
+
id
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
puppetclasses {
|
21
|
+
totalCount
|
22
|
+
edges {
|
23
|
+
node {
|
24
|
+
id
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
GRAPHQL
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:environment) { FactoryBot.create(:environment) }
|
34
|
+
let(:organization_object) { FactoryBot.create(:organization, environments: [environment]) }
|
35
|
+
|
36
|
+
let(:global_id) { Foreman::GlobalId.for(organization_object) }
|
37
|
+
let(:variables) { { id: global_id } }
|
38
|
+
let(:data) { result['data']['organization'] }
|
39
|
+
|
40
|
+
setup do
|
41
|
+
FactoryBot.create(:puppetclass, environments: [environment])
|
42
|
+
end
|
43
|
+
|
44
|
+
test 'fetching organization attributes' do
|
45
|
+
assert_empty result['errors']
|
46
|
+
|
47
|
+
assert_equal global_id, data['id']
|
48
|
+
assert_collection organization_object.environments, data['environments']
|
49
|
+
assert_collection organization_object.puppetclasses, data['puppetclasses']
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module Queries
|
4
|
+
class PuppetclassQueryTest < GraphQLQueryTestCase
|
5
|
+
let(:query) do
|
6
|
+
<<-GRAPHQL
|
7
|
+
query (
|
8
|
+
$id: String!
|
9
|
+
) {
|
10
|
+
puppetclass(id: $id) {
|
11
|
+
id
|
12
|
+
createdAt
|
13
|
+
updatedAt
|
14
|
+
name
|
15
|
+
environments {
|
16
|
+
totalCount
|
17
|
+
edges {
|
18
|
+
node {
|
19
|
+
id
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
locations {
|
24
|
+
totalCount
|
25
|
+
edges {
|
26
|
+
node {
|
27
|
+
id
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
organizations {
|
32
|
+
totalCount
|
33
|
+
edges {
|
34
|
+
node {
|
35
|
+
id
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
GRAPHQL
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:environment) { FactoryBot.create(:environment) }
|
45
|
+
let(:puppetclass) { FactoryBot.create(:puppetclass) }
|
46
|
+
|
47
|
+
let(:global_id) { Foreman::GlobalId.for(puppetclass) }
|
48
|
+
let(:variables) { { id: global_id } }
|
49
|
+
let(:data) { result['data']['puppetclass'] }
|
50
|
+
|
51
|
+
setup do
|
52
|
+
FactoryBot.create(:environment_class, puppetclass: puppetclass, environment: environment)
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'fetching puppetclass attributes' do
|
56
|
+
assert_empty result['errors']
|
57
|
+
|
58
|
+
assert_equal global_id, data['id']
|
59
|
+
assert_equal puppetclass.created_at.utc.iso8601, data['createdAt']
|
60
|
+
assert_equal puppetclass.updated_at.utc.iso8601, data['updatedAt']
|
61
|
+
assert_equal puppetclass.name, data['name']
|
62
|
+
|
63
|
+
assert_collection puppetclass.environments, data['environments']
|
64
|
+
assert_collection puppetclass.locations, data['locations']
|
65
|
+
assert_collection puppetclass.organizations, data['organizations']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module Queries
|
4
|
+
class PuppetclassesQueryTest < GraphQLQueryTestCase
|
5
|
+
let(:query) do
|
6
|
+
<<-GRAPHQL
|
7
|
+
query {
|
8
|
+
puppetclasses {
|
9
|
+
totalCount
|
10
|
+
pageInfo {
|
11
|
+
startCursor
|
12
|
+
endCursor
|
13
|
+
hasNextPage
|
14
|
+
hasPreviousPage
|
15
|
+
}
|
16
|
+
edges {
|
17
|
+
cursor
|
18
|
+
node {
|
19
|
+
id
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
GRAPHQL
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:data) { result['data']['puppetclasses'] }
|
28
|
+
|
29
|
+
setup do
|
30
|
+
FactoryBot.create_list(:puppetclass, 2)
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'fetching puppetclasses attributes' do
|
34
|
+
assert_empty result['errors']
|
35
|
+
|
36
|
+
expected_count = ForemanPuppet::Puppetclass.count
|
37
|
+
|
38
|
+
assert_not_equal 0, expected_count
|
39
|
+
assert_equal expected_count, data['totalCount']
|
40
|
+
assert_equal expected_count, data['edges'].count
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -5,6 +5,9 @@ module ForemanPuppet
|
|
5
5
|
class EnvironmentJSTest < IntegrationTestWithJavascript
|
6
6
|
include ForemanPuppet::Engine.routes.url_helpers
|
7
7
|
|
8
|
+
let(:environment) { FactoryBot.create(:environment) }
|
9
|
+
setup { environment }
|
10
|
+
|
8
11
|
test 'index page' do
|
9
12
|
assert_index_page(environments_path, 'Environments', 'Create Puppet Environment')
|
10
13
|
end
|
@@ -18,7 +21,7 @@ module ForemanPuppet
|
|
18
21
|
|
19
22
|
test 'edit page' do
|
20
23
|
visit environments_path
|
21
|
-
click_link
|
24
|
+
click_link environment.name
|
22
25
|
fill_in 'environment_name', with: 'production222'
|
23
26
|
assert_submit_button(environments_path)
|
24
27
|
assert page.has_link? 'production222'
|
@@ -141,7 +141,7 @@ module ForemanPuppet
|
|
141
141
|
click_on_inherit('puppet_proxy')
|
142
142
|
select2(overridden_hostgroup.name, from: 'host_hostgroup_id')
|
143
143
|
|
144
|
-
assert find('#s2id_host_puppet_attributes_environment_id .select2-chosen').has_text? original_hostgroup.environment.name
|
144
|
+
assert find('#s2id_host_puppet_attributes_environment_id .select2-chosen').has_text? original_hostgroup.puppet.environment.name
|
145
145
|
|
146
146
|
# On host group change, the disabled select will be reset to an empty value - disabled select2 is invisible on chrome
|
147
147
|
assert find('#s2id_host_puppet_proxy_id .select2-chosen', visible: :all).has_text? ''
|
@@ -11,6 +11,7 @@ module ForemanPuppet
|
|
11
11
|
let(:puppetclass) { FactoryBot.create(:puppetclass, environments: [environment]) }
|
12
12
|
|
13
13
|
test 'edit page' do
|
14
|
+
FactoryBot.create(:puppetclass, name: 'vim', environments: [environment]) if ForemanPuppet.extracted_from_core?
|
14
15
|
visit puppetclasses_path
|
15
16
|
click_link 'vim'
|
16
17
|
assert page.has_no_link? 'Common'
|
@@ -4,6 +4,8 @@ module ForemanPuppet
|
|
4
4
|
class ConfigGroupClassTest < ActiveSupport::TestCase
|
5
5
|
should validate_presence_of(:config_group)
|
6
6
|
should validate_presence_of(:puppetclass)
|
7
|
-
|
7
|
+
# can not validate_uniqueness_of associations
|
8
|
+
# https://github.com/thoughtbot/shoulda-matchers/issues/814
|
9
|
+
# should validate_uniqueness_of(:config_group).scoped_to(:puppetclass_id)
|
8
10
|
end
|
9
11
|
end
|
@@ -2,6 +2,8 @@ require 'test_puppet_helper'
|
|
2
2
|
|
3
3
|
module ForemanPuppet
|
4
4
|
class EnvironmentTest < ActiveSupport::TestCase
|
5
|
+
setup { FactoryBot.create(:environment) }
|
6
|
+
|
5
7
|
should validate_presence_of(:name)
|
6
8
|
should validate_uniqueness_of(:name)
|
7
9
|
should have_many(:provisioning_templates).through(:template_combinations)
|
@@ -79,7 +79,7 @@ module ForemanPuppet
|
|
79
79
|
|
80
80
|
test 'can search hosts by puppet class from config group in parent hostgroup' do
|
81
81
|
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc)
|
82
|
-
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.environment)
|
82
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
83
83
|
config_group = FactoryBot.create(:config_group, :with_puppetclass)
|
84
84
|
hostgroup.puppet.config_groups << config_group
|
85
85
|
result = Host.search_for("class = #{config_group.puppetclass_names.first}")
|
@@ -138,7 +138,8 @@ module ForemanPuppet
|
|
138
138
|
describe '#clone' do
|
139
139
|
test '#classes etc. on cloned host return the same' do
|
140
140
|
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_config_group, :with_puppetclass)
|
141
|
-
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
141
|
+
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
142
|
+
hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
142
143
|
copy = host.clone
|
143
144
|
assert_equal host.puppet.individual_puppetclasses.map(&:id), copy.puppet.individual_puppetclasses.map(&:id)
|
144
145
|
assert_equal host.puppet.classes_in_groups.map(&:id), copy.puppet.classes_in_groups.map(&:id)
|
@@ -22,15 +22,14 @@ module ForemanPuppet
|
|
22
22
|
end
|
23
23
|
|
24
24
|
test 'changing environment should preserve puppetclasses' do
|
25
|
-
skip 'Something fishy on env update, try once extracted' unless ForemanPuppet.extracted_from_core?
|
26
25
|
new_environment = FactoryBot.create(:environment)
|
27
|
-
old_puppetclass_ids = hostgroup.puppet.
|
26
|
+
old_puppetclass_ids = hostgroup.puppet.puppetclasses.all
|
28
27
|
|
29
28
|
hostgroup.puppet.update!(environment: new_environment)
|
30
29
|
hostgroup.reload
|
31
30
|
|
32
31
|
assert_equal new_environment, hostgroup.puppet.environment
|
33
|
-
assert_equal old_puppetclass_ids.sort, hostgroup.puppet.
|
32
|
+
assert_equal old_puppetclass_ids.sort, hostgroup.puppet.puppetclasses.all
|
34
33
|
end
|
35
34
|
|
36
35
|
test 'should return all classes for environment only' do
|
@@ -37,7 +37,7 @@ module ForemanPuppet
|
|
37
37
|
assert_equal [], tmplt.template_combinations
|
38
38
|
end
|
39
39
|
|
40
|
-
describe '
|
40
|
+
describe '#find_template by template_combinations' do
|
41
41
|
setup do
|
42
42
|
@arch = FactoryBot.create(:architecture)
|
43
43
|
medium = FactoryBot.create(:medium, name: 'combo_medium', path: 'http://www.example.com/m')
|
@@ -74,50 +74,50 @@ module ForemanPuppet
|
|
74
74
|
@ctd.os_default_templates.create(operatingsystem: @os1, template_kind_id: @ctd.template_kind_id)
|
75
75
|
end
|
76
76
|
|
77
|
-
test '
|
77
|
+
test 'finds a matching template with hg and env' do
|
78
78
|
assert_equal @ct1.name,
|
79
79
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
operatingsystem_id: @os1.id,
|
81
|
+
hostgroup_id: @hg1.id,
|
82
|
+
environment_id: @ev1.id }).name
|
83
83
|
end
|
84
84
|
|
85
|
-
test '
|
85
|
+
test 'finds a matching template with hg only' do
|
86
86
|
assert_equal @ct2.name,
|
87
87
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
88
|
-
|
89
|
-
|
88
|
+
operatingsystem_id: @os1.id,
|
89
|
+
hostgroup_id: @hg1.id }).name
|
90
90
|
end
|
91
91
|
|
92
|
-
test '
|
92
|
+
test 'finds a matching template with hg and mismatched env' do
|
93
93
|
assert_equal @ct2.name,
|
94
94
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
operatingsystem_id: @os1.id,
|
96
|
+
hostgroup_id: @hg1.id,
|
97
|
+
environment_id: @ev3.id }).name
|
98
98
|
end
|
99
99
|
|
100
|
-
test '
|
100
|
+
test 'finds a matching template with env only' do
|
101
101
|
assert_equal @ct3.name,
|
102
102
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
103
|
-
|
104
|
-
|
103
|
+
operatingsystem_id: @os1.id,
|
104
|
+
environment_id: @ev1.id }).name
|
105
105
|
end
|
106
106
|
|
107
|
-
test '
|
107
|
+
test 'finds a matching template with env and mismatched hg' do
|
108
108
|
assert_equal @ct3.name,
|
109
109
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
operatingsystem_id: @os1.id,
|
111
|
+
hostgroup_id: @hg3.id,
|
112
|
+
environment_id: @ev1.id }).name
|
113
113
|
end
|
114
114
|
|
115
|
-
test '
|
115
|
+
test 'finds the default template when hg and env do not match' do
|
116
116
|
assert_equal @ctd.name,
|
117
117
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
operatingsystem_id: @os1.id,
|
119
|
+
hostgroup_id: @hg3.id,
|
120
|
+
environment_id: @ev3.id }).name
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|