feat: send x-goog-user-project header
This commit is contained in:
parent
90be148aa9
commit
6938a0de02
|
@ -53,6 +53,10 @@ module Google
|
|||
# @return [void]
|
||||
def prepare!
|
||||
set_xgac
|
||||
if options&.authorization.respond_to? :quota_project_id
|
||||
quota_project_id = options.authorization.quota_project_id
|
||||
header['X-Goog-User-Project'] = quota_project_id if quota_project_id
|
||||
end
|
||||
if options && options.api_format_version
|
||||
header['X-Goog-Api-Format-Version'] = options.api_format_version.to_s
|
||||
end
|
||||
|
|
|
@ -65,6 +65,17 @@ RSpec.describe Google::Apis::Core::ApiCommand do
|
|||
expect(command.header['X-Goog-Api-Client']).to eql "foo/1.2.3 bar/4.5.6 #{x_goog_api_client_value}"
|
||||
expect(command.header['x-goog-api-client']).to be nil
|
||||
end
|
||||
|
||||
it 'should not set the X-Goog-User-Project header if there is no quota_project' do
|
||||
command.prepare!
|
||||
expect(command.header['X-Goog-User-Project']).to be_nil
|
||||
end
|
||||
|
||||
it 'should set the X-Goog-User-Project to a given quota_project' do
|
||||
command.options.authorization = OpenStruct.new quota_project_id: "b_project_id"
|
||||
command.prepare!
|
||||
expect(command.header['X-Goog-User-Project']).to eql "b_project_id"
|
||||
end
|
||||
end
|
||||
|
||||
context('with a request body') do
|
||||
|
|
|
@ -43,6 +43,7 @@ require 'webmock/rspec'
|
|||
require 'fakefs/spec_helpers'
|
||||
require 'json_spec'
|
||||
require 'logging'
|
||||
require 'ostruct'
|
||||
require 'rspec/logging_helper'
|
||||
require 'google/apis'
|
||||
require 'google/apis/core/base_service'
|
||||
|
|
Loading…
Reference in New Issue