Sha256: a53bb68c02b21ab314c196481655a7290f3f39744c89cdcce2f3925e34f80949

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

require "helpers/test_helper"

class UnitTestJsonRequests < MiniTest::Test
  def setup
    Fog.mock!
    @client = Fog::Storage.new(provider: "google",
                               google_project: "",
                               google_json_key_location: "")
  end

  def teardown
    Fog.unmock!
  end

  def test_get_url_path_has_query_params
    url = @client.get_object_url("bucket",
                                 "just some file.json",
                                 Time.now + 2 * 60,
                                 query: { "projection" => 'full, noAcl"' })

    assert_match(/projection=full%2C%20noAcl/, url,
                 "query string should be escaped")
  end

  def test_get_url_filter_nil_query_params
    url = @client.get_object_url("bucket",
                                 "just some file.json",
                                 Time.now + 2 * 60,
                                 query: { "projection" => nil })

    refute_match(/projection/, url,
                 "nil query params should be omitted")
  end

  def test_put_url_path_is_properly_escaped
    url = @client.put_object_url("bucket",
                                 "just some file.json",
                                 Time.now + 2 * 60,
                                 "Content-Type" => "application/json")

    assert_match(/just%20some%20file\.json/, url,
                 "space should be escaped with '%20'")
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
gitlab-fog-google-1.14.0 test/unit/storage/test_json_requests.rb
fog-google-1.13.0 test/unit/storage/test_json_requests.rb
gitlab-fog-google-1.13.0 test/unit/storage/test_json_requests.rb
fog-google-1.12.1 test/unit/storage/test_json_requests.rb
fog-google-1.12.0 test/unit/storage/test_json_requests.rb
fog-google-1.11.0 test/unit/storage/test_json_requests.rb
fog-google-1.10.0 test/unit/storage/test_json_requests.rb
fog-google-1.9.1 test/unit/storage/test_json_requests.rb
fog-google-1.9.0 test/unit/storage/test_json_requests.rb