Sha256: 0eea7ba5195b711615db43604ddd2c645c12ce3d08176abf6646eedf06d21fbb

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

Shindo.tests("Fog::Identity[:openstack] | users", ['openstack']) do
  openstack = Fog::Identity::OpenStack.new(:openstack_auth_url => 'http://openstack:35357/v2.0/tokens')
  tenant_id = openstack.list_tenants.body['tenants'].first['id']
  @instance = openstack.users.create(
    :name      => 'foobar',
    :email     => 'foo@bar.com',
    :tenant_id => tenant_id,
    :password  => 'spoof',
    :enabled   => true
  )

  tests('success') do
    tests('#find_by_id').succeeds do
      openstack = Fog::Identity::OpenStack.new(:openstack_auth_url => 'http://openstack:35357/v2.0/tokens')
      user = openstack.users.find_by_id(@instance.id)
      user.id == @instance.id
    end

    tests('#find_by_name').succeeds do
      openstack = Fog::Identity::OpenStack.new(:openstack_auth_url => 'http://openstack:35357/v2.0/tokens')
      user = openstack.users.find_by_name(@instance.name)
      user.name == @instance.name
    end

    tests('#destroy').succeeds do
      openstack = Fog::Identity::OpenStack.new(:openstack_auth_url => 'http://openstack:35357/v2.0/tokens')
      openstack.users.destroy(@instance.id)
    end
  end

  tests('fails') do
    pending if Fog.mocking?

    tests('#find_by_id').raises(Fog::Identity::OpenStack::NotFound) do
      Fog::Identity[:openstack].users.find_by_id('fake')
    end

    tests('#find_by_name').raises(Fog::Identity::OpenStack::NotFound) do
      Fog::Identity[:openstack].users.find_by_name('fake')
    end

    tests('#destroy').raises(Fog::Identity::OpenStack::NotFound) do
      Fog::Identity[:openstack].users.destroy('fake')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-openstack-0.1.6 tests/openstack/models/identity/users_tests.rb