Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ruby-passwordstate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LiU IT - Infrastructure
ruby-passwordstate
Commits
1079bf3e
Verified
Commit
1079bf3e
authored
5 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Allow specifying reasons for all resources
parent
ea2ae9c6
No related branches found
No related tags found
No related merge requests found
Pipeline
#5467
failed
5 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/passwordstate/client.rb
+3
-3
3 additions, 3 deletions
lib/passwordstate/client.rb
lib/passwordstate/resource.rb
+10
-5
10 additions, 5 deletions
lib/passwordstate/resource.rb
with
13 additions
and
8 deletions
lib/passwordstate/client.rb
+
3
−
3
View file @
1079bf3e
...
@@ -77,9 +77,9 @@ module Passwordstate
...
@@ -77,9 +77,9 @@ module Passwordstate
raise
"Your version of Passwordstate (
#{
version
}
) doesn't support the requested feature"
unless
version?
compare
raise
"Your version of Passwordstate (
#{
version
}
) doesn't support the requested feature"
unless
version?
compare
end
end
def
request
(
method
,
api_path
,
options
=
{}
)
def
request
(
method
,
api_path
,
query:
nil
,
reason:
nil
,
**
options
)
uri
=
URI
(
server_url
+
"/
#{
api_type
}
/"
+
api_path
)
uri
=
URI
(
server_url
+
"/
#{
api_type
}
/"
+
api_path
)
uri
.
query
=
URI
.
encode_www_form
(
options
.
fetch
(
:query
))
if
options
.
key?
:query
uri
.
query
=
URI
.
encode_www_form
(
query
)
unless
query
.
nil?
uri
.
query
=
nil
if
uri
.
query
.
nil?
||
uri
.
query
.
empty?
uri
.
query
=
nil
if
uri
.
query
.
nil?
||
uri
.
query
.
empty?
req_obj
=
Net
::
HTTP
.
const_get
(
method
.
to_s
.
capitalize
.
to_sym
).
new
uri
req_obj
=
Net
::
HTTP
.
const_get
(
method
.
to_s
.
capitalize
.
to_sym
).
new
uri
...
@@ -92,7 +92,7 @@ module Passwordstate
...
@@ -92,7 +92,7 @@ module Passwordstate
req_obj
.
ntlm_auth
(
auth_data
[
:username
],
auth_data
[
:password
])
if
api_type
==
:winapi
req_obj
.
ntlm_auth
(
auth_data
[
:username
],
auth_data
[
:password
])
if
api_type
==
:winapi
headers
.
each
{
|
h
,
v
|
req_obj
[
h
]
=
v
}
headers
.
each
{
|
h
,
v
|
req_obj
[
h
]
=
v
}
req_obj
[
'APIKey'
]
=
auth_data
[
:apikey
]
if
api_type
==
:api
req_obj
[
'APIKey'
]
=
auth_data
[
:apikey
]
if
api_type
==
:api
req_obj
[
'Reason'
]
=
options
.
fetch
(
:
reason
)
if
options
.
key?
(
:
reason
)
&&
version?
(
'>= 8.4.8449'
)
req_obj
[
'Reason'
]
=
reason
if
!
reason
.
nil?
&&
version?
(
'>= 8.4.8449'
)
print_http
req_obj
print_http
req_obj
res_obj
=
http
.
request
req_obj
res_obj
=
http
.
request
req_obj
...
...
This diff is collapsed.
Click to expand it.
lib/passwordstate/resource.rb
+
10
−
5
View file @
1079bf3e
...
@@ -36,9 +36,10 @@ module Passwordstate
...
@@ -36,9 +36,10 @@ module Passwordstate
def
self
.
all
(
client
,
query
=
{})
def
self
.
all
(
client
,
query
=
{})
path
=
query
.
fetch
(
:_api_path
,
api_path
)
path
=
query
.
fetch
(
:_api_path
,
api_path
)
reason
=
query
.
delete
(
:_reason
)
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
[
client
.
request
(
:get
,
path
,
query:
query
)].
flatten
.
map
do
|
object
|
[
client
.
request
(
:get
,
path
,
query:
query
,
reason:
reason
)].
flatten
.
map
do
|
object
|
new
object
.
merge
(
_client:
client
)
new
object
.
merge
(
_client:
client
)
end
end
end
end
...
@@ -49,9 +50,10 @@ module Passwordstate
...
@@ -49,9 +50,10 @@ module Passwordstate
return
new
_client:
client
,
index_field
=>
object
if
query
[
:_bare
]
return
new
_client:
client
,
index_field
=>
object
if
query
[
:_bare
]
path
=
query
.
fetch
(
:_api_path
,
api_path
)
path
=
query
.
fetch
(
:_api_path
,
api_path
)
reason
=
query
.
delete
(
:_reason
)
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
resp
=
client
.
request
(
:get
,
"
#{
path
}
/
#{
object
}
"
,
query:
query
).
map
do
|
data
|
resp
=
client
.
request
(
:get
,
"
#{
path
}
/
#{
object
}
"
,
query:
query
,
reason:
reason
).
map
do
|
data
|
new
data
.
merge
(
_client:
client
)
new
data
.
merge
(
_client:
client
)
end
end
return
resp
.
first
if
resp
.
one?
||
resp
.
empty?
return
resp
.
first
if
resp
.
one?
||
resp
.
empty?
...
@@ -61,26 +63,29 @@ module Passwordstate
...
@@ -61,26 +63,29 @@ module Passwordstate
def
self
.
post
(
client
,
data
,
query
=
{})
def
self
.
post
(
client
,
data
,
query
=
{})
path
=
query
.
fetch
(
:_api_path
,
api_path
)
path
=
query
.
fetch
(
:_api_path
,
api_path
)
reason
=
query
.
delete
(
:_reason
)
data
=
passwordstateify_hash
data
data
=
passwordstateify_hash
data
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
new
[
client
.
request
(
:post
,
path
,
body:
data
,
query:
query
)].
flatten
.
first
.
merge
(
_client:
client
)
new
[
client
.
request
(
:post
,
path
,
body:
data
,
query:
query
,
reason:
reason
)].
flatten
.
first
.
merge
(
_client:
client
)
end
end
def
self
.
put
(
client
,
data
,
query
=
{})
def
self
.
put
(
client
,
data
,
query
=
{})
path
=
query
.
fetch
(
:_api_path
,
api_path
)
path
=
query
.
fetch
(
:_api_path
,
api_path
)
reason
=
query
.
delete
(
:_reason
)
data
=
passwordstateify_hash
data
data
=
passwordstateify_hash
data
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
client
.
request
:put
,
path
,
body:
data
,
query:
query
client
.
request
:put
,
path
,
body:
data
,
query:
query
,
reason:
reason
end
end
def
self
.
delete
(
client
,
object
,
query
=
{})
def
self
.
delete
(
client
,
object
,
query
=
{})
path
=
query
.
fetch
(
:_api_path
,
api_path
)
path
=
query
.
fetch
(
:_api_path
,
api_path
)
reason
=
query
.
delete
(
:_reason
)
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
query
=
passwordstateify_hash
query
.
reject
{
|
k
|
k
.
to_s
.
start_with?
'_'
}
object
=
object
.
send
(
object
.
class
.
send
(
index_field
))
if
object
.
is_a?
Resource
object
=
object
.
send
(
object
.
class
.
send
(
index_field
))
if
object
.
is_a?
Resource
client
.
request
:delete
,
"
#{
path
}
/
#{
object
}
"
,
query:
query
client
.
request
:delete
,
"
#{
path
}
/
#{
object
}
"
,
query:
query
,
reason:
reason
end
end
def
self
.
passwordstateify_hash
(
hash
)
def
self
.
passwordstateify_hash
(
hash
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment