key_control 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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a226c9ceecfaba7c34e789b1b075803b1c31fda1
4
- data.tar.gz: f5205dc20534d1be565527d3905ac2e51a6b0853
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmI3Yjk3YjQwODc1ZDcxZjVmYzBhZDgzYmY0MmE3NDAwZWZkNjBiNg==
5
+ data.tar.gz: !binary |-
6
+ ZDcxNmJmYWFiMjE0MThjZTFkY2ViZTk1Y2Q5YjA0N2NhYjEyNDVkMA==
5
7
  SHA512:
6
- metadata.gz: c7f52114b183f8c1be55fd2e9c49ae3f81cf2bde49e8d2940e4bd1b1deeba0bdba811634c2ed1258e0afe9599efc2d0aeed10b5751e60ce1790d64a7208c07e6
7
- data.tar.gz: 73b9a063cfe17fdda8ccce6dfb1d61cc5838a0f8130c345d96e4e7a1a9bc4cc66a6097610f4e1c44865a8e6a0cbeb212ef3fc780798916fc6f1f3b84be8fe2ad
8
+ metadata.gz: !binary |-
9
+ NzNlMjRhOGNlOTdjODRkYjE1ZTQ4NjhmZTM2Y2RjYTc2ZGQzNDMzYThhMzcx
10
+ Y2RkNmI2Y2ZkMzhjNGNlYTllNWE2NGNkNTYwYmE0ZmY3NGEwMGUyZjI1OWEz
11
+ ZWQyOWVlYTAxYTJjMjIwM2VjNWE5NGMwMjBiYjlkNThmNGZkYmM=
12
+ data.tar.gz: !binary |-
13
+ MjA2ZWYyMTgyM2Q1NDMwMGZiNWNhYzgwNjQxYTJhZWQ4ODQxOWU4MWE0NjFm
14
+ ZjAxNTM4NmM4ZWE1OTAyNWMxYjBhNTg4N2E1MThkNTU4MjdlNTg1MWRjZjIx
15
+ MWJiM2RlZjRhOTBjYTAyNTg2Y2IwMDAyMzNhYzNlMzRkMmNkMTA=
@@ -36,12 +36,5 @@ module KeyControl
36
36
 
37
37
  system.get(:read, handle)
38
38
  end
39
-
40
- # Public: Inspect the structure of and data stored in the current keyring.
41
- #
42
- # Returns
43
- def inspect
44
- system.get(:describe, @keyring)
45
- end
46
39
  end
47
40
  end
@@ -94,17 +94,5 @@ module KeyControl
94
94
  Fiddle::TYPE_SIZE_T ],
95
95
  Fiddle::TYPE_LONG )
96
96
  end
97
-
98
- # Private: Get a proc representing the keyctl_describe system call.
99
- #
100
- # Returns a Fiddle::Function.
101
- def describe
102
- @describe ||= Fiddle::Function.new(
103
- keyutils["keyctl_describe"],
104
- [ Fiddle::TYPE_INT,
105
- Fiddle::ALIGN_CHAR,
106
- Fiddle::TYPE_SIZE_T ],
107
- Fiddle::TYPE_INT )
108
- end
109
97
  end
110
98
  end
@@ -1,3 +1,3 @@
1
1
  module KeyControl
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
3
  describe KeyControl::KeyRing do
4
+ let(:secret) { "the secret time forgot" }
4
5
 
5
6
  describe "thread keyring" do
6
7
  let(:ring) do
@@ -8,18 +9,20 @@ describe KeyControl::KeyRing do
8
9
  end
9
10
 
10
11
  it "allows read/write for values in the same thread" do
11
- ring["testing"] = "testdata"
12
- ring["testing"].must_equal "testdata"
12
+ key = "single-thread-test"
13
+ ring[key].must_equal nil
14
+
15
+ ring[key] = secret
16
+ ring[key].must_equal secret
13
17
  end
14
18
 
15
19
  it "uses a new keyring for new threads" do
16
- ring["thread_test"].must_equal nil
17
- thr = Thread.new do
18
- ring["thread-test"] = "testdata"
19
- end
20
- thr.join
20
+ key = "multi-thread-test"
21
+ ring[key].must_equal nil
22
+
23
+ Thread.new { ring[key] = secret }.join
21
24
 
