Sha256: fc58656ccc619423afd614c2dca6eed77579b36d2ea21fd9599715b04f2d542d

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe SurveyGizmo::Configuration do
  before(:each) do
    SurveyGizmo.configure do |config|
      config.api_token = 'king_of_the&whirled$'
      config.api_token_secret = 'dream/word'
    end
    @severity = 'INFO'
    @time_string = '2015-04-15 05:46:30'
    @progname = 'TEST'
  end

  after(:each) do
    SurveyGizmo.reset!
  end

  it 'should mask unencoded api token' do
    config = SurveyGizmo.configuration
    formatted_message = config.logger.format_message(
      @severity,
      @time_string.to_time,
      @progname,
      config.api_token
    )
    expect(
      formatted_message
    ).to eq(
      "#{@time_string} #{@severity} <SG_API_KEY>\n"
    )
  end

  it 'should mask percent encoded api token' do
    config = SurveyGizmo.configuration
    formatted_message = config.logger.format_message(
      @severity,
      @time_string.to_time,
      @progname,
      CGI.escape(config.api_token)
    )
    expect(
      formatted_message
    ).to eq(
      "#{@time_string} #{@severity} <SG_API_KEY>\n"
    )
  end

  it 'should mask unencoded api token secret' do
    config = SurveyGizmo.configuration
    formatted_message = config.logger.format_message(
      @severity,
      @time_string.to_time,
      @progname,
      config.api_token_secret
    )
    expect(
      formatted_message
    ).to eq(
      "#{@time_string} #{@severity} <SG_API_SECRET>\n"
    )
  end

  it 'should mask percent encoded api token secret' do
    config = SurveyGizmo.configuration
    formatted_message = config.logger.format_message(
      @severity,
      @time_string.to_time,
      @progname,
      CGI.escape(config.api_token_secret)
    )
    expect(
      formatted_message
    ).to eq(
      "#{@time_string} #{@severity} <SG_API_SECRET>\n"
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
survey-gizmo-ruby-6.2.13 spec/logger_spec.rb
survey-gizmo-ruby-6.2.12 spec/logger_spec.rb
survey-gizmo-ruby-6.2.11 spec/logger_spec.rb