Skip to content

Commit 44d180d

Browse files
authored
Add method to Vault::Sys to retrieve mount tuning settings. (#257)
1 parent 9ebb47e commit 44d180d

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

lib/vault/api/sys/mount.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,48 @@ class Mount < Response
2323
field :options
2424
end
2525

26+
class MountTune < Response
27+
# @!attribute [r] description
28+
# Specifies the description of the mount.
29+
# @return [String]
30+
field :description
31+
32+
# @!attribute [r] default_lease_ttl
33+
# Specifies the default time-to-live.
34+
# @return [Fixnum]
35+
field :default_lease_ttl
36+
37+
# @!attribute [r] max_lease_ttl
38+
# Specifies the maximum time-to-live.
39+
# @return [Fixnum]
40+
field :max_lease_ttl
41+
42+
# @!attribute [r] audit_non_hmac_request_keys
43+
# Specifies the comma-separated list of keys that will not be HMAC'd by audit devices in the request data object.
44+
# @return [Array<String>]
45+
field :audit_non_hmac_request_keys
46+
47+
# @!attribute [r] audit_non_hmac_response_keys
48+
# Specifies the comma-separated list of keys that will not be HMAC'd by audit devices in the response data object.
49+
# @return [Array<String>]
50+
field :audit_non_hmac_response_keys
51+
52+
# @!attribute [r] listing_visibility
53+
# Specifies whether to show this mount in the UI-specific listing endpoint.
54+
# @return [String]
55+
field :listing_visibility
56+
57+
# @!attribute [r] passthrough_request_headers
58+
# Comma-separated list of headers to whitelist and pass from the request to the plugin.
59+
# @return [Array<String>]
60+
field :passthrough_request_headers
61+
62+
# @!attribute [r] allowed_response_headers
63+
# Comma-separated list of headers to whitelist, allowing a plugin to include them in the response.
64+
# @return [Array<String>]
65+
field :allowed_response_headers
66+
end
67+
2668
class Sys < Request
2769
# List all mounts in the vault.
2870
#
@@ -57,6 +99,18 @@ def mount(path, type, description = nil, options = {})
5799
return true
58100
end
59101

102+
# Get the mount tunings at a given path.
103+
#
104+
# @example
105+
# Vault.sys.get_mount_tune("pki") #=> { :pki => #<struct Vault::MountTune default_lease_ttl=2764800> }
106+
#
107+
# @return [MountTune]
108+
def get_mount_tune(path)
109+
json = client.get("/v1/sys/mounts/#{encode_path(path)}/tune")
110+
json = json[:data] if json[:data]
111+
return MountTune.decode(json)
112+
end
113+
60114
# Tune a mount at the given path.
61115
#
62116
# @example

spec/integration/api/sys/mount_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ module Vault
4444
end
4545
end
4646

47+
describe "#get_mount_tune" do
48+
it "gets the mount tune settings" do
49+
subject.mount("test_mount_get_tune", "aws")
50+
result = subject.get_mount_tune("test_mount_get_tune")
51+
expect(result.default_lease_ttl).to eq(2764800)
52+
expect(result).to be_a(MountTune)
53+
54+
# Modify the mount tuning setting and recheck
55+
subject.mount_tune("test_mount_get_tune", default_lease_ttl: 12345)
56+
result = subject.get_mount_tune("test_mount_get_tune")
57+
expect(result.default_lease_ttl).to eq(12345)
58+
expect(result).to be_a(MountTune)
59+
end
60+
end
61+
4762
describe "#mount_tune" do
4863
it "tunes the mount" do
4964
expect(subject.mount("test_mount_tune", "aws")).to be(true)

0 commit comments

Comments
 (0)