GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

registry_spec.rb 1.03 KB
Newer Older
1 2 3 4 5 6
require 'spec_helper'

describe Gitlab::Ci::Build::Credentials::Registry do
  let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
  let(:registry_url) { 'registry.example.com:5005' }

7
  subject { described_class.new(build) }
8 9 10 11 12 13

  before do
    stub_container_registry_config(host_port: registry_url)
  end

  it 'contains valid DockerRegistry credentials' do
14
    expect(subject).to be_kind_of(described_class)
15 16 17 18 19 20 21 22

    expect(subject.username).to eq 'gitlab-ci-token'
    expect(subject.password).to eq build.token
    expect(subject.url).to eq registry_url
    expect(subject.type).to eq 'registry'
  end

  describe '.valid?' do
23
    subject { described_class.new(build).valid? }
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

    context 'when registry is enabled' do
      before do
        stub_container_registry_config(enabled: true)
      end

      it { is_expected.to be_truthy }
    end

    context 'when registry is disabled' do
      before do
        stub_container_registry_config(enabled: false)
      end

      it { is_expected.to be_falsey }
    end
  end
end