Sha256: 6147bcac9fc2e83792bb195f8758a84cc9ce30e0c9885aebbfd8877e2b95f757

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

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

class CloudfilesAuthenticationTest < Test::Unit::TestCase
  

  def test_good_authentication
    response = {'x-cdn-management-url' => 'http://cdn.example.com/path', 'x-storage-url' => 'http://cdn.example.com/storage', 'authtoken' => 'dummy_token'}
    response.stubs(:code).returns('204')
    server = mock(:use_ssl= => true, :verify_mode= => true, :start => true, :finish => true)
    server.stubs(:get).returns(response)
    Net::HTTP.stubs(:new).returns(server)
    @connection = stub(:authuser => 'dummy_user', :authkey => 'dummy_key', :cdnmgmthost= => true, :cdnmgmtpath= => true, :storagehost= => true, :storagepath= => true, :authtoken= => true, :authok= => true)
    result = CloudFiles::Authentication.new(@connection)
    assert_equal result.class, CloudFiles::Authentication
  end
  
  def test_bad_authentication
    response = mock()
    response.stubs(:code).returns('499')
    server = mock(:use_ssl= => true, :verify_mode= => true, :start => true)
    server.stubs(:get).returns(response)
    Net::HTTP.stubs(:new).returns(server)
    @connection = stub(:authuser => 'bad_user', :authkey => 'bad_key', :authok= => true, :authtoken= => true)
    assert_raises(AuthenticationException) do
      result = CloudFiles::Authentication.new(@connection)
    end
  end
    
  def test_bad_hostname
    Net::HTTP.stubs(:new).raises(ConnectionException)
    @connection = stub(:authuser => 'bad_user', :authkey => 'bad_key', :authok= => true, :authtoken= => true)
    assert_raises(ConnectionException) do
      result = CloudFiles::Authentication.new(@connection)
    end
  end
    
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
briancollins-cloudfiles-1.3.0.1 test/cloudfiles_authentication_test.rb
jmstacey-ruby-cloudfiles-1.3.2 test/cloudfiles_authentication_test.rb
jmstacey-ruby-cloudfiles-1.3.3 test/cloudfiles_authentication_test.rb
rackspace-cloudfiles-1.3.0.2 test/cloudfiles_authentication_test.rb
rackspace-cloudfiles-1.3.0.3 test/cloudfiles_authentication_test.rb
rackspace-cloudfiles-1.3.0.5 test/cloudfiles_authentication_test.rb
rackspace-cloudfiles-1.3.0.6 test/cloudfiles_authentication_test.rb
rackspace-cloudfiles-1.3.0.7 test/cloudfiles_authentication_test.rb
tikhon-cloudfiles-1.3.0 test/cloudfiles_authentication_test.rb