Sha256: f3980edf59a82f43a81ef508114590432b92e0f25b0557e38ceb8a1e9bb8d4ac

Contents?: true

Size: 1.26 KB

Versions: 22

Compression:

Stored size: 1.26 KB

Contents

require "test_helper"

describe S3Relay::UploadPresigner do
  before do
    S3Relay::UploadPresigner.any_instance.stubs(:access_key_id)
      .returns("access-key-id")
    S3Relay::UploadPresigner.any_instance.stubs(:secret_access_key)
      .returns("secret-access-key")
    S3Relay::UploadPresigner.any_instance.stubs(:region)
      .returns("region")
    S3Relay::UploadPresigner.any_instance.stubs(:bucket)
      .returns("bucket")
    S3Relay::UploadPresigner.any_instance.stubs(:acl)
      .returns("acl")
  end

  describe "#form_data" do
    it do
      uuid = SecureRandom.uuid
      time = Time.parse("2014-12-01 12:00am")

      S3Relay::UploadPresigner.any_instance.stubs(:uuid).returns(uuid)

      data = S3Relay::UploadPresigner.new(expires: time).form_data

      data["awsaccesskeyid"].must_equal "access-key-id"
      data["x_amz_server_side_encryption"].must_equal "AES256"
      data["key"].must_equal "#{uuid}/${filename}"
      data["success_action_status"].must_equal "201"
      data["acl"].must_equal "acl"
      data["endpoint"].must_equal "https://bucket.s3-region.amazonaws.com"
      data["policy"].length.must_equal 400  # TODO: Improve this
      data["signature"].length.must_equal 28  # TODO: Improve this
      data["uuid"].must_equal uuid
    end
  end

end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
s3_relay-0.6.2 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.6.1 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.7 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.6 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.5 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.4 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.3 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.2 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.1 test/lib/s3_relay/upload_presigner_test.rb
mongoid-direct-s3-upload-0.1.0 test/lib/s3_relay/upload_presigner_test.rb
mongoid_direct_s3_upload-0.1.0 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.6.0 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.5.1 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.5.0 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.4.2 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.4.1 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.4.0 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.3.2 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.3.1 test/lib/s3_relay/upload_presigner_test.rb
s3_relay-0.3.0 test/lib/s3_relay/upload_presigner_test.rb