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