# frozen_string_literal: true

require 'spec_helper'
require 'utils/secrets'

describe 'Utils::Secrets' do
  describe '#get_secret' do
    before do
      allow(Utils::Secrets::SECRETS_MANAGER_CLIENT).to receive(:get_secret_value)
        .and_return({ 'secret_string' => 'test' })

      stub_const('Config::ENVIRONMENT', 'qa')
    end

    it 'retrieves the secret based on the environment' do
      Utils::Secrets.get_secret('id')
      expect(Utils::Secrets::SECRETS_MANAGER_CLIENT).to have_received(:get_secret_value).once.with(
        secret_id: 'qa/lambda-create-ssm-activation/id'
      )
    end

    it 'returns the value of the given secret' do
      secret = Utils::Secrets.get_secret('id')
      expect(secret).to eq('test')
    end
  end
end
