fakes3 0.1.6.0 → 0.1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afc9d8c94ab0b848399aae28b8031acf3a27cadb
4
- data.tar.gz: d46b07e6f772a54bcece517ae7a7c6517a4243c8
3
+ metadata.gz: 69d4e3942f56c4509fb48ff63077170b7be0cef0
4
+ data.tar.gz: f02b9f875c59110a0247c2fae8a65fd819e355e2
5
5
  SHA512:
6
- metadata.gz: 9db326bbb641bfedc2be1553b1846dcaab6a886d133a50be6912de8bce365a4bf509e73399650508148d125bee1cd11039a2988d2a644d081f7bdc2ef79f79d3
7
- data.tar.gz: 3dafd2e1c59227812fd5b004c99e8a9c41287402d154cc3eea8d70fba121b94b6d88822e37f173e5362de976f8d7a46c39ec1dedbcb63fb0ee8a854a33d3861b
6
+ metadata.gz: 7011a1d606e2336f6b344b64c341aa1fc96a571aa60cddf5044bea0aa9afe376fa2d42e8113de3f418ed7862a4f9681c11d3076bea217776226da38f4d591d7c
7
+ data.tar.gz: 9e6566785bb12340bd0b4eeb23464c2b02c9b343cf4742b19747e6f7de3b5fd753703e91e349231537960fe347dde22da8859002fbb4cfd86bc5d9945b493d89
data/.gitignore CHANGED
@@ -3,3 +3,6 @@ pkg/*
3
3
  .bundle
4
4
  tmp
5
5
  test_root
6
+
7
+ # Don't check in RVM/rbenv files
8
+ .ruby-version
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fakes3 (0.1.6.0)
4
+ fakes3 (0.1.6.1)
5
5
  builder
6
6
  thor
7
7
 
@@ -7,9 +7,10 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Curtis Spencer"]
9
9
  s.email = ["thorin@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/jubos/fake-s3"
11
11
  s.summary = %q{FakeS3 is a server that simulates S3 commands so you can test your S3 functionality in your projects}
12
12
  s.description = %q{Use FakeS3 to test basic S3 functionality without actually connecting to S3}
13
+ s.license = "MIT"
13
14
 
14
15
  s.rubyforge_project = "fakes3"
15
16
 
@@ -12,6 +12,9 @@ module FakeS3
12
12
  method_option :address, :type => :string, :aliases => '-a', :required => false, :desc => "Bind to this address. Defaults to 0.0.0.0"
13
13
  method_option :hostname, :type => :string, :aliases => '-h', :desc => "The root name of the host. Defaults to s3.amazonaws.com."
14
14
  method_option :limit, :aliases => '-l', :type => :string, :desc => 'Rate limit for serving (ie. 50K, 1.0M)'
15
+ method_option :sslcert, :type => :string, :desc => 'Path to SSL certificate'
16
+ method_option :sslkey, :type => :string, :desc => 'Path to SSL certificate key'
17
+
15
18
  def server
16
19
  store = nil
17
20
  if options[:root]
@@ -21,8 +24,7 @@ module FakeS3
21
24
  end
22
25
 
23
26
  if store.nil?
24
- puts "You must specify a root to use a file store (the current default)"
25
- exit(-1)
27
+ abort "You must specify a root to use a file store (the current default)"
26
28
  end
27
29
 
28
30
  hostname = 's3.amazonaws.com'
@@ -38,15 +40,20 @@ module FakeS3
38
40
  begin
39
41
  store.rate_limit = options[:limit]
40
42
  rescue
41
- puts $!.message
42
- exit(-1)
43
+ abort $!.message
43
44
  end
44
45
  end
45
46
 
46
47
  address = options[:address] || '0.0.0.0'
48
+ ssl_cert_path = options[:sslcert]
49
+ ssl_key_path = options[:sslkey]
50
+
51
+ if (ssl_cert_path.nil? && !ssl_key_path.nil?) || (!ssl_cert_path.nil? && ssl_key_path.nil?)
52
+ abort "If you specify an SSL certificate you must also specify an SSL certificate key"
53
+ end
47
54
 
48
55
  puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostname #{hostname}"
49
- server = FakeS3::Server.new(address,options[:port],store,hostname)
56
+ server = FakeS3::Server.new(address,options[:port],store,hostname,ssl_cert_path,ssl_key_path)
50
57
  server.serve
51
58
  end
52
59
 
@@ -9,6 +9,11 @@ require 'yaml'
9
9
  module FakeS3
10
10
  class FileStore
11
11
  SHUCK_METADATA_DIR = ".fakes3_metadataFFF"
12
+ # S3 clients with overly strict date parsing fails to parse ISO 8601 dates
13
+ # without any sub second precision (e.g. jets3t v0.7.2), and the examples
14
+ # given in the official AWS S3 documentation specify three (3) decimals for
15
+ # sub second precision.
16
+ SUBSECOND_PRECISION = 3
12
17
 
13
18
  def initialize(root)
14
19
  @root = root
@@ -82,8 +87,10 @@ module FakeS3
82
87
  #real_obj.io = File.open(File.join(obj_root,"content"),'rb')
83
88
  real_obj.io = RateLimitableFile.open(File.join(obj_root,"content"),'rb')
84
89
  real_obj.size = metadata.fetch(:size) { 0 }
85
- real_obj.creation_date = File.ctime(obj_root).utc.iso8601()
86
- real_obj.modified_date = metadata.fetch(:modified_date) { File.mtime(File.join(obj_root,"content")).utc.iso8601() }
90
+ real_obj.creation_date = File.ctime(obj_root).utc.iso8601(SUBSECOND_PRECISION)
91
+ real_obj.modified_date = metadata.fetch(:modified_date) do
92
+ File.mtime(File.join(obj_root,"content")).utc.iso8601(SUBSECOND_PRECISION)
93
+ end
87
94
  real_obj.custom_metadata = metadata.fetch(:custom_metadata) { {} }
88
95
  return real_obj
89
96
  rescue
@@ -218,13 +225,14 @@ module FakeS3
218
225
  metadata[:md5] = Digest::MD5.file(content).hexdigest
219
226
  metadata[:content_type] = request.header["content-type"].first
220
227
  metadata[:size] = File.size(content)
221
- metadata[:modified_date] = File.mtime(content).utc.iso8601()
228
+ metadata[:modified_date] = File.mtime(content).utc.iso8601(SUBSECOND_PRECISION)
229
+ metadata[:custom_metadata] = {}
222
230
 
223
231
  # Add custom metadata from the request header
224
232
  request.header.each do |key, value|
225
233
  match = /^x-amz-meta-(.*)$/.match(key)
226
- if match
227
- metadata_struct[:custom_metadata][match[1]] = value.join(', ')
234
+ if match && (match_key = match[1])
235
+ metadata[:custom_metadata][match_key] = value.join(', ')
228
236
  end
229
237
  end
230
238
  return metadata
@@ -1,5 +1,7 @@
1
1
  require 'time'
2
2
  require 'webrick'
3
+ require 'webrick/https'
4
+ require 'openssl'
3
5
  require 'fakes3/file_store'
4
6
  require 'fakes3/xml_adapter'
5
7
  require 'fakes3/bucket_query'
@@ -171,10 +173,10 @@ module FakeS3
171
173
  filename = 'default'
172
174
  filename = $1 if request.body =~ /filename="(.*)"/
173
175
  key=key.gsub('${filename}', filename)
174
-
176
+
175
177
  bucket_obj = @store.get_bucket(s_req.bucket) || @store.create_bucket(s_req.bucket)
176
178
  real_obj=@store.store_object(bucket_obj, key, s_req.webrick_request)
177
-
179
+
178
180
  response['Etag'] = "\"#{real_obj.md5}\""
179
181
  response.body = ""
180
182
  if success_action_redirect
@@ -212,11 +214,11 @@ module FakeS3
212
214
  response.status = 204
213
215
  response.body = ""
214
216
  end
215
-
217
+
216
218
  def do_OPTIONS(request, response)
217
219
  super
218
220
  response["Access-Control-Allow-Origin"]="*"
219
- end
221
+ end
220
222
 
221
223
  private
222
224
 
@@ -322,7 +324,7 @@ module FakeS3
322
324
  def normalize_post(webrick_req,s_req)
323
325
  path = webrick_req.path
324
326
  path_len = path.size
325
-
327
+
326
328
  s_req.path = webrick_req.query['key']
327
329
 
328
330
  s_req.webrick_request = webrick_req
@@ -373,15 +375,30 @@ module FakeS3
373
375
 
374
376
 
375
377
  class Server
376
- def initialize(address,port,store,hostname)
378
+ def initialize(address,port,store,hostname,ssl_cert_path,ssl_key_path)
377
379
  @address = address
378
380
  @port = port
379
381
  @store = store
380
382
  @hostname = hostname
383
+ @ssl_cert_path = ssl_cert_path
384
+ @ssl_key_path = ssl_key_path
385
+ webrick_config = {
386
+ :BindAddress => @address,
387
+ :Port => @port
388
+ }
389
+ if !@ssl_cert_path.to_s.empty?
390
+ webrick_config.merge!(
391
+ {
392
+ :SSLEnable => true,
393
+ :SSLCertificate => OpenSSL::X509::Certificate.new(File.read(@ssl_cert_path)),
394
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read(@ssl_key_path))
395
+ }
396
+ )
397
+ end
398
+ @server = WEBrick::HTTPServer.new(webrick_config)
381
399
  end
382
400
 
383
401
  def serve
384
- @server = WEBrick::HTTPServer.new(:BindAddress => @address, :Port => @port)
385
402
  @server.mount "/", Servlet, @store,@hostname
386
403
  trap "INT" do @server.shutdown end
387
404
  @server.start
@@ -1,3 +1,3 @@
1
1
  module FakeS3
2
- VERSION = "0.1.6.0"
2
+ VERSION = "0.1.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6.0
4
+ version: 0.1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curtis Spencer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,8 +146,9 @@ files:
146
146
  - test/s3_commands_test.rb
147
147
  - test/s3cmd_test.rb
148
148
  - test/test_helper.rb
149
- homepage: ''
150
- licenses: []
149
+ homepage: https://github.com/jubos/fake-s3
150
+ licenses:
151
+ - MIT
151
152
  metadata: {}
152
153
  post_install_message:
153
154
  rdoc_options: []