Sha256: a466a8544b6045cba473c1a3ba2a356980e0d3dafd3b9d28a622160df5d07dd5

Contents?: true

Size: 1.44 KB

Versions: 42

Compression:

Stored size: 1.44 KB

Contents

describe Ufo::Ecr::Auth do
  let(:repo_domain) { "123456789.dkr.ecr.us-east-1.amazonaws.com" }
  let(:username) { "user" }
  let(:password) { "opensesame" }
  let(:auth) { Ufo::Ecr::Auth.new(repo_domain) }
  before(:each) do
    allow(auth).to receive(:fetch_auth_token).and_return(Base64.encode64("#{username}:#{password}"))
  end

  context("update") do
    context("with ecr repo") do
      context("when login successful") do
        it "should create the auth token" do
          command = "docker login -u #{username} --password-stdin #{repo_domain}"
          command_result = double(success?: true)
          expect(Open3).to receive(:capture3)
            .with(command, stdin_data: password)
            .and_return(['', '', command_result])

          auth.update
        end
      end

      context("when login failed") do
        it "should exit with code 1" do
          command = "docker login -u #{username} --password-stdin #{repo_domain}"
          command_result = double(success?: false)
          expect(Open3).to receive(:capture3)
            .with(command, stdin_data: password)
            .and_return(['', '', command_result])
          expect(auth).to receive(:exit).with(1)

          auth.update
        end
      end
    end

    context("with not ecr repo") do
      let(:repo_domain) { "example/test" }

      it "should not update credentials" do
        expect(Open3).not_to receive(:capture3)

        auth.update
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
ufo-6.3.13 spec/ufo/ecr_auth_spec.rb
ufo-6.3.12 spec/ufo/ecr_auth_spec.rb
ufo-6.3.11 spec/ufo/ecr_auth_spec.rb
ufo-6.3.10 spec/ufo/ecr_auth_spec.rb
ufo-6.3.9 spec/ufo/ecr_auth_spec.rb
ufo-6.3.8 spec/ufo/ecr_auth_spec.rb
ufo-6.3.7 spec/ufo/ecr_auth_spec.rb
ufo-6.3.6 spec/ufo/ecr_auth_spec.rb
ufo-6.3.5 spec/ufo/ecr_auth_spec.rb
ufo-6.3.4 spec/ufo/ecr_auth_spec.rb
ufo-6.3.3 spec/ufo/ecr_auth_spec.rb
ufo-6.3.2 spec/ufo/ecr_auth_spec.rb
ufo-6.3.1 spec/ufo/ecr_auth_spec.rb
ufo-6.3.0 spec/ufo/ecr_auth_spec.rb
ufo-6.2.5 spec/ufo/ecr_auth_spec.rb
ufo-6.2.4 spec/ufo/ecr_auth_spec.rb
ufo-6.2.3 spec/ufo/ecr_auth_spec.rb
ufo-6.2.2 spec/ufo/ecr_auth_spec.rb
ufo-6.2.1 spec/ufo/ecr_auth_spec.rb
ufo-6.2.0 spec/ufo/ecr_auth_spec.rb