commit
1d82e1fa48
2 changed files with 39 additions and 4 deletions
|
@ -38,9 +38,16 @@ module Psenv
|
|||
end
|
||||
|
||||
def parameters
|
||||
ssm.
|
||||
get_parameters_by_path(path: @path, with_decryption: true).
|
||||
parameters
|
||||
parameters = []
|
||||
response = ssm.get_parameters_by_path(path: @path, with_decryption: true)
|
||||
parameters << response.parameters
|
||||
|
||||
while response.next_page?
|
||||
response = response.next_page
|
||||
parameters << response.parameters
|
||||
end
|
||||
|
||||
parameters.flatten
|
||||
rescue StandardError => error
|
||||
raise RetrieveError, error
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ RSpec.describe Psenv::Retriever do
|
|||
|
||||
subject { Psenv::Retriever.new("/psenv/test").call }
|
||||
|
||||
context "with a successful request" do
|
||||
context "with a single page request" do
|
||||
before(:each) do
|
||||
allow(ssm).to receive(:get_parameters_by_path) {
|
||||
OpenStruct.new(
|
||||
|
@ -60,6 +60,34 @@ RSpec.describe Psenv::Retriever do
|
|||
end
|
||||
end
|
||||
|
||||
context "with multiple pages" do
|
||||
before(:each) do
|
||||
allow(ssm).to receive(:get_parameters_by_path) {
|
||||
OpenStruct.new(
|
||||
parameters: [{
|
||||
name: "/psenv/test/API_KEY",
|
||||
value: "value",
|
||||
type: "String",
|
||||
version: 1,
|
||||
}],
|
||||
next_page?: true,
|
||||
next_page: OpenStruct.new(
|
||||
parameters: [{
|
||||
name: "/psenv/test/CLIENT_KEY",
|
||||
value: "value",
|
||||
type: "String",
|
||||
version: 1,
|
||||
}],
|
||||
),
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
it "returns both parameters" do
|
||||
expect(subject).to eq("API_KEY" => "value", "CLIENT_KEY" => "value")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the request fails" do
|
||||
before(:each) { allow(ssm).to receive(:get_parameters_by_path).and_raise }
|
||||
|
||||
|
|
Loading…
Reference in a new issue