Skip to content

Commit

Permalink
(PUP-7260) Remove audited field from the report
Browse files Browse the repository at this point in the history
Since the audit metaparameter is being disabled, this field is no longer
relevant. This commit removes it from the schema, serialization code,
and tests.
  • Loading branch information
Magisus committed Jun 7, 2017
1 parent 3313ecf commit c2e1c14
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
6 changes: 0 additions & 6 deletions api/schemas/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,6 @@
"type": "object",
"properties": {

"audited": {
"description": "True if this property is being audited, otherwise false. True in report of `inspect` kind.",
"type": "boolean"
},

"property": {
"description": "The property for which the event occurred.",
"oneOf": [
Expand Down Expand Up @@ -630,7 +625,6 @@
}
},
"required": [
"audited",
"property",
"message",
"name",
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/transaction/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class Puppet::Transaction::Event
include Puppet::Util::Logging
include Puppet::Network::FormatSupport

ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited, :invalidate_refreshes, :redacted, :corrective_change]
ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :invalidate_refreshes, :redacted, :corrective_change]
attr_accessor *ATTRIBUTES
attr_accessor :time
attr_reader :default_log_level

EVENT_STATUSES = %w{noop success failure audit}
EVENT_STATUSES = %w{noop success failure }

def self.from_data_hash(data)
obj = self.allocate
Expand All @@ -25,7 +25,6 @@ def self.from_data_hash(data)
end

def initialize(options = {})
@audited = false
@redacted = false
@corrective_change = false

Expand All @@ -40,7 +39,6 @@ def eql?(event)

def initialize_from_hash(data)
data = Puppet::Pops::Serialization::FromDataConverter.convert(data)
@audited = data['audited']
@property = data['property']
@previous_value = data['previous_value']
@desired_value = data['desired_value']
Expand All @@ -56,7 +54,6 @@ def initialize_from_hash(data)

def to_data_hash
hash = {
'audited' => @audited,
'property' => @property,
'previous_value' => @previous_value,
'desired_value' => @desired_value,
Expand Down
11 changes: 1 addition & 10 deletions spec/unit/transaction/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def [](v)
expect(event.status).to eq("success")
end

it "should fail if the status is not to 'audit', 'noop', 'success', or 'failure" do
it "should fail if the status is not to 'noop', 'success', or 'failure" do
event = Puppet::Transaction::Event.new
expect { event.status = "foo" }.to raise_error(ArgumentError)
end
Expand All @@ -54,12 +54,6 @@ def [](v)
expect(Puppet::Transaction::Event.new.time).to be_instance_of(Time)
end

describe "audit property" do
it "should default to false" do
expect(Puppet::Transaction::Event.new.audited).to eq(false)
end
end

describe "when sending logs" do
before do
Puppet::Util::Log.stubs(:new)
Expand Down Expand Up @@ -156,7 +150,6 @@ def [](v)

tripped = Puppet::Transaction::Event.from_data_hash(PSON.parse(event.to_pson))

expect(tripped.audited).to eq(event.audited)
expect(tripped.property).to eq(event.property)
expect(tripped.previous_value).to eq(event.previous_value)
expect(tripped.desired_value).to eq(event.desired_value)
Expand All @@ -170,7 +163,6 @@ def [](v)
it "should round trip an event for an inspect report through pson" do
resource = Puppet::Type.type(:file).new(:title => make_absolute("/tmp/foo"))
event = Puppet::Transaction::Event.new(
:audited => true,
:source_description => "/my/param",
:resource => resource,
:file => "/foo.rb",
Expand All @@ -187,7 +179,6 @@ def [](v)
expect(tripped.historical_value).to be_nil
expect(tripped.name).to be_nil

expect(tripped.audited).to eq(event.audited)
expect(tripped.property).to eq(event.property)
expect(tripped.previous_value).to eq(event.previous_value)
expect(tripped.message).to eq(event.message)
Expand Down
1 change: 0 additions & 1 deletion spec/unit/transaction/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ def expect_equivalent_resource_statuses(tripped, report)

def generate_report
event_hash = {
:audited => false,
:property => 'message',
:previous_value => SemanticPuppet::VersionRange.parse('>=1.0.0'),
:desired_value => SemanticPuppet::VersionRange.parse('>=1.2.0'),
Expand Down

0 comments on commit c2e1c14

Please sign in to comment.