<commit_before>describe Envoku::Adapters::S3 do
  let!(:uri) { URI("s3://example-bucket/test.env") }
  let!(:adapter) { described_class.new(uri) }

  it { expect(adapter.is_a?(Envoku::Adapters::Http)).to eq(true) }

  describe "#config" do
    it "returns nil if URI is not valid" do
      expect(Envoku).to receive(:uri).and_return(nil)
      expect(adapter.send(:config)).to eq({})
    end

    it "returns hash with basic details" do
      expect(Envoku).to receive(:uri).and_return(uri)
      expect(adapter.send(:config)).to eq({
        'filename' => 'test.env',
        'bucket_name' => 'example-bucket',
      })
    end

    it "returns hash with auth details" do
      uri = URI("s3://abc123:XXX@example-bucket/test.env")
      expect(Envoku).to receive(:uri).and_return(uri)
      expect(adapter.send(:config)).to eq({
        'filename' => 'test.env',
        'bucket_name' => 'example-bucket',
        'access_key_id' => 'abc123',
        'secret_access_key' => 'XXX',
      })
    end
  end

  describe "#remote_uri" do
    it "returns direct_s3_url if not access tokens" do
      direct_url = 'http://s3.amazonaws.com/direct_s3_url'
      expect(adapter).to receive(:direct_s3_url).and_return(direct_url)
      expect(adapter.send(:remote_uri)).to eq(URI(direct_url))
    end

    it "returns signed_s3_url it access tokens are present" do
      adapter.instance_variable_set(:@_config, 'access_key_id' => '123', 'secret_access_key' => 'XXX')
      signed_url = 'http://s3.amazonaws.com/signed_s3_url'
      expect(adapter).to receive(:signed_s3_url).and_return(signed_url)
      expect(adapter.send(:remote_uri)).to eq(URI(signed_url))
    end
  end

  describe "#direct_s3_url" do
  end

  describe "#signed_s3_url" do
  end
end<commit_msg>Ensure non authenticated S3 URLs are constructed correctly<commit_after>describe Envoku::Adapters::S3 do
  let!(:uri) { URI("s3://example-bucket/test.env") }
  let!(:adapter) { described_class.new(uri) }

  it { expect(adapter.is_a?(Envoku::Adapters::Http)).to eq(true) }

  describe "#config" do
    it "returns nil if URI is not valid" do
      expect(Envoku).to receive(:uri).and_return(nil)
      expect(adapter.send(:config)).to eq({})
    end

    it "returns hash with basic details" do
      expect(Envoku).to receive(:uri).and_return(uri)
      expect(adapter.send(:config)).to eq({
        'filename' => 'test.env',
        'bucket_name' => 'example-bucket',
      })
    end

    it "returns hash with auth details" do
      uri = URI("s3://abc123:XXX@example-bucket/test.env")
      expect(Envoku).to receive(:uri).and_return(uri)
      expect(adapter.send(:config)).to eq({
        'filename' => 'test.env',
        'bucket_name' => 'example-bucket',
        'access_key_id' => 'abc123',
        'secret_access_key' => 'XXX',
      })
    end
  end

  describe "#remote_uri" do
    it "returns direct_s3_url if not access tokens" do
      direct_url = 'http://s3.amazonaws.com/direct_s3_url'
      expect(adapter).to receive(:direct_s3_url).and_return(direct_url)
      expect(adapter.send(:remote_uri)).to eq(URI(direct_url))
    end

    it "returns signed_s3_url it access tokens are present" do
      adapter.instance_variable_set(:@_config, 'access_key_id' => '123', 'secret_access_key' => 'XXX')
      signed_url = 'http://s3.amazonaws.com/signed_s3_url'
      expect(adapter).to receive(:signed_s3_url).and_return(signed_url)
      expect(adapter.send(:remote_uri)).to eq(URI(signed_url))
    end
  end

  describe "#direct_s3_url" do
    it "builds a basic http URL" do
      adapter.instance_variable_set(:@_config, 'filename' => 'test.env', 'bucket_name' => 'example-bucket')
      expect(adapter.send(:direct_s3_url)).to eq('https://example-bucket.s3.amazonaws.com/test.env')
    end
  end

  describe "#signed_s3_url" do
  end
end
{'fraction_non_alphanumeric': 0.15031479538300105, 'fraction_numerical': 0.012329485834207765, 'mean_word_length': 3.4964622641509435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1187162', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1286, 'n_words': 251}