cloud_encrypted_sync_s3_adapter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cloud_encrypted_sync_s3_adapter (0.
|
4
|
+
cloud_encrypted_sync_s3_adapter (0.3.0)
|
5
5
|
aws-sdk (~> 1.7.1)
|
6
|
-
cloud_encrypted_sync (~> 0.
|
6
|
+
cloud_encrypted_sync (~> 0.3.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
json (~> 1.4)
|
17
17
|
nokogiri (>= 1.4.4)
|
18
18
|
uuidtools (~> 2.1)
|
19
|
-
cloud_encrypted_sync (0.
|
19
|
+
cloud_encrypted_sync (0.3.0)
|
20
20
|
httparty (0.9.0)
|
21
21
|
multi_json (~> 1.0)
|
22
22
|
multi_xml
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = %q{Plugin adapter for CloudEncryptedSync gem that provides interface to AmazonS3.}
|
12
12
|
|
13
13
|
s.add_dependency('aws-sdk', '~> 1.7.1')
|
14
|
-
s.add_dependency('cloud_encrypted_sync', '~> 0.
|
14
|
+
s.add_dependency('cloud_encrypted_sync', '~> 0.3.0')
|
15
15
|
|
16
16
|
s.add_development_dependency('rake')
|
17
17
|
s.add_development_dependency('mocha')
|
@@ -3,15 +3,15 @@ require 'aws-sdk'
|
|
3
3
|
module CloudEncryptedSync
|
4
4
|
module Adapters
|
5
5
|
class S3 < Template
|
6
|
+
attr_accessor :bucket_name, :credentials
|
6
7
|
|
7
|
-
def parse_command_line_options(
|
8
|
-
|
9
|
-
|
8
|
+
def parse_command_line_options(parser)
|
9
|
+
parser.on('--bucket BUCKETNAME', 'Name of S3 bucket to use.') do |bucket_argument|
|
10
|
+
self.bucket_name = bucket_argument.to_sym
|
10
11
|
end
|
11
|
-
|
12
|
-
|
12
|
+
parser.on('--s3-credentials ACCESS_KEY_ID,SECRET_ACCESS_KEY', Array, "Credentials for your S3 account." ) do |credentials_argument|
|
13
|
+
self.credentials = credentials_argument
|
13
14
|
end
|
14
|
-
return command_line_options
|
15
15
|
end
|
16
16
|
|
17
17
|
def write(data, key)
|
@@ -38,18 +38,10 @@ module CloudEncryptedSync
|
|
38
38
|
private
|
39
39
|
#######
|
40
40
|
|
41
|
-
def credentials
|
42
|
-
Configuration.settings[:s3_credentials]
|
43
|
-
end
|
44
|
-
|
45
41
|
def connection
|
46
42
|
@connection ||= AWS::S3.new(:access_key_id => credentials[0], :secret_access_key => credentials[1])
|
47
43
|
end
|
48
44
|
|
49
|
-
def bucket_name
|
50
|
-
Configuration.settings[:bucket].to_sym
|
51
|
-
end
|
52
|
-
|
53
45
|
def bucket
|
54
46
|
connection.buckets[bucket_name]
|
55
47
|
end
|
data/test/unit/adapter_test.rb
CHANGED
@@ -7,15 +7,7 @@ module CloudEncryptedSyncS3Adapter
|
|
7
7
|
if File.exist?(CloudEncryptedSync::Configuration.send(:config_file_path))
|
8
8
|
@config = YAML.load_file(CloudEncryptedSync::Configuration.send(:config_file_path))
|
9
9
|
end
|
10
|
-
|
11
|
-
{
|
12
|
-
:excryption_key => 'abc',
|
13
|
-
:adapter => 's3',
|
14
|
-
:bucket => test_bucket_name,
|
15
|
-
:sync_path => '/non/existent/path',
|
16
|
-
:s3_credentials => @config['s3_credentials']
|
17
|
-
}
|
18
|
-
)
|
10
|
+
stub_configuration
|
19
11
|
create_test_bucket
|
20
12
|
end
|
21
13
|
|
@@ -24,14 +16,17 @@ module CloudEncryptedSyncS3Adapter
|
|
24
16
|
end
|
25
17
|
|
26
18
|
test 'should parse command line options' do
|
19
|
+
unstub_configuration
|
27
20
|
Object.send(:remove_const,:ARGV)
|
28
21
|
::ARGV = '--bucket foobar --s3-credentials KEY_ID,ACCESS_KEY'.split(/\s/)
|
29
22
|
@command_line_options = {}
|
30
|
-
@option_parser = OptionParser.new do |
|
31
|
-
|
23
|
+
@option_parser = OptionParser.new do |parser|
|
24
|
+
adapter.parse_command_line_options(parser)
|
32
25
|
end
|
33
26
|
@option_parser.parse!
|
34
|
-
assert_equal(
|
27
|
+
assert_equal(:foobar,CloudEncryptedSync::Adapters::S3.instance.bucket_name)
|
28
|
+
assert_equal(['KEY_ID','ACCESS_KEY'],CloudEncryptedSync::Adapters::S3.instance.credentials)
|
29
|
+
stub_configuration
|
35
30
|
end
|
36
31
|
|
37
32
|
test 'should write readable data to s3 and then delete it' do
|
@@ -80,5 +75,24 @@ module CloudEncryptedSyncS3Adapter
|
|
80
75
|
@test_bucket_name ||= "cloud_encrypted_sync_unit_test_bucket_#{Digest::SHA1.hexdigest(rand.to_s)}"
|
81
76
|
end
|
82
77
|
|
78
|
+
def stub_configuration
|
79
|
+
CloudEncryptedSync::Configuration.stubs(:settings).returns(
|
80
|
+
{
|
81
|
+
:excryption_key => 'abc',
|
82
|
+
:adapter => 's3',
|
83
|
+
:bucket => test_bucket_name,
|
84
|
+
:sync_path => '/non/existent/path',
|
85
|
+
:s3_credentials => @config['s3_credentials']
|
86
|
+
}
|
87
|
+
)
|
88
|
+
CloudEncryptedSync::Adapters::S3.any_instance.stubs(:bucket_name).returns(test_bucket_name)
|
89
|
+
CloudEncryptedSync::Adapters::S3.any_instance.stubs(:credentials).returns(@config['s3_credentials'])
|
90
|
+
end
|
91
|
+
|
92
|
+
def unstub_configuration
|
93
|
+
CloudEncryptedSync::Configuration.unstub(:settings)
|
94
|
+
CloudEncryptedSync::Adapters::S3.any_instance.unstub(:bucket_name)
|
95
|
+
CloudEncryptedSync::Adapters::S3.any_instance.unstub(:credentials)
|
96
|
+
end
|
83
97
|
end
|
84
98
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_encrypted_sync_s3_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.3.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.3.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|