1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
require File.dirname(__FILE__) + '/../test_helper'
class ComputeConnectionTest < Test::Unit::TestCase
def setup
connection = stub()
OpenStack::Authentication.stubs(:init).returns(connection)
end
def test_init_connection_no_credentials
assert_raises(OpenStack::Exception::MissingArgument) do
conn = OpenStack::Connection.create(:api_key => "AABBCCDD11", :auth_url => "a.b.c")
end
end
def test_init_connection_no_password
assert_raises(OpenStack::Exception::MissingArgument) do
conn = OpenStack::Connection.create(:username => "test_account", :auth_url => "a.b.c")
end
end
def test_init_connection_no_auth_url
assert_raises(OpenStack::Exception::MissingArgument) do
conn = OpenStack::Connection.create(:username => "test_account", :api_key => "AABBCCDD11")
end
end
def test_init_connection_bad_auth_url
assert_raises(OpenStack::Exception::InvalidArgument) do
conn = OpenStack::Connection.create(:username => "test_account", :api_key => "AABBCCDD11", :auth_url => "***")
end
end
def test_init_connection
conn = OpenStack::Connection.create(:username => "test_account", :api_key => "AABBCCDD11", :auth_url => "https://a.b.c")
assert_not_nil conn, "Connection.new returned nil."
end
end
|