Commit 39302c58 authored by Balasankar "Balu" C's avatar Balasankar "Balu" C

Update code and tests to match aws_sigv4 faraday middleware

Signed-off-by: default avatarBalasankar "Balu" C <balasankarc@autistici.org>
parent 32f12e69
# frozen_string_literal: true
require 'faraday_middleware/aws_sigv4'
module Gitlab
module Elastic
module Client
......@@ -17,7 +19,7 @@ module Gitlab
region = config[:aws_region]
::Elasticsearch::Client.new(base_config) do |fmid|
fmid.request(:aws_signers_v4, credentials: creds, service_name: 'es', region: region)
fmid.request(:aws_sigv4, credentials: creds, service: 'es', region: region)
end
else
::Elasticsearch::Client.new(base_config)
......
......@@ -28,6 +28,8 @@ describe Gitlab::Elastic::Client do
.to_return(status: 200, body: "RoleName", headers: {})
stub_request(:get, "http://169.254.169.254/latest/meta-data/iam/security-credentials/RoleName")
.to_return(status: 200, body: creds_response, headers: {})
stub_request(:put, "http://169.254.169.254/latest/api/token")
.to_return(status: 200, body: "", headers: {})
end
describe '.build' do
......@@ -62,8 +64,13 @@ describe Gitlab::Elastic::Client do
stub_request(:get, 'http://example-elastic:9200/foo/_all/1')
.with(
headers: {
'Authorization' => 'AWS4-HMAC-SHA256 Credential=0/20170303/us-east-1/es/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=4ba2aae19a476152dacf5a2191da67b0cf81b9d7152dab5c42b1bba701da19f1',
'Accept' => '*/*',
'Accept-Encoding' => 'gzip,deflate',
'Authorization' => 'AWS4-HMAC-SHA256 Credential=0/20170303/us-east-1/es/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date, Signature=e52132ac542972698e99d9a8337b7493e4ca6210f61fc8da5cbb8008d8b2fb87',
'Content-Type' => 'application/json',
'Date' => 'Fri, 03 Mar 2017 13:39:52 GMT',
'Host' => 'example-elastic:9200',
'User-Agent' => 'Faraday v0.15.4',
'X-Amz-Content-Sha256' => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
'X-Amz-Date' => '20170303T133952Z'
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment