Sha256: 6801757fe46ca55950782bad15a4bed2560f36aa6a37c906a16a612af56f34f2

Contents?: true

Size: 1.33 KB

Versions: 31

Compression:

Stored size: 1.33 KB

Contents

require 'hybrid_platforms_conductor/secrets_reader'

module HybridPlatformsConductorTest

  # Mock a secrets reader plugin
  class TestSecretsReaderPlugin < HybridPlatformsConductor::SecretsReader

    class << self

      attr_accessor :calls, :deployer, :mocked_secrets

    end

    # Return secrets for a given service to be deployed on a node.
    # [API] - This method is mandatory
    # [API] - The following API components are accessible:
    # * *@config* (Config): Main configuration API.
    # * *@cmd_runner* (CmdRunner): Command Runner API.
    # * *@nodes_handler* (NodesHandler): Nodes handler API.
    #
    # Parameters::
    # * *node* (String): Node to be deployed
    # * *service* (String): Service to be deployed
    # Result::
    # * Hash: The secrets
    def secrets_for(node, service)
      # Get the name by looking into the plugins' map
      plugin_name, _plugin = TestSecretsReaderPlugin.deployer.instance_variable_get(:@secrets_readers).find { |_plugin_name, plugin| plugin == self }
      TestSecretsReaderPlugin.calls << {
        instance: plugin_name,
        node: node,
        service: service
      }
      TestSecretsReaderPlugin.mocked_secrets.dig(node, service, plugin_name) || {
        node => {
          service => {
            plugin_name.to_s => 'Secret value'
          }
        }
      }
    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.9.4 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.9.2 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.9.1 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.9.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.8.4 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.8.3 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.8.2 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.8.1 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.8.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.7.4 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.7.3 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.7.2 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.7.1 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.7.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.6.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.5.1 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.5.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.4.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb
hybrid_platforms_conductor-33.3.0 spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb