passwordstate 0.1.1 → 0.1.2
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/.gitlab-ci.yml +1 -1
- data/CHANGELOG.md +9 -0
- data/lib/passwordstate/client.rb +1 -0
- data/lib/passwordstate/errors.rb +5 -1
- data/lib/passwordstate/resource.rb +22 -15
- data/lib/passwordstate/resource_list.rb +2 -2
- data/lib/passwordstate/resources/document.rb +5 -5
- data/lib/passwordstate/resources/password.rb +4 -2
- data/lib/passwordstate/resources/password_list.rb +1 -1
- data/lib/passwordstate/version.rb +1 -1
- data/lib/passwordstate.rb +0 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8339c30925359da2d1fb10918796945cb5bdc4ad56beff7e99af39781bdfae96
|
4
|
+
data.tar.gz: 6d9c0c54ce250813c874fa7007c63e8378c9c20ac4a6b9df887b6fe74b5939b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cbe2c67683aa901f0d4b3fc4c9991115c59f93ecef0b1b8436e78c0f752abcf71c60a2f8151df7714e0d872d9620402a2fc1273d30875f70648916f8f5459ab
|
7
|
+
data.tar.gz: 5feb809a4426576eb901a18c137f0d70337a692ef7cfdc633122ca1d0042d7b59f1727841f8b32ff68186ff0cc93cf4fa895de21622b250d5d9c92341d44a709
|
data/.gitlab-ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/passwordstate/client.rb
CHANGED
data/lib/passwordstate/errors.rb
CHANGED
@@ -12,10 +12,14 @@ module Passwordstate
|
|
12
12
|
@code = code.to_i
|
13
13
|
@request = request
|
14
14
|
@response = response
|
15
|
+
|
16
|
+
if errors.count == 1 && errors.first.is_a?(Hash) && errors.first.key?('errors')
|
17
|
+
errors = errors.first['errors']
|
18
|
+
end
|
15
19
|
@errors = errors
|
16
20
|
|
17
21
|
errorstr = errors.map { |err| err['message'] || err['phrase'] || err['error'] }.join('; ')
|
18
|
-
super
|
22
|
+
super("Passwordstate responded with an error to the request:\n#{errorstr}")
|
19
23
|
end
|
20
24
|
|
21
25
|
def self.new_by_code(code, req, res, errors = [])
|
@@ -34,8 +34,7 @@ module Passwordstate
|
|
34
34
|
|
35
35
|
def initialize(data)
|
36
36
|
@client = data.delete :_client
|
37
|
-
set! data
|
38
|
-
old
|
37
|
+
set! data
|
39
38
|
end
|
40
39
|
|
41
40
|
# Is the object stored on the Passwordstate server
|
@@ -126,7 +125,7 @@ module Passwordstate
|
|
126
125
|
nil_as_string = opts.fetch(:nil_as_string, self.class.nil_as_string)
|
127
126
|
(self.class.send(:accessor_field_names) + self.class.send(:read_field_names) + self.class.send(:write_field_names)).to_h do |field|
|
128
127
|
redact = self.class.send(:field_options)[field]&.fetch(:redact, false) && !ignore_redact
|
129
|
-
at_field = "@#{field}"
|
128
|
+
at_field = :"@#{field}"
|
130
129
|
field = at_field if atify
|
131
130
|
value = instance_variable_get(at_field) unless redact
|
132
131
|
value = '[ REDACTED ]' if redact
|
@@ -164,16 +163,11 @@ module Passwordstate
|
|
164
163
|
end
|
165
164
|
|
166
165
|
def modified
|
167
|
-
|
168
|
-
attribs.reject { |field| old[field] == attribs[field] }
|
166
|
+
@modified ||= {}
|
169
167
|
end
|
170
168
|
|
171
|
-
def
|
172
|
-
@
|
173
|
-
end
|
174
|
-
|
175
|
-
def set!(data, store_old: true)
|
176
|
-
@old = attributes.dup if store_old
|
169
|
+
def set!(data, reset_modified = true)
|
170
|
+
@modified = {} if reset_modified
|
177
171
|
data = data.attributes if data.is_a? Passwordstate::Resource
|
178
172
|
data.each do |key, value|
|
179
173
|
field = self.class.passwordstate_to_ruby_field(key)
|
@@ -190,7 +184,7 @@ module Passwordstate
|
|
190
184
|
parsed_value = convert.call(value, direction: :from)
|
191
185
|
end
|
192
186
|
|
193
|
-
instance_variable_set "@#{field}"
|
187
|
+
instance_variable_set :"@#{field}", parsed_value || value
|
194
188
|
end
|
195
189
|
self
|
196
190
|
end
|
@@ -274,7 +268,8 @@ module Passwordstate
|
|
274
268
|
fields.each do |field|
|
275
269
|
if field.is_a? Symbol
|
276
270
|
accessor_field_names << field
|
277
|
-
|
271
|
+
attr_reader field
|
272
|
+
build_writer_method field
|
278
273
|
else
|
279
274
|
field_options[accessor_field_names.last] = field
|
280
275
|
end
|
@@ -296,12 +291,24 @@ module Passwordstate
|
|
296
291
|
fields.each do |field|
|
297
292
|
if field.is_a? Symbol
|
298
293
|
write_field_names << field
|
299
|
-
|
294
|
+
build_writer_method field
|
300
295
|
else
|
301
296
|
field_options[write_field_names.last] = field
|
302
297
|
end
|
303
298
|
end
|
304
299
|
end
|
300
|
+
|
301
|
+
private
|
302
|
+
|
303
|
+
def build_writer_method(field)
|
304
|
+
field = field.to_s.to_sym unless field.is_a? Symbol
|
305
|
+
define_method(:"#{field}=") do |arg|
|
306
|
+
return arg if send(field) == arg
|
307
|
+
|
308
|
+
instance_variable_set "@#{field}", arg
|
309
|
+
modified[field] = arg
|
310
|
+
end
|
311
|
+
end
|
305
312
|
end
|
306
313
|
end
|
307
314
|
# rubocop:enable Metrics/ClassLength
|
@@ -317,7 +324,7 @@ module Passwordstate
|
|
317
324
|
autoload :PasswordList, 'passwordstate/resources/password_list'
|
318
325
|
autoload :PasswordListPermission, 'passwordstate/resources/password_list'
|
319
326
|
autoload :PasswordHistory, 'passwordstate/resources/password'
|
320
|
-
autoload :PasswordPermission, 'passwordstate/resources/
|
327
|
+
autoload :PasswordPermission, 'passwordstate/resources/password'
|
321
328
|
autoload :PrivilegedAccount, 'passwordstate/resources/privileged_account'
|
322
329
|
autoload :PrivilegedAccountPermission, 'passwordstate/resources/privileged_account'
|
323
330
|
autoload :Permission, 'passwordstate/resources/permission'
|
@@ -62,11 +62,11 @@ module Passwordstate
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def operation_supported?(operation)
|
65
|
-
return
|
65
|
+
return false unless %i[search all get post put delete].include?(operation)
|
66
66
|
return false if options.key?(:only) && !options[:only].include?(operation)
|
67
67
|
return false if options.key?(:except) && options[:except].include?(operation)
|
68
68
|
|
69
|
-
!options.fetch("#{operation}_path"
|
69
|
+
!options.fetch(:"#{operation}_path", '').nil?
|
70
70
|
end
|
71
71
|
|
72
72
|
def new(data)
|
@@ -13,7 +13,7 @@ module Passwordstate
|
|
13
13
|
alias title document_name
|
14
14
|
|
15
15
|
def self.all(client, store, **query)
|
16
|
-
super
|
16
|
+
super(client, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.search(client, store, **options)
|
@@ -21,19 +21,19 @@ module Passwordstate
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.get(client, store, object)
|
24
|
-
super
|
24
|
+
super(client, object, _api_path: "#{api_path}/#{validate_store! store}")
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.post(client, store, data, **query)
|
28
|
-
super
|
28
|
+
super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.put(client, store, data, **query)
|
32
|
-
super
|
32
|
+
super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.delete(client, store, object, **query)
|
36
|
-
super
|
36
|
+
super(client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
37
37
|
end
|
38
38
|
|
39
39
|
class << self
|
@@ -112,11 +112,13 @@ module Passwordstate
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def self.all(client, **query)
|
115
|
-
|
115
|
+
query = { query_all: true }.merge(query)
|
116
|
+
super(client, **query)
|
116
117
|
end
|
117
118
|
|
118
119
|
def self.search(client, **query)
|
119
|
-
|
120
|
+
query = { _api_path: 'searchpasswords' }.merge(query)
|
121
|
+
super(client, **query)
|
120
122
|
end
|
121
123
|
|
122
124
|
def self.generate(client, **options)
|
data/lib/passwordstate.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passwordstate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Olofsson
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: logging
|
@@ -173,7 +172,6 @@ licenses:
|
|
173
172
|
- MIT
|
174
173
|
metadata:
|
175
174
|
rubygems_mfa_required: 'true'
|
176
|
-
post_install_message:
|
177
175
|
rdoc_options: []
|
178
176
|
require_paths:
|
179
177
|
- lib
|
@@ -188,8 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
186
|
- !ruby/object:Gem::Version
|
189
187
|
version: '0'
|
190
188
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
189
|
+
rubygems_version: 3.6.9
|
193
190
|
specification_version: 4
|
194
191
|
summary: A ruby API client for interacting with a passwordstate server
|
195
192
|
test_files: []
|