foreman_puppet 0.0.2 → 1.0.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 +4 -4
- data/README.md +61 -7
- data/app/controllers/concerns/foreman_puppet/environments_import.rb +1 -1
- 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/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +3 -10
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +2 -2
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +5 -2
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +9 -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} +3 -4
- 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/config_groups_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +2 -2
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +12 -4
- 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/interface_attributes_input_extensions.rb +9 -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/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_helper.rb +15 -0
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +2 -2
- 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 +24 -9
- data/app/models/concerns/foreman_puppet/extensions/host_common.rb +17 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +13 -7
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +19 -13
- data/app/models/concerns/foreman_puppet/extensions/report.rb +18 -0
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/user.rb +19 -12
- data/app/models/foreman_puppet/environment.rb +2 -0
- data/app/models/foreman_puppet/environment_class.rb +1 -1
- data/app/models/foreman_puppet/host_class.rb +1 -1
- data/app/models/foreman_puppet/host_puppet_facet.rb +6 -5
- 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 +15 -1
- 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/host_info_providers/config_groups_info.rb +2 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +17 -18
- data/app/views/foreman_puppet/common/_puppetclasses_or_envs_changed.html.erb +62 -0
- 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/index.html.erb +1 -1
- 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/app/views/foreman_puppet/puppetclasses/_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/index.html.erb +1 -1
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +1 -1
- data/app/views/hosts/select_multiple_environment.html.erb +1 -1
- data/app/views/smart_proxies/plugins/_puppet_ca.html.erb +44 -0
- data/config/initializers/api_reroute.rb +13 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +37 -12
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +13 -1
- data/lib/foreman_puppet/engine.rb +68 -20
- data/lib/foreman_puppet/register.rb +7 -2
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +3 -3
- data/locale/Makefile +1 -1
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.edit.po +19 -3
- data/locale/en/foreman_puppet.po +18 -6
- data/locale/en/foreman_puppet.pox +0 -0
- data/locale/foreman_puppet.pot +19 -3
- 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 +18 -16
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +3 -2
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb +32 -0
- 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 +2 -2
- 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/foreman_puppet_factories.rb +3 -0
- data/test/factories/host_puppet_enhancements.rb +6 -6
- data/test/graphql/mutations/hosts/create_mutation_test.rb +87 -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 +4 -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_puppet_facet_test.rb +34 -1
- data/test/models/foreman_puppet/host_test.rb +4 -3
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
- data/test/models/foreman_puppet/provisioning_template_test.rb +14 -7
- data/test/models/foreman_puppet/report_test.rb +21 -0
- data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +37 -0
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +35 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +159 -197
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +16 -2
- data/webpack/index.js +3 -4
- data/webpack/src/Components/Environments/Welcome.js +37 -0
- metadata +51 -12
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'test_puppet_helper'
|
|
2
|
+
|
|
3
|
+
module Queries
|
|
4
|
+
class EnvironmentQueryTest < GraphQLQueryTestCase
|
|
5
|
+
let(:query) do
|
|
6
|
+
<<-GRAPHQL
|
|
7
|
+
query (
|
|
8
|
+
$id: String!
|
|
9
|
+
) {
|
|
10
|
+
environment(id: $id) {
|
|
11
|
+
id
|
|
12
|
+
createdAt
|
|
13
|
+
updatedAt
|
|
14
|
+
name
|
|
15
|
+
locations {
|
|
16
|
+
totalCount
|
|
17
|
+
edges {
|
|
18
|
+
node {
|
|
19
|
+
id
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
organizations {
|
|
24
|
+
totalCount
|
|
25
|
+
edges {
|
|
26
|
+
node {
|
|
27
|
+
id
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
GRAPHQL
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
let(:environment) { FactoryBot.create(:environment) }
|
|
37
|
+
|
|
38
|
+
let(:global_id) { Foreman::GlobalId.for(environment) }
|
|
39
|
+
let(:variables) { { id: global_id } }
|
|
40
|
+
let(:data) { result['data']['environment'] }
|
|
41
|
+
|
|
42
|
+
test 'fetching environment attributes' do
|
|
43
|
+
assert_empty result['errors']
|
|
44
|
+
|
|
45
|
+
assert_equal global_id, data['id']
|
|
46
|
+
assert_equal environment.created_at.utc.iso8601, data['createdAt']
|
|
47
|
+
assert_equal environment.updated_at.utc.iso8601, data['updatedAt']
|
|
48
|
+
assert_equal environment.name, data['name']
|
|
49
|
+
|
|
50
|
+
assert_collection environment.locations, data['locations']
|
|
51
|
+
assert_collection environment.organizations, data['organizations']
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Queries
|
|
4
|
+
class EnvironmentsQueryTest < GraphQLQueryTestCase
|
|
5
|
+
let(:query) do
|
|
6
|
+
<<-GRAPHQL
|
|
7
|
+
query {
|
|
8
|
+
environments {
|
|
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']['environments'] }
|
|
28
|
+
|
|
29
|
+
setup do
|
|
30
|
+
FactoryBot.create_list(:environment, 2)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test 'fetching environments attributes' do
|
|
34
|
+
assert_empty result['errors']
|
|
35
|
+
|
|
36
|
+
expected_count = ForemanPuppet::Environment.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
|
|
@@ -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,9 +11,11 @@ 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'
|
|
18
|
+
find(:xpath, "//a[@title='Select All']").hover
|
|
17
19
|
find(:xpath, "//a[@data-original-title='Select All']").click
|
|
18
20
|
assert_submit_button(puppetclasses_path)
|
|
19
21
|
assert page.has_link? 'vim'
|
|
@@ -24,6 +26,7 @@ module ForemanPuppet
|
|
|
24
26
|
smart_class_parameter_long = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 50)
|
|
25
27
|
visit edit_puppetclass_path(puppetclass)
|
|
26
28
|
click_link 'Smart Class Parameter'
|
|
29
|
+
page.find("#pill_#{smart_class_parameter_long.id}-#{smart_class_parameter_long.key}").hover
|
|
27
30
|
assert_equal smart_class_parameter_long.key, page.find("#pill_#{smart_class_parameter_long.id}-#{smart_class_parameter_long.key}")['data-original-title']
|
|
28
31
|
end
|
|
29
32
|
|
|
@@ -31,6 +34,7 @@ module ForemanPuppet
|
|
|
31
34
|
smart_class_parameter_short = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 40)
|
|
32
35
|
visit edit_puppetclass_path(puppetclass)
|
|
33
36
|
click_link 'Smart Class Parameter'
|
|
37
|
+
page.find("#pill_#{smart_class_parameter_short.id}-#{smart_class_parameter_short.key}").hover
|
|
34
38
|
assert_empty page.find("#pill_#{smart_class_parameter_short.id}-#{smart_class_parameter_short.key}")['data-original-title']
|
|
35
39
|
end
|
|
36
40
|
end
|
|
@@ -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
|