Class: Fog::OpenStack::Introspection::Mock

Inherits:
Object
  • Object
show all
Includes:
Core
Defined in:
lib/fog/openstack/introspection.rb,
lib/fog/openstack/introspection/requests/get_rules.rb,
lib/fog/openstack/introspection/requests/list_rules.rb,
lib/fog/openstack/introspection/requests/create_rules.rb,
lib/fog/openstack/introspection/requests/delete_rules.rb,
lib/fog/openstack/introspection/requests/delete_rules_all.rb,
lib/fog/openstack/introspection/requests/get_introspection.rb,
lib/fog/openstack/introspection/requests/abort_introspection.rb,
lib/fog/openstack/introspection/requests/create_introspection.rb,
lib/fog/openstack/introspection/requests/get_introspection_details.rb

Instance Attribute Summary

Attributes included from Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_api_version, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Core

#credentials, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



58
59
60
61
# File 'lib/fog/openstack/introspection.rb', line 58

def initialize(options = {})
  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86_400).iso8601
end

Class Method Details

.dataObject



44
45
46
47
48
49
50
# File 'lib/fog/openstack/introspection.rb', line 44

def self.data
  @data ||= Hash.new do |hash, key|
    # Introspection data is *huge* we load it from a yaml file
    file = "test/fixtures/introspection.yaml"
    hash[key] = YAML.load(File.read(file))
  end
end

.resetObject



52
53
54
# File 'lib/fog/openstack/introspection.rb', line 52

def self.reset
  @data = nil
end

Instance Method Details

#abort_introspection(_node_id) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/openstack/introspection/requests/abort_introspection.rb', line 16

def abort_introspection(_node_id)
  response = Excon::Response.new
  response.status = 202
  response.body = ""
  response
end

#create_introspection(_node_id, _options = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/fog/openstack/introspection/requests/create_introspection.rb', line 26

def create_introspection(_node_id, _options = {})
  response = Excon::Response.new
  response.status = 202
  response.body = ""
  response
end

#create_rules(_) ⇒ Object



28
29
30
31
32
33
# File 'lib/fog/openstack/introspection/requests/create_rules.rb', line 28

def create_rules(_)
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#dataObject



63
64
65
# File 'lib/fog/openstack/introspection.rb', line 63

def data
  self.class.data[@openstack_username]
end

#delete_rules(_rule_id) ⇒ Object



15
16
17
18
19
# File 'lib/fog/openstack/introspection/requests/delete_rules.rb', line 15

def delete_rules(_rule_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_rules_allObject



15
16
17
18
19
# File 'lib/fog/openstack/introspection/requests/delete_rules_all.rb', line 15

def delete_rules_all
  response = Excon::Response.new
  response.status = 204
  response
end

#get_introspection(_node_id) ⇒ Object



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

def get_introspection(_node_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"error" => "null", "finished" => "true"}
  response
end

#get_introspection_details(_node_id) ⇒ Object



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

def get_introspection_details(_node_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"data" => data[:introspection_data]}
  response
end

#get_rules(_rule_id) ⇒ Object



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

def get_rules(_rule_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#list_rulesObject



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

def list_rules
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#reset_dataObject



67
68
69
# File 'lib/fog/openstack/introspection.rb', line 67

def reset_data
  self.class.data.delete(@openstack_username)
end