Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Move vcr config, require relative to load from inspec profile #39

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# ----------------------------------------------------------------------------

require 'vcr_config'
require_relative '../vcr_config'

title 'Test GCP google_compute_ssl_policies resource.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# ----------------------------------------------------------------------------

require 'vcr_config'
require_relative '../vcr_config'

title 'Test GCP google_compute_ssl_policy resource.'

Expand Down
34 changes: 34 additions & 0 deletions test/integration/verify-mm/vcr_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'vcr'

VCR.configure do |c|
c.hook_into :webmock
c.cassette_library_dir = 'inspec-cassettes'
c.allow_http_connections_when_no_cassette = true

c.before_record do |i|
i.response.headers.delete_if { |key| key != 'Content-Type' }
i.request.headers.delete_if { |key| true }
if auth_call?(i)
i.request.body = 'AUTH REQUEST'
i.response.body = "{\n \"access_token\": \"ya29.c.samsamsamsamsamsamsamsamsa-thisisnintysixcharactersoftexttolooklikeanauthtokenthisisnintysixcharactersoftexttolooklikeanaut\",\n \"expires_in\": 3600,\n \"token_type\": \"Bearer\"\n}"
end
end
end

def auth_call?(interaction)
# Auth calls require extra scrubbing, this method is very broad, this is intentional
interaction.request.uri.include? 'oauth2'
end