How to use resolve method of Secrets Package

Best Inspec_ruby code snippet using Secrets.resolve

input_registry_test.rb

Source:input_registry_test.rb Github

copy

Full Screen

...65 it "returns an empty hash" do66 _(seen_inputs).must_equal({})67 end68 end69 describe "when a CLI --attrs option is provided and does not resolve" do70 let(:sources) { { cli_input_files: ["nope.jpg"] } }71 it "raises an exception" do72 Inspec::SecretsBackend.expects(:resolve).with("nope.jpg").returns(nil)73 _(proc { seen_inputs }).must_raise Inspec::Exceptions::SecretsBackendNotFound74 end75 end76 describe "when a CLI --attrs option is provided and has no inputs" do77 let(:sources) { { cli_input_files: ["empty.yaml"] } }78 it "returns an empty hash" do79 secrets = mock80 secrets.stubs(:inputs).returns(nil)81 Inspec::SecretsBackend.expects(:resolve).with("empty.yaml").returns(secrets)82 _(seen_inputs).must_equal({})83 end84 end85 describe "when a CLI --attrs file is provided and has inputs" do86 let(:sources) { { cli_input_files: ["file1.yaml"] } }87 it "returns a hash containing the inputs" do88 fixture_inputs = { "foo" => "bar" }89 secrets = mock90 secrets.stubs(:inputs).returns(fixture_inputs)91 Inspec::SecretsBackend.expects(:resolve).with("file1.yaml").returns(secrets)92 _(seen_inputs).must_equal(fixture_inputs)93 end94 end95 describe "when multiple CLI --attrs option args are provided and one fails" do96 let(:sources) { { cli_input_files: ["file1.yaml", "file2.yaml"] } }97 it "raises an exception" do98 secrets = mock99 secrets.stubs(:inputs).returns(nil)100 Inspec::SecretsBackend.expects(:resolve).with("file1.yaml").returns(secrets)101 Inspec::SecretsBackend.expects(:resolve).with("file2.yaml").returns(nil)102 _(proc { seen_inputs }).must_raise Inspec::Exceptions::SecretsBackendNotFound103 end104 end105 describe "when multiple CLI --attrs option args are provided and one has no inputs" do106 let(:sources) { { cli_input_files: ["file1.yaml", "file2.yaml"] } }107 it "returns a hash containing the inputs from the valid files" do108 inputs = { "foo" => "bar" }109 secrets1 = mock110 secrets1.stubs(:inputs).returns(nil)111 secrets2 = mock112 secrets2.stubs(:inputs).returns(inputs)113 Inspec::SecretsBackend.expects(:resolve).with("file1.yaml").returns(secrets1)114 Inspec::SecretsBackend.expects(:resolve).with("file2.yaml").returns(secrets2)115 _(seen_inputs).must_equal(inputs)116 end117 end118 describe "when multiple CLI --attrs option args are provided and all have inputs" do119 let(:sources) { { cli_input_files: ["file1.yaml", "file2.yaml"] } }120 it "returns a hash containing all the inputs" do121 secrets1 = mock122 secrets1.stubs(:inputs).returns({ "key1" => "value1" })123 secrets2 = mock124 secrets2.stubs(:inputs).returns({ "key2" => "value2" })125 Inspec::SecretsBackend.expects(:resolve).with("file1.yaml").returns(secrets1)126 Inspec::SecretsBackend.expects(:resolve).with("file2.yaml").returns(secrets2)127 _(seen_inputs).must_equal({ "key1" => "value1", "key2" => "value2" })128 end129 end130 end131end...

Full Screen

Full Screen

runner_test.rb

Source:runner_test.rb Github

copy

Full Screen

...9 options = {}10 runner.load_attributes(options).must_equal({})11 end12 end13 describe 'when an attr is provided and does not resolve' do14 it 'raises an exception' do15 options = { attrs: ['nope.jpg'] }16 Inspec::SecretsBackend.expects(:resolve).with('nope.jpg').returns(nil)17 proc { runner.load_attributes(options) }.must_raise Inspec::Exceptions::SecretsBackendNotFound18 end19 end20 describe 'when an attr is provided and has no attributes' do21 it 'returns an empty hash' do22 secrets = mock23 secrets.stubs(:attributes).returns(nil)24 options = { attrs: ['empty.yaml'] }25 Inspec::SecretsBackend.expects(:resolve).with('empty.yaml').returns(secrets)26 runner.load_attributes(options).must_equal({})27 end28 end29 describe 'when an attr is provided and has attributes' do30 it 'returns a hash containing the attributes' do31 options = { attrs: ['file1.yaml'] }32 attributes = { foo: 'bar' }33 secrets = mock34 secrets.stubs(:attributes).returns(attributes)35 Inspec::SecretsBackend.expects(:resolve).with('file1.yaml').returns(secrets)36 runner.load_attributes(options).must_equal(attributes)37 end38 end39 describe 'when multiple attrs are provided and one fails' do40 it 'raises an exception' do41 options = { attrs: ['file1.yaml', 'file2.yaml'] }42 secrets = mock43 secrets.stubs(:attributes).returns(nil)44 Inspec::SecretsBackend.expects(:resolve).with('file1.yaml').returns(secrets)45 Inspec::SecretsBackend.expects(:resolve).with('file2.yaml').returns(nil)46 proc { runner.load_attributes(options) }.must_raise Inspec::Exceptions::SecretsBackendNotFound47 end48 end49 describe 'when multiple attrs are provided and one has no attributes' do50 it 'returns a hash containing the attributes from the valid files' do51 options = { attrs: ['file1.yaml', 'file2.yaml'] }52 attributes = { foo: 'bar' }53 secrets1 = mock54 secrets1.stubs(:attributes).returns(nil)55 secrets2 = mock56 secrets2.stubs(:attributes).returns(attributes)57 Inspec::SecretsBackend.expects(:resolve).with('file1.yaml').returns(secrets1)58 Inspec::SecretsBackend.expects(:resolve).with('file2.yaml').returns(secrets2)59 runner.load_attributes(options).must_equal(attributes)60 end61 end62 describe 'when multiple attrs are provided and all have attributes' do63 it 'returns a hash containing all the attributes' do64 options = { attrs: ['file1.yaml', 'file2.yaml'] }65 secrets1 = mock66 secrets1.stubs(:attributes).returns({ key1: 'value1' })67 secrets2 = mock68 secrets2.stubs(:attributes).returns({ key2: 'value2' })69 Inspec::SecretsBackend.expects(:resolve).with('file1.yaml').returns(secrets1)70 Inspec::SecretsBackend.expects(:resolve).with('file2.yaml').returns(secrets2)71 runner.load_attributes(options).must_equal({ key1: 'value1', key2: 'value2' })72 end73 end74 end75end...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Inspec_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful