Class: Heroku::Samorau::SsoCheck

Inherits:
ApiCheck show all
Includes:
HTTP
Defined in:
lib/heroku/samorau.rb

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods included from HTTP

#delete, #get, #post, #request

Methods inherited from ApiCheck

#credentials, #url

Methods inherited from Check

#call, #check, #error, #initialize, #run, #test, #to_proc

Constructor Details

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

Instance Method Details

#call!Object



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/heroku/samorau.rb', line 485

def call!
  sso = Sso.new(data)
  t   = Time.now.to_i

  test "GET #{sso.path}"
  check "validates token" do
    code, _ = get(sso.path, { :token => 'invalid', :timestamp => t })
    error("expected 403, got #{code}") if code != 403
    true
  end

  check "validates timestamp" do
    prev = (Time.now - 60*6).to_i
    code, _ = get(sso.path, { :token => sso.make_token(prev), :timestamp => prev })
    error("expected 403, got #{code}") if code != 403
    true
  end

  check "logs in" do
    code, _ = get(sso.path, { :token => sso.make_token(t), :timestamp => t })
    error("expected 200, got #{code}") if code != 200
    true
  end
end