Class: Fog::Compute::DigitalOceanV2::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/fog/compute/digital_ocean_v2.rb

Overview

These mocking improvements are not yet in fog master: github.com/fog/fog/pull/3748

Instance Method Summary collapse

Instance Method Details

#create_ssh_key(name, public_key) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ext/fog/compute/digital_ocean_v2.rb', line 39

def create_ssh_key(name, public_key)
  response        = Excon::Response.new
  response.status = 201

  data[:ssh_keys] << {
    "id" => Fog::Mock.random_numbers(6).to_i,
    "fingerprint" => (["00"] * 16).join(':'),
    "public_key" => public_key,
    "name" => name
  }

  response.body ={
    'ssh_key' => data[:ssh_keys].last
  }

  response
end

#delete_ssh_key(id) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/ext/fog/compute/digital_ocean_v2.rb', line 70

def delete_ssh_key(id)
  self.data[:ssh_keys].select! do |key|
    key["id"] != id
  end

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

#list_ssh_keysObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ext/fog/compute/digital_ocean_v2.rb', line 57

def list_ssh_keys
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "ssh_keys" => data[:ssh_keys],
    "links" => {},
    "meta" => {
      "total" => data[:ssh_keys].count
    }
  }
  response
end