diff --git a/spec/lib/ldp/client_spec.rb b/spec/lib/ldp/client_spec.rb index 17348f4..cac27d4 100644 --- a/spec/lib/ldp/client_spec.rb +++ b/spec/lib/ldp/client_spec.rb @@ -202,13 +202,13 @@ ).to_return(status: 200, body: "", headers: {}) ldp_client.initialize_http_client do |conn| - conn.request :authorization, :basic, 'Aladdin', 'open sesame' + conn.request :authorization, :basic, 'Kevin Mitnick', 'hack the planet' end ldp_client.post "http://localhost/a_container", 'foo' expect(a_request(:post, "http://localhost/a_container").with(body: "foo", headers: { - 'Authorization'=>'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==', + 'Authorization'=>'Basic S2V2aW4gTWl0bmljazpoYWNrIHRoZSBwbGFuZXQ=', 'Content-Type'=>'text/turtle', })).to have_been_made.once end @@ -258,31 +258,41 @@ end it "should preserve basic auth headers" do - #subject.http.basic_auth('Aladdin', 'open sesame') - http do |conn| - conn.request :authorization, :basic, 'Aladdin', 'open sesame' - end + stub_request(:put, "http://localhost/a_resource").with( + body: "some-payload", + ).to_return(status: 200, body: "", headers: {}) - subject.put "a_resource", "some-payload" do |req| - expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" }) + ldp_client.initialize_http_client do |conn| + conn.request :authorization, :basic, 'Kevin Mitnick', 'hack the planet' end + + ldp_client.put "http://localhost/a_resource", "some-payload" + + expect(a_request(:put, "http://localhost/a_resource").with(body: "some-payload", headers: { + 'Authorization'=>'Basic S2V2aW4gTWl0bmljazpoYWNrIHRoZSBwbGFuZXQ=', + 'Content-Type'=>'text/turtle', + })).to have_been_made.once end end describe 'patch' do - it "should preserve basic auth headers" do - #subject.http.basic_auth('Aladdin', 'open sesame') - http do |conn| - conn.request :authorization, :basic, 'Aladdin', 'open sesame' - end + stub_request(:patch, "http://localhost/a_container").with( + body: "foo", + ).to_return(status: 200, body: "", headers: {}) - subject.patch "a_container", 'foo' do |req| - expect(req.headers).to include({ "Authorization" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" }) + ldp_client.initialize_http_client do |conn| + conn.request :authorization, :basic, 'Kevin Mitnick', 'hack the planet' end - end + ldp_client.patch "http://localhost/a_container", "foo" + + expect(a_request(:patch, "http://localhost/a_container").with(body: "foo", headers: { + 'Authorization'=>'Basic S2V2aW4gTWl0bmljazpoYWNrIHRoZSBwbGFuZXQ=', + 'Content-Type'=>'application/sparql-update', + })).to have_been_made.once + end end describe "find_or_initialize" do