foreman_puppet 0.0.1 → 1.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- 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} +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/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 +5 -4
- 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.rb +3 -3
- data/lib/foreman_puppet/engine.rb +68 -19
- data/lib/foreman_puppet/register.rb +7 -2
- data/lib/foreman_puppet/version.rb +1 -1
- data/locale/Makefile +1 -1
- data/locale/action_names.rb +4 -4
- 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/package.json +45 -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 +54 -14
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
module Mutations
|
5
|
+
module Hosts
|
6
|
+
class CreateMutationTest < GraphQLQueryTestCase
|
7
|
+
let(:hostname) { 'my-graphql-host' }
|
8
|
+
let(:tax_location) { FactoryBot.create(:location) }
|
9
|
+
let(:organization) { FactoryBot.create(:organization) }
|
10
|
+
let(:environment) { FactoryBot.create(:environment, locations: [tax_location], organizations: [organization]) }
|
11
|
+
let(:environment_id) { Foreman::GlobalId.for(environment) }
|
12
|
+
let(:puppetclass) { FactoryBot.create(:puppetclass) }
|
13
|
+
let(:puppetclass_id) { Foreman::GlobalId.for(puppetclass) }
|
14
|
+
|
15
|
+
let(:variables) do
|
16
|
+
{
|
17
|
+
name: hostname,
|
18
|
+
environmentId: environment_id,
|
19
|
+
puppetclassIds: [puppetclass_id],
|
20
|
+
interfacesAttributes: [
|
21
|
+
{
|
22
|
+
type: 'bond',
|
23
|
+
attachedTo: %w[eth0 eth1],
|
24
|
+
identifier: 'bond0',
|
25
|
+
primary: true,
|
26
|
+
provision: true,
|
27
|
+
managed: true,
|
28
|
+
},
|
29
|
+
],
|
30
|
+
}
|
31
|
+
end
|
32
|
+
let(:context_user) { FactoryBot.create(:user, :admin, locations: [tax_location], organizations: [organization]) }
|
33
|
+
let(:data) { result['data']['createHost']['host'] }
|
34
|
+
|
35
|
+
let(:query) do
|
36
|
+
<<-GRAPHQL
|
37
|
+
mutation createHostMutation(
|
38
|
+
$name: String!,
|
39
|
+
$environmentId: ID,
|
40
|
+
$puppetclassIds: [ID!],
|
41
|
+
$interfacesAttributes: [InterfaceAttributesInput!]
|
42
|
+
) {
|
43
|
+
createHost(input: {
|
44
|
+
name: $name,
|
45
|
+
environmentId: $environmentId,
|
46
|
+
puppetclassIds: $puppetclassIds,
|
47
|
+
interfacesAttributes: $interfacesAttributes,
|
48
|
+
}) {
|
49
|
+
host {
|
50
|
+
id
|
51
|
+
},
|
52
|
+
errors {
|
53
|
+
path
|
54
|
+
message
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
GRAPHQL
|
59
|
+
end
|
60
|
+
|
61
|
+
setup :disable_orchestration
|
62
|
+
|
63
|
+
it 'creates a host with puppet parameters' do
|
64
|
+
assert_difference(-> { Host.count }, +1) do
|
65
|
+
assert_empty result['errors']
|
66
|
+
assert_empty result['data']['createHost']['errors']
|
67
|
+
|
68
|
+
host = Host.find(Foreman::GlobalId.decode(data['id'])[2])
|
69
|
+
assert_equal environment.id, host.puppet.environment_id
|
70
|
+
assert_equal [puppetclass.id], host.puppet.puppetclasses.pluck(:id)
|
71
|
+
|
72
|
+
assert_equal 1, host.interfaces.count
|
73
|
+
interface = host.interfaces.first
|
74
|
+
assert_equal 'Nic::Bond', interface.type
|
75
|
+
assert_equal 'eth0, eth1', interface.attached_to
|
76
|
+
assert_equal 'bond0', interface.identifier
|
77
|
+
assert interface.primary
|
78
|
+
assert interface.provision
|
79
|
+
assert interface.managed
|
80
|
+
|
81
|
+
assert_not_nil data
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -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
|