ruby-paloalto-client 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/palo_alto/client/version.rb +1 -1
- data/lib/palo_alto/helpers/rest.rb +1 -0
- data/lib/palo_alto/v6/api.rb +4 -0
- data/lib/palo_alto/v6/commit_api.rb +95 -0
- data/lib/palo_alto/v6/security_rule_api.rb +129 -0
- data/ruby-paloalto-client.gemspec +1 -0
- data/spec/fixtures/address_group_missing_description.xml +15 -0
- data/spec/fixtures/commit_complete.xml +25 -0
- data/spec/fixtures/commit_in_progress.xml +18 -0
- data/spec/fixtures/security_rule.xml +41 -0
- data/spec/fixtures/security_rule_create_success.xml +3 -0
- data/spec/fixtures/security_rule_not_exist.xml +5 -0
- data/spec/lib/palo-alto/helpers/rest_spec.rb +1 -0
- data/spec/lib/palo-alto/v6/commit_api_spec.rb +80 -0
- data/spec/lib/palo-alto/v6/security_rule_api_spec.rb +65 -0
- metadata +34 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0463b73f0491b8b37ef4a7bf60b794e436ccd5
|
4
|
+
data.tar.gz: c94dba7b0f379b97d97348c46f1bbd19c7d5f121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cbf04665ddf6beeac626169957afa6f2f6fddc789d865156850c6a2429f4a40a95774bcdd2d5c8c78cf3d7920e77f1bf2887eeddd1b7e8b404a596278494b74
|
7
|
+
data.tar.gz: eb215a758ac4e7be3ad924d4c370994155b248aa5e5021588ce17e5fcece740633126a1d58f69cdc8e4eb527d843c35dcfecb7c743e9505958b0338719596c1a
|
@@ -23,6 +23,7 @@ module PaloAlto
|
|
23
23
|
def self.make_request(opts)
|
24
24
|
options = {}
|
25
25
|
options[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
|
26
|
+
options[:timeout] = 60
|
26
27
|
options[:headers] = {}
|
27
28
|
options[:headers]["User-Agent"] = "ruby-keystone-client"
|
28
29
|
options[:headers]["Accept"] = "application/xml"
|
data/lib/palo_alto/v6/api.rb
CHANGED
@@ -3,6 +3,8 @@ require "palo_alto/v6/virtual_system_api"
|
|
3
3
|
require "palo_alto/v6/address_api"
|
4
4
|
require "palo_alto/v6/address_group_api"
|
5
5
|
require "palo_alto/v6/log_api"
|
6
|
+
require "palo_alto/v6/security_rule_api"
|
7
|
+
require "palo_alto/v6/commit_api"
|
6
8
|
|
7
9
|
module PaloAlto
|
8
10
|
module V6
|
@@ -13,6 +15,8 @@ module PaloAlto
|
|
13
15
|
include PaloAlto::V6::AddressApi
|
14
16
|
include PaloAlto::V6::AddressGroupApi
|
15
17
|
include PaloAlto::V6::LogApi
|
18
|
+
include PaloAlto::V6::SecurityRuleApi
|
19
|
+
include PaloAlto::V6::CommitApi
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "crack/xml"
|
2
|
+
|
3
|
+
module PaloAlto
|
4
|
+
module V6
|
5
|
+
module CommitApi
|
6
|
+
# Gets the status of a commit job based on the job ID
|
7
|
+
#
|
8
|
+
# == Parameters
|
9
|
+
#
|
10
|
+
# * +job_id+ - ID of the job that is performing the commit
|
11
|
+
#
|
12
|
+
# == Returns
|
13
|
+
#
|
14
|
+
# * +Boolean+ - True if job is complete, false if job is still processing
|
15
|
+
#
|
16
|
+
# == Raises
|
17
|
+
#
|
18
|
+
# * +Exception+ - Raises an exception if the request is unsuccessful
|
19
|
+
def commit_job_complete?(job_id:)
|
20
|
+
status = false
|
21
|
+
|
22
|
+
# get the job XML
|
23
|
+
options = {}
|
24
|
+
options[:url] = self.endpoint
|
25
|
+
options[:method] = :post
|
26
|
+
options[:payload] = { :type => "op",
|
27
|
+
:cmd => "<show><jobs><id>#{job_id}</id></jobs></show>",
|
28
|
+
:key => self.auth_key }
|
29
|
+
|
30
|
+
html_result = Helpers::Rest.make_request(options)
|
31
|
+
|
32
|
+
raise "Error obtaining commit job XML" if html_result.nil?
|
33
|
+
|
34
|
+
xml_data = Nokogiri::XML(html_result)
|
35
|
+
response_code = xml_data.xpath('//response/@status').to_s
|
36
|
+
|
37
|
+
if response_code == "success"
|
38
|
+
job_status = xml_data.xpath('//response/result/job/status')[0].content.to_s
|
39
|
+
status = true if job_status == "FIN"
|
40
|
+
else
|
41
|
+
raise "Error in response XML: #{xml_data.inspect}"
|
42
|
+
end
|
43
|
+
|
44
|
+
status
|
45
|
+
end
|
46
|
+
|
47
|
+
# Gets the overall result and report for the commit job
|
48
|
+
#
|
49
|
+
# == Parameters
|
50
|
+
#
|
51
|
+
# * +job_id+ - ID of the job that performed the commit
|
52
|
+
#
|
53
|
+
# == Returns
|
54
|
+
#
|
55
|
+
# * +Hash+ - Hash containing the result of the commit job
|
56
|
+
#
|
57
|
+
# == Raises
|
58
|
+
#
|
59
|
+
# * +Exception+ - Raises an exception if the request is unsuccessful
|
60
|
+
def commit_job_result(job_id:)
|
61
|
+
return Crack::XML.parse(get_job_xml(job_id: job_id).to_xml)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# Retrieves the XML file for a given Job ID and returns the data in XML format
|
67
|
+
#
|
68
|
+
# == Parameters
|
69
|
+
#
|
70
|
+
# * +job_id+ - ID of the job to retrieve data for
|
71
|
+
#
|
72
|
+
# == Returns
|
73
|
+
#
|
74
|
+
# * +Nokogiri::XML::Document+ - XML data structure containing the response data from the job request
|
75
|
+
#
|
76
|
+
# == Raises
|
77
|
+
#
|
78
|
+
# * +Exception+ - Raises an exception if the request is unsuccessful
|
79
|
+
def get_job_xml(job_id:)
|
80
|
+
options = {}
|
81
|
+
options[:url] = self.endpoint
|
82
|
+
options[:method] = :post
|
83
|
+
options[:payload] = { :type => "op",
|
84
|
+
:cmd => "<show><jobs><id>#{job_id}</id></jobs></show>",
|
85
|
+
:key => self.auth_key }
|
86
|
+
|
87
|
+
html_result = Helpers::Rest.make_request(options)
|
88
|
+
|
89
|
+
raise "Error obtaining log job XML" if html_result.nil?
|
90
|
+
|
91
|
+
Nokogiri::XML(html_result)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require "crack/xml"
|
2
|
+
require "palo_alto/models/rulebase"
|
3
|
+
|
4
|
+
module PaloAlto
|
5
|
+
module V6
|
6
|
+
module SecurityRuleApi
|
7
|
+
# Get a security rule with the given name (if exists)
|
8
|
+
#
|
9
|
+
# == Inputs
|
10
|
+
#
|
11
|
+
# * +name+ - Name of the rule to query for
|
12
|
+
#
|
13
|
+
# == Returns
|
14
|
+
#
|
15
|
+
# * +JSON+ - JSON data containing the rule found
|
16
|
+
#
|
17
|
+
# == Raises
|
18
|
+
#
|
19
|
+
# * +Exception+ - Exception if there is a communication/other issue
|
20
|
+
#
|
21
|
+
# == TODO
|
22
|
+
#
|
23
|
+
# * Eventually this function should be changed to return an actual PaloAlto::Models::Rulebase
|
24
|
+
# object instance rather than JSON to be more consistent with library function.
|
25
|
+
def get_security_rule(name:)
|
26
|
+
xpath_search = "/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='#{name}']"
|
27
|
+
|
28
|
+
options = {}
|
29
|
+
options[:url] = self.endpoint
|
30
|
+
options[:method] = :post
|
31
|
+
options[:payload] = { type: "config",
|
32
|
+
action: "show",
|
33
|
+
key: self.auth_key,
|
34
|
+
xpath: xpath_search }
|
35
|
+
|
36
|
+
# attempt to perform the query
|
37
|
+
html_result = Helpers::Rest.make_request(options)
|
38
|
+
|
39
|
+
raise "Error obtaining XML" if html_result.nil?
|
40
|
+
|
41
|
+
# parse the XML data
|
42
|
+
data = Nokogiri::XML(html_result)
|
43
|
+
response_code = data.xpath('//response/@status').to_s
|
44
|
+
|
45
|
+
if response_code == "success"
|
46
|
+
if (rule_elements = data.xpath('//response/result/entry')).length > 0
|
47
|
+
return Crack::XML.parse(rule_elements[0].to_xml)
|
48
|
+
else
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
else
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create a security rule (firewall rule)
|
57
|
+
#
|
58
|
+
# == Returns
|
59
|
+
#
|
60
|
+
# * +Hash+ - Hash of a Model::Rulebase instance
|
61
|
+
#
|
62
|
+
# == Raises
|
63
|
+
#
|
64
|
+
# * +Exception+ - Raises an exception if the request is unsuccessful
|
65
|
+
def create_security_rule(rule_hash:)
|
66
|
+
# construct the XML elements for the request
|
67
|
+
element_xpath = "/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='#{rule_hash[:name]}']"
|
68
|
+
|
69
|
+
element_value = "<action>" + rule_hash[:action] + "</action>"
|
70
|
+
element_value += "<from>" + rule_hash[:from_zones].split(',').map{ |e| "<member>#{e}</member>" }.join + "</from>"
|
71
|
+
element_value += "<to>" + rule_hash[:to_zones].split(',').map{ |e| "<member>#{e}</member>" }.join + "</to>"
|
72
|
+
element_value += "<source>" + rule_hash[:sources].split(',').map{ |e| "<member>#{e}</member>" }.join + "</source>" if rule_hash[:sources]
|
73
|
+
element_value += "<destination>" + rule_hash[:destinations].split(',').map{ |e| "<member>#{e}</member>" }.join + "</destination>" if rule_hash[:destinations]
|
74
|
+
element_value += "<source-user>" + rule_hash[:source_users].split(',').map{ |e| "<member>#{e}</member>" }.join + "</source-user>" if rule_hash[:source_users]
|
75
|
+
element_value += "<service>" + rule_hash[:services].split(',').map{ |e| "<member>#{e}</member>" }.join + "</service>" if rule_hash[:services]
|
76
|
+
element_value += "<category>" + rule_hash[:categories].split(',').map{ |e| "<member>#{e}</member>" }.join + "</category>" if rule_hash[:categories]
|
77
|
+
element_value += "<application>" + rule_hash[:applications].split(',').map{ |e| "<member>#{e}</member>" }.join + "</application>" if rule_hash[:applications]
|
78
|
+
element_value += "<hip-profiles>" + rule_hash[:hip_profiles].split(',').map{ |e| "<member>#{e}</member>" }.join + "</hip-profiles>" if rule_hash[:hip_profiles]
|
79
|
+
element_value += "<log-start>" + rule_hash[:log_session_start] + "</log-start>" if rule_hash[:log_session_start]
|
80
|
+
element_value += "<log-end>" + rule_hash[:log_session_end] + "</log-end>" if rule_hash[:log_session_end]
|
81
|
+
|
82
|
+
# configure options for the request
|
83
|
+
options = {}
|
84
|
+
options[:url] = self.endpoint
|
85
|
+
options[:method] = :post
|
86
|
+
options[:payload] = { type: "config",
|
87
|
+
action: "set",
|
88
|
+
key: self.auth_key,
|
89
|
+
xpath: element_xpath,
|
90
|
+
element: element_value }
|
91
|
+
|
92
|
+
html_result = Helpers::Rest.make_request(options)
|
93
|
+
|
94
|
+
raise "Error during security rule create" if html_result.nil?
|
95
|
+
|
96
|
+
# parse the XML data
|
97
|
+
data = Nokogiri::XML(html_result)
|
98
|
+
|
99
|
+
# check that the operation was successful
|
100
|
+
if data.xpath('//response/@status').to_s == "success"
|
101
|
+
# commit the change to be operational
|
102
|
+
# TODO: Should probably do partial commit once device IDs are built in
|
103
|
+
options = {}
|
104
|
+
options[:url] = self.endpoint
|
105
|
+
options[:method] = :post
|
106
|
+
options[:payload] = { type: "commit",
|
107
|
+
key: self.auth_key,
|
108
|
+
cmd: "<commit></commit>" }
|
109
|
+
|
110
|
+
html_result = Helpers::Rest.make_request(options)
|
111
|
+
|
112
|
+
raise "Error during security rule commit" if html_result.nil?
|
113
|
+
|
114
|
+
# parse the XML data
|
115
|
+
data = Nokogiri::XML(html_result)
|
116
|
+
|
117
|
+
# check that the operation was successful and return the job ID
|
118
|
+
if data.xpath('//response/@status').to_s == "success"
|
119
|
+
return data.xpath('//response/result/job')[0].content.to_s
|
120
|
+
else
|
121
|
+
raise "#{Crack::XML.parse(data.to_xml)}"
|
122
|
+
end
|
123
|
+
else
|
124
|
+
raise "#{Crack::XML.parse(data.to_xml)}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<response status="success" code="19">
|
2
|
+
<result total-count="1" count="1">
|
3
|
+
<vsys src="tpl" admin="admin" time="2015/03/05 10:22:56">
|
4
|
+
<entry name="vsys1" src="tpl" admin="admin" time="2015/03/05 10:22:56">
|
5
|
+
<address-group admin="admin" time="2015/03/04 13:45:08">
|
6
|
+
<entry name="test" admin="admin" time="2015/03/04 13:45:08">
|
7
|
+
<static admin="admin" time="2015/03/04 13:45:08">
|
8
|
+
<member admin="admin" time="2015/03/04 13:45:08">address-group-1</member>
|
9
|
+
</static>
|
10
|
+
</entry>
|
11
|
+
</address-group>
|
12
|
+
</entry>
|
13
|
+
</vsys>
|
14
|
+
</result>
|
15
|
+
</response>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<response status="success">
|
3
|
+
<result>
|
4
|
+
<job>
|
5
|
+
<tenq>2015/07/06 14:17:09</tenq>
|
6
|
+
<id>77</id>
|
7
|
+
<user>test_user</user>
|
8
|
+
<type>Commit</type>
|
9
|
+
<status>FIN</status>
|
10
|
+
<stoppable>no</stoppable>
|
11
|
+
<result>OK</result>
|
12
|
+
<tfin>14:18:30</tfin>
|
13
|
+
<progress>14:18:30</progress>
|
14
|
+
<details>
|
15
|
+
<line>vsys1 (vsys1)</line>
|
16
|
+
<line> Security Policy:</line>
|
17
|
+
<line> - Rule 'Deny All' shadows rule 'testa'</line>
|
18
|
+
<line> - Rule 'Deny All' shadows rule 'testb'</line>
|
19
|
+
<line>(Module: device)</line>
|
20
|
+
<line>Configuration committed successfully</line>
|
21
|
+
</details>
|
22
|
+
<warnings/>
|
23
|
+
</job>
|
24
|
+
</result>
|
25
|
+
</response>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<response status="success">
|
3
|
+
<result>
|
4
|
+
<job>
|
5
|
+
<tenq>2015/07/06 14:17:09</tenq>
|
6
|
+
<id>77</id>
|
7
|
+
<user>test_user</user>
|
8
|
+
<type>Commit</type>
|
9
|
+
<status>ACT</status>
|
10
|
+
<stoppable>yes</stoppable>
|
11
|
+
<result>PEND</result>
|
12
|
+
<tfin>Still Active</tfin>
|
13
|
+
<progress>0</progress>
|
14
|
+
<warnings/>
|
15
|
+
<details/>
|
16
|
+
</job>
|
17
|
+
</result>
|
18
|
+
</response>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<response status="success">
|
2
|
+
<result>
|
3
|
+
<entry name="test1">
|
4
|
+
<option>
|
5
|
+
<disable-server-response-inspection>no</disable-server-response-inspection>
|
6
|
+
</option>
|
7
|
+
<from>
|
8
|
+
<member>from_member</member>
|
9
|
+
</from>
|
10
|
+
<to>
|
11
|
+
<member>to_member</member>
|
12
|
+
</to>
|
13
|
+
<source>
|
14
|
+
<member>any</member>
|
15
|
+
</source>
|
16
|
+
<destination>
|
17
|
+
<member>192.168.1.2/24</member>
|
18
|
+
</destination>
|
19
|
+
<source-user>
|
20
|
+
<member>any</member>
|
21
|
+
</source-user>
|
22
|
+
<category>
|
23
|
+
<member>any</member>
|
24
|
+
</category>
|
25
|
+
<application>
|
26
|
+
<member>dns</member>
|
27
|
+
</application>
|
28
|
+
<service>
|
29
|
+
<member>any</member>
|
30
|
+
</service>
|
31
|
+
<hip-profiles>
|
32
|
+
<member>any</member>
|
33
|
+
</hip-profiles>
|
34
|
+
<log-start>no</log-start>
|
35
|
+
<log-end>yes</log-end>
|
36
|
+
<negate-source>no</negate-source>
|
37
|
+
<negate-destination>no</negate-destination>
|
38
|
+
<action>allow</action>
|
39
|
+
</entry>
|
40
|
+
</result>
|
41
|
+
</response>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "palo_alto/v6/commit_api"
|
2
|
+
require "palo_alto/helpers/rest"
|
3
|
+
|
4
|
+
describe "PaloAlto::V6::CommitApi" do
|
5
|
+
# dummy class to demonstrate functionality
|
6
|
+
class DummyClass
|
7
|
+
extend PaloAlto::V6::CommitApi
|
8
|
+
|
9
|
+
def self.endpoint
|
10
|
+
"https://some.host:80/api/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.auth_key
|
14
|
+
"OIGHOEIHT()*#Y"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:job_id) { "77" }
|
19
|
+
let(:commit_in_progress_xml) { File.open(fixture_file("commit_in_progress.xml")).read }
|
20
|
+
let(:commit_complete_xml) { File.open(fixture_file("commit_complete.xml")).read }
|
21
|
+
|
22
|
+
describe ".commit_job_complete?" do
|
23
|
+
describe "when a job is still in progress" do
|
24
|
+
before do
|
25
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(commit_in_progress_xml)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false" do
|
29
|
+
expect(DummyClass.commit_job_complete?(job_id: job_id)).to eq(false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when a job has completed" do
|
34
|
+
before do
|
35
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(commit_complete_xml)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns true" do
|
39
|
+
expect(DummyClass.commit_job_complete?(job_id: job_id)).to eq(true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "when errors occur" do
|
44
|
+
it "raises an exception if an error occurred obtaining XML" do
|
45
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(File.open(fixture_file("failure.xml")).read)
|
46
|
+
expect{ DummyClass.commit_job_complete?(job_id: job_id) }.to raise_exception
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".commit_job_result" do
|
52
|
+
describe "for valid XML" do
|
53
|
+
it "returns the resulting Hash of the XML data" do
|
54
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(commit_complete_xml)
|
55
|
+
expect(DummyClass.commit_job_result(job_id: job_id)).to be_instance_of(Hash)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "when errors occur" do
|
60
|
+
it "raises an exception if an error occurred obtaining XML" do
|
61
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_raise(Exception)
|
62
|
+
expect{ DummyClass.commit_job_result(job_id: job_id) }.to raise_exception
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "private function" do
|
68
|
+
describe ".get_job_xml" do
|
69
|
+
it "returns a Nokogiri Document for valid XML" do
|
70
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(commit_complete_xml)
|
71
|
+
expect(DummyClass.commit_job_result(job_id: job_id)).to be_instance_of(Hash)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "raises an exception when no XML is returned for request" do
|
75
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_raise(Exception)
|
76
|
+
expect{ DummyClass.send(:commit_job_result, { job_id: job_id }) }.to raise_exception
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "palo_alto/v6/security_rule_api"
|
2
|
+
require "palo_alto/helpers/rest"
|
3
|
+
|
4
|
+
describe "PaloAlto::V6::SecurityRuleApi" do
|
5
|
+
# dummy class to demonstrate functionality
|
6
|
+
class DummyClass
|
7
|
+
extend PaloAlto::V6::SecurityRuleApi
|
8
|
+
|
9
|
+
def self.endpoint
|
10
|
+
"https://some.host:80/api/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.auth_key
|
14
|
+
"OIGHOEIHT()*#Y"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:security_rule_xml) { File.open(fixture_file("security_rule.xml")).read }
|
19
|
+
let(:security_rule_not_exist_xml) { File.open(fixture_file("security_rule_not_exist.xml")).read }
|
20
|
+
let(:security_rule_create_success) { File.open(fixture_file("security_rule_create_success.xml")).read }
|
21
|
+
|
22
|
+
describe ".get_security_rule" do
|
23
|
+
describe "when the security rule exists" do
|
24
|
+
before do
|
25
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(security_rule_xml)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns the security rule as JSON data" do
|
29
|
+
expect(DummyClass.get_security_rule(name: "test1")).to be_instance_of(Hash)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when the security rule does not exist" do
|
34
|
+
before do
|
35
|
+
expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(security_rule_not_exist_xml)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns nil" do
|
39
|
+
expect(DummyClass.get_security_rule(name: "bogusmissing")).to be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".create_security_rule" do
|
45
|
+
it "returns the XML content response when the rule is successfully created" do
|
46
|
+
pending("TODO: Create spec")
|
47
|
+
fail
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns the XML content raw when the rule is successfully created but there is no internal msg" do
|
51
|
+
pending("TODO: Create spec")
|
52
|
+
fail
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns an exception when there is an HTTP issue" do
|
56
|
+
pending("TODO: Create spec")
|
57
|
+
fail
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns a JSON array of error data when the returned data contains a non-success code" do
|
61
|
+
pending("TODO: Create spec")
|
62
|
+
fail
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-paloalto-client
|
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
|
- Justin Karimi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: crack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: nokogiri
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,10 +152,13 @@ files:
|
|
138
152
|
- lib/palo_alto/v6/address_api.rb
|
139
153
|
- lib/palo_alto/v6/address_group_api.rb
|
140
154
|
- lib/palo_alto/v6/api.rb
|
155
|
+
- lib/palo_alto/v6/commit_api.rb
|
141
156
|
- lib/palo_alto/v6/device_api.rb
|
142
157
|
- lib/palo_alto/v6/log_api.rb
|
158
|
+
- lib/palo_alto/v6/security_rule_api.rb
|
143
159
|
- lib/palo_alto/v6/virtual_system_api.rb
|
144
160
|
- ruby-paloalto-client.gemspec
|
161
|
+
- spec/fixtures/address_group_missing_description.xml
|
145
162
|
- spec/fixtures/address_groups.xml
|
146
163
|
- spec/fixtures/addresses.xml
|
147
164
|
- spec/fixtures/blank_address_groups.xml
|
@@ -149,6 +166,8 @@ files:
|
|
149
166
|
- spec/fixtures/blank_devices.xml
|
150
167
|
- spec/fixtures/blank_traffic_logs.xml
|
151
168
|
- spec/fixtures/blank_virtual_systems.xml
|
169
|
+
- spec/fixtures/commit_complete.xml
|
170
|
+
- spec/fixtures/commit_in_progress.xml
|
152
171
|
- spec/fixtures/devices.xml
|
153
172
|
- spec/fixtures/failure.xml
|
154
173
|
- spec/fixtures/log_complete.xml
|
@@ -161,6 +180,9 @@ files:
|
|
161
180
|
- spec/fixtures/no_rulebase_virtual_systems.xml
|
162
181
|
- spec/fixtures/no_vsys_devices.xml
|
163
182
|
- spec/fixtures/pending_traffic_logs.xml
|
183
|
+
- spec/fixtures/security_rule.xml
|
184
|
+
- spec/fixtures/security_rule_create_success.xml
|
185
|
+
- spec/fixtures/security_rule_not_exist.xml
|
164
186
|
- spec/fixtures/system_logs.xml
|
165
187
|
- spec/fixtures/traffic_logs.xml
|
166
188
|
- spec/fixtures/unsupported_log_attribute.xml
|
@@ -180,8 +202,10 @@ files:
|
|
180
202
|
- spec/lib/palo-alto/v6/address_api_spec.rb
|
181
203
|
- spec/lib/palo-alto/v6/address_group_api_spec.rb
|
182
204
|
- spec/lib/palo-alto/v6/api_spec.rb
|
205
|
+
- spec/lib/palo-alto/v6/commit_api_spec.rb
|
183
206
|
- spec/lib/palo-alto/v6/device_api_spec.rb
|
184
207
|
- spec/lib/palo-alto/v6/log_api_spec.rb
|
208
|
+
- spec/lib/palo-alto/v6/security_rule_api_spec.rb
|
185
209
|
- spec/lib/palo-alto/v6/virtual_system_api_spec.rb
|
186
210
|
- spec/spec_helper.rb
|
187
211
|
homepage: ''
|
@@ -209,6 +233,7 @@ signing_key:
|
|
209
233
|
specification_version: 4
|
210
234
|
summary: Ruby PaloAlto Client (API V6.X)
|
211
235
|
test_files:
|
236
|
+
- spec/fixtures/address_group_missing_description.xml
|
212
237
|
- spec/fixtures/address_groups.xml
|
213
238
|
- spec/fixtures/addresses.xml
|
214
239
|
- spec/fixtures/blank_address_groups.xml
|
@@ -216,6 +241,8 @@ test_files:
|
|
216
241
|
- spec/fixtures/blank_devices.xml
|
217
242
|
- spec/fixtures/blank_traffic_logs.xml
|
218
243
|
- spec/fixtures/blank_virtual_systems.xml
|
244
|
+
- spec/fixtures/commit_complete.xml
|
245
|
+
- spec/fixtures/commit_in_progress.xml
|
219
246
|
- spec/fixtures/devices.xml
|
220
247
|
- spec/fixtures/failure.xml
|
221
248
|
- spec/fixtures/log_complete.xml
|
@@ -228,6 +255,9 @@ test_files:
|
|
228
255
|
- spec/fixtures/no_rulebase_virtual_systems.xml
|
229
256
|
- spec/fixtures/no_vsys_devices.xml
|
230
257
|
- spec/fixtures/pending_traffic_logs.xml
|
258
|
+
- spec/fixtures/security_rule.xml
|
259
|
+
- spec/fixtures/security_rule_create_success.xml
|
260
|
+
- spec/fixtures/security_rule_not_exist.xml
|
231
261
|
- spec/fixtures/system_logs.xml
|
232
262
|
- spec/fixtures/traffic_logs.xml
|
233
263
|
- spec/fixtures/unsupported_log_attribute.xml
|
@@ -247,7 +277,9 @@ test_files:
|
|
247
277
|
- spec/lib/palo-alto/v6/address_api_spec.rb
|
248
278
|
- spec/lib/palo-alto/v6/address_group_api_spec.rb
|
249
279
|
- spec/lib/palo-alto/v6/api_spec.rb
|
280
|
+
- spec/lib/palo-alto/v6/commit_api_spec.rb
|
250
281
|
- spec/lib/palo-alto/v6/device_api_spec.rb
|
251
282
|
- spec/lib/palo-alto/v6/log_api_spec.rb
|
283
|
+
- spec/lib/palo-alto/v6/security_rule_api_spec.rb
|
252
284
|
- spec/lib/palo-alto/v6/virtual_system_api_spec.rb
|
253
285
|
- spec/spec_helper.rb
|