open_directory_utils 0.1.3 → 0.1.4

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: f61e2e2aca525175359c6fb86db2fd8a29951f2b36a134dbce4eed2c58bd646a
4
- data.tar.gz: da2402a3e3c19cc361173a28765af73b97c15ffa920c0135774cb10c966d1c99
3
+ metadata.gz: c37dea537a3c3bc485752eda8c5ffc5ae651ba59abeb19ed797c9361337eca77
4
+ data.tar.gz: 9acd8a277cd637a83fa5e2c378f58542b2ca8a64498ad80cabc2848ad1dddd47
5
5
  SHA512:
6
- metadata.gz: b2331c724ea6e615328177b1665268623da72f4944c52659b6c381ecda39899a2269db1408f8321c2315094c7c74f6b9ac6c6551ef0dc567c2b34d21f022410f
7
- data.tar.gz: 372507f3d5f28b8984ac319cd57700bda70c51fffde75757a7b594efcb40b657a17675f433e09338625d3f64156de2e6cf8f57ad47f018e31087118b9fb3fc41
6
+ metadata.gz: a2e8b07003c61f730a5f1559737cfb7e20740694981ebba75afd3aadcb32973931e3b357705ee1b52c8cd0f0e32ac098ff335145bbf4639b2982c8b838edf628
7
+ data.tar.gz: 153f9fc11e4951844fb27a20d462abb1035416cecec907a60573940fd43308d13d4a68e4c881276982ad47c4856167b9b3622be5d88f3d002b7fa6b8a39c6db2
data/README.md CHANGED
@@ -7,6 +7,7 @@ One can also build custom DSCL commands and send them to the server as needed to
7
7
 
8
8
  ## Change Log
9
9
 
10
+ * **v0.1.4** - 2018-06-13 - changed the return hash to {response: xxx, status: 'success'}
10
11
  * **v0.1.3** - 2018-06-13 - able to sync all fields in typcial OD
11
12
  - refactored results code (ssh_cmds have redacted passwords)
12
13
  - finished adding pre-built od commands for users - good for syncing accounts
@@ -42,6 +42,7 @@ module OpenDirectoryUtils
42
42
  # @command [Symbol] - required -- to choose the action wanted
43
43
  # @params [Hash] - required -- necessary information to accomplish action
44
44
  # @output [String] - optional -- 'xml' or 'plist' will return responses using xml format
45
+ # response [Hash] - { response: results, status: status, command: command, attributes: params, dscl_cmds: ssh_clean }
45
46
  def run(command:, params:, output: nil)
46
47
  answer = {}
47
48
  params[:format] = output
@@ -54,7 +55,7 @@ module OpenDirectoryUtils
54
55
  answer = process_results(results, command, params, ssh_cmds )
55
56
  return answer
56
57
  rescue ArgumentError, NoMethodError => error
57
- format_results(error.message, command, params, ssh_cmds, success: false)
58
+ format_results(error.message, command, params, ssh_cmds, 'error')
58
59
  end
59
60
 
60
61
  private
@@ -78,7 +79,7 @@ module OpenDirectoryUtils
78
79
  if missing_resource?(results)
79
80
  results = ["Resource not found", results]
80
81
  # report lack of success
81
- return format_results(results, command, params, ssh_cmds, success: false)
82
+ return format_results(results, command, params, ssh_cmds, 'error')
82
83
  end
83
84
  if command.eql?(:user_password_verified?) or command.eql?(:user_password_ok?)
84
85
  return report_password_check(results, command, params, ssh_cmds)
@@ -91,35 +92,28 @@ module OpenDirectoryUtils
91
92
  end
92
93
  if results.to_s.include? 'attribute status: eDSNoStdMappingAvailable'
93
94
  results = ["Bad Attribute Description", results]
94
- format_results(results, command, params, ssh_cmds, success: false)
95
+ format_results(results, command, params, ssh_cmds, 'error')
95
96
  end
96
97
  if missed_errors?(results)
97
98
  results = ["Unexpected Error", results]
98
- format_results(results, command, params, ssh_cmds, success: false)
99
+ format_results(results, command, params, ssh_cmds, 'error')
99
100
  end
100
101
  # return any general success answers
101
- format_results(results, command, params, ssh_cmds, success: true)
102
+ format_results(results, command, params, ssh_cmds, 'success')
102
103
  end
103
104
 
104
- def format_results(results, command, params, ssh_cmds, success:)
105
+ def format_results(results, command, params, ssh_cmds, status)
105
106
  ssh_clean = ssh_cmds.to_s
106
107
  ssh_clean = ssh_clean.gsub(/-[p] ".+"/, '-p "************"')
107
108
  ssh_clean = ssh_clean.gsub(/-[P] ".+"/, '-P "************"')
108
-
109
- case success
110
- when true
111
- return { success:{response: results, command: command,
112
- attributes: params, dscl_cmds: ssh_clean} }
113
- else
114
- return { error: {response: results, command: command,
115
- attributes: params, dscl_cmds: ssh_clean} }
116
- end
109
+ { response: results, status: status, command: command,
110
+ attributes: params, dscl_cmds: ssh_clean }
117
111
  end
118
112
 
119
113
  def report_existence(results, command, params, ssh_cmds)
120
114
  results = [false, results] if results.to_s.include?('eDSRecordNotFound')
121
115
  results = [true, results] unless results.to_s.include?('eDSRecordNotFound')
122
- return format_results(results, command, params, ssh_cmds, success: true)
116
+ return format_results(results, command, params, ssh_cmds, 'success')
123
117
  end
124
118
 
125
119
  def missing_resource?(results)
@@ -135,7 +129,7 @@ module OpenDirectoryUtils
135
129
  def report_password_check(results, command, params, ssh_cmds)
136
130
  results = [false, results] if results.to_s.include?('eDSAuthFailed')
137
131
  results = [true, results] unless results.to_s.include?('eDSAuthFailed')
138
- return format_results(results, command, params, ssh_cmds, success: true)
132
+ return format_results(results, command, params, ssh_cmds, 'success')
139
133
  end
140
134
 
141
135
  def missed_errors?(results)
@@ -149,14 +143,14 @@ module OpenDirectoryUtils
149
143
  results = [false, results] if results.to_s.include?('account is disabled')
150
144
  results = [true, results] unless results.to_s.include?('isDisabled=1') or
151
145
  results.to_s.include?('account is disabled')
152
- return format_results(results, command, params, ssh_cmds, success: true)
146
+ return format_results(results, command, params, ssh_cmds, 'success')
153
147
  end
154
148
 
155
149
  def report_in_group(results, command, params, ssh_cmds)
156
150
  username = params[:value]
157
151
  results = [true, results] if results.to_s.include?( username )
158
152
  results = [false, results] unless results.to_s.include?( username )
159
- return format_results(results, command, params, ssh_cmds, success: true)
153
+ return format_results(results, command, params, ssh_cmds, 'success')
160
154
  end
161
155
 
162
156
  def defaults
@@ -1,5 +1,5 @@
1
1
  module OpenDirectoryUtils
2
2
  module Version
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_directory_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tihen