Sha256: 7f53d2c4bf51738e19b9a5eb97379f44c181cc0b0d8a75ff09d6a514b2cdc561

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path("../spec_helper", __dir__)
require "search_flip/aws_sigv4_plugin"

RSpec.describe SearchFlip::AwsSigv4Plugin do
  describe "#call" do
    subject(:plugin) do
      SearchFlip::AwsSigv4Plugin.new(
        region: "us-east-1",
        access_key_id: "access key",
        secret_access_key: "secret access key"
      )
    end

    let(:client) { SearchFlip::HTTPClient.new }

    it "adds the signed headers to the request" do
      Timecop.freeze Time.parse("2020-01-01 12:00:00 UTC") do
        expect(client).to receive(:headers).with(
          "host" => "localhost",
          "authorization" => /.*/,
          "x-amz-content-sha256" => /.*/,
          "x-amz-date" => /20200101T120000Z/
        )

        plugin.call(client, :get, "http://localhost/index")
      end
    end

    it "feeds the http method, full url and body to the signer" do
      signing_request = {
        http_method: "GET",
        url: "http://localhost/index?param=value",
        body: JSON.generate(key: "value")
      }

      expect(plugin.signer).to receive(:sign_request).with(signing_request).and_call_original

      plugin.call(client, :get, "http://localhost/index", params: { param: "value" }, json: { key: "value" })
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
search_flip-3.5.0 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta9 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta8 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.4.0 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.3.0 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta7 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta6 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta5 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta4 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.2.1 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.2.0 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta3 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta2 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta1 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-4.0.0.beta spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.1.2 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.1.1 spec/search_flip/aws_sigv4_plugin_spec.rb
search_flip-3.1.0 spec/search_flip/aws_sigv4_plugin_spec.rb