Skip to content

Commit

Permalink
[wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Jun 27, 2022
1 parent f7852ee commit 9ce2521
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions spec/lib/ldp/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ce2521

Please sign in to comment.