2013-03-27 10:53:16 -04:00
|
|
|
require 'date'
|
|
|
|
|
2013-03-27 14:44:08 -04:00
|
|
|
Shindo.tests('Fog::HP::BlockStorage', ['hp', 'blockstorage']) do
|
2013-03-27 10:53:16 -04:00
|
|
|
credentials = {
|
|
|
|
:auth_token => 'auth_token',
|
2013-03-28 13:57:00 -04:00
|
|
|
:endpoint_url => 'http://127.0.0.1/bpath/',
|
2013-03-28 15:40:20 -04:00
|
|
|
:service_catalog => {
|
2013-03-28 13:57:00 -04:00
|
|
|
:"Block Storage" => {
|
|
|
|
:zone => 'http://127.0.0.1/bpath/'}},
|
2013-03-27 10:53:16 -04:00
|
|
|
:expires => (DateTime.now + 1).to_s
|
|
|
|
}
|
|
|
|
options = {
|
2013-03-28 13:57:00 -04:00
|
|
|
:hp_access_key => 'key',
|
|
|
|
:hp_secret_key => 'secret',
|
|
|
|
:hp_tenant_id => 'tenant',
|
|
|
|
:hp_avl_zone => 'zone',
|
|
|
|
:hp_auth_uri => 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens',
|
2013-03-27 10:53:16 -04:00
|
|
|
:credentials => credentials
|
|
|
|
}
|
|
|
|
tests('Test good credentials').returns(credentials) do
|
|
|
|
conn = Fog::HP::BlockStorage::Real.new(options)
|
|
|
|
conn.credentials
|
|
|
|
end
|
|
|
|
tests('Test expired credentials') do
|
|
|
|
credentials[:expires] = (DateTime.now - 1).to_s
|
2013-03-28 13:57:00 -04:00
|
|
|
raises(Excon::Errors::Unauthorized) { Fog::HP::BlockStorage::Real.new(options) }
|
2013-03-27 10:53:16 -04:00
|
|
|
end
|
|
|
|
tests('Test no expires') do
|
|
|
|
credentials[:expires] = nil
|
2013-03-28 13:57:00 -04:00
|
|
|
raises(Excon::Errors::Unauthorized) { Fog::HP::BlockStorage::Real.new(options) }
|
2013-03-27 10:53:16 -04:00
|
|
|
end
|
2013-03-27 14:44:08 -04:00
|
|
|
tests('Test no creds') do
|
|
|
|
options[:credentials] = nil
|
2013-03-28 13:57:00 -04:00
|
|
|
raises(Excon::Errors::Unauthorized) { Fog::HP::BlockStorage::Real.new(options) }
|
|
|
|
end
|
|
|
|
tests('Test no service') do
|
|
|
|
options[:credentials] = credentials
|
2013-03-28 15:40:20 -04:00
|
|
|
options[:credentials][:service_catalog] = {
|
2013-03-28 13:57:00 -04:00
|
|
|
:"CDN" => {
|
|
|
|
:zone => 'http://127.0.0.1/bpath/'}},
|
|
|
|
raises(Excon::Errors::Unauthorized) { Fog::HP::BlockStorage::Real.new(options) }
|
|
|
|
end
|
|
|
|
tests('Test no creds') do
|
2013-03-28 15:40:20 -04:00
|
|
|
options[:credentials][:service_catalog] = nil
|
2013-03-28 13:57:00 -04:00
|
|
|
raises(Excon::Errors::Unauthorized) { Fog::HP::BlockStorage::Real.new(options) }
|
2013-03-27 14:44:08 -04:00
|
|
|
end
|
2013-03-27 10:53:16 -04:00
|
|
|
end
|