class Fog::OpenStack::KeyManager::Mock

Public Class Methods

new(options = {}) click to toggle source
# 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

Public Instance Methods

credentials() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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