ftpmvc-gpg 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5392adeeee961dafdcf2102567bcef7afd0e1992
4
+ data.tar.gz: ccf073afb1e1ea1dd5c8ff03febfbbbaddae3f3d
5
+ SHA512:
6
+ metadata.gz: 107da1310efc682b26e039b35ac5ee3e400960234553c188b1329544e3ab10fe164fc0c77a9c8ff7a5d8c2675373e34b2da6adc9cf7d6c8915092acf7c8a00ea
7
+ data.tar.gz: 2376cc2c89afbf172d0ebf754795de001f957c8027d91e509687da25cf94d230ccda531dbedff4dbf9f7e224d34ceb9b2e5e477ae1ff00c5553848ecaa0c2a66
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ftpmvc-gpg.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,33 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+
17
+ # Rails example
18
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
20
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
21
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
22
+ watch('config/routes.rb') { "spec/routing" }
23
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
24
+ watch('spec/rails_helper.rb') { "spec" }
25
+
26
+ # Capybara features specs
27
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
28
+
29
+ # Turnip features and steps
30
+ watch(%r{^spec/acceptance/(.+)\.feature$})
31
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
32
+ end
33
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 André Aizim Kelmanson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ftpmvc::Gpg
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ftpmvc-gpg'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ftpmvc-gpg
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/ftpmvc-gpg/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ftpmvc/gpg/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ftpmvc-gpg"
8
+ spec.version = FTPMVC::GPG::VERSION
9
+ spec.authors = ["André Aizim Kelmanson"]
10
+ spec.email = ["akelmanson@gmail.com"]
11
+ spec.summary = "FTPMVC filter to encrypt/decrypt files"
12
+ spec.description = "FTPMVC filter to encrypt/decrypt files"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "guard-rspec"
24
+ spec.add_dependency "ftpmvc"
25
+ spec.add_dependency "gpgme"
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'ftpmvc/filter'
2
+ require 'gpgme'
3
+
4
+ module FTPMVC
5
+ module GPG
6
+ class Filter < FTPMVC::Filter
7
+ def initialize(fs, chain, options={})
8
+ super fs, chain
9
+ @crypto = GPGME::Crypto.new recipients: options[:recipients]
10
+ end
11
+
12
+ def index(path)
13
+ @chain.index(path).each do |node|
14
+ if node.kind_of?(File) and not ::File.extname(node.name) == '.gpg'
15
+ node.name = "#{node.name}.gpg"
16
+ end
17
+ end
18
+ end
19
+
20
+ def get(path)
21
+ StringIO.new(@crypto.encrypt(GPGME::Data.from_io(@chain.get(path))).read)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module FTPMVC
2
+ module GPG
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/ftpmvc/gpg.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'ftpmvc/gpg/version'
2
+ require 'ftpmvc/gpg/filter'
3
+
4
+ module FTPMVC
5
+ module GPG
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ require './spec/spec_helper'
2
+ require 'ftpmvc'
3
+ require 'ftpmvc/gpg'
4
+ require 'net/ftp'
5
+
6
+
7
+ describe FTPMVC::GPG::Filter do
8
+ let(:app) do
9
+ FTPMVC::Application.new do
10
+
11
+ filter FTPMVC::GPG::Filter, recipients: 'john.doe@gmail.com'
12
+
13
+ filesystem do
14
+ directory :encrypted
15
+ end
16
+ end
17
+ end
18
+
19
+ before do
20
+ class EncryptedDirectory < FTPMVC::Directory
21
+ def index
22
+ super + [ FTPMVC::File.new('password.txt') ]
23
+ end
24
+
25
+ def get(path)
26
+ StringIO.new('secret')
27
+ end
28
+ end
29
+ end
30
+
31
+ describe 'LIST' do
32
+ it 'includes .gpg to filenames extension' do
33
+ with_application(app) do |ftp|
34
+ ftp.login
35
+ expect(ftp.list('/encrypted')).to include(/password.txt.gpg/)
36
+ end
37
+ end
38
+ end
39
+ describe 'GET/RETR' do
40
+ it 'encrypts files content' do
41
+ with_application(app) do |ftp|
42
+ ftp.login
43
+ expect(get(ftp, '/encrypted/password.txt.gpg').size).to eq 342
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ require 'ftpmvc/gpg/filter'
2
+ require 'ftpmvc/file'
3
+ require 'ftpmvc/directory'
4
+
5
+ describe FTPMVC::GPG::Filter do
6
+ before do
7
+ stub_const 'OtherFilter', Class.new(FTPMVC::Filter)
8
+ end
9
+ let(:other_filter) { OtherFilter.new(nil, nil) }
10
+ let(:gpg_filter) { FTPMVC::GPG::Filter.new(nil, other_filter, recipients: 'john.doe@gmail.com') }
11
+ describe '#index' do
12
+ before do
13
+ allow(other_filter)
14
+ .to receive(:index)
15
+ .and_return [ FTPMVC::File.new(original_filename), FTPMVC::Directory.new('documents') ]
16
+ end
17
+ let(:original_filename) { 'secret.txt' }
18
+ it 'adds .gpg extension to files returned by chain' do
19
+ expect(gpg_filter.index('/').map(&:name)).to include 'secret.txt.gpg'
20
+ end
21
+ context 'when file already has .gpg as extensions' do
22
+ let(:original_filename) { 'secret.txt.gpg' }
23
+ it 'keeps filename untouched' do
24
+ expect(gpg_filter.index('/').map(&:name)).to include 'secret.txt.gpg'
25
+ end
26
+ end
27
+ it 'keeps directory names untouched' do
28
+ expect(gpg_filter.index('/').map(&:name)).to include 'documents'
29
+ end
30
+ context 'when file already has .gpg as extensions' do
31
+ let(:original_filename) { 'secret.txt.gpg' }
32
+ it 'keeps filename unchanged' do
33
+ expect(gpg_filter.index('/').map(&:name)).to include 'secret.txt.gpg'
34
+ end
35
+ end
36
+ end
37
+
38
+ describe '#get' do
39
+ before do
40
+ allow(other_filter)
41
+ .to receive(:get)
42
+ .and_return StringIO.new('secret')
43
+ end
44
+ it 'encrypts original content' do
45
+ expect(gpg_filter.get('/file.txt.gpg').read.size).to eq 342
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ require 'ftpmvc/test_helpers'
2
+
3
+ RSpec.configure do |config|
4
+ config.include FTPMVC::TestHelpers
5
+ config.before :each do
6
+ ActiveSupport::Dependencies.clear
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ftpmvc-gpg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - André Aizim Kelmanson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ftpmvc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gpgme
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: FTPMVC filter to encrypt/decrypt files
84
+ email:
85
+ - akelmanson@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - Guardfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - ftpmvc-gpg.gemspec
99
+ - lib/ftpmvc/gpg.rb
100
+ - lib/ftpmvc/gpg/filter.rb
101
+ - lib/ftpmvc/gpg/version.rb
102
+ - spec/integration/ftpmvc/gpg/filter_spec.rb
103
+ - spec/lib/ftpmvc/gpg/filter_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: ''
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: FTPMVC filter to encrypt/decrypt files
129
+ test_files:
130
+ - spec/integration/ftpmvc/gpg/filter_spec.rb
131
+ - spec/lib/ftpmvc/gpg/filter_spec.rb
132
+ - spec/spec_helper.rb