Sha256: cde692094fe52483a952b43545f792cf3dcbb81566082148593a8cd996f632cc

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestAuth < Test::Unit::TestCase

  include Instapaper::Exceptions
  include Instapaper::Response

  def setup
    @instapaper_a = Instapaper::Base.new("instapaper-rubygem","instapaper-rubygem")
    @instapaper_b = Instapaper::Base.new("instapaper-rubygem")
    @instapaper_c = Instapaper::Base.new("UnknownUserNameThatHopefullyDoesNotExist")
  end
  
  def test_secure_authenticate_valid
    res = @instapaper_a.authenticate
    
    assert_instance_of(AuthenticationSuccessResponse, res)
    assert_equal(200,res.code)
  end
  
  def test_clear_authenticate_valid
    @instapaper_a.use_clear_protocol!
    
    res = @instapaper_a.authenticate
    
    assert_instance_of(AuthenticationSuccessResponse, res)
    assert_equal(200,res.code)
  end
  
  def test_secure_authenticate_invalid_password
    res = @instapaper_b.authenticate
    
    assert_instance_of(AuthenticationInvalidResponse, res)
    assert_equal(403,res.code)
  end
  
  def test_clear_authenticate_invalid_password
    @instapaper_b.use_clear_protocol!
    
    res = @instapaper_b.authenticate
    
    assert_instance_of(AuthenticationInvalidResponse, res)
    assert_equal(403,res.code)
  end
  
  def test_secure_authenticate_invalid_username
    res = @instapaper_c.authenticate
    
    assert_instance_of(AuthenticationInvalidResponse, res)
    assert_equal(403,res.code)
  end
  
  def test_clear_authenticate_invalid_username
    @instapaper_c.use_clear_protocol!
    
    res = @instapaper_c.authenticate
    
    assert_instance_of(AuthenticationInvalidResponse, res)
    assert_equal(403,res.code)
  end
   
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
instapaper-0.1.0 test/test_auth.rb