spec/lib/connection_spec.rb in flexirest-1.10.12 vs spec/lib/connection_spec.rb in flexirest-1.11.0
- old
+ new
@@ -173,16 +173,27 @@
result = @connection.get("/foo", @options)
auth_header = result.env.request_headers['Authorization']
expect(auth_header == "APIAuth id123:TQiQIW6vVaDC5jvh99uTNkxIg6Q=" || auth_header == "APIAuth id123:PMWBThkB8vKbvUccHvoqu9G3eVk=").to be_truthy
end
- it 'should have an Content-MD5 header' do
- stub_request(:put, "www.example.com/foo").
- with(body: "body", :headers => @default_headers).
- to_return(body: "{result:true}")
+ if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s < "2.5.0"
+ it 'should have an Content-MD5 header' do
+ stub_request(:put, "www.example.com/foo").
+ with(body: "body", :headers => @default_headers).
+ to_return(body: "{result:true}")
- result = @connection.put("/foo", "body", @options)
- expect(result.env.request_headers['Content-MD5']).to eq("hBotaJrYa9FhFEdFPCLG/A==")
+ result = @connection.put("/foo", "body", @options)
+ expect(result.env.request_headers['Content-MD5']).to eq("hBotaJrYa9FhFEdFPCLG/A==")
+ end
+ else
+ it 'should have an X-AUTHORIZATION-CONTENT-SHA256 header' do
+ stub_request(:put, "www.example.com/foo").
+ with(body: "body", :headers => @default_headers).
+ to_return(body: "{result:true}")
+
+ result = @connection.put("/foo", "body", @options)
+ expect(result.env.request_headers['X-AUTHORIZATION-CONTENT-SHA256']).to eq("Iw2DWNyOiJC0xY3utikS7i8gNXrpKlzIYbmOaP4xrLU=")
+ end
end
end
it "should retry once in the event of a connection failed" do
stub_request(:get, "www.example.com/foo").to_raise(Faraday::ConnectionFailed.new("Foo"))