Class: Heroku::Kensa::DeprovisionCheck

Inherits:
ApiCheck show all
Includes:
HTTPForChecks
Defined in:
lib/heroku/kensa/check.rb

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods included from HTTPForChecks

#delete, #get, #post, #put, #request

Methods inherited from ApiCheck

#base_path, #callback, #create_provision_payload, #credentials, #heroku_id

Methods inherited from Check

#api_requires?, #call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url, #warning

Constructor Details

This class inherits a constructor from Heroku::Kensa::Check

Instance Method Details

#call!Object

Raises:

  • (ArgumentError)


429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/heroku/kensa/check.rb', line 429

def call!
  id = data[:id]
  raise ArgumentError, "No id specified" if id.nil?

  path = "#{base_path}/#{CGI::escape(id.to_s)}"

  test "DELETE #{path}"
  check "response" do
    code, _ = delete(credentials, path, nil)
    if code == 200
      true
    elsif code == -1
      error("unable to connect to #{url}")
    else
      error("expected 200, got #{code}")
    end
  end

  check "authentication" do
    wrong_credentials = ['wrong', 'secret']
    code, _ = delete(wrong_credentials, path, nil)
    error("expected 401, got #{code}") if code != 401
    true
  end

end