audit 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/audit.gemspec +2 -2
- data/lib/audit.rb +1 -1
- data/lib/audit/log.rb +1 -1
- data/lib/audit/tracking.rb +1 -1
- data/test/log_test.rb +12 -1
- data/test/storage-conf.xml +1 -1
- data/test/test_helper.rb +4 -0
- metadata +3 -3
data/audit.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'audit'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '2010-11-
|
16
|
+
s.version = '0.5.0'
|
17
|
+
s.date = '2010-11-17'
|
18
18
|
s.rubyforge_project = 'audit'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/audit.rb
CHANGED
data/lib/audit/log.rb
CHANGED
@@ -20,7 +20,7 @@ module Audit::Log
|
|
20
20
|
# Returns nothing.
|
21
21
|
def self.record(bucket, key, timestamp, changes)
|
22
22
|
json = Yajl::Encoder.encode(changes)
|
23
|
-
payload = {
|
23
|
+
payload = {timestamp => json}
|
24
24
|
connection.insert(:Audits, "#{bucket}:#{key}", payload)
|
25
25
|
end
|
26
26
|
|
data/lib/audit/tracking.rb
CHANGED
@@ -34,7 +34,7 @@ module Audit::Tracking
|
|
34
34
|
end
|
35
35
|
|
36
36
|
data = {"changes" => changes, "metadata" => audit_metadata}
|
37
|
-
Audit::Tracking.log.record(audit_bucket, self.id, Time.now.utc, data)
|
37
|
+
Audit::Tracking.log.record(audit_bucket, self.id, Time.now.utc.iso8601, data)
|
38
38
|
@audit_metadata = {}
|
39
39
|
end
|
40
40
|
|
data/test/log_test.rb
CHANGED
@@ -7,6 +7,12 @@ class LogTest < Test::Unit::TestCase
|
|
7
7
|
Audit::Log.record(:Users, 1, timestamp, simple_change)
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
11
|
+
should "save audit records idempotently" do
|
12
|
+
t = Time.now.utc.iso8601
|
13
|
+
3.times { Audit::Log.record(:Users, 1, t, simple_change) }
|
14
|
+
assert_equal 1, Audit::Log.audits(:Users, 1).length
|
15
|
+
end
|
10
16
|
|
11
17
|
should "load audit records" do
|
12
18
|
Audit::Log.record(:Users, 1, timestamp, simple_change)
|
@@ -23,8 +29,13 @@ class LogTest < Test::Unit::TestCase
|
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
32
|
+
def teardown
|
33
|
+
# FIXME: figure out how to properly clear a keyspace or CF
|
34
|
+
Audit::Log.connection.remove(:Audits, "Users:1")
|
35
|
+
end
|
36
|
+
|
26
37
|
def timestamp
|
27
|
-
Time.now.utc
|
38
|
+
Time.now.utc.iso8601
|
28
39
|
end
|
29
40
|
|
30
41
|
def simple_change
|
data/test/storage-conf.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<Keyspaces>
|
3
3
|
<Keyspace Name="Audit">
|
4
4
|
<KeysCachedFraction>0.01</KeysCachedFraction>
|
5
|
-
<ColumnFamily CompareWith="
|
5
|
+
<ColumnFamily CompareWith="UTF8Type" Name="Audits" />
|
6
6
|
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
7
7
|
<ReplicationFactor>1</ReplicationFactor>
|
8
8
|
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 5
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adam Keys
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-17 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|