win32-taskscheduler 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e586400ec6f09917fb684fb99037a5bd2c332995ecb72c43b37222ce9e2a61
4
- data.tar.gz: 7a081a2f498d932400424d87885a89d2f58126366f6d51d6a361d97a215c18c6
3
+ metadata.gz: 75d6081629e7734ccc70835edb8bcf222111038f4a169bc196348a66dd8e9f9d
4
+ data.tar.gz: 11722828b8240e0096df6bce84c425ecae0f6018500a83614529e45e717d3fa8
5
5
  SHA512:
6
- metadata.gz: 4fffce988d9274141c58c5cfce948ac86ff9b03396313f2721ce7bea08c6daf3a118be23418a2b56c7cfa58628db4e7e3943c0fe011b2b7da343007f80c9a7d0
7
- data.tar.gz: 7a282afc6a6be4a3cefd6258ee33257221e2d397c327f07329b1972178165c64df0ef89b3c408c951db7375a85a5afea4a0ad63895f3a449036f18b94db13ae4
6
+ metadata.gz: 59b2f4034e7ae6ed9048b2b99af095e1402907dae5d917445f9cbba00cdbe9e309b2dca7d87254d077a52643093ac07e2672fd2c4276fa54c22d088f8a3a58b3
7
+ data.tar.gz: 568cae572869dfa9e93abaaf1f8d593e516fdba1388b75ed962b08020a0c7caa8ec5b5a9831c7b915f3113973dbb27a89bcc745e3255a8a0b33fa1d9fa1229cd
data/CHANGELOG.md CHANGED
@@ -4,28 +4,34 @@ Note: this log contains only changes from win32-taskscheduler release 0.4.0 and
4
4
  -- it does not contain the changes from prior releases. To view change history
