Class: Kitsune::Kit::Adapters::FakeSecretStore

Inherits:
SecretStores::Store show all
Defined in:
lib/kitsune/kit/adapters/fake_secret_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ FakeSecretStore

Returns a new instance of FakeSecretStore.



12
13
14
15
16
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 12

def initialize(values = {})
  super()
  @values = values.transform_keys(&:to_s)
  @fetches = []
end

Instance Attribute Details

#fetchesObject (readonly)

Returns the value of attribute fetches.



10
11
12
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 10

def fetches
  @fetches
end

Instance Method Details

#configured?(name) ⇒ Boolean

Returns:

  • (Boolean)


30
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 30

def configured?(name) = !@values.fetch(name.to_s, "").empty?

#fetch(name, required: true) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 18

def fetch(name, required: true)
  key = name.to_s
  @fetches << key
  value = @values.fetch(key, "")
  if required && value.empty?
    raise Errors::ConfigurationError.new(
      "required secret #{key} is not set", hint: "Provide #{key} through the configured secret store."
    )
  end
  value
end

#set(name, value) ⇒ Object



31
# File 'lib/kitsune/kit/adapters/fake_secret_store.rb', line 31

def set(name, value) = @values[name.to_s] = value.to_s