File: s3_client_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (33 lines) | stat: -rw-r--r-- 933 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Aws::S3Client, feature_category: :audit_events do
  let_it_be(:region) { 'eu-west-1' }
  let_it_be(:access_key_id) { 'AKIARANDOM123' }
  let_it_be(:secret_access_key) { 'TOPSECRET/XYZ' }

  let(:s3_client) { described_class.new(access_key_id, secret_access_key, region) }

  describe '#upload_object' do
    let(:key) { 'file.txt' }
    let(:bucket_name) { 'gitlab-audit-logs' }
    let(:body) { 'content' }
    let(:content_type) { 'Text/plain' }

    it 'calls put_object with correct params' do
      allow_next_instance_of(Aws::S3::Client) do |s3_client|
        expect(s3_client).to receive(:put_object).with(
          {
            key: key,
            bucket: bucket_name,
            body: body,
            content_type: 'Text/plain'
          }
        )
      end

      s3_client.upload_object(key, bucket_name, body, content_type)
    end
  end
end