5
5
  prior to release 0.4.0, please visit the [source repository](https://github.com/chef/win32-taskscheduler/commits).
6
6
 
7
- <!-- latest_release unreleased -->
8
- ## Unreleased
7
+ <!-- latest_release 2.0.1 -->
8
+ ## [win32-taskscheduler-2.0.1](https://github.com/chef/win32-taskscheduler/tree/win32-taskscheduler-2.0.1) (2018-11-01)
9
9
 
10
10
  #### Merged Pull Requests
11
+ - Minor Fix for logon_type flag while task registration [#75](https://github.com/chef/win32-taskscheduler/pull/75) ([Nimesh-Msys](https://github.com/Nimesh-Msys))
11
12
  - Bump version to 2.0 [#71](https://github.com/chef/win32-taskscheduler/pull/71) ([btm](https://github.com/btm))
12
13
  <!-- latest_release -->
13
14
 
14
- <!-- release_rollup since=1.0.12 -->
15
- ### Changes since 1.0.12 release
15
+ <!-- release_rollup since=2.0.0 -->
16
+ ### Changes since 2.0.0 release
16
17
 
17
18
  #### Merged Pull Requests
18
- - Bump version to 2.0 [#71](https://github.com/chef/win32-taskscheduler/pull/71) ([btm](https://github.com/btm)) <!-- 2.0.0 -->
19
- - Move helpers under the Win32::TaskScheduler namespace [#70](https://github.com/chef/win32-taskscheduler/pull/70) ([btm](https://github.com/btm)) <!-- 1.0.13 -->
19
+ - Minor Fix for logon_type flag while task registration [#75](https://github.com/chef/win32-taskscheduler/pull/75) ([Nimesh-Msys](https://github.com/Nimesh-Msys)) <!-- 2.0.1 -->
20
20
  <!-- release_rollup -->
21
21
 
22
22
  <!-- latest_stable_release -->
23
+ ## [win32-taskscheduler-2.0.0](https://github.com/chef/win32-taskscheduler/tree/win32-taskscheduler-2.0.0) (2018-10-11)
24
+
25
+ #### Merged Pull Requests
26
+ - Move helpers under the Win32::TaskScheduler namespace [#70](https://github.com/chef/win32-taskscheduler/pull/70) ([btm](https://github.com/btm))
27
+ - Bump version to 2.0 [#71](https://github.com/chef/win32-taskscheduler/pull/71) ([btm](https://github.com/btm))
28
+ <!-- latest_stable_release -->
29
+
23
30
  ## [win32-taskscheduler-1.0.12](https://github.com/chef/win32-taskscheduler/tree/win32-taskscheduler-1.0.12) (2018-10-11)
24
31
 
25
32
  #### Merged Pull Requests
26
33
  - Refactored configure_settings [#67](https://github.com/chef/win32-taskscheduler/pull/67) ([btm](https://github.com/btm))
27
34
  - Fixing user registration at Non English version of windows [#69](https://github.com/chef/win32-taskscheduler/pull/69) ([Nimesh-Msys](https://github.com/Nimesh-Msys))
28
- <!-- latest_stable_release -->
29
35
 
30
36
  ## [win32-taskscheduler-1.0.10](https://github.com/chef/win32-taskscheduler/tree/win32-taskscheduler-1.0.10) (2018-07-24)
31
37
 
data/VERSION CHANGED
@@ -1,2 +1 @@
1
- 2.0.0
2
-
1
+ 2.0.1
@@ -512,7 +512,7 @@ module Win32
512
512
  # trigger variable is a hash of options that define when the scheduled
513
513
  # job should run.
514
514
  #
515
- def new_work_item(task, trigger, userinfo = { user: nil, password: nil })
515
+ def new_work_item(task, trigger, userinfo = { user: nil, password: nil, interactive: false })
516
516
  raise TypeError unless userinfo.is_a?(Hash) && task.is_a?(String) && trigger.is_a?(Hash)
517
517
 
518
518
  # If user ID is not given, consider it as a 'SYSTEM' user
@@ -609,6 +609,7 @@ module Win32
609
609
  act.Path = 'cmd'
610
610
 
611
611
  @password = userinfo[:password]
612
+ @interactive = userinfo[:interactive]
612
613
 
613
614
  register_task_definition(taskDefinition, task, userinfo[:user], userinfo[:password])
614
615
 
@@ -1236,6 +1237,7 @@ module Win32
1236
1237
  definition.Principal.LogonType = principals[:logon_type] if principals[:logon_type].to_s != ""
1237
1238
  definition.Principal.GroupId = principals[:group_id] if principals[:group_id].to_s != ""
1238
1239
  definition.Principal.RunLevel = principals[:run_level] if principals[:run_level].to_s != ""
1240
+ @interactive = true if principals[:logon_type] == TASK_LOGON_INTERACTIVE_TOKEN
1239
1241
  register_task_definition(definition)
1240
1242
  principals
1241
1243
  end
@@ -1417,8 +1419,12 @@ module Win32
1417
1419
  TASK_LOGON_SERVICE_ACCOUNT
1418
1420
  elsif group_user?(user_id)
1419
1421
  TASK_LOGON_GROUP
1420
- elsif !password.to_s.empty? # Password is present
1421
- TASK_LOGON_PASSWORD
1422
+ elsif !user_id.to_s.empty? && !password.to_s.empty?
1423
+ if @interactive
1424
+ TASK_LOGON_INTERACTIVE_TOKEN
1425
+ else
1426
+ TASK_LOGON_PASSWORD
1427
+ end
1422
1428
  else
1423
1429
  TASK_LOGON_INTERACTIVE_TOKEN
1424
1430
  end
@@ -1435,6 +1441,7 @@ module Win32
1435
1441
  #
1436
1442
  def register_task_definition(definition, path = nil, user_id = nil, password = nil)
1437
1443
  user_id ||= task_user_id(definition)
1444
+ password ||= @password
1438
1445
  path ||= @task.Path
1439
1446
  @task = @root.RegisterTaskDefinition(
1440
1447
  path, # Path (name) of the task
@@ -1,6 +1,6 @@
1
1
  module Win32
2
2
  class TaskScheduler
3
3
  # The version of the win32-taskscheduler library
4
- VERSION = '2.0.0'.freeze
4
+ VERSION = '2.0.1'.freeze
5
5
  end
6
6
  end
@@ -112,6 +112,43 @@ RSpec.describe Win32::TaskScheduler, :windows_only do
112
112
  end
113
113
  end
114
114
 
115
+ describe '#logon_type' do
116
+ let(:user_id) { 'User' }
117
+ context 'With Password' do
118
+ let(:password) { 'Password' }
119
+ it 'Returns PASSWORD flag for non-system users' do
120
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_PASSWORD)
121
+ end
122
+
123
+ it 'Returns GROUP flag for group users' do
124
+ user_id = 'Guests'
125
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_GROUP)
126
+ end
127
+
128
+ it 'Returns SERVICE_ACCOUNT flag for service-account users' do
129
+ user_id = 'System'
130
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_SERVICE_ACCOUNT)
131
+ end
132
+ end
133
+
134
+ context 'Without Password' do
135
+ let(:password) { nil }
136
+ it 'Returns INTERACTIVE_TOKEN flag for non-system users' do
137
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_INTERACTIVE_TOKEN)
138
+ end
139
+
140
+ it 'Returns GROUP flag for group users' do
141
+ user_id = 'Guests'
142
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_GROUP)
143
+ end
144
+
145
+ it 'Returns SERVICE_ACCOUNT flag for service-account users' do
146
+ user_id = 'System'
147
+ expect(@ts.send(:logon_type, user_id, password)).to eq(Win32::TaskScheduler::TASK_LOGON_SERVICE_ACCOUNT)
148
+ end
149
+ end
150
+ end
151
+
115
152
  private
116
153
 
117
154
  def load_task_variables
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-taskscheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Park Heesob
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-11 00:00:00.000000000 Z
12
+ date: 2018-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi