diff --git a/lib/lumberg/cpanel/ssl.rb b/lib/lumberg/cpanel/ssl.rb index 2da9b17c..fdf81f6f 100644 --- a/lib/lumberg/cpanel/ssl.rb +++ b/lib/lumberg/cpanel/ssl.rb @@ -201,6 +201,20 @@ def uploadcrt(options = {}) api_function: "uploadcrt", }.merge(options)) end + + # Public: Removes a domain's SSL certificate. This function requires + # access to the 'sslinstall' feature + # + # options - Hash options for API call params (default: {}) + # domain: String domain corresponding to the SSL certificate + # to remove + # + # Returns Hash API response + def remove(options = {}) + perform_request({ + api_version: 1, api_function: "delete", response_key: "data" + }.merge(options)) + end end end end diff --git a/spec/cpanel/ssl_spec.rb b/spec/cpanel/ssl_spec.rb index a6544a34..feafdad8 100644 --- a/spec/cpanel/ssl_spec.rb +++ b/spec/cpanel/ssl_spec.rb @@ -144,5 +144,15 @@ module Lumberg host: domain)[:params][:data][0][:result].should eq(1) end end + + describe "#remove" do + use_vcr_cassette "cpanel/ssl/remove" + + subject { ssl.remove(domain: domain)[:params][:result] } + + it "removes a certificate " do + subject.should include "The SSL host was successfully removed." + end + end end end diff --git a/spec/vcr_cassettes/cpanel/ssl/remove.yml b/spec/vcr_cassettes/cpanel/ssl/remove.yml new file mode 100644 index 00000000..c6042910 --- /dev/null +++ b/spec/vcr_cassettes/cpanel/ssl/remove.yml @@ -0,0 +1,43 @@ +--- +http_interactions: +- request: + method: get + uri: https://myhost.com:2087/json-api/cpanel?cpanel_jsonapi_apiversion=1&cpanel_jsonapi_func=delete&cpanel_jsonapi_module=SSL&cpanel_jsonapi_user=lumberg&domain=lumberg-test.com + body: + encoding: US-ASCII + string: '' + headers: + Authorization: + - WHM root:iscool + User-Agent: + - Faraday v0.8.8 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - '*/*' + response: + status: + code: 200 + message: OK + headers: + Server: + - cpsrvd/11.40.0.19 + X-Keep-Alive-Count: + - '1' + Connection: + - Keep-Alive + Keep-Alive: + - timeout=70, max=200 + Date: + - Fri, 08 Nov 2013 16:27:02 GMT + Content-Type: + - text/plain; charset="utf-8" + Content-Length: + - '148' + body: + encoding: UTF-8 + string: '{"apiversion":"1","type":"event","module":"SSL","func":"delete","source":"module","data":{"result":" +
The SSL host was successfully removed.\n"},"event":{"result":1}}' + http_version: + recorded_at: Fri, 08 Nov 2013 16:27:03 GMT +recorded_with: VCR 2.5.0