Commit 2b1001e
Changed files (3)
lib
net
hippie
test
fixtures
net
lib/net/hippie/client.rb
@@ -52,6 +52,11 @@ module Net
execute(uri, request, &block)
end
+ def delete(uri, headers: {}, body: {}, &block)
+ request = request_for(Net::HTTP::Delete, uri, headers: headers, body: body)
+ execute(uri, request, &block)
+ end
+
private
attr_reader :default_headers
test/fixtures/delete_breaches.yml
@@ -0,0 +1,24 @@
+---
+http_interactions:
+- request:
+ method: delete
+ uri: https://haveibeenpwned.com/api/breaches
+ body:
+ encoding: UTF-8
+ string: ""
+ headers:
+ Accept:
+ - application/vnd.haveibeenpwned.v2+json
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Content-Type:
+ - application/json; charset=utf-8
+ body:
+ encoding: UTF-8
+ string: '{"Message":"Congratulations!"}'
+ http_version:
+ recorded_at: Mon, 07 May 2018 20:21:13 GMT
+recorded_with: VCR 4.0.0
test/net/client_test.rb
@@ -104,6 +104,15 @@ class ClientTest < Minitest::Test
end
end
+ def test_delete
+ uri = URI.parse('https://haveibeenpwned.com/api/breaches')
+ VCR.use_cassette('delete_breaches') do
+ response = subject.delete(uri)
+ refute_nil response
+ assert_equal 'Congratulations!', JSON.parse(response.body)['Message']
+ end
+ end
+
def test_client_tls
private_key = OpenSSL::PKey::RSA.new(2048)
certificate = OpenSSL::X509::Certificate.new