passwordstate 0.1.1 → 0.2.0
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/.rubocop.yml +2 -2
- data/CHANGELOG.md +15 -0
- data/lib/passwordstate/client.rb +17 -24
- data/lib/passwordstate/errors.rb +3 -1
- data/lib/passwordstate/resource.rb +25 -17
- data/lib/passwordstate/resource_list.rb +8 -8
- data/lib/passwordstate/resources/active_directory.rb +2 -1
- data/lib/passwordstate/resources/document.rb +18 -6
- data/lib/passwordstate/resources/folder.rb +5 -1
- data/lib/passwordstate/resources/host.rb +1 -0
- data/lib/passwordstate/resources/password.rb +10 -7
- data/lib/passwordstate/resources/password_list.rb +4 -2
- data/lib/passwordstate/resources/privileged_account.rb +2 -1
- data/lib/passwordstate/resources/report.rb +22 -1
- data/lib/passwordstate/util.rb +5 -2
- data/lib/passwordstate/version.rb +1 -1
- data/lib/passwordstate.rb +0 -1
- data/passwordstate.gemspec +1 -1
- data/test/fixtures/create_password.json +41 -0
- data/test/fixtures/get_password.json +18 -6
- data/test/fixtures/get_password_list.json +15 -15
- data/test/fixtures/get_password_otp.json +3 -5
- data/test/fixtures/password_list_search_passwords.json +44 -16
- data/test/fixtures/update_password.json +22 -10
- data/test/resources/password_list_test.rb +8 -8
- data/test/resources/password_test.rb +15 -15
- metadata +5 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16f9541b2823f0afcc423ea6a1dc815fa325d03b8634ad176e3ee0761cd0989d
|
|
4
|
+
data.tar.gz: 66cc0353de3b5c7f773dc59b027abec898ba2bb41cd19175ccefa47238f0a644
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8748e111737f2a536cbaf9f80c03687dbe2aed6fc5fa418f4bebe8b657bafdd40dc7c621c77506362697d8db258f0b34372e7e1945a44c3614f0636d220d3afb
|
|
7
|
+
data.tar.gz: 2a76e68492d073eefad2604663bedc690a6e9a0fe496a8a95864739925f3e11defde2bba6c57476244b0b320dc2490c235b5fb1699d2db0d5bc98b4e458e8d1e
|
data/.gitlab-ci.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
AllCops:
|
|
3
|
-
TargetRubyVersion:
|
|
3
|
+
TargetRubyVersion: 3.0
|
|
4
4
|
Exclude:
|
|
5
5
|
- '*.spec'
|
|
6
6
|
- 'Rakefile'
|
|
@@ -11,7 +11,7 @@ AllCops:
|
|
|
11
11
|
Style/Documentation:
|
|
12
12
|
Enabled: false
|
|
13
13
|
|
|
14
|
-
Style/
|
|
14
|
+
Style/DirectiveScope:
|
|
15
15
|
Enabled: false
|
|
16
16
|
|
|
17
17
|
Style/MultilineBlockChain:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## v0.2.0 2026-11-23
|
|
2
|
+
|
|
3
|
+
- Update against Passwordstate 10.0+ API docs
|
|
4
|
+
- Remove no longer possible multi-version support, now always assumes latest version
|
|
5
|
+
- Remove old Ruby 2.X references
|
|
6
|
+
|
|
7
|
+
## v0.1.2 2025-08-26
|
|
8
|
+
|
|
9
|
+
- Improved performance when working with large lists
|
|
10
|
+
|
|
11
|
+
## v0.1.1 2024-03-27
|
|
12
|
+
|
|
13
|
+
- Add Client#open_timeout=
|
|
14
|
+
- Add Resource#modified?
|
|
15
|
+
|
|
1
16
|
## v0.1.0 2022-12-05
|
|
2
17
|
|
|
3
18
|
- Reduced data transferred for regular queries
|
data/lib/passwordstate/client.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
|
+
require 'pp'
|
|
4
5
|
|
|
5
6
|
module Passwordstate
|
|
6
7
|
class Client
|
|
7
|
-
USER_AGENT = "RubyPasswordstate/#{Passwordstate::VERSION}"
|
|
8
|
+
USER_AGENT = "RubyPasswordstate/#{Passwordstate::VERSION}".freeze
|
|
8
9
|
DEFAULT_HEADERS = {
|
|
9
10
|
'accept' => 'application/json',
|
|
10
11
|
'user-agent' => USER_AGENT
|
|
@@ -18,7 +19,7 @@ module Passwordstate
|
|
|
18
19
|
@server_url = URI(url)
|
|
19
20
|
@validate_certificate = true
|
|
20
21
|
@headers = DEFAULT_HEADERS
|
|
21
|
-
@auth_data = options.
|
|
22
|
+
@auth_data = options.slice(:apikey, :user_id, :username, :password)
|
|
22
23
|
@api_type = options.fetch(:api_type) if options.key? :api_type
|
|
23
24
|
@open_timeout = options.fetch(:open_timeout, 5)
|
|
24
25
|
@timeout = options.fetch(:timeout, 15)
|
|
@@ -29,7 +30,12 @@ module Passwordstate
|
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def api_type
|
|
32
|
-
@api_type ||
|
|
33
|
+
@api_type || begin
|
|
34
|
+
api_type ||= :userapi if auth_data.key?(:apikey) && auth_data.key?(:user_id)
|
|
35
|
+
api_type ||= :api if auth_data.key?(:apikey)
|
|
36
|
+
api_type ||= :winapi
|
|
37
|
+
api_type
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
def open_timeout=(sec)
|
|
@@ -77,32 +83,19 @@ module Passwordstate
|
|
|
77
83
|
false
|
|
78
84
|
end
|
|
79
85
|
|
|
86
|
+
## Stub methods
|
|
87
|
+
#
|
|
88
|
+
# Passwordstate no longer provides any API compatibility information
|
|
80
89
|
def version
|
|
81
|
-
|
|
82
|
-
html = request(:get, '', allow_html: true)
|
|
83
|
-
version = html.find_line { |line| line.include? '<span>V</span>' }
|
|
84
|
-
version = />(\d\.\d) \(Build (.+)\)</.match(version)
|
|
85
|
-
"#{version[1]}.#{version[2]}" if version
|
|
86
|
-
end
|
|
90
|
+
nil
|
|
87
91
|
end
|
|
88
92
|
|
|
89
|
-
def version?(
|
|
90
|
-
|
|
91
|
-
logger.debug 'Unable to detect Passwordstate version, assuming recent enough.'
|
|
92
|
-
return true
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
Gem::Dependency.new(to_s, compare).match?(to_s, version)
|
|
93
|
+
def version?(_compare)
|
|
94
|
+
true
|
|
96
95
|
end
|
|
97
96
|
|
|
98
|
-
def require_version(compare)
|
|
99
|
-
|
|
100
|
-
logger.debug 'Unable to detect Passwordstate version, assuming recent enough.'
|
|
101
|
-
return true
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
raise "Your version of Passwordstate (#{version}) doesn't support the requested feature" unless version? compare
|
|
105
|
-
end
|
|
97
|
+
def require_version(compare); end
|
|
98
|
+
## End stub methods
|
|
106
99
|
|
|
107
100
|
def request(method, api_path, query: nil, reason: nil, **options)
|
|
108
101
|
uri = URI(server_url + "/#{api_type}/" + api_path)
|
data/lib/passwordstate/errors.rb
CHANGED
|
@@ -12,10 +12,12 @@ module Passwordstate
|
|
|
12
12
|
@code = code.to_i
|
|
13
13
|
@request = request
|
|
14
14
|
@response = response
|
|
15
|
+
|
|
16
|
+
errors = errors.first['errors'] if errors.one? && errors.first.is_a?(Hash) && errors.first.key?('errors')
|
|
15
17
|
@errors = errors
|
|
16
18
|
|
|
17
19
|
errorstr = errors.map { |err| err['message'] || err['phrase'] || err['error'] }.join('; ')
|
|
18
|
-
super
|
|
20
|
+
super("Passwordstate responded with an error to the request:\n#{errorstr}")
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def self.new_by_code(code, req, res, errors = [])
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Passwordstate
|
|
4
4
|
# A simple resource DSL helper
|
|
5
5
|
#
|
|
6
|
-
# rubocop:disable Metrics/ClassLength This DSL class will be large
|
|
6
|
+
# rubocop:disable Metrics/ClassLength -- This DSL class will be large
|
|
7
7
|
class Resource
|
|
8
8
|
attr_reader :client
|
|
9
9
|
|
|
@@ -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
|
|
@@ -220,7 +214,7 @@ module Passwordstate
|
|
|
220
214
|
def acceptable_methods(*meths)
|
|
221
215
|
if meths.empty?
|
|
222
216
|
@acceptable_methods || %i[post get put delete]
|
|
223
|
-
elsif meths.
|
|
217
|
+
elsif meths.one? && meths.to_s.upcase == meths.to_s
|
|
224
218
|
@acceptable_methods = []
|
|
225
219
|
meths = meths.first.to_s
|
|
226
220
|
@acceptable_methods << :post if meths.include? 'C'
|
|
@@ -274,7 +268,9 @@ 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
|
+
|
|
273
|
+
build_writer_method field
|
|
278
274
|
else
|
|
279
275
|
field_options[accessor_field_names.last] = field
|
|
280
276
|
end
|
|
@@ -296,12 +292,24 @@ module Passwordstate
|
|
|
296
292
|
fields.each do |field|
|
|
297
293
|
if field.is_a? Symbol
|
|
298
294
|
write_field_names << field
|
|
299
|
-
|
|
295
|
+
build_writer_method field
|
|
300
296
|
else
|
|
301
297
|
field_options[write_field_names.last] = field
|
|
302
298
|
end
|
|
303
299
|
end
|
|
304
300
|
end
|
|
301
|
+
|
|
302
|
+
private
|
|
303
|
+
|
|
304
|
+
def build_writer_method(field)
|
|
305
|
+
field = field.to_s.to_sym unless field.is_a? Symbol
|
|
306
|
+
define_method(:"#{field}=") do |arg|
|
|
307
|
+
return arg if send(field) == arg
|
|
308
|
+
|
|
309
|
+
instance_variable_set "@#{field}", arg
|
|
310
|
+
modified[field] = arg
|
|
311
|
+
end
|
|
312
|
+
end
|
|
305
313
|
end
|
|
306
314
|
end
|
|
307
315
|
# rubocop:enable Metrics/ClassLength
|
|
@@ -317,7 +325,7 @@ module Passwordstate
|
|
|
317
325
|
autoload :PasswordList, 'passwordstate/resources/password_list'
|
|
318
326
|
autoload :PasswordListPermission, 'passwordstate/resources/password_list'
|
|
319
327
|
autoload :PasswordHistory, 'passwordstate/resources/password'
|
|
320
|
-
autoload :PasswordPermission, 'passwordstate/resources/
|
|
328
|
+
autoload :PasswordPermission, 'passwordstate/resources/password'
|
|
321
329
|
autoload :PrivilegedAccount, 'passwordstate/resources/privileged_account'
|
|
322
330
|
autoload :PrivilegedAccountPermission, 'passwordstate/resources/privileged_account'
|
|
323
331
|
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)
|
|
@@ -87,7 +87,7 @@ module Passwordstate
|
|
|
87
87
|
api_path = options.fetch(:search_path, resource.api_path)
|
|
88
88
|
query = options.fetch(:search_query, {}).merge(query)
|
|
89
89
|
|
|
90
|
-
resource.search(client, **query
|
|
90
|
+
resource.search(client, **query, _api_path: api_path)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def all(**query)
|
|
@@ -96,7 +96,7 @@ module Passwordstate
|
|
|
96
96
|
api_path = options.fetch(:all_path, resource.api_path)
|
|
97
97
|
query = options.fetch(:all_query, {}).merge(query)
|
|
98
98
|
|
|
99
|
-
load resource.all(client, **query
|
|
99
|
+
load resource.all(client, **query, _api_path: api_path)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def get(id, **query)
|
|
@@ -112,7 +112,7 @@ module Passwordstate
|
|
|
112
112
|
api_path = options.fetch(:get_path, resource.api_path)
|
|
113
113
|
query = options.fetch(:get_query, {}).merge(query)
|
|
114
114
|
|
|
115
|
-
resource.get(client, id, **query
|
|
115
|
+
resource.get(client, id, **query, _api_path: api_path)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
def post(data, **query)
|
|
@@ -121,7 +121,7 @@ module Passwordstate
|
|
|
121
121
|
api_path = options.fetch(:post_path, resource.api_path)
|
|
122
122
|
query = options.fetch(:post_query, {}).merge(query)
|
|
123
123
|
|
|
124
|
-
resource.post(client, data, **query
|
|
124
|
+
resource.post(client, data, **query, _api_path: api_path)
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def put(data, **query)
|
|
@@ -130,7 +130,7 @@ module Passwordstate
|
|
|
130
130
|
api_path = options.fetch(:put_path, resource.api_path)
|
|
131
131
|
query = options.fetch(:put_query, {}).merge(query)
|
|
132
132
|
|
|
133
|
-
resource.put(client, data, **query
|
|
133
|
+
resource.put(client, data, **query, _api_path: api_path)
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
def delete(id, **query)
|
|
@@ -139,7 +139,7 @@ module Passwordstate
|
|
|
139
139
|
api_path = options.fetch(:delete_path, resource.api_path)
|
|
140
140
|
query = options.fetch(:delete_query, {}).merge(query)
|
|
141
141
|
|
|
142
|
-
resource.delete(client, id, **query
|
|
142
|
+
resource.delete(client, id, **query, _api_path: api_path)
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
private
|
|
@@ -7,13 +7,25 @@ module Passwordstate
|
|
|
7
7
|
|
|
8
8
|
index_field :document_id
|
|
9
9
|
|
|
10
|
+
accessor_fields :document_name,
|
|
11
|
+
:document_description
|
|
12
|
+
|
|
10
13
|
read_fields :document_id, { name: 'DocumentID' },
|
|
11
|
-
:
|
|
14
|
+
:modified, { is: Time },
|
|
15
|
+
:modified_by,
|
|
16
|
+
:file_size,
|
|
17
|
+
:folder_id, { name: 'FolderID' },
|
|
18
|
+
:folder_name,
|
|
19
|
+
:password_list_id, { name: 'PasswordListID' },
|
|
20
|
+
:password_list,
|
|
21
|
+
:tree_path,
|
|
22
|
+
:password_id, { name: 'PasswordID' },
|
|
23
|
+
:title
|
|
12
24
|
|
|
13
25
|
alias title document_name
|
|
14
26
|
|
|
15
27
|
def self.all(client, store, **query)
|
|
16
|
-
super
|
|
28
|
+
super(client, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
|
17
29
|
end
|
|
18
30
|
|
|
19
31
|
def self.search(client, store, **options)
|
|
@@ -21,19 +33,19 @@ module Passwordstate
|
|
|
21
33
|
end
|
|
22
34
|
|
|
23
35
|
def self.get(client, store, object)
|
|
24
|
-
super
|
|
36
|
+
super(client, object, _api_path: "#{api_path}/#{validate_store! store}")
|
|
25
37
|
end
|
|
26
38
|
|
|
27
39
|
def self.post(client, store, data, **query)
|
|
28
|
-
super
|
|
40
|
+
super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
|
29
41
|
end
|
|
30
42
|
|
|
31
43
|
def self.put(client, store, data, **query)
|
|
32
|
-
super
|
|
44
|
+
super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
|
33
45
|
end
|
|
34
46
|
|
|
35
47
|
def self.delete(client, store, object, **query)
|
|
36
|
-
super
|
|
48
|
+
super(client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}"))
|
|
37
49
|
end
|
|
38
50
|
|
|
39
51
|
class << self
|
|
@@ -27,7 +27,6 @@ module Passwordstate
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def permissions
|
|
30
|
-
client.require_version('>= 8.4.8449')
|
|
31
30
|
FolderPermission.new(_client: client, folder_id: folder_id)
|
|
32
31
|
end
|
|
33
32
|
|
|
@@ -43,6 +42,11 @@ module Passwordstate
|
|
|
43
42
|
|
|
44
43
|
index_field :folder_id
|
|
45
44
|
|
|
45
|
+
accessor_fields :permission,
|
|
46
|
+
:apply_permissions_for_user_id, { name: 'ApplyPermissionsForUserID' },
|
|
47
|
+
:apply_permissions_for_security_group_id, { name: 'ApplyPermissionsForSecurityGroupID' },
|
|
48
|
+
:apply_permissions_for_security_group_name
|
|
49
|
+
|
|
46
50
|
read_fields :folder_id, { name: 'FolderID' }
|
|
47
51
|
end
|
|
48
52
|
end
|
|
@@ -26,19 +26,21 @@ module Passwordstate
|
|
|
26
26
|
:generic_field_info,
|
|
27
27
|
:account_type_id, { name: 'AccountTypeID' },
|
|
28
28
|
:notes,
|
|
29
|
-
:url,
|
|
29
|
+
:url, { name: 'URL' },
|
|
30
30
|
:password, { redact: true },
|
|
31
31
|
:expiry_date, { is: Time },
|
|
32
32
|
:allow_export,
|
|
33
33
|
:web_user_id, { name: 'WebUser_ID' },
|
|
34
34
|
:web_password_id, { name: 'WebPassword_ID' },
|
|
35
|
+
:web_otp_id, { name: 'WebOTP_ID' },
|
|
35
36
|
:password_list_id, { name: 'PasswordListID' } # NB: POST only
|
|
36
37
|
# rubocop:enable Naming/VariableNumber
|
|
37
38
|
|
|
38
39
|
read_fields :account_type,
|
|
39
40
|
:password_id, { name: 'PasswordID' },
|
|
40
41
|
:password_list,
|
|
41
|
-
:otp,
|
|
42
|
+
:otp, { name: 'OTP', redact: true },
|
|
43
|
+
:otp_uri, { name: 'OTPUri', redact: true },
|
|
42
44
|
# For 'Managed' passwords
|
|
43
45
|
:status,
|
|
44
46
|
:current_password,
|
|
@@ -61,7 +63,7 @@ module Passwordstate
|
|
|
61
63
|
:validate_with_priv_account
|
|
62
64
|
|
|
63
65
|
def otp!
|
|
64
|
-
client.request(:get, "onetimepassword/#{password_id}").first['OTP']
|
|
66
|
+
[client.request(:get, "onetimepassword/#{password_id}")].flatten.first['OTP']
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
def check_in
|
|
@@ -97,7 +99,6 @@ module Passwordstate
|
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
def permissions
|
|
100
|
-
client.require_version('>= 8.4.8449')
|
|
101
102
|
PasswordPermission.new(_client: client, password_id: password_id)
|
|
102
103
|
end
|
|
103
104
|
|
|
@@ -112,16 +113,18 @@ module Passwordstate
|
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
def self.all(client, **query)
|
|
115
|
-
|
|
116
|
+
query = { query_all: true }.merge(query)
|
|
117
|
+
super
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
def self.search(client, **query)
|
|
119
|
-
|
|
121
|
+
query = { _api_path: 'searchpasswords' }.merge(query)
|
|
122
|
+
super
|
|
120
123
|
end
|
|
121
124
|
|
|
122
125
|
def self.generate(client, **options)
|
|
123
126
|
results = client.request(:get, 'generatepassword', query: options).map { |r| r['Password'] }
|
|
124
|
-
return results.first if results.
|
|
127
|
+
return results.first if results.one?
|
|
125
128
|
|
|
126
129
|
results
|
|
127
130
|
end
|
|
@@ -28,6 +28,8 @@ module Passwordstate
|
|
|
28
28
|
:private_password_list,
|
|
29
29
|
:time_based_access_required,
|
|
30
30
|
:handshake_approval_required,
|
|
31
|
+
:no_approvers,
|
|
32
|
+
:disable_notifications,
|
|
31
33
|
:password_strength_policy_id, { name: 'PasswordStrengthPolicyID' },
|
|
32
34
|
:password_generator_id, { name: 'PasswordGeneratorID' },
|
|
33
35
|
:code_page,
|
|
@@ -35,6 +37,7 @@ module Passwordstate
|
|
|
35
37
|
:authentication_type,
|
|
36
38
|
:authentication_per_session,
|
|
37
39
|
:prevent_expiry_date_modification,
|
|
40
|
+
:set_expiry_date,
|
|
38
41
|
:reset_expiry_date,
|
|
39
42
|
:prevent_drag_drop,
|
|
40
43
|
:prevent_bad_password_use,
|
|
@@ -70,7 +73,7 @@ module Passwordstate
|
|
|
70
73
|
alias title password_list
|
|
71
74
|
|
|
72
75
|
def self.search(client, **query)
|
|
73
|
-
super
|
|
76
|
+
super(client, **query.merge(_api_path: 'searchpasswordlists'))
|
|
74
77
|
end
|
|
75
78
|
|
|
76
79
|
def passwords
|
|
@@ -83,7 +86,6 @@ module Passwordstate
|
|
|
83
86
|
end
|
|
84
87
|
|
|
85
88
|
def permissions
|
|
86
|
-
client.require_version('>= 8.4.8449')
|
|
87
89
|
PasswordListPermission.new(_client: client, password_list_id: password_list_id)
|
|
88
90
|
end
|
|
89
91
|
|
|
@@ -4,6 +4,7 @@ module Passwordstate
|
|
|
4
4
|
module Resources
|
|
5
5
|
class Report < Passwordstate::Resource
|
|
6
6
|
REPORT_PARAMETERS = {
|
|
7
|
+
# User reports
|
|
7
8
|
1 => %i[user_id],
|
|
8
9
|
2 => %i[user_id site_id],
|
|
9
10
|
3 => %i[user_id duration],
|
|
@@ -15,6 +16,8 @@ module Passwordstate
|
|
|
15
16
|
9 => %i[],
|
|
16
17
|
10 => %i[duration],
|
|
17
18
|
11 => %i[duration],
|
|
19
|
+
41 => %i[site_id],
|
|
20
|
+
# Passwords
|
|
18
21
|
12 => %i[site_id],
|
|
19
22
|
13 => %i[site_id],
|
|
20
23
|
14 => %i[site_i],
|
|
@@ -25,19 +28,37 @@ module Passwordstate
|
|
|
25
28
|
19 => %i[site_id],
|
|
26
29
|
20 => %i[site_id],
|
|
27
30
|
21 => %i[site_id],
|
|
31
|
+
36 => %i[site_id],
|
|
28
32
|
22 => %i[site_id],
|
|
33
|
+
35 => %i[],
|
|
34
|
+
# Permissions
|
|
29
35
|
23 => %i[site_id],
|
|
30
36
|
24 => %i[site_id user_id],
|
|
31
37
|
25 => %i[site_id security_group_name],
|
|
32
38
|
26 => %i[duration],
|
|
39
|
+
43 => %i[site_id],
|
|
40
|
+
44 => %i[site_id],
|
|
33
41
|
27 => %i[duration],
|
|
34
42
|
28 => %i[duration],
|
|
43
|
+
37 => %i[site_id],
|
|
44
|
+
38 => %i[site_id],
|
|
45
|
+
# Activity
|
|
35
46
|
29 => %i[duration],
|
|
36
47
|
30 => %i[duration],
|
|
37
48
|
31 => %i[duration],
|
|
38
49
|
32 => %i[duration],
|
|
39
50
|
33 => %i[duration],
|
|
40
|
-
34 => %i[duration]
|
|
51
|
+
34 => %i[duration],
|
|
52
|
+
# Document Reports
|
|
53
|
+
45 => %i[site_id],
|
|
54
|
+
46 => %i[site_id],
|
|
55
|
+
47 => %i[site_id],
|
|
56
|
+
48 => %i[site_id],
|
|
57
|
+
49 => %i[site_id],
|
|
58
|
+
# Misc Reports
|
|
59
|
+
39 => %i[site_id],
|
|
60
|
+
40 => %i[site_id],
|
|
61
|
+
42 => %i[site_id]
|
|
41
62
|
}.freeze
|
|
42
63
|
|
|
43
64
|
api_path 'reporting'
|
data/lib/passwordstate/util.rb
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
require 'net/http'
|
|
4
4
|
require 'net/ntlm'
|
|
5
5
|
|
|
6
|
+
# rubocop:disable Style/OneClassPerFile
|
|
7
|
+
|
|
6
8
|
module Net
|
|
7
9
|
# NTLM header extension
|
|
8
10
|
#
|
|
@@ -63,7 +65,7 @@ module Passwordstate
|
|
|
63
65
|
# }
|
|
64
66
|
module NetHTTPExtensions
|
|
65
67
|
def request(req, body = nil, &block)
|
|
66
|
-
return super
|
|
68
|
+
return super if req.ntlm_auth_information.nil?
|
|
67
69
|
|
|
68
70
|
unless started?
|
|
69
71
|
@last_body = req.body
|
|
@@ -88,7 +90,7 @@ module Passwordstate
|
|
|
88
90
|
req.body_stream.rewind if req.body_stream
|
|
89
91
|
req.body = @last_body if @last_body
|
|
90
92
|
|
|
91
|
-
super
|
|
93
|
+
super
|
|
92
94
|
else
|
|
93
95
|
yield res if block_given?
|
|
94
96
|
res
|
|
@@ -98,3 +100,4 @@ module Passwordstate
|
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
Net::HTTP.prepend Passwordstate::NetHTTPExtensions unless Net::HTTP.ancestors.include? Passwordstate::NetHTTPExtensions
|
|
103
|
+
# rubocop:enable Style/OneClassPerFile
|
data/lib/passwordstate.rb
CHANGED
data/passwordstate.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = 'https://github.com/ananace/ruby-passwordstate'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
16
|
-
spec.required_ruby_version = '>=
|
|
16
|
+
spec.required_ruby_version = '>= 3.0'
|
|
17
17
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
18
18
|
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"PasswordID": 3,
|
|
3
|
+
"Title": "borgdrone-4673615 @ Unimatrix Zero",
|
|
4
|
+
"Domain": "",
|
|
5
|
+
"HostName": "",
|
|
6
|
+
"UserName": "borgdrone-4673615",
|
|
7
|
+
"Description": "",
|
|
8
|
+
"GenericField1": "",
|
|
9
|
+
"GenericField2": "",
|
|
10
|
+
"GenericField3": "",
|
|
11
|
+
"GenericField4": "",
|
|
12
|
+
"GenericField5": "",
|
|
13
|
+
"GenericField6": "",
|
|
14
|
+
"GenericField7": "",
|
|
15
|
+
"GenericField8": "",
|
|
16
|
+
"GenericField9": "",
|
|
17
|
+
"GenericField10": "",
|
|
18
|
+
"GenericFieldInfo": [],
|
|
19
|
+
"AccountTypeID": 0,
|
|
20
|
+
"Notes": "",
|
|
21
|
+
"URL": "",
|
|
22
|
+
"Password": "shrine-jsb4D",
|
|
23
|
+
"ExpiryDate": "",
|
|
24
|
+
"AllowExport": true,
|
|
25
|
+
"AccountType": "",
|
|
26
|
+
"OTP": "",
|
|
27
|
+
"OTPUri": null,
|
|
28
|
+
"WebUser_ID": "",
|
|
29
|
+
"WebPassword_ID": "",
|
|
30
|
+
"WebOTP_ID": "",
|
|
31
|
+
"WebGenericField1_ID": "",
|
|
32
|
+
"WebGenericField2_ID": "",
|
|
33
|
+
"WebGenericField3_ID": "",
|
|
34
|
+
"WebGenericField4_ID": "",
|
|
35
|
+
"WebGenericField5_ID": "",
|
|
36
|
+
"WebGenericField6_ID": "",
|
|
37
|
+
"WebGenericField7_ID": "",
|
|
38
|
+
"WebGenericField8_ID": "",
|
|
39
|
+
"WebGenericField9_ID": "",
|
|
40
|
+
"WebGenericField10_ID": ""
|
|
41
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"
|
|
4
|
-
"PasswordList": "Managed Passwords",
|
|
5
|
-
"PasswordID": 18075,
|
|
3
|
+
"PasswordID": 3,
|
|
6
4
|
"Title": "borgdrone-4673615 @ Unimatrix Zero",
|
|
7
5
|
"Domain": "",
|
|
8
6
|
"HostName": "",
|
|
9
7
|
"UserName": "borgdrone-4673615",
|
|
10
|
-
"Description": "
|
|
8
|
+
"Description": "",
|
|
11
9
|
"GenericField1": "",
|
|
12
10
|
"GenericField2": "",
|
|
13
11
|
"GenericField3": "",
|
|
@@ -22,10 +20,24 @@
|
|
|
22
20
|
"AccountTypeID": 0,
|
|
23
21
|
"Notes": "",
|
|
24
22
|
"URL": "",
|
|
25
|
-
"Password": "
|
|
23
|
+
"Password": "shrine-jsb4D",
|
|
26
24
|
"ExpiryDate": "",
|
|
27
25
|
"AllowExport": true,
|
|
28
26
|
"AccountType": "",
|
|
29
|
-
"OTP":
|
|
27
|
+
"OTP": "",
|
|
28
|
+
"OTPUri": null,
|
|
29
|
+
"WebUser_ID": "",
|
|
30
|
+
"WebPassword_ID": "",
|
|
31
|
+
"WebOTP_ID": "",
|
|
32
|
+
"WebGenericField1_ID": "",
|
|
33
|
+
"WebGenericField2_ID": "",
|
|
34
|
+
"WebGenericField3_ID": "",
|
|
35
|
+
"WebGenericField4_ID": "",
|
|
36
|
+
"WebGenericField5_ID": "",
|
|
37
|
+
"WebGenericField6_ID": "",
|
|
38
|
+
"WebGenericField7_ID": "",
|
|
39
|
+
"WebGenericField8_ID": "",
|
|
40
|
+
"WebGenericField9_ID": "",
|
|
41
|
+
"WebGenericField10_ID": ""
|
|
30
42
|
}
|
|
31
43
|
]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"PasswordListID":
|
|
4
|
-
"PasswordList": "
|
|
5
|
-
"Description": "
|
|
6
|
-
"ImageFileName": "
|
|
3
|
+
"PasswordListID": 7,
|
|
4
|
+
"PasswordList": "Unimatrix",
|
|
5
|
+
"Description": "",
|
|
6
|
+
"ImageFileName": "protect.png",
|
|
7
7
|
"Guide": "",
|
|
8
|
-
"AllowExport":
|
|
8
|
+
"AllowExport": true,
|
|
9
9
|
"PrivatePasswordList": false,
|
|
10
10
|
"NoApprovers": "1",
|
|
11
11
|
"DisableNotifications": false,
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
"PasswordStrengthPolicyID": 1,
|
|
14
14
|
"PasswordGeneratorID": 1,
|
|
15
15
|
"CodePage": "Using Passwordstate Default Code Page",
|
|
16
|
-
"PreventPasswordReuse":
|
|
17
|
-
"AuthenticationType": "
|
|
16
|
+
"PreventPasswordReuse": 5,
|
|
17
|
+
"AuthenticationType": "None Required",
|
|
18
18
|
"AuthenticationPerSession": false,
|
|
19
|
-
"PreventExpiryDateModification":
|
|
19
|
+
"PreventExpiryDateModification": false,
|
|
20
20
|
"SetExpiryDate": 0,
|
|
21
21
|
"ResetExpiryDate": 0,
|
|
22
22
|
"PreventDragDrop": true,
|
|
23
|
-
"
|
|
24
|
-
"ProvideAccessReason":
|
|
25
|
-
"TreePath": "\\
|
|
26
|
-
"TotalPasswords":
|
|
27
|
-
"GeneratorName": "
|
|
28
|
-
"PolicyName": "
|
|
23
|
+
"PreventBlacklistedPasswordUse": true,
|
|
24
|
+
"ProvideAccessReason": false,
|
|
25
|
+
"TreePath": "\\Collective\\Control\\Unimatrix",
|
|
26
|
+
"TotalPasswords": 2,
|
|
27
|
+
"GeneratorName": "Default Password Generator",
|
|
28
|
+
"PolicyName": "Default Policy",
|
|
29
29
|
"PasswordResetEnabled": false,
|
|
30
30
|
"ForcePasswordGenerator": false,
|
|
31
31
|
"HidePasswords": "False:True:False",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"SiteID": 0,
|
|
38
38
|
"SiteLocation": "Internal",
|
|
39
39
|
"OneTimePasswords": false,
|
|
40
|
-
"DisableInheritance":
|
|
40
|
+
"DisableInheritance": false
|
|
41
41
|
}
|
|
42
42
|
]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"PasswordListID": "
|
|
4
|
-
"PasswordList": "
|
|
5
|
-
"PasswordID":
|
|
6
|
-
"Title": "
|
|
3
|
+
"PasswordListID": "7",
|
|
4
|
+
"PasswordList": "Unimatrix",
|
|
5
|
+
"PasswordID": 2,
|
|
6
|
+
"Title": "dronecontrol",
|
|
7
7
|
"Domain": "",
|
|
8
8
|
"HostName": "",
|
|
9
|
-
"UserName": "
|
|
10
|
-
"Description": "
|
|
9
|
+
"UserName": "admin",
|
|
10
|
+
"Description": "Borg Drone admin",
|
|
11
11
|
"GenericField1": "",
|
|
12
12
|
"GenericField2": "",
|
|
13
13
|
"GenericField3": "",
|
|
@@ -22,21 +22,35 @@
|
|
|
22
22
|
"AccountTypeID": 0,
|
|
23
23
|
"Notes": "",
|
|
24
24
|
"URL": "",
|
|
25
|
-
"Password": "
|
|
25
|
+
"Password": "ebai6uoLie2coht3uzuwaRieD9ieroon7chie2choexoiThoofaing0xuosh3aez",
|
|
26
26
|
"ExpiryDate": "",
|
|
27
27
|
"AllowExport": true,
|
|
28
28
|
"AccountType": "",
|
|
29
|
-
"OTP": null
|
|
29
|
+
"OTP": null,
|
|
30
|
+
"OTPUri": null,
|
|
31
|
+
"WebUser_ID": null,
|
|
32
|
+
"WebPassword_ID": null,
|
|
33
|
+
"WebOTP_ID": null,
|
|
34
|
+
"WebGenericField1_ID": null,
|
|
35
|
+
"WebGenericField2_ID": null,
|
|
36
|
+
"WebGenericField3_ID": null,
|
|
37
|
+
"WebGenericField4_ID": null,
|
|
38
|
+
"WebGenericField5_ID": null,
|
|
39
|
+
"WebGenericField6_ID": null,
|
|
40
|
+
"WebGenericField7_ID": null,
|
|
41
|
+
"WebGenericField8_ID": null,
|
|
42
|
+
"WebGenericField9_ID": null,
|
|
43
|
+
"WebGenericField10_ID": null
|
|
30
44
|
},
|
|
31
45
|
{
|
|
32
|
-
"PasswordListID": "
|
|
33
|
-
"PasswordList": "
|
|
34
|
-
"PasswordID":
|
|
35
|
-
"Title": "
|
|
46
|
+
"PasswordListID": "7",
|
|
47
|
+
"PasswordList": "Unimatrix",
|
|
48
|
+
"PasswordID": 1,
|
|
49
|
+
"Title": "hivemind - unimatrix01",
|
|
36
50
|
"Domain": "",
|
|
37
51
|
"HostName": "",
|
|
38
|
-
"UserName": "
|
|
39
|
-
"Description": "
|
|
52
|
+
"UserName": "unimatrix01",
|
|
53
|
+
"Description": "Borg Hivemind admin @ unimatrix01",
|
|
40
54
|
"GenericField1": "",
|
|
41
55
|
"GenericField2": "",
|
|
42
56
|
"GenericField3": "",
|
|
@@ -51,10 +65,24 @@
|
|
|
51
65
|
"AccountTypeID": 0,
|
|
52
66
|
"Notes": "",
|
|
53
67
|
"URL": "",
|
|
54
|
-
"Password": "
|
|
68
|
+
"Password": "ou3chaengieY1rai7oesee2thi1ohb4the5eidux8ETaeteish6diiJ9UWi6AeQu",
|
|
55
69
|
"ExpiryDate": "",
|
|
56
70
|
"AllowExport": true,
|
|
57
71
|
"AccountType": "",
|
|
58
|
-
"OTP": null
|
|
72
|
+
"OTP": null,
|
|
73
|
+
"OTPUri": null,
|
|
74
|
+
"WebUser_ID": null,
|
|
75
|
+
"WebPassword_ID": null,
|
|
76
|
+
"WebOTP_ID": null,
|
|
77
|
+
"WebGenericField1_ID": null,
|
|
78
|
+
"WebGenericField2_ID": null,
|
|
79
|
+
"WebGenericField3_ID": null,
|
|
80
|
+
"WebGenericField4_ID": null,
|
|
81
|
+
"WebGenericField5_ID": null,
|
|
82
|
+
"WebGenericField6_ID": null,
|
|
83
|
+
"WebGenericField7_ID": null,
|
|
84
|
+
"WebGenericField8_ID": null,
|
|
85
|
+
"WebGenericField9_ID": null,
|
|
86
|
+
"WebGenericField10_ID": null
|
|
59
87
|
}
|
|
60
88
|
]
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"
|
|
4
|
-
"PasswordList": "Managed Passwords",
|
|
5
|
-
"PasswordID": 18075,
|
|
3
|
+
"PasswordID": 3,
|
|
6
4
|
"Title": "borgdrone-4673615 @ Unimatrix Zero",
|
|
7
|
-
"Domain":
|
|
8
|
-
"HostName":
|
|
5
|
+
"Domain": null,
|
|
6
|
+
"HostName": null,
|
|
9
7
|
"UserName": "borgdrone-4673615",
|
|
10
|
-
"Description": "
|
|
8
|
+
"Description": "",
|
|
11
9
|
"GenericField1": "",
|
|
12
10
|
"GenericField2": "",
|
|
13
11
|
"GenericField3": "",
|
|
@@ -21,11 +19,25 @@
|
|
|
21
19
|
"GenericFieldInfo": [],
|
|
22
20
|
"AccountTypeID": 0,
|
|
23
21
|
"Notes": "",
|
|
24
|
-
"URL": "",
|
|
25
|
-
"Password": "
|
|
22
|
+
"URL": "https://1c0389a1-6e63-4276-8500-1e595f0288e9.cube.collective",
|
|
23
|
+
"Password": "shrine-jsb4D",
|
|
26
24
|
"ExpiryDate": "",
|
|
27
25
|
"AllowExport": true,
|
|
28
|
-
"AccountType":
|
|
29
|
-
"OTP":
|
|
26
|
+
"AccountType": null,
|
|
27
|
+
"OTP": "",
|
|
28
|
+
"OTPUri": null,
|
|
29
|
+
"WebUser_ID": "",
|
|
30
|
+
"WebPassword_ID": "",
|
|
31
|
+
"WebOTP_ID": "",
|
|
32
|
+
"WebGenericField1_ID": "",
|
|
33
|
+
"WebGenericField2_ID": "",
|
|
34
|
+
"WebGenericField3_ID": "",
|
|
35
|
+
"WebGenericField4_ID": "",
|
|
36
|
+
"WebGenericField5_ID": "",
|
|
37
|
+
"WebGenericField6_ID": "",
|
|
38
|
+
"WebGenericField7_ID": "",
|
|
39
|
+
"WebGenericField8_ID": "",
|
|
40
|
+
"WebGenericField9_ID": "",
|
|
41
|
+
"WebGenericField10_ID": ""
|
|
30
42
|
}
|
|
31
43
|
]
|
|
@@ -8,10 +8,10 @@ class PasswordListTest < Minitest::Test
|
|
|
8
8
|
|
|
9
9
|
@client = Passwordstate::Client.new 'http://passwordstate.example.com'
|
|
10
10
|
@client.expects(:request)
|
|
11
|
-
.with(:get, 'passwordlists/
|
|
11
|
+
.with(:get, 'passwordlists/7', query: {}, reason: nil)
|
|
12
12
|
.returns(JSON.parse(File.read('test/fixtures/get_password_list.json')))
|
|
13
13
|
|
|
14
|
-
@list = @client.password_lists.get
|
|
14
|
+
@list = @client.password_lists.get 7
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# CRUD tests
|
|
@@ -32,7 +32,7 @@ class PasswordListTest < Minitest::Test
|
|
|
32
32
|
|
|
33
33
|
def test_read
|
|
34
34
|
@client.expects(:request)
|
|
35
|
-
.with(:get, 'passwordlists/
|
|
35
|
+
.with(:get, 'passwordlists/7', query: {}, reason: nil)
|
|
36
36
|
.returns(JSON.parse(File.read('test/fixtures/get_password_list.json')))
|
|
37
37
|
|
|
38
38
|
@list.get
|
|
@@ -50,13 +50,13 @@ class PasswordListTest < Minitest::Test
|
|
|
50
50
|
def test_parsed
|
|
51
51
|
refute_nil @list.nil?
|
|
52
52
|
|
|
53
|
-
assert_equal
|
|
53
|
+
assert_equal 7, @list.password_list_id
|
|
54
54
|
|
|
55
55
|
assert_equal false, @list.hide_passwords.view
|
|
56
56
|
assert_equal true, @list.hide_passwords.modify
|
|
57
57
|
assert_equal false, @list.hide_passwords.admin
|
|
58
58
|
|
|
59
|
-
assert_equal '/
|
|
59
|
+
assert_equal '/Collective/Control/Unimatrix', @list.full_path(unix: true)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def test_search
|
|
@@ -69,13 +69,13 @@ class PasswordListTest < Minitest::Test
|
|
|
69
69
|
|
|
70
70
|
def test_password_search
|
|
71
71
|
@client.expects(:request)
|
|
72
|
-
.with(:get, 'searchpasswords/
|
|
72
|
+
.with(:get, 'searchpasswords/7', query: { 'Description' => 'borg' }, reason: nil)
|
|
73
73
|
.returns(JSON.parse(File.read('test/fixtures/password_list_search_passwords.json')))
|
|
74
74
|
|
|
75
75
|
passwords = @list.passwords.search description: 'borg'
|
|
76
76
|
|
|
77
77
|
assert_equal 2, passwords.count
|
|
78
|
-
assert_equal '
|
|
79
|
-
assert_equal '
|
|
78
|
+
assert_equal 'admin', passwords.first.user_name
|
|
79
|
+
assert_equal 'unimatrix01', passwords.last.user_name
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -7,11 +7,11 @@ class PasswordTest < Minitest::Test
|
|
|
7
7
|
Net::HTTP.any_instance.expects(:start).never
|
|
8
8
|
|
|
9
9
|
@client = Passwordstate::Client.new 'http://passwordstate.example.com'
|
|
10
|
-
@client.
|
|
11
|
-
.with(:get, 'passwords/
|
|
10
|
+
@client.stubs(:request)
|
|
11
|
+
.with(:get, 'passwords/3', query: {}, reason: nil)
|
|
12
12
|
.returns(JSON.parse(File.read('test/fixtures/get_password.json')))
|
|
13
13
|
|
|
14
|
-
@password = @client.passwords.get
|
|
14
|
+
@password = @client.passwords.get 3
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# CRUD tests
|
|
@@ -19,14 +19,14 @@ class PasswordTest < Minitest::Test
|
|
|
19
19
|
@client.expects(:request)
|
|
20
20
|
.with(:post, 'passwords', query: {}, reason: nil, body:
|
|
21
21
|
{
|
|
22
|
-
'PasswordListID' =>
|
|
22
|
+
'PasswordListID' => 7,
|
|
23
23
|
'Title' => 'borgdrone-4673615 @ Unimatrix Zero',
|
|
24
24
|
'UserName' => 'borgdrone-4673615',
|
|
25
25
|
'GeneratePassword' => true
|
|
26
26
|
})
|
|
27
|
-
.returns(JSON.parse(File.read('test/fixtures/
|
|
27
|
+
.returns(JSON.parse(File.read('test/fixtures/create_password.json')))
|
|
28
28
|
|
|
29
|
-
@client.passwords.create password_list_id:
|
|
29
|
+
@client.passwords.create password_list_id: 7,
|
|
30
30
|
title: 'borgdrone-4673615 @ Unimatrix Zero',
|
|
31
31
|
user_name: 'borgdrone-4673615',
|
|
32
32
|
generate_password: true
|
|
@@ -34,20 +34,20 @@ class PasswordTest < Minitest::Test
|
|
|
34
34
|
|
|
35
35
|
def test_read
|
|
36
36
|
@client.expects(:request)
|
|
37
|
-
.with(:get, 'passwords/
|
|
37
|
+
.with(:get, 'passwords/3', query: {}, reason: nil)
|
|
38
38
|
.returns(JSON.parse(File.read('test/fixtures/get_password.json')))
|
|
39
39
|
|
|
40
40
|
@password.get
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def test_update
|
|
44
|
-
@password.
|
|
44
|
+
@password.url = 'https://1c0389a1-6e63-4276-8500-1e595f0288e9.cube.collective'
|
|
45
45
|
|
|
46
46
|
@client.expects(:request)
|
|
47
47
|
.with(:put, 'passwords', query: {}, reason: nil, body:
|
|
48
48
|
{
|
|
49
|
-
'PasswordID' =>
|
|
50
|
-
'
|
|
49
|
+
'PasswordID' => 3,
|
|
50
|
+
'URL' => @password.url
|
|
51
51
|
})
|
|
52
52
|
.returns(JSON.parse(File.read('test/fixtures/update_password.json')))
|
|
53
53
|
|
|
@@ -58,7 +58,7 @@ class PasswordTest < Minitest::Test
|
|
|
58
58
|
@client.expects(:request)
|
|
59
59
|
.with(:put, 'passwords', query: {}, reason: nil, body:
|
|
60
60
|
{
|
|
61
|
-
'PasswordID' =>
|
|
61
|
+
'PasswordID' => 3,
|
|
62
62
|
'Password' => '<redacted>'
|
|
63
63
|
})
|
|
64
64
|
.returns(JSON.parse(File.read('test/fixtures/update_password_managed.json')))
|
|
@@ -73,13 +73,13 @@ class PasswordTest < Minitest::Test
|
|
|
73
73
|
|
|
74
74
|
def test_delete
|
|
75
75
|
@client.expects(:request)
|
|
76
|
-
.with(:delete, 'passwords/
|
|
76
|
+
.with(:delete, 'passwords/3', query: { 'MoveToRecycleBin' => false }, reason: nil)
|
|
77
77
|
.returns(true)
|
|
78
78
|
|
|
79
79
|
@password.delete
|
|
80
80
|
|
|
81
81
|
@client.expects(:request)
|
|
82
|
-
.with(:get, 'passwords/
|
|
82
|
+
.with(:get, 'passwords/3', query: {}, reason: nil)
|
|
83
83
|
.raises(Passwordstate::HTTPError.new_by_code(404, nil, nil))
|
|
84
84
|
|
|
85
85
|
assert_raises(Passwordstate::NotFoundError) { @password.get }
|
|
@@ -88,7 +88,7 @@ class PasswordTest < Minitest::Test
|
|
|
88
88
|
# Functionality test
|
|
89
89
|
def test_otp
|
|
90
90
|
@client.expects(:request)
|
|
91
|
-
.with(:get, 'onetimepassword/
|
|
91
|
+
.with(:get, 'onetimepassword/3')
|
|
92
92
|
.returns(JSON.parse(File.read('test/fixtures/get_password_otp.json')))
|
|
93
93
|
|
|
94
94
|
assert_nil @password.otp
|
|
@@ -97,7 +97,7 @@ class PasswordTest < Minitest::Test
|
|
|
97
97
|
|
|
98
98
|
def test_check_in
|
|
99
99
|
@client.expects(:request)
|
|
100
|
-
.with(:get, 'passwords/
|
|
100
|
+
.with(:get, 'passwords/3', query: { 'CheckIn' => nil })
|
|
101
101
|
.returns(true)
|
|
102
102
|
|
|
103
103
|
@password.check_in
|
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.
|
|
4
|
+
version: 0.2.0
|
|
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
|
|
@@ -158,6 +157,7 @@ files:
|
|
|
158
157
|
- lib/passwordstate/version.rb
|
|
159
158
|
- passwordstate.gemspec
|
|
160
159
|
- test/client_test.rb
|
|
160
|
+
- test/fixtures/create_password.json
|
|
161
161
|
- test/fixtures/get_password.json
|
|
162
162
|
- test/fixtures/get_password_list.json
|
|
163
163
|
- test/fixtures/get_password_otp.json
|
|
@@ -173,7 +173,6 @@ licenses:
|
|
|
173
173
|
- MIT
|
|
174
174
|
metadata:
|
|
175
175
|
rubygems_mfa_required: 'true'
|
|
176
|
-
post_install_message:
|
|
177
176
|
rdoc_options: []
|
|
178
177
|
require_paths:
|
|
179
178
|
- lib
|
|
@@ -181,15 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
181
180
|
requirements:
|
|
182
181
|
- - ">="
|
|
183
182
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: '
|
|
183
|
+
version: '3.0'
|
|
185
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
185
|
requirements:
|
|
187
186
|
- - ">="
|
|
188
187
|
- !ruby/object:Gem::Version
|
|
189
188
|
version: '0'
|
|
190
189
|
requirements: []
|
|
191
|
-
rubygems_version: 3.
|
|
192
|
-
signing_key:
|
|
190
|
+
rubygems_version: 3.6.9
|
|
193
191
|
specification_version: 4
|
|
194
192
|
summary: A ruby API client for interacting with a passwordstate server
|
|
195
193
|
test_files: []
|