revenc 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.document +5 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +30 -0
  4. data/CLONING.rdoc +108 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +198 -0
  7. data/Rakefile +64 -0
  8. data/VERSION +1 -0
  9. data/bin/revenc +81 -0
  10. data/config/cucumber.yml +7 -0
  11. data/examples/rsync/encrypted_data/key/encfs6.xml +35 -0
  12. data/examples/rsync/revenc.conf +18 -0
  13. data/examples/rsync/scripts/passphrase +1 -0
  14. data/examples/rsync/unencrypted_data/test_file1.txt +1 -0
  15. data/examples/rsync/unencrypted_data/test_file2.txt +1 -0
  16. data/examples/simple/encfs6.xml +35 -0
  17. data/examples/simple/passphrase +1 -0
  18. data/examples/simple/unencrypted_data/test_file1.txt +1 -0
  19. data/examples/simple/unencrypted_data/test_file2.txt +1 -0
  20. data/features/app.feature +59 -0
  21. data/features/bin.feature +35 -0
  22. data/features/configuration.feature +98 -0
  23. data/features/copy.feature +169 -0
  24. data/features/generator.feature +15 -0
  25. data/features/mount.feature +133 -0
  26. data/features/step_definitions/.gitignore +0 -0
  27. data/features/step_definitions/revenc_steps.rb +64 -0
  28. data/features/support/aruba.rb +21 -0
  29. data/features/support/env.rb +4 -0
  30. data/features/support/hooks.rb +6 -0
  31. data/features/unmount.feature +58 -0
  32. data/lib/revenc/app.rb +128 -0
  33. data/lib/revenc/encfs_wrapper.rb +96 -0
  34. data/lib/revenc/errors.rb +78 -0
  35. data/lib/revenc/io.rb +265 -0
  36. data/lib/revenc/lockfile.rb +66 -0
  37. data/lib/revenc.rb +22 -0
  38. data/spec/revenc/error_spec.rb +50 -0
  39. data/spec/revenc/io_spec.rb +185 -0
  40. data/spec/revenc/lockfile_spec.rb +44 -0
  41. data/spec/spec.opts +2 -0
  42. data/spec/spec_helper.rb +16 -0
  43. data/spec/watchr.rb +142 -0
  44. metadata +179 -0
