smart_proxy_dhcp_remote_isc 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -1
- data/bundler.d/dhcp_remote_isc.rb +1 -1
- data/lib/smart_proxy_dhcp_remote_isc/version.rb +1 -1
- data/test/integration_test.rb +134 -0
- data/test/test_helper.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54cb8f5d6a4e40a2f4f13a888ac1df66e9113fb29910c7911dc166af6e3cd5c7
|
4
|
+
data.tar.gz: 81964c0de192cb59c8db20b1662f95b055dfa26d6694a26c9f7262776d614acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c6544702a8b3b283ea3766956f1e56f2dbead04a3fa009f0810278f00d89c4d6f201739e7005b5b6e9d1a181f9b1898c2b258ce3215cc13d7f639ee9e30e70
|
7
|
+
data.tar.gz: 23fb0984b315bbd79a07a808d866c05cf37bad56804dbe7333eedaf3b4f2d89a5a21d0306d9ff4de9ac14b5ea7faabc4faff23d2d7474958c492eef7a6e5c8d0
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# SmartProxyDhcpRemoteISC
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/theforeman/smart_proxy_dhcp_remote_isc.svg?branch=master)](https://travis-ci.org/theforeman/smart_proxy_dhcp_remote_isc)
|
4
|
+
|
3
5
|
This plugin allows to interface with ISC dhcpd servers that have configuration and lease files shared over NFS
|
4
6
|
|
5
7
|
## Installation
|
@@ -11,7 +13,7 @@ This plugin is compatible with Smart Proxy 1.15 or higher.
|
|
11
13
|
|
12
14
|
When installing using "gem", make sure to install the bundle file:
|
13
15
|
|
14
|
-
echo "gem '
|
16
|
+
echo "gem 'smart_proxy_dhcp_remote_isc'" > /usr/share/foreman-proxy/bundler.d/dhcp_remote_isc.rb
|
15
17
|
|
16
18
|
## Configuration
|
17
19
|
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require "rack/test"
|
2
|
+
require 'test_helper'
|
3
|
+
require 'json'
|
4
|
+
require 'dhcp_common/dhcp_common'
|
5
|
+
require 'dhcp_common/subnet_service'
|
6
|
+
require 'dhcp_common/free_ips'
|
7
|
+
require 'dhcp_common/isc/omapi_provider'
|
8
|
+
require 'dhcp_common/isc/configuration_parser'
|
9
|
+
require 'dhcp_common/isc/subnet_service_initialization'
|
10
|
+
require 'smart_proxy_dhcp_remote_isc/subnet_service_initializer'
|
11
|
+
require 'dhcp/dhcp'
|
12
|
+
require 'dhcp/dependency_injection'
|
13
|
+
require 'dhcp/dhcp_api'
|
14
|
+
|
15
|
+
ENV['RACK_ENV'] = 'test'
|
16
|
+
|
17
|
+
class IntegrationTest < ::Test::Unit::TestCase
|
18
|
+
include Rack::Test::Methods
|
19
|
+
|
20
|
+
class SubnetServiceInitializerForTesting < Proxy::DHCP::RemoteISC::SubnetServiceInitializer
|
21
|
+
def read_leases_file
|
22
|
+
return <<EOF
|
23
|
+
host testing-01 { hardware ethernet 11:22:33:a9:61:09; fixed-address 10.0.0.200; dynamic; }
|
24
|
+
EOF
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_config_file
|
28
|
+
return <<EOF
|
29
|
+
subnet 10.0.0.0 netmask 255.255.255.0 {
|
30
|
+
}
|
31
|
+
EOF
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class IscOmapiProviderForTesting < Proxy::DHCP::CommonISC::IscOmapiProvider
|
36
|
+
def om
|
37
|
+
@om ||= StringIO.new
|
38
|
+
end
|
39
|
+
|
40
|
+
def om_disconnect(msg)
|
41
|
+
@om = nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def app
|
46
|
+
app = Proxy::DhcpApi.new
|
47
|
+
app.helpers.server = @server
|
48
|
+
app
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup
|
52
|
+
@subnet_service = ::Proxy::DHCP::SubnetService.new(::Proxy::MemoryStore.new, ::Proxy::MemoryStore.new, ::Proxy::MemoryStore.new,
|
53
|
+
::Proxy::MemoryStore.new, ::Proxy::MemoryStore.new)
|
54
|
+
@parser = ::Proxy::DHCP::CommonISC::ConfigurationParser.new
|
55
|
+
|
56
|
+
subnet_service_initializer =
|
57
|
+
SubnetServiceInitializerForTesting.new("config_path", "leases_path", @parser, @subnet_service)
|
58
|
+
@initialized_subnet_service = subnet_service_initializer.initialized_subnet_service
|
59
|
+
|
60
|
+
@free_ips = ::Proxy::DHCP::FreeIps.new(10)
|
61
|
+
|
62
|
+
@server = IscOmapiProviderForTesting.new("127.0.0.1", '7911', [], 'key', 'secret', @initialized_subnet_service, @free_ips)
|
63
|
+
|
64
|
+
@expected_reservation = {"name" => "testing-01", "ip" => "10.0.0.200", "mac" => "11:22:33:a9:61:09",
|
65
|
+
"subnet" => "10.0.0.0/255.255.255.0", "type" => "reservation", "deleteable" => true,
|
66
|
+
"hostname" => "testing-01", "hardware_type" => "ethernet"}
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def test_get_subnets
|
71
|
+
get "/"
|
72
|
+
|
73
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
74
|
+
parsed_response = JSON.parse(last_response.body)
|
75
|
+
assert_equal 1, parsed_response.size
|
76
|
+
assert_equal "10.0.0.0", parsed_response.first['network']
|
77
|
+
assert_equal "255.255.255.0", parsed_response.first['netmask']
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_get_network
|
81
|
+
get "/10.0.0.0"
|
82
|
+
|
83
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
84
|
+
parsed_response = JSON.parse(last_response.body)
|
85
|
+
assert parsed_response.key?('reservations')
|
86
|
+
assert_equal 1, parsed_response['reservations'].size
|
87
|
+
assert parsed_response.key?('leases')
|
88
|
+
assert parsed_response['leases'].empty?
|
89
|
+
assert_equal@expected_reservation, parsed_response['reservations'].first
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_get_unused_ip
|
93
|
+
get "/10.0.0.0/unused_ip"
|
94
|
+
|
95
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
96
|
+
parsed_response = JSON.parse(last_response.body)
|
97
|
+
assert parsed_response.key?('ip')
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_get_records_by_ip
|
101
|
+
get "/10.0.0.0/ip/10.0.0.200"
|
102
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
103
|
+
parsed_response = JSON.parse(last_response.body)
|
104
|
+
assert_equal 1, parsed_response.size
|
105
|
+
assert_equal @expected_reservation, parsed_response.first
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_get_record_by_mac
|
109
|
+
get "/10.0.0.0/mac/11:22:33:a9:61:09"
|
110
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
111
|
+
assert_equal @expected_reservation, JSON.parse(last_response.body)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_create_record
|
115
|
+
record = {
|
116
|
+
"hostname" => "test-02",
|
117
|
+
"ip" => "10.0.0.250",
|
118
|
+
"mac" => "10:10:10:10:10:10",
|
119
|
+
"network" => "10.0.0.0",
|
120
|
+
}
|
121
|
+
post "/10.0.0.0", record
|
122
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_delete_records_by_ip
|
126
|
+
delete "/10.0.0.0/ip/10.0.0.200"
|
127
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_delete_record_by_mac
|
131
|
+
delete "/10.0.0.0/mac/11:22:33:a9:61:09"
|
132
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
133
|
+
end
|
134
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dhcp_remote_isc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitri Dolguikh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rsec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1'
|
27
27
|
description: Smart-Proxy dhcp module provider for NFS-accessible ISC dhcpd installations
|
28
28
|
email:
|
29
29
|
- dmitri@appliedlogic.ca
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/smart_proxy_dhcp_remote_isc/plugin_configuration.rb
|
41
41
|
- lib/smart_proxy_dhcp_remote_isc/subnet_service_initializer.rb
|
42
42
|
- lib/smart_proxy_dhcp_remote_isc/version.rb
|
43
|
+
- test/integration_test.rb
|
43
44
|
- test/plugin_configuration_test.rb
|
44
45
|
- test/test_helper.rb
|
45
46
|
homepage: https://github.com/theforeman/smart_proxy_dhcp_remote_isc
|
@@ -61,11 +62,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
62
|
- !ruby/object:Gem::Version
|
62
63
|
version: '0'
|
63
64
|
requirements: []
|
64
|
-
|
65
|
-
rubygems_version: 2.6.14
|
65
|
+
rubygems_version: 3.1.2
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Smart-Proxy dhcp module provider for NFS-accessible ISC dhcpd installations
|
69
69
|
test_files:
|
70
|
+
- test/integration_test.rb
|
70
71
|
- test/plugin_configuration_test.rb
|
71
72
|
- test/test_helper.rb
|