Skip to content

Commit

Permalink
Maintenance: Added general VCR cassette BasicAuth mask handling for F…
Browse files Browse the repository at this point in the history
…reshdesk.
  • Loading branch information
dominikklein authored and thorsteneckel committed Jul 14, 2021
1 parent 7dda3cd commit ee62e47
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 156 deletions.
13 changes: 0 additions & 13 deletions spec/integration/freshdesk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,11 @@
RSpec.describe 'Freshdesk import', type: :integration, use_vcr: true, db_strategy: :reset, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT IMPORT_FRESHDESK_ENDPOINT_KEY IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN] do # rubocop:disable RSpec/DescribeClass

before do

if !ENV['IMPORT_FRESHDESK_ENDPOINT']
raise "ERROR: Need IMPORT_FRESHDESK_ENDPOINT - hint IMPORT_FRESHDESK_ENDPOINT='https://example.freshdesk.com/api/v2'"
end
if !ENV['IMPORT_FRESHDESK_ENDPOINT_KEY']
raise "ERROR: Need IMPORT_FRESHDESK_ENDPOINT_KEY - hint IMPORT_FRESHDESK_ENDPOINT_KEY='01234567899876543210'"
end

Setting.set('import_freshdesk_endpoint', ENV['IMPORT_FRESHDESK_ENDPOINT'])
Setting.set('import_freshdesk_endpoint_key', ENV['IMPORT_FRESHDESK_ENDPOINT_KEY'])
Setting.set('import_mode', true)
Setting.set('system_init_done', false)

VCR.configure do |c|
# The API key is used only inside the base64 encoded Basic Auth string, so mask that as well.
c.filter_sensitive_data('<IMPORT_FRESHDESK_ENDPOINT_BASIC_AUTH>') { Base64.encode64( "#{ENV['IMPORT_FRESHDESK_ENDPOINT_KEY']}:X" ).chomp }
end

VCR.use_cassette 'freshdesk_import' do
ImportJob.create(name: 'Import::Freshdesk').start
end
Expand Down
6 changes: 6 additions & 0 deletions spec/support/vcr_mask_freshdesk_endpoint_auth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/

# The API key is used only inside the base64 encoded Basic Auth string, so mask that as well.
VCR.configure do |c|
c.filter_sensitive_data('<IMPORT_FRESHDESK_ENDPOINT_BASIC_AUTH>') { Base64.encode64( "#{ENV['IMPORT_FRESHDESK_ENDPOINT_KEY']}:X" ).chomp }
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ee62e47

Please sign in to comment.