@@ -0,0 +1,185 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Revenc::FileSystemEntity do
4
+
5
+ before(:each) do
6
+ FileUtils.rm_rf(current_dir)
7
+ end
8
+
9
+ describe Revenc::TextFile do
10
+
11
+ it "should be valid" do
12
+ filename = "text_file"
13
+ create_file(filename, "passphrase")
14
+ text_file = Revenc::TextFile.new(fullpath(filename))
15
+ text_file.should be_valid
16
+ end
17
+
18
+ it "should return a fully qualified file name" do
19
+ filename = "text_file"
20
+ create_file(filename, "passphrase")
21
+ relative_path_filename = File.join('tmp', 'aruba', filename)
22
+ text_file = Revenc::TextFile.new(relative_path_filename)
23
+ text_file.should be_valid
24
+ text_file.name.should_not be(filename)
25
+ text_file.name.should_not be(relative_path_filename)
26
+ text_file.name.should == fullpath(filename)
27
+ end
28
+
29
+ it "should return a name for non-existing files" do
30
+ filename = "text_file"
31
+ relative_path_filename = File.join('tmp', 'aruba', filename)
32
+ text_file = Revenc::TextFile.new(relative_path_filename)
33
+ text_file.name.should_not be(filename)
34
+ text_file.name.should be(relative_path_filename)
35
+ end
36
+
37
+ it "should be valid if empty" do
38
+ filename = "text_file"
39
+ create_file(filename, "")
40
+ text_file = Revenc::TextFile.new(fullpath(filename))
41
+ text_file.should be_valid
42
+ end
43
+
44
+ it "should not be valid if name missing" do
45
+ text_file = Revenc::TextFile.new
46
+ text_file.should_not be_valid
47
+ end
48
+
49
+ describe Revenc::PassphraseFile do
50
+
51
+ it "should be valid" do
52
+ filename = "text_file"
53
+ create_file(filename, "passphrase")
54
+ text_file = Revenc::PassphraseFile.new(fullpath(filename))
55
+ text_file.should be_valid
56
+ end
57
+
58
+ it "should not be valid if empty" do
59
+ filename = "text_file"
60
+ create_file(filename, "")
61
+ text_file = Revenc::PassphraseFile.new(fullpath(filename))
62
+ text_file.exists?.should be(true)
63
+ text_file.should_not be_valid
64
+ text_file.errors.to_sentences.should match(/is empty/)
65
+ end
66
+
67
+ end
68
+
69
+ describe Revenc::KeyFile do
70
+
71
+ it "should be valid" do
72
+ filename = "encfs6.xml"
73
+ create_file(filename, "DOCTYPE boost_serialization")
74
+ text_file = Revenc::KeyFile.new(fullpath(filename))
75
+ text_file.should be_valid
76
+ end
77
+
78
+ it "should not be valid if empty" do
79
+ filename = "encfs6.xml"
80
+ create_file(filename, "")
81
+ text_file = Revenc::KeyFile.new(fullpath(filename))
82
+ text_file.exists?.should be(true)
83
+ text_file.should_not be_valid
84
+ text_file.errors.to_sentences.should match(/is empty/)
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
91
+ describe Revenc::FileFolder do
92
+
93
+ it "should be valid if empty" do
94
+ foldername = "folder1"
95
+ create_dir(foldername)
96
+ file_folder = Revenc::FileFolder.new(fullpath(foldername))
97
+ file_folder.should be_valid
98
+ file_folder.empty?.should be(true)
99
+ end
100
+
101
+ it "should return a fully qualified folder name" do
102
+ foldername = "folder1"
103
+ create_dir(foldername)
104
+ relative_path_foldername = File.join('tmp', 'aruba', foldername)
105
+ file_folder = Revenc::FileFolder.new(relative_path_foldername)
106
+ file_folder.should be_valid
107
+ file_folder.name.should_not be(foldername)
108
+ file_folder.name.should_not be(relative_path_foldername)
109
+ file_folder.name.should == fullpath(foldername)
110
+ end
111
+
112
+ it "should not be valid if missing" do
113
+ foldername = "folder1"
114
+ file_folder = Revenc::FileFolder.new(fullpath(foldername))
115
+ file_folder.exists?.should be(false)
116
+ file_folder.should_not be_valid
117
+ file_folder.errors.to_sentences.should match(/not found/)
118
+ end
119
+
120
+ it "should return true on a call to empty? if folder missing" do
121
+ foldername = "folder1"
122
+ file_folder = Revenc::FileFolder.new(fullpath(foldername))
123
+ file_folder.exists?.should be(false)
124
+ file_folder.should_not be_valid
125
+ file_folder.empty?.should be(true)
126
+ end
127
+
128
+ describe Revenc::ActionFolder do
129
+
130
+ it "should process ERB in cmd" do
131
+ foldername = "folder1"
132
+ file_folder = Revenc::ActionFolder.new(fullpath(foldername))
133
+ file_folder.exists?.should be(false)
134
+ file_folder.cmd = "<%= \"hello world\" %>"
135
+ file_folder.cmd.should == "hello world"
136
+ end
137
+
138
+ it "should process instance vars in ERB cmd" do
139
+ foldername = "folder1"
140
+ file_folder = Revenc::ActionFolder.new(fullpath(foldername))
141
+ file_folder.exists?.should be(false)
142
+ file_folder.cmd = "hello <%= name %>"
143
+ file_folder.cmd.should eql("hello #{file_folder.name}")
144
+ file_folder.cmd.should_not eql("hello ")
145
+ end
146
+
147
+ describe Revenc::MountPoint do
148
+
149
+ it "should have an accessor 'mountpoint' equal to self" do
150
+ foldername = "folder1"
151
+ mountpoint = Revenc::MountPoint.new(fullpath(foldername))
152
+ mountpoint.name.should eql(fullpath(foldername))
153
+ mountpoint.mountpoint.name.should == mountpoint.name
154
+ end
155
+
156
+ it "should not be valid if encfs executable not found" do
157
+ # stub out check for executable with double that can't find encfs
158
+ double = Revenc::MountPoint.new
159
+ double.stub!(:executable).and_return('')
160
+ Revenc::MountPoint.stub!(:new).and_return(double)
161
+
162
+ file_folder = Revenc::MountPoint.new
163
+ file_folder.validate
164
+ file_folder.errors.to_sentences.should match(/encfs executable not found/)
165
+ end
166
+ end
167
+
168
+ describe Revenc::UnmountPoint do
169
+
170
+ it "should not be valid if fusermount executable not found" do
171
+ # stub out check for executable with double that can't find fusermount
172
+ double = Revenc::UnmountPoint.new
173
+ double.stub!(:executable).and_return('')
174
+ Revenc::UnmountPoint.stub!(:new).and_return(double)
175
+
176
+ file_folder = Revenc::UnmountPoint.new
177
+ file_folder.validate
178
+ file_folder.errors.to_sentences.should match(/fusermount executable not found/)
179
+ end
180
+ end
181
+ end
182
+
183
+ end
184
+ end
185
+
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Revenc::Mutex do
4
+
5
+ before(:each) do
6
+ FileUtils.rm_rf(current_dir)
7
+ end
8
+
9
+ describe 'mutex' do
10
+
11
+ it "should create a mutex, yield, and clean up" do
12
+ in_current_dir do
13
+ mutex = Revenc::Mutex.new
14
+ result = mutex.execute do
15
+ File.should be_file('revenc.lck')
16
+ mutex.should be_locked
17
+ end
18
+ result.should be_true
19
+ mutex.should_not be_locked
20
+ File.should_not be_file('revenc.lck')
21
+ end
22
+ end
23
+
24
+ it "should prevent recursion but not block" do
25
+ in_current_dir do
26
+ Revenc::Mutex.new.execute do
27
+ File.should be_file('revenc.lck')
28
+
29
+ mutext = Revenc::Mutex.new
30
+ result = mutext.execute do
31
+ # This block is protected, should not be here
32
+ true.should be(false)
33
+ end
34
+ result.should be_false
35
+ mutext.should be_locked
36
+ end
37
+ File.should_not be_file('revenc.lck')
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'revenc'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'aruba/api'
7
+
8
+ # aruba helper, returns to full path to files
9
+ # in the aruba tmp folder
10
+ def fullpath(filename)
11
+ File.expand_path(File.join(current_dir, filename))
12
+ end
13
+
14
+ Spec::Runner.configure do |config|
15
+ config.include Aruba::Api
16
+ end
data/spec/watchr.rb ADDED
@@ -0,0 +1,142 @@
1
+ # Watchr: Autotest like functionality
2
+ #
3
+ # Run me with:
4
+ #
5
+ # $ watchr spec/watchr.rb
6
+
7
+ require 'term/ansicolor'
8
+
9
+ $c = Term::ANSIColor
10
+
11
+ def getch
12
+ state = `stty -g`
13
+ begin
14
+ `stty raw -echo cbreak`
15
+ $stdin.getc
16
+ ensure
17
+ `stty #{state}`
18
+ end
19
+ end
20
+
21
+ # --------------------------------------------------
22
+ # Convenience Methods
23
+ # --------------------------------------------------
24
+ def all_feature_files
25
+ Dir['features/*.feature']
26
+ end
27
+
28
+ def all_spec_files
29
+ files = Dir['spec/revenc/*.rb']
30
+ end
31
+
32
+ def run(cmd)
33
+
34
+ pid = fork do
35
+ puts "\n"
36
+ print $c.cyan, cmd, $c.clear, "\n"
37
+ exec(cmd)
38
+ end
39
+ Signal.trap('INT') do
40
+ puts "sending KILL to pid: #{pid}"
41
+ Process.kill("KILL", pid)
42
+ end
43
+ Process.waitpid(pid)
44
+
45
+ prompt
46
+ end
47
+
48
+ def run_all
49
+ run_all_specs
50
+ run_default_cucumber
51
+ end
52
+
53
+ # allow cucumber rerun.txt smarts
54
+ def run_default_cucumber
55
+ cmd = "cucumber"
56
+ run(cmd)
57
+ end
58
+
59
+ def run_all_features
60
+ cmd = "cucumber #{all_feature_files.join(' ')}"
61
+ run(cmd)
62
+ end
63
+
64
+ def run_feature(feature)
65
+ cmd = "cucumber #{feature}"
66
+ $last_feature = feature
67
+ run(cmd)
68
+ end
69
+
70
+ def run_last_feature
71
+ run_feature($last_feature) if $last_feature
72
+ end
73
+
74
+ def run_default_spec
75
+ cmd = "spec --color --format s ./spec"
76
+ run(cmd)
77
+ end
78
+
79
+ def run_all_specs
80
+ cmd = "spec --color --format s #{all_spec_files.join(' ')}"
81
+ p cmd
82
+ run(cmd)
83
+ end
84
+
85
+ def run_spec(spec)
86
+ cmd = "spec --color --format s #{spec}"
87
+ $last_spec = spec
88
+ run(cmd)
89
+ end
90
+
91
+ def run_last_spec
92
+ run_spec($last_spec) if $last_spec
93
+ end
94
+
95
+ def prompt
96
+ puts "Ctrl-\\ for menu, Ctrl-C to quit"
97
+ end
98
+
99
+ # init
100
+ $last_feature = nil
101
+ prompt
102
+
103
+ # --------------------------------------------------
104
+ # Watchr Rules
105
+ # --------------------------------------------------
106
+ #watch( '^features/(.*)\.feature' ) { |m| run_feature(m[0]) }
107
+ watch( '^features/(.*)\.feature' ) { run_default_cucumber }
108
+
109
+ watch( '^bin/(.*)' ) { run_default_cucumber }
110
+ watch( '^lib/(.*)' ) { run_default_cucumber }
111
+
112
+ watch( '^features/step_definitions/(.*)\.rb' ) { run_default_cucumber }
113
+ watch( '^features/support/(.*)\.rb' ) { run_default_cucumber }
114
+
115
+ watch( '^spec/(.*)_spec\.rb' ) { |m| run_spec(m[0]) }
116
+ # watch( '^lib/revenc/io.rb' ) { run_default_spec }
117
+ watch( '^lib/revenc/errors.rb' ) { run_default_spec }
118
+ watch( '^lib/revenc/lockfile.rb' ) { run_default_spec }
119
+
120
+ # --------------------------------------------------
121
+ # Signal Handling
122
+ # --------------------------------------------------
123
+
124
+ # Ctrl-\
125
+ Signal.trap('QUIT') do
126
+
127
+ puts "\n\nMENU: a = all , f = features s = specs, l = last feature (#{$last_feature ? $last_feature : 'none'}), q = quit\n\n"
128
+ c = getch
129
+ puts c.chr
130
+ if c.chr == "a"
131
+ run_all
132
+ elsif c.chr == "f"
133
+ run_default_cucumber
134
+ elsif c.chr == "s"
135
+ run_all_specs
136
+ elsif c.chr == "q"
137
+ abort("exiting\n")
138
+ elsif c.chr == "l"
139
+ run_last_feature
140
+ end
141
+
142
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: revenc
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 2
9
+ version: 0.1.2
10
+ platform: ruby
11
+ authors:
12
+ - Robert Wahler
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-12 00:00:00 -05:00
18
+ default_executable: revenc
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: term-ansicolor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 4
31
+ version: 1.0.4
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: configatron
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 5
44
+ - 1
45
+ version: 2.5.1
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 2
58
+ - 9
59
+ version: 1.2.9
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: cucumber
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ - 6
72
+ version: "0.6"
73
+ type: :development
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: aruba
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ - 1
85
+ - 7
86
+ version: 0.1.7
87
+ type: :development
88
+ version_requirements: *id005
89
+ description: |-
90
+ Mount, unmount, and copy/synchronize encrypted files to
91
+ untrusted destinations using EncFS and rsync
92
+ email: robert@gearheadforhire.com
93
+ executables:
94
+ - revenc
95
+ extensions: []
96
+
97
+ extra_rdoc_files:
98
+ - LICENSE
99
+ - README.rdoc
100
+ files:
101
+ - .document
102
+ - .gitattributes
103
+ - .gitignore
104
+ - CLONING.rdoc
105
+ - LICENSE
106
+ - README.rdoc
107
+ - Rakefile
108
+ - VERSION
109
+ - bin/revenc
110
+ - config/cucumber.yml
111
+ - examples/rsync/encrypted_data/key/encfs6.xml
112
+ - examples/rsync/revenc.conf
113
+ - examples/rsync/scripts/passphrase
114
+ - examples/rsync/unencrypted_data/test_file1.txt
115
+ - examples/rsync/unencrypted_data/test_file2.txt
116
+ - examples/simple/encfs6.xml
117
+ - examples/simple/passphrase
118
+ - examples/simple/unencrypted_data/test_file1.txt
119
+ - examples/simple/unencrypted_data/test_file2.txt
120
+ - features/app.feature
121
+ - features/bin.feature
122
+ - features/configuration.feature
123
+ - features/copy.feature
124
+ - features/generator.feature
125
+ - features/mount.feature
126
+ - features/step_definitions/.gitignore
127
+ - features/step_definitions/revenc_steps.rb
128
+ - features/support/aruba.rb
129
+ - features/support/env.rb
130
+ - features/support/hooks.rb
131
+ - features/unmount.feature
132
+ - lib/revenc.rb
133
+ - lib/revenc/app.rb
134
+ - lib/revenc/encfs_wrapper.rb
135
+ - lib/revenc/errors.rb
136
+ - lib/revenc/io.rb
137
+ - lib/revenc/lockfile.rb
138
+ - spec/revenc/error_spec.rb
139
+ - spec/revenc/io_spec.rb
140
+ - spec/revenc/lockfile_spec.rb
141
+ - spec/spec.opts
142
+ - spec/spec_helper.rb
143
+ - spec/watchr.rb
144
+ has_rdoc: true
145
+ homepage: http://github.com/robertwahler/revenc
146
+ licenses: []
147
+
148
+ post_install_message:
149
+ rdoc_options:
150
+ - --charset=UTF-8
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ segments:
158
+ - 0
159
+ version: "0"
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ requirements: []
168
+
169
+ rubyforge_project:
170
+ rubygems_version: 1.3.6
171
+ signing_key:
172
+ specification_version: 3
173
+ summary: Helper for reverse mounting encrypted file systems
174
+ test_files:
175
+ - spec/spec_helper.rb
176
+ - spec/watchr.rb
177
+ - spec/revenc/lockfile_spec.rb
178
+ - spec/revenc/io_spec.rb
179
+ - spec/revenc/error_spec.rb