Sha256: f03ae5cd762ba306587d54735b9be1a394eadccde2006d641acba993de424b03

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Ufo::EcrAuth do
  let(:repo_domain) { "https://123456789.dkr.ecr.us-east-1.amazonaws.com" }
  let(:auth) { Ufo::EcrAuth.new(repo_domain) }
  before(:each) do
    allow(auth).to receive(:fetch_auth_token).and_return("opensesame")
  end

  context("update") do
    before(:each) do
      clean_home
      ENV['HOME'] = "spec/fixtures/home"
    end

    context("missing ~/.docker/config.json") do
      it "should create the auth token" do
        auth.update
        data = JSON.load(IO.read("spec/fixtures/home/.docker/config.json"))
        auth_token = data["auths"][repo_domain]["auth"]
        expect(auth_token).to eq("opensesame")
      end
    end

    context("existing ~/.docker/config.json") do
      it "should update the auth token" do
        FileUtils.cp_r("spec/fixtures/home_existing", "spec/fixtures/home")
        auth.update
        data = JSON.load(IO.read("spec/fixtures/home/.docker/config.json"))
        auth_token = data["auths"][repo_domain]["auth"]
        expect(auth_token).to eq("opensesame")
      end
    end
  end

  def clean_home
    FileUtils.rm_rf("spec/fixtures/home")
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ufo-1.2.0 spec/lib/ecr_auth_spec.rb
ufo-1.1.0 spec/lib/ecr_auth_spec.rb
ufo-1.0.1 spec/lib/ecr_auth_spec.rb
ufo-1.0.0 spec/lib/ecr_auth_spec.rb
ufo-0.1.6 spec/lib/ecr_auth_spec.rb
ufo-0.1.5 spec/lib/ecr_auth_spec.rb
ufo-0.1.4 spec/lib/ecr_auth_spec.rb
ufo-0.1.3 spec/lib/ecr_auth_spec.rb
ufo-0.1.2 spec/lib/ecr_auth_spec.rb
ufo-0.1.1 spec/lib/ecr_auth_spec.rb
ufo-0.1.0 spec/lib/ecr_auth_spec.rb
ufo-0.0.6 spec/lib/ecr_auth_spec.rb