Project

General

Profile

Download (1.12 KB) Statistics
| Branch: | Tag: | Revision:

foreman_docker / test / units / docker_registry_test.rb @ a79b7ae3

1
require 'test_plugin_helper'
2

    
3
class DockerRegistryTest < ActiveSupport::TestCase
4
  test 'used_location_ids should return correct location ids' do
5
    location = FactoryGirl.build(:location)
6
    r = as_admin do
7
      FactoryGirl.create(:docker_registry, :locations => ([location]))
8
    end
9
    assert r.used_location_ids.include?(location.id)
10
  end
11

    
12
  test 'used_organization_ids should return correct organization ids' do
13
    organization = FactoryGirl.build(:organization)
14
    r = as_admin do
15
      FactoryGirl.create(:docker_registry, :organizations => ([organization]))
16
    end
17
    assert r.used_organization_ids.include?(organization.id)
18
  end
19

    
20
  test 'password is stored encrypted' do
21
    registry = as_admin { FactoryGirl.build(:docker_registry) }
22
    registry.password = 'encrypted-whatever'
23
    DockerRegistry.any_instance.expects(:encryption_key).at_least_once.returns('fakeencryptionkey')
24
    assert registry.is_decryptable?(registry.password_in_db)
25
  end
26

    
27
  %w(name url).each do |property|
28
    test "registries need a #{property}" do
29
      refute FactoryGirl.build(:docker_registry, property.to_sym => '').valid?
30
    end
31
  end
32
end