Module: KeaApiStubs
- Defined in:
- spec/fixtures/kea_api_stubs.rb
Overview
This module provides a set of helper methods that return mock data structures, mimicking the JSON responses from the ISC Kea API. This allows us to test the client and services without needing a live Kea server.
Instance Method Summary collapse
-
#error_response ⇒ Hash
An error response from the API.
-
#successful_config_get ⇒ Hash
A successful response for a 'config-get' command.
-
#successful_lease_get ⇒ Hash
A successful response for a 'lease4-get-all' command with one active lease.
-
#successful_reservation_add ⇒ Hash
A successful response for a 'reservation-add' command.
-
#successful_reservation_del ⇒ Hash
A successful response for a 'reservation-del' command.
Instance Method Details
#error_response ⇒ Hash
An error response from the API.
51 52 53 |
# File 'spec/fixtures/kea_api_stubs.rb', line 51 def error_response { "result" => 1, "text" => "Something went wrong." } end |
#successful_config_get ⇒ Hash
A successful response for a 'config-get' command.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'spec/fixtures/kea_api_stubs.rb', line 9 def successful_config_get { "Dhcp4" => { "subnet4" => [ { "id" => 1, "subnet" => "192.168.1.0/24", "pools" => [{ "pool" => "192.168.1.10-192.168.1.20" }], "option-data" => [{ "name" => "routers", "data" => "192.168.1.1" }], "reservations" => [ { "hw-address" => "aa:bb:cc:dd:ee:ff", "ip-address" => "192.168.1.5", "hostname" => "test-host" } ] } ] } } end |
#successful_lease_get ⇒ Hash
A successful response for a 'lease4-get-all' command with one active lease.
29 30 31 32 33 34 35 |
# File 'spec/fixtures/kea_api_stubs.rb', line 29 def successful_lease_get { "leases" => [ { "ip-address" => "192.168.1.11", "hw-address" => "ff:ee:dd:cc:bb:aa", "cltt" => 1678886400, "expire" => 1678890000 } ] } end |
#successful_reservation_add ⇒ Hash
A successful response for a 'reservation-add' command.
39 40 41 |
# File 'spec/fixtures/kea_api_stubs.rb', line 39 def successful_reservation_add { "result" => 0, "text" => "Reservation added successfully." } end |
#successful_reservation_del ⇒ Hash
A successful response for a 'reservation-del' command.
45 46 47 |
# File 'spec/fixtures/kea_api_stubs.rb', line 45 def successful_reservation_del { "result" => 0, "text" => "Reservation deleted successfully." } end |