|
| 1 | +require 'katello_test_helper' |
| 2 | + |
| 3 | +module ::Actions::Pulp3 |
| 4 | + class DockerUpdateTest < ActiveSupport::TestCase |
| 5 | + include Katello::Pulp3Support |
| 6 | + |
| 7 | + def setup |
| 8 | + @master = FactoryBot.create(:smart_proxy, :default_smart_proxy, :with_pulp3) |
| 9 | + @repo = katello_repositories(:busybox) |
| 10 | + create_repo(@repo, @master) |
| 11 | + |
| 12 | + ForemanTasks.sync_task( |
| 13 | + ::Actions::Katello::Repository::MetadataGenerate, @repo, |
| 14 | + repository_creation: true) |
| 15 | + |
| 16 | + assert_equal 1, |
| 17 | + Katello::Pulp3::DistributionReference.where(root_repository_id: @repo.root.id).count, |
| 18 | + "Expected a distribution reference." |
| 19 | + @repo.root.update_attributes( |
| 20 | + verify_ssl_on_sync: false, |
| 21 | + ssl_ca_cert: katello_gpg_keys(:unassigned_gpg_key), |
| 22 | + ssl_client_cert: katello_gpg_keys(:unassigned_gpg_key), |
| 23 | + ssl_client_key: katello_gpg_keys(:unassigned_gpg_key)) |
| 24 | + end |
| 25 | + |
| 26 | + def test_update_ssl_validation |
| 27 | + refute @repo.root.verify_ssl_on_sync, "Respository verify_ssl_on_sync option was false." |
| 28 | + @repo.root.update_attributes( |
| 29 | + verify_ssl_on_sync: true) |
| 30 | + |
| 31 | + ForemanTasks.sync_task( |
| 32 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 33 | + @repo, |
| 34 | + @master) |
| 35 | + end |
| 36 | + |
| 37 | + def test_update_url |
| 38 | + @repo.root.update_attributes( |
| 39 | + url: 'http://website.com/') |
| 40 | + |
| 41 | + ForemanTasks.sync_task( |
| 42 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 43 | + @repo, |
| 44 | + @master) |
| 45 | + end |
| 46 | + |
| 47 | + def test_update_upstream_name |
| 48 | + @repo.root.update_attributes( |
| 49 | + docker_upstream_name: 'test') |
| 50 | + |
| 51 | + ForemanTasks.sync_task( |
| 52 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 53 | + @repo, |
| 54 | + @master) |
| 55 | + end |
| 56 | + |
| 57 | + def test_update_whitelist_tags |
| 58 | + @repo.root.update_attributes( |
| 59 | + docker_tags_whitelist: 'test_tag') |
| 60 | + |
| 61 | + ForemanTasks.sync_task( |
| 62 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 63 | + @repo, |
| 64 | + @master) |
| 65 | + end |
| 66 | + |
| 67 | + def test_update_whitelist_tags_empty |
| 68 | + @repo.root.update_attributes( |
| 69 | + docker_tags_whitelist: nil) |
| 70 | + |
| 71 | + ForemanTasks.sync_task( |
| 72 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 73 | + @repo, |
| 74 | + @master) |
| 75 | + end |
| 76 | + |
| 77 | + def test_update_unset_unprotected |
| 78 | + assert @repo.root.unprotected |
| 79 | + assert_equal 1, Katello::Pulp3::DistributionReference.where( |
| 80 | + root_repository_id: @repo.root.id).count |
| 81 | + |
| 82 | + @repo.root.update_attributes(unprotected: false) |
| 83 | + |
| 84 | + ForemanTasks.sync_task( |
| 85 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 86 | + @repo, |
| 87 | + @master) |
| 88 | + |
| 89 | + dist_refs = Katello::Pulp3::DistributionReference.where( |
| 90 | + root_repository_id: @repo.root.id) |
| 91 | + |
| 92 | + assert_equal 1, dist_refs.count, "Expected 1 distribution reference." |
| 93 | + end |
| 94 | + |
| 95 | + def test_update_set_unprotected |
| 96 | + @repo.root.update_attributes(unprotected: false) |
| 97 | + |
| 98 | + ForemanTasks.sync_task( |
| 99 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 100 | + @repo, |
| 101 | + @master) |
| 102 | + |
| 103 | + dist_refs = Katello::Pulp3::DistributionReference.where( |
| 104 | + root_repository_id: @repo.root.id) |
| 105 | + |
| 106 | + assert_equal 1, dist_refs.count, "Expected only 1 distribution reference." |
| 107 | + @repo.root.update_attributes(unprotected: true) |
| 108 | + |
| 109 | + ForemanTasks.sync_task( |
| 110 | + ::Actions::Pulp3::Orchestration::Repository::Update, |
| 111 | + @repo, |
| 112 | + @master) |
| 113 | + |
| 114 | + dist_refs = Katello::Pulp3::DistributionReference.where( |
| 115 | + root_repository_id: @repo.root.id) |
| 116 | + assert_equal 1, dist_refs.count, "Expected a distribution reference." |
| 117 | + end |
| 118 | + end |
| 119 | +end |
0 commit comments