Class: Fog::OpenStack::KeyManager::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/openstack/key_manager.rb,
lib/fog/openstack/key_manager/requests/get_secret.rb,
lib/fog/openstack/key_manager/requests/list_secrets.rb,
lib/fog/openstack/key_manager/requests/create_secret.rb,
lib/fog/openstack/key_manager/requests/delete_secret.rb,
lib/fog/openstack/key_manager/requests/get_container.rb,
lib/fog/openstack/key_manager/requests/get_secret_acl.rb,
lib/fog/openstack/key_manager/requests/list_containers.rb,
lib/fog/openstack/key_manager/requests/create_container.rb,
lib/fog/openstack/key_manager/requests/delete_container.rb,
lib/fog/openstack/key_manager/requests/delete_secret_acl.rb,
lib/fog/openstack/key_manager/requests/get_container_acl.rb,
lib/fog/openstack/key_manager/requests/update_secret_acl.rb,
lib/fog/openstack/key_manager/requests/get_secret_payload.rb,
lib/fog/openstack/key_manager/requests/replace_secret_acl.rb,
lib/fog/openstack/key_manager/requests/get_secret_metadata.rb,
lib/fog/openstack/key_manager/requests/delete_container_acl.rb,
lib/fog/openstack/key_manager/requests/update_container_acl.rb,
lib/fog/openstack/key_manager/requests/replace_container_acl.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fog/openstack/key_manager.rb', line 57

def initialize(options = {})
  @openstack_username = options[:openstack_username]
  @openstack_tenant   = options[:openstack_tenant]
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])

  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86400).iso8601

  management_url = URI.parse(options[:openstack_auth_url])
  management_url.port = 9311
  management_url.path = '/v1'
  @openstack_management_url = management_url.to_s

  @data ||= {:users => {}}
  unless @data[:users].detect { |u| u['name'] == options[:openstack_username] }
    id = Fog::Mock.random_numbers(6).to_s
    @data[:users][id] = {
      'id'       => id,
      'name'     => options[:openstack_username],
      'email'    => "#{options[:openstack_username]}@mock.com",
      'tenantId' => Fog::Mock.random_numbers(6).to_s,
      'enabled'  => true
    }
  end
end

Instance Method Details

#credentialsObject



83
84
85
86
87
88
89
# File 'lib/fog/openstack/key_manager.rb', line 83

def credentials
  {:provider                 => 'openstack',
   :openstack_auth_url       => @openstack_auth_uri.to_s,
   :openstack_auth_token     => @auth_token,
   :openstack_region         => @openstack_region,
   :openstack_management_url => @openstack_management_url}
end

#delete_container_acl(_uuid) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/key_manager/requests/delete_container_acl.rb', line 15

def delete_container_acl(_uuid)
  response = Excon::Response.new
  response.status = 200
  response.body = "null"
  response
end

#delete_secret_acl(_uuid) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/key_manager/requests/delete_secret_acl.rb', line 15

def delete_secret_acl(_uuid)
  response = Excon::Response.new
  response.status = 200
  response.body = "null"
  response
end

#get_container_acl(_uuid) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/openstack/key_manager/requests/get_container_acl.rb', line 15

def get_container_acl(_uuid)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "read" => {
      "project-access" => true,
      "updated"        => "2017-04-25T19:10:52",
      "users"          => ["45895d3a393f42b2a8760f5dafa9c6d8"],
      "created"        => "2017-04-25T19:10:52"
    }
  }
  response
end

#get_secret_acl(_uuid) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/openstack/key_manager/requests/get_secret_acl.rb', line 15

def get_secret_acl(_uuid)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "read" => {
      "project-access" => false,
      "updated"        => "2017-04-25T19:10:52",
      "users"          => %w(45895d3a393f42b2a8760f5dafa9c6d8 dc2cb4f0d30044e2b0251409c94cc955),
      "created"        => "2017-04-25T19:10:52"
    }
  }
  response
end

#replace_container_acl(_uuid, _options) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/key_manager/requests/replace_container_acl.rb', line 16

def replace_container_acl(_uuid, _options)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "acl_ref" => "https://10.0.2.15:9311/v1/containers/4ab86cb0-a736-48df-ae97-b10d3e5bc60a/acl"
  }
  response
end

#replace_secret_acl(_uuid, _options) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/key_manager/requests/replace_secret_acl.rb', line 16

def replace_secret_acl(_uuid, _options)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "acl_ref" => "https://10.0.2.15:9311/v1/secrets/17ca49d9-0804-4ba7-b931-d34cabaa1f04/acl"
  }
  response
end

#update_container_acl(_uuid, _options) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/key_manager/requests/update_container_acl.rb', line 15

def update_container_acl(_uuid, _options)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "acl_ref" => "https://10.0.2.15:9311/v1/containers/4ab86cb0-a736-48df-ae97-b10d3e5bc60a/acl"
  }
  response
end

#update_secret_acl(_uuid, _options) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/key_manager/requests/update_secret_acl.rb', line 15

def update_secret_acl(_uuid, _options)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "acl_ref" => "https://10.0.2.15:9311/v1/secrets/17ca49d9-0804-4ba7-b931-d34cabaa1f04/acl"
  }
  response
end