22
- ring["thread-test"].must_equal nil
25
+ ring[key].must_equal nil
23
26
  end
24
27
  end
25
28
 
@@ -29,31 +32,30 @@ describe KeyControl::KeyRing do
29
32
  end
30
33
 
31
34
  it "allows read/write of values in the same process" do
32
- ring["process-test-1"] = "foobar"
33
- ring["process-test-1"].must_equal "foobar"
35
+ key = "single-process-test"
36
+ ring[key].must_equal nil
37
+
38
+ ring[key] = secret
39
+ ring[key].must_equal secret
34
40
  end
35
41
 
36
42
  it "allows read/write of values across threads in the same process" do
37
- ring["process-thread-test"].must_equal nil
43
+ key = "process-thread-test"
44
+ ring[key].must_equal nil
38
45
 
39
- thr = Thread.new do
40
- ring["process-thread-test"] = "baz"
41
- end
42
- thr.join
46
+ Thread.new { ring[key] = secret }.join
43
47
 
44
- ring["process-thread-test"].must_equal "baz"
48
+ ring[key].must_equal secret
45
49
  end
46
50
 
47
51
  it "uses a new keyring for new processes" do
48
- ring["child-process-test"].must_equal nil
49
-
50
- pid = fork do
51
- ring["child-process-test"] = "too many secrets"
52
- exit
53
- end
52
+ key = "multi-process-test"
53
+ ring[key].must_equal nil
54
54
 
55
+ pid = fork { ring[key] = secret and exit }
55
56
  Process.waitpid(pid)
56
- ring["child-process-test"].must_equal nil
57
+
58
+ ring[key].must_equal nil
57
59
  end
58
60
  end
59
61
 
@@ -62,31 +64,31 @@ describe KeyControl::KeyRing do
62
64
  KeyControl::KeyRing.new(KeyControl::SESSION)
63
65
  end
64
66
 
65
- it "allows read/write of values in the same process" do
66
- ring["session-test"] = "foobar"
67
- ring["session-test"].must_equal "foobar"
67
+ it "allows read/write of values in the same thread/process" do
68
+ key = "session-test"
69
+ ring[key].must_equal nil
70
+
71
+ ring[key] = secret
72
+ ring[key].must_equal secret
68
73
  end
69
74
 
70
75
  it "allows read/write of values across threads in the same process" do
71
- ring["session-thread-test"].must_equal nil
72
- thr = Thread.new do
73
- ring["session-thread-test"] = "baz"
74
- end
75
- thr.join
76
+ key = "session-thread-test"
77
+ ring[key].must_equal nil
78
+
79
+ Thread.new { ring[key] = secret }.join
76
80
 
77
- ring["session-thread-test"].must_equal "baz"
81
+ ring[key].must_equal secret
78
82
  end
79
83
 
80
84
  it "allows read/write of values across processes in the same session" do
81
- ring["session-process-test"].must_equal nil
82
-
83
- pid = fork do
84
- ring["session-process-test"] = "too many secrets"
85
- exit
86
- end
85
+ key = "session-process-test"
86
+ ring[key].must_equal nil
87
87
 
88
+ pid = fork { ring[key] = secret and exit }
88
89
  Process.waitpid(pid)
89
- ring["session-process-test"].must_equal "too many secrets"
90
+
91
+ ring[key].must_equal secret
90
92
  end
91
93
  end
92
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,19 +28,18 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: |2
42
- Provides a Hash-like syntax for storing and retrieving data from the
43
- system's keyctl utility.
41
+ description: ! " Provides a Hash-like syntax for storing and retrieving data from
42
+ the\n system's keyctl utility.\n"
44
43
  email:
45
44
  - andrew@tablexi.com
46
45
  executables: []
@@ -71,17 +70,17 @@ require_paths:
71
70
  - lib
72
71
  required_ruby_version: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - '>='
73
+ - - ! '>='
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  required_rubygems_version: !ruby/object:Gem::Requirement
78
77
  requirements:
79
- - - '>='
78
+ - - ! '>='
80
79
  - !ruby/object:Gem::Version
81
80
  version: '0'
82
81
  requirements: []
83
82
  rubyforge_project:
84
- rubygems_version: 2.0.6
83
+ rubygems_version: 2.2.2
85
84
  signing_key:
86
85
  specification_version: 4
87
86
  summary: A simple wrapper for the `keyctl` utility.