ruby-jss 1.0.0b2 → 1.0.0b6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.yardopts +1 -1
- data/CHANGES.md +46 -8
- data/README.md +26 -27
- data/bin/cgrouper +2 -2
- data/bin/jamfHelperBackgrounder +0 -2
- data/bin/netseg-update +3 -4
- data/data/ruby-jss.conf.example +2 -8
- data/lib/jss/api_connection.rb +6 -3
- data/lib/jss/api_object/advanced_search.rb +1 -1
- data/lib/jss/api_object/computer_invitation.rb +1 -1
- data/lib/jss/api_object/criteriable.rb +1 -1
- data/lib/jss/api_object/ebook.rb +25 -0
- data/lib/jss/api_object/group.rb +1 -1
- data/lib/jss/api_object/mobile_device_application.rb +1 -1
- data/lib/jss/api_object/patch_title.rb +98 -46
- data/lib/jss/api_object/peripheral.rb +2 -2
- data/lib/jss/api_object/sitable.rb +1 -1
- data/lib/jss/api_object.rb +2 -2
- data/lib/jss/client/management_action.rb +2 -2
- data/lib/jss/utility.rb +1 -1
- data/lib/jss/validate.rb +32 -29
- data/lib/jss/version.rb +1 -1
- data/test/README.md +149 -0
- data/test/bin/runtests +290 -0
- data/test/lib/testhelper/auth.rb +275 -0
- data/test/lib/testhelper/patch_mgmt.rb +123 -0
- data/test/lib/testhelper.rb +69 -0
- data/test/specs/api_connection_spec.rb +57 -0
- data/test/specs/patch01_source_spec.rb +54 -0
- data/test/specs/patch02_internal_source_spec.rb +88 -0
- data/test/specs/patch03_external_source_spec.rb +120 -0
- data/test/specs/patch04_titles_spec.rb +207 -0
- data/test/specs/patch05_policies_spec.rb +119 -0
- data/test/specs/patch06_cleanup_spec.rb +52 -0
- data/test/specs/policy_spec.rb +112 -0
- metadata +16 -3
@@ -0,0 +1,120 @@
|
|
1
|
+
### Copyright 2018 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
# External Sources
|
27
|
+
#
|
28
|
+
describe JSS::PatchExternalSource do
|
29
|
+
|
30
|
+
##### Constants
|
31
|
+
|
32
|
+
##### Class methods
|
33
|
+
|
34
|
+
# this effectively makes the tests run in the order defined, which is
|
35
|
+
# needed in this situattion.
|
36
|
+
def self.test_order
|
37
|
+
:alpha
|
38
|
+
end
|
39
|
+
|
40
|
+
##### Instance Methods
|
41
|
+
|
42
|
+
# shortcut
|
43
|
+
def src
|
44
|
+
JSSTestHelper::PatchMgmt.external_src
|
45
|
+
end
|
46
|
+
|
47
|
+
##### Specs
|
48
|
+
|
49
|
+
it 'can delete crufty objects from earlier tests' do
|
50
|
+
crufty_name = JSSTestHelper::PatchMgmt::EXT_SRC_NAME
|
51
|
+
break unless JSS::PatchExternalSource.all_names(:refresh).include? crufty_name
|
52
|
+
|
53
|
+
puts 'Found crufty External Source from Previous Tests - deleting'
|
54
|
+
|
55
|
+
crufty_id = JSS::PatchExternalSource.map_all_ids_to(:name).invert[crufty_name]
|
56
|
+
deleted = JSS::PatchExternalSource.delete crufty_id
|
57
|
+
|
58
|
+
deleted.must_be_instance_of Array
|
59
|
+
deleted.must_be_empty
|
60
|
+
JSS::PatchExternalSource.all_names(:refresh).wont_include crufty_name
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'can be made' do
|
64
|
+
src.must_be_instance_of JSS::PatchExternalSource
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'cannot be created without a host' do
|
68
|
+
proc { src.save }.must_raise JSS::UnsupportedError
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'can be created with a host' do
|
72
|
+
src.host_name = JSSTestHelper::PatchMgmt::EXT_SRC_NAME
|
73
|
+
src.save.must_be_kind_of Integer
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'can set the port' do
|
77
|
+
src.port = JSSTestHelper::PatchMgmt::EXT_SRC_PORT
|
78
|
+
src.port.must_equal JSSTestHelper::PatchMgmt::EXT_SRC_PORT
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can be enabled and disabled' do
|
82
|
+
src.enable
|
83
|
+
src.enabled?.must_be_instance_of TrueClass
|
84
|
+
src.disable
|
85
|
+
src.enabled?.must_be_instance_of FalseClass
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'can enable and disable ssl' do
|
89
|
+
src.disable_ssl
|
90
|
+
src.ssl_enabled?.must_be_instance_of FalseClass
|
91
|
+
src.enable_ssl
|
92
|
+
src.ssl_enabled?.must_be_instance_of TrueClass
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'can update changes to the server' do
|
96
|
+
src.update
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'can be fetched by name' do
|
100
|
+
JSSTestHelper::PatchMgmt.refetch_external_src
|
101
|
+
src.must_be_instance_of JSS::PatchExternalSource
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'tells us its host' do
|
105
|
+
src.host_name.must_equal JSSTestHelper::PatchMgmt::EXT_SRC_NAME
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'tells us its port' do
|
109
|
+
src.port.must_equal JSSTestHelper::PatchMgmt::EXT_SRC_PORT
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'tells us if it is enabled' do
|
113
|
+
JSS::TRUE_FALSE.must_include src.enabled?
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'tells us if ssl is enabled' do
|
117
|
+
JSS::TRUE_FALSE.must_include src.ssl_enabled?
|
118
|
+
end
|
119
|
+
|
120
|
+
end # describe JSS::PatchInternalSource
|
@@ -0,0 +1,207 @@
|
|
1
|
+
### Copyright 2018 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
describe JSS::PatchTitle do
|
27
|
+
|
28
|
+
##### Constants
|
29
|
+
|
30
|
+
##### Class Methods
|
31
|
+
|
32
|
+
# this effectively makes the tests run in the order defined, which is
|
33
|
+
# needed in this situattion.
|
34
|
+
def self.test_order
|
35
|
+
:alpha
|
36
|
+
end
|
37
|
+
|
38
|
+
##### Instance Methods
|
39
|
+
|
40
|
+
# shortcuts
|
41
|
+
|
42
|
+
def tt
|
43
|
+
JSSTestHelper::PatchMgmt.title
|
44
|
+
end
|
45
|
+
|
46
|
+
def tv
|
47
|
+
tt.versions[JSSTestHelper::PatchMgmt.version_key]
|
48
|
+
end
|
49
|
+
|
50
|
+
def prompt_for_name_id
|
51
|
+
puts '***************************'
|
52
|
+
puts 'Enter an unused Patch Title name_id for testing.'
|
53
|
+
puts 'Must be one of the following:'
|
54
|
+
unused_name_ids = self.class.unused_name_ids
|
55
|
+
unused_name_ids.each { |ni| puts " #{ni}" }
|
56
|
+
puts
|
57
|
+
print 'which one?: '
|
58
|
+
chosen = $stdin.gets.chomp
|
59
|
+
until unused_name_ids.include? chosen
|
60
|
+
puts 'that one isnt on the list'
|
61
|
+
print 'which one?: '
|
62
|
+
chosen = $stdin.gets.chomp
|
63
|
+
end
|
64
|
+
chosen
|
65
|
+
end
|
66
|
+
|
67
|
+
##### Specs
|
68
|
+
|
69
|
+
it 'can delete crufty title from earlier tests' do
|
70
|
+
deleted = JSSTestHelper::PatchMgmt.delete_title
|
71
|
+
deleted.must_be_instance_of Array
|
72
|
+
deleted.must_be_empty
|
73
|
+
JSS::PatchTitle.all_names(:refresh).wont_include JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'can list all patch title source_name_ids' do
|
77
|
+
source_name_ids = JSS::PatchTitle.all_source_name_ids
|
78
|
+
source_name_ids.must_be_instance_of Array
|
79
|
+
break if source_name_ids.empty?
|
80
|
+
source_name_ids.first.must_be_instance_of String
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'can list source_ids in use' do
|
84
|
+
srcids = JSS::PatchTitle.all_source_ids
|
85
|
+
srcids.must_be_instance_of Array
|
86
|
+
break if srcids.empty?
|
87
|
+
srcids.first.must_be_kind_of Integer
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'cannot be made without a source and name_id' do
|
91
|
+
proc {
|
92
|
+
JSS::PatchTitle.make name: JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME
|
93
|
+
}.must_raise JSS::MissingDataError
|
94
|
+
|
95
|
+
proc {
|
96
|
+
JSS::PatchTitle.make name: JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME,
|
97
|
+
source: 'Foobar'
|
98
|
+
}.must_raise JSS::MissingDataError
|
99
|
+
|
100
|
+
proc {
|
101
|
+
JSS::PatchTitle.make name: JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME,
|
102
|
+
name_id: 'Foobar'
|
103
|
+
}.must_raise JSS::MissingDataError
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'must check that the source exists' do
|
107
|
+
proc {
|
108
|
+
JSS::PatchTitle.make(
|
109
|
+
name: JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME,
|
110
|
+
source: 'Foobar',
|
111
|
+
name_id: 'FoobarNoSuchNameId'
|
112
|
+
)
|
113
|
+
}.must_raise JSS::NoSuchItemError
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'must check that the name_id is available in the source' do
|
117
|
+
proc {
|
118
|
+
JSS::PatchTitle.make(
|
119
|
+
name: JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME,
|
120
|
+
source: JSSTestHelper::PatchMgmt::PATCH_TITLE_SOURCE,
|
121
|
+
name_id: 'FoobarNoSuchNameId'
|
122
|
+
)
|
123
|
+
}.must_raise JSS::NoSuchItemError
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'can be made with name, source, and name_id' do
|
127
|
+
tt.must_be_instance_of JSS::PatchTitle
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'can be created' do
|
131
|
+
tt.create
|
132
|
+
JSS::PatchTitle.all_names(:refresh).must_include JSSTestHelper::PatchMgmt::PATCH_TITLE_NAME
|
133
|
+
tt.in_jss.must_be_instance_of TrueClass
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'can be fetched by souce and name_id' do
|
137
|
+
id = tt.id
|
138
|
+
JSSTestHelper::PatchMgmt.title(:refetch)
|
139
|
+
tt.id.must_equal id
|
140
|
+
end
|
141
|
+
|
142
|
+
# TODO: simplify this when we aren't reading the data via
|
143
|
+
# XMLWorkaround
|
144
|
+
it 'can get a patch report' do
|
145
|
+
report = JSS::PatchTitle.patch_report tt.id
|
146
|
+
report.must_be_instance_of Hash
|
147
|
+
report.keys.must_include :versions
|
148
|
+
report[:versions].must_be_instance_of Hash
|
149
|
+
break if report[:versions].empty?
|
150
|
+
|
151
|
+
vers_name = report[:versions].keys.sample
|
152
|
+
vers_name.must_be_instance_of String
|
153
|
+
report[:versions][vers_name].must_be_instance_of Array
|
154
|
+
break if report[:versions][vers_name].empty?
|
155
|
+
|
156
|
+
client = report[:versions][vers_name].sample
|
157
|
+
client.must_be_instance_of Hash
|
158
|
+
client[:id].must_be_kind_of Integer
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'has an array of Version objects' do
|
162
|
+
tt.versions.must_be_instance_of Hash
|
163
|
+
tv.must_be_instance_of JSS::PatchTitle::Version
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'has no packages assigned by default' do
|
167
|
+
tv.package_assigned?.must_be_instance_of FalseClass
|
168
|
+
tt.versions_with_packages.size.must_be :==, 0
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'cannot assign a non-existing package to a version' do
|
172
|
+
proc { tv.package = 'there should be no such package here' }.must_raise JSS::NoSuchItemError
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'can assign a package to a version' do
|
176
|
+
pkg = JSS::Package.all.sample
|
177
|
+
tv.package = pkg[:id]
|
178
|
+
tv.package_name.must_equal pkg[:name]
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'can get a patch report from a version' do
|
182
|
+
tv.patch_report.must_be_instance_of Hash
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'can set email notifications' do
|
186
|
+
tt.email_notification = true
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'can set web notifications' do
|
190
|
+
tt.web_notification = true
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'can update the JSS with changes' do
|
194
|
+
tt.update
|
195
|
+
tt.need_to_update.must_be_instance_of FalseClass
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'has the saved values when re-fetched' do
|
199
|
+
JSSTestHelper::PatchMgmt.title :refetch
|
200
|
+
tt.email_notification.must_be_instance_of TrueClass
|
201
|
+
tt.web_notification.must_be_instance_of TrueClass
|
202
|
+
verss = tt.versions_with_packages
|
203
|
+
verss.size.must_be :==, 1
|
204
|
+
verss.keys.first.must_equal tv.version
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
### Copyright 2018 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
describe JSS::PatchPolicy do
|
27
|
+
##### Constants
|
28
|
+
|
29
|
+
DEADLINE_DAYS = 17
|
30
|
+
|
31
|
+
##### Class Methods
|
32
|
+
|
33
|
+
# this effectively makes the tests run in the order defined, which is
|
34
|
+
# needed in this situattion.
|
35
|
+
def self.test_order
|
36
|
+
:alpha
|
37
|
+
end
|
38
|
+
|
39
|
+
##### Specs
|
40
|
+
|
41
|
+
it 'can delete crufty patch policies from earlier tests' do
|
42
|
+
deleted = JSSTestHelper::PatchMgmt.delete_policy
|
43
|
+
deleted.must_be_instance_of Array
|
44
|
+
deleted.must_be_empty
|
45
|
+
JSS::PatchPolicy.all_names(:refresh).wont_include JSSTestHelper::PatchMgmt::PATCHCPOL_NAME
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'cannot be made without a patch title' do
|
49
|
+
proc { JSS::PatchPolicy.make name: JSSTestHelper::PatchMgmt::PATCHCPOL_NAME }.must_raise JSS::MissingDataError
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can be made with a patch title' do
|
53
|
+
# JSSTestHelper::PatchMgmt.policy will do a make with our test title the
|
54
|
+
# first time its called
|
55
|
+
JSSTestHelper::PatchMgmt.policy.must_be_instance_of JSS::PatchPolicy
|
56
|
+
JSSTestHelper::PatchMgmt.policy.in_jss.must_be_instance_of FalseClass
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'cannot be created without a target_version' do
|
60
|
+
proc { JSSTestHelper::PatchMgmt.policy.create }.must_raise JSS::MissingDataError
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'will not accept a target_version that has no package' do
|
64
|
+
title = JSSTestHelper::PatchMgmt.title
|
65
|
+
badvers = (title.versions.keys - title.versions_with_packages.keys).sample
|
66
|
+
proc { JSSTestHelper::PatchMgmt.policy.target_version = badvers }.must_raise JSS::UnsupportedError
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'can be created with a target_version that has a package' do
|
70
|
+
JSSTestHelper::PatchMgmt.policy.target_version = JSSTestHelper::PatchMgmt.version_key
|
71
|
+
JSSTestHelper::PatchMgmt.policy.create
|
72
|
+
JSS::PatchPolicy.all_names(:refresh).must_include JSSTestHelper::PatchMgmt::PATCHCPOL_NAME
|
73
|
+
JSSTestHelper::PatchMgmt.policy.in_jss.must_be_instance_of TrueClass
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'can be fetched by name' do
|
77
|
+
id = JSSTestHelper::PatchMgmt.policy.id
|
78
|
+
JSSTestHelper::PatchMgmt.policy :refresh
|
79
|
+
JSSTestHelper::PatchMgmt.policy.id.must_equal id
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'can be put into self service' do
|
83
|
+
JSSTestHelper::PatchMgmt.policy.add_to_self_service
|
84
|
+
JSSTestHelper::PatchMgmt.policy.in_self_service?.must_be_instance_of TrueClass
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'interprets non-positive deadline as no deadline' do
|
88
|
+
JSSTestHelper::PatchMgmt.policy.deadline = 0
|
89
|
+
JSSTestHelper::PatchMgmt.policy.deadline.must_equal JSS::PatchPolicy::NO_DEADLINE
|
90
|
+
JSSTestHelper::PatchMgmt.policy.deadline = -2
|
91
|
+
JSSTestHelper::PatchMgmt.policy.deadline.must_equal JSS::PatchPolicy::NO_DEADLINE
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'can take a positive deadline value' do
|
95
|
+
JSSTestHelper::PatchMgmt.policy.deadline = DEADLINE_DAYS
|
96
|
+
JSSTestHelper::PatchMgmt.policy.deadline.must_equal DEADLINE_DAYS
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'interprets negative grace period value as zero' do
|
100
|
+
JSSTestHelper::PatchMgmt.policy.grace_period = -12
|
101
|
+
JSSTestHelper::PatchMgmt.policy.grace_period.must_equal 0
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'can take a non-negative grace period value' do
|
105
|
+
JSSTestHelper::PatchMgmt.policy.grace_period = 0
|
106
|
+
JSSTestHelper::PatchMgmt.policy.grace_period.must_equal 0
|
107
|
+
JSSTestHelper::PatchMgmt.policy.grace_period = 16
|
108
|
+
JSSTestHelper::PatchMgmt.policy.grace_period.must_equal 16
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'can save changes' do
|
112
|
+
JSSTestHelper::PatchMgmt.policy.update.must_equal JSSTestHelper::PatchMgmt.policy.id
|
113
|
+
JSSTestHelper::PatchMgmt.policy :refresh
|
114
|
+
JSSTestHelper::PatchMgmt.policy.grace_period.must_equal 16
|
115
|
+
JSSTestHelper::PatchMgmt.policy.deadline.must_equal DEADLINE_DAYS
|
116
|
+
JSSTestHelper::PatchMgmt.policy.in_self_service?.must_be_instance_of TrueClass
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
### Copyright 2018 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
describe JSSTestHelper do
|
27
|
+
|
28
|
+
# this effectively makes the tests run in the order defined, which is
|
29
|
+
# needed in this situattion.
|
30
|
+
def self.test_order
|
31
|
+
:alpha
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can delete external source' do
|
35
|
+
gone = JSSTestHelper::PatchMgmt.delete_external_src
|
36
|
+
gone.must_be_instance_of Array
|
37
|
+
gone.must_be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can delete patch policy' do
|
41
|
+
gone = JSSTestHelper::PatchMgmt.delete_policy
|
42
|
+
gone.must_be_instance_of Array
|
43
|
+
gone.must_be_empty
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'can delete patch title' do
|
47
|
+
gone = JSSTestHelper::PatchMgmt.delete_title
|
48
|
+
gone.must_be_instance_of Array
|
49
|
+
gone.must_be_empty
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
### Copyright 2018 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
describe JSSTestHelper do
|
27
|
+
|
28
|
+
# CONSTANTS
|
29
|
+
|
30
|
+
POLICY_NAME = 'rubyjss-testPolicy'.freeze
|
31
|
+
|
32
|
+
# CLASS METHODS
|
33
|
+
|
34
|
+
# this effectively makes the tests run in the order defined
|
35
|
+
def self.test_order
|
36
|
+
:alpha
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.policy(refresh = false)
|
40
|
+
@policy = nil if refresh
|
41
|
+
return @policy if @policy
|
42
|
+
@policy =
|
43
|
+
if JSS::Policy.all_names.include? POLICY_NAME
|
44
|
+
JSS::Policy.fetch name: POLICY_NAME
|
45
|
+
else
|
46
|
+
JSS::Policy.make name: POLICY_NAME
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.delete_policy
|
51
|
+
return [] unless JSS::Policy.all_names(:refresh).include? POLICY_NAME
|
52
|
+
JSS::Policy.delete JSS::Policy.map_all_ids_to(:name).invert[POLICY_NAME]
|
53
|
+
end
|
54
|
+
|
55
|
+
# SPECS
|
56
|
+
|
57
|
+
it 'can delete crufty policies from earlier tests' do
|
58
|
+
deleted = self.class.delete_policy
|
59
|
+
deleted.must_be_instance_of Array
|
60
|
+
deleted.must_be_empty
|
61
|
+
JSS::Policy.all_names(:refresh).wont_include POLICY_NAME
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can be made' do
|
65
|
+
# see .policy class method above
|
66
|
+
self.class.policy.must_be_instance_of JSS::Policy
|
67
|
+
self.class.policy.in_jss.must_be_instance_of FalseClass
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'can set maintenance tasks' do
|
71
|
+
pol = self.class.policy
|
72
|
+
pol.verify_startup_disk = true
|
73
|
+
pol.permissions_repair = false
|
74
|
+
pol.recon = true
|
75
|
+
pol.fix_byhost = false
|
76
|
+
pol.reset_name = true
|
77
|
+
pol.flush_system_cache = false
|
78
|
+
pol.install_cached_pkgs = true
|
79
|
+
pol.flush_user_cache = false
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'can be created ' do
|
83
|
+
pol = self.class.policy
|
84
|
+
pol.create
|
85
|
+
JSS::Policy.all_names(:refresh).must_include POLICY_NAME
|
86
|
+
pol.in_jss.must_be_instance_of TrueClass
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'can be fetched by name' do
|
90
|
+
id = self.class.policy.id
|
91
|
+
self.class.policy :refresh
|
92
|
+
self.class.policy.id.must_equal id
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'still has correct maintenance tasks' do
|
96
|
+
pol = self.class.policy
|
97
|
+
pol.verify_startup_disk.must_be_instance_of TrueClass
|
98
|
+
pol.permissions_repair.must_be_instance_of FalseClass
|
99
|
+
pol.recon.must_be_instance_of TrueClass
|
100
|
+
pol.fix_byhost.must_be_instance_of FalseClass
|
101
|
+
pol.reset_name.must_be_instance_of TrueClass
|
102
|
+
pol.flush_system_cache.must_be_instance_of FalseClass
|
103
|
+
pol.install_cached_pkgs.must_be_instance_of TrueClass
|
104
|
+
pol.flush_user_cache.must_be_instance_of FalseClass
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'can be deleted' do
|
108
|
+
self.class.policy.delete.must_equal :deleted
|
109
|
+
JSS::Policy.all_names(:refresh).wont_include POLICY_NAME
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0b6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|
@@ -252,6 +252,19 @@ files:
|
|
252
252
|
- lib/jss/version.rb
|
253
253
|
- lib/jss/xml_workaround.rb
|
254
254
|
- lib/ruby-jss.rb
|
255
|
+
- test/README.md
|
256
|
+
- test/bin/runtests
|
257
|
+
- test/lib/testhelper.rb
|
258
|
+
- test/lib/testhelper/auth.rb
|
259
|
+
- test/lib/testhelper/patch_mgmt.rb
|
260
|
+
- test/specs/api_connection_spec.rb
|
261
|
+
- test/specs/patch01_source_spec.rb
|
262
|
+
- test/specs/patch02_internal_source_spec.rb
|
263
|
+
- test/specs/patch03_external_source_spec.rb
|
264
|
+
- test/specs/patch04_titles_spec.rb
|
265
|
+
- test/specs/patch05_policies_spec.rb
|
266
|
+
- test/specs/patch06_cleanup_spec.rb
|
267
|
+
- test/specs/policy_spec.rb
|
255
268
|
homepage: http://pixaranimationstudios.github.io/ruby-jss/
|
256
269
|
licenses:
|
257
270
|
- Apache-2.0 WITH Modifications
|
@@ -277,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
290
|
version: 1.3.1
|
278
291
|
requirements: []
|
279
292
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
293
|
+
rubygems_version: 2.7.7
|
281
294
|
signing_key:
|
282
295
|
specification_version: 4
|
283
296
|
summary: A Ruby interface to the Jamf Pro REST API
|