diff options
| -rw-r--r-- | lib/net/hippie/client.rb | 5 | ||||
| -rw-r--r-- | test/fixtures/delete_breaches.yml | 24 | ||||
| -rw-r--r-- | test/net/client_test.rb | 9 |
3 files changed, 38 insertions, 0 deletions
diff --git a/lib/net/hippie/client.rb b/lib/net/hippie/client.rb index 0042e92..da79973 100644 --- a/lib/net/hippie/client.rb +++ b/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 diff --git a/test/fixtures/delete_breaches.yml b/test/fixtures/delete_breaches.yml new file mode 100644 index 0000000..cc1cef3 --- /dev/null +++ b/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 diff --git a/test/net/client_test.rb b/test/net/client_test.rb index db50f5d..499f54c 100644 --- a/test/net/client_test.rb +++ b/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 |
