mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
* Define missing InvalidLogin exception
* Add login tests
This commit is contained in:
parent
d480b3e3c6
commit
ae6e59849f
2 changed files with 39 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
||||||
module Fog
|
module Fog
|
||||||
module XenServer
|
module XenServer
|
||||||
|
|
||||||
|
class InvalidLogin < Fog::Errors::Error; end
|
||||||
|
|
||||||
extend Fog::Provider
|
extend Fog::Provider
|
||||||
|
|
||||||
service(:compute, 'xenserver/compute', 'Compute')
|
service(:compute, 'xenserver/compute', 'Compute')
|
||||||
|
@ -13,10 +16,8 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate( username, password )
|
def authenticate( username, password )
|
||||||
begin
|
response = @factory.call('session.login_with_password', username, password )
|
||||||
response = @factory.call('session.login_with_password', username, password )
|
raise Fog::XenServer::InvalidLogin.new unless response["Status"] =~ /Success/
|
||||||
raise Fog::XenServer::InvalidLogin unless response["Status"] =~ /Success/
|
|
||||||
end
|
|
||||||
@credentials = response["Value"]
|
@credentials = response["Value"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
34
tests/xenserver/xenserver_tests.rb
Normal file
34
tests/xenserver/xenserver_tests.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
Shindo.tests('Fog::Compute[:xenserver]', ['xenserver']) do
|
||||||
|
|
||||||
|
tests("Login") do
|
||||||
|
raises(Fog::XenServer::InvalidLogin, 'raises error when invalid password') do
|
||||||
|
conn = Fog::Compute.new({
|
||||||
|
:provider => 'XenServer',
|
||||||
|
:xenserver_url => 'xenserver-test',
|
||||||
|
:xenserver_username => 'root',
|
||||||
|
:xenserver_password => 'asdfsadf'
|
||||||
|
|
||||||
|
})
|
||||||
|
end
|
||||||
|
raises(Fog::XenServer::InvalidLogin, 'raises error when invalid user') do
|
||||||
|
conn = Fog::Compute.new({
|
||||||
|
:provider => 'XenServer',
|
||||||
|
:xenserver_url => 'xenserver-test',
|
||||||
|
:xenserver_username => 'rootffff',
|
||||||
|
:xenserver_password => 'changeme'
|
||||||
|
|
||||||
|
})
|
||||||
|
end
|
||||||
|
raises(SocketError, 'raises error when invalid host') do
|
||||||
|
conn = Fog::Compute.new({
|
||||||
|
:provider => 'XenServer',
|
||||||
|
:xenserver_url => 'xenserver-testlakjsdflkj',
|
||||||
|
:xenserver_username => 'root',
|
||||||
|
:xenserver_password => 'changeme'
|
||||||
|
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue