File: user_tests.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (53 lines) | stat: -rw-r--r-- 1,543 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require "test_helper"

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

describe "Fog::Identity[:openstack] | user requests" do
  before do
    @identity = Fog::OpenStack::Identity.new(:openstack_identity_api_version => 'v2.0')

    @user_format = {
      'id'       => String,
      'name'     => String,
      'enabled'  => Fog::Boolean,
      'email'    => String,
      'tenantId' => Fog::Nullable::String
    }

    @user_name = Fog::Mock.random_hex(64)
    @user_name_update = Fog::Mock.random_hex(64)

    @user = @identity.create_user(
      @user_name, "mypassword", "morph@example.com",
      OpenStack::Identity.get_tenant_id(@identity)
    ).body['user']
  end

  describe "success" do
    it "#create_user(#{@user_name}, 'mypassword', 'morph@example.com', 't3n4nt1d', true)" do
      @user.must_match_schema(@user_format, nil, :allow_optional_rules => false)
    end

    it "#list_users" do
      @identity.list_users.body["users"][0].must_match_schema(@user_format)
    end

    it "#get_user_by_id" do
      @identity.get_user_by_id(@user['id']).body['user'].must_match_schema(@user_format)
    end

    it "#get_user_by_name" do
      @identity.get_user_by_name(@user['name']).body['user'].must_match_schema(@user_format)
    end

    it "#update_user" do
      @identity.update_user(
        @user['id'], :name => @user_name_update, :email => 'fog@test.com'
      ).status.must_equal 200
    end

    it "#delete_user" do
      @identity.delete_user(@user['id']).status.must_equal 204
    end
  end
end