Skip to content

Commit

Permalink
Fixes #37865 - Add Multi environments to activation key info
Browse files Browse the repository at this point in the history
Also enabled a skipped test that has been fixed since katello 4.5
  • Loading branch information
chris1984 committed Oct 1, 2024
1 parent a2797aa commit c07a1f0
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 25 deletions.
61 changes: 41 additions & 20 deletions lib/hammer_cli_katello/activation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,61 @@ def request_params
field :id, _("Id")
field :description, _("Description"), Fields::Field, :hide_blank => true
field :format_consumed, _("Host Limit")
field :auto_attach, _("Auto Attach")
field :multi_content_view_environment, _("Multi Content View Environment"), Fields::Boolean
field :release_version, _("Release Version"), Fields::Field, :hide_blank => true

from :environment do
field :name, _("Lifecycle Environment")
collection :organization, _("Organization") do
field :id, _("Id"), Fields::Field, :hide_blank => true
field :name, _("Name"), Fields::Field, :hide_blank => true
end
from :content_view do
field :name, _("Content View")

collection :content_view_environments, _('Content view environments') do
from :content_view do
label _("Content view") do
field :id, _("Id")
field :name, _("Name")
field :content_view_version, _("Version")
field :content_view_version_id, _("Content view version Id")
field :composite, _("Composite"), Fields::Boolean
end
end
from :lifecycle_environment do
label _("Lifecycle environment") do
field :id, _("Id")
field :name, _("Name")
end
end
field :candlepin_name, _("Candlepin Name")
end

collection :hosts, _("Associated Hosts") do
field :id, _('Id')
field :name, _("Name")
collection :hosts, _("Associated Hosts"), hide_blank: true, hide_empty: true do
field :id, _('Id'), Fields::Field, :hide_blank => true
field :name, _("Name"), Fields::Field, :hide_blank => true
end

collection :host_collections, _("Host Collections") do
field :id, _("Id")
field :name, _("Name")
collection :host_collections, _("Host Collections"), hide_blank: true, hide_empty: true do
field :id, _("Id"), Fields::Field, :hide_blank => true
field :name, _("Name"), Fields::Field, :hide_blank => true
end

collection :content_overrides, _("Content Overrides") do
field :content_label, _("Content Label")
field :name, _("Name")
field :value, _("Value")
collection :content_overrides, _("Content Overrides"), hide_blank: true, hide_empty: true do
field :content_label, _("Content Label"), Fields::Field, :hide_blank => true
field :name, _("Name"), Fields::Field, :hide_blank => true
field :value, _("Value"), Fields::Field, :hide_blank => true
end

label _("System Purpose") do
field :service_level, _('Service Level')
field :purpose_usage, _('Purpose Usage')
field :purpose_role, _('Purpose Role')
field :purpose_addons, _('Purpose Addons'), Fields::List
label _("System Purpose"), hide_blank: true, hide_empty: true do
field :service_level, _('Service Level'), Fields::Field, :hide_blank => true
field :purpose_usage, _('Purpose Usage'), Fields::Field, :hide_blank => true
field :purpose_role, _('Purpose Role'), Fields::Field, :hide_blank => true
field :purpose_addons, _('Purpose Addons'), Fields::List, :hide_blank => true
end
end

def extend_data(data)
# rubocop:disable Layout/LineLength
# Hack to hide purpose addons if it's not set since it's not possible to hide the Fields::List values
data["purpose_addons"].length.positive? ? data["purpose_addons"] = data["purpose_addons"] : data["purpose_addons"] = nil
limit = data["unlimited_hosts"] ? _("Unlimited") : data["max_hosts"]

data["format_consumed"] = _("%{consumed} of %{limit}") %
Expand All @@ -99,6 +119,7 @@ def extend_data(data)
:limit => limit
}
data
# rubocop:enable Layout/LineLength
end

build_options
Expand Down
1 change: 1 addition & 0 deletions test/data/4.14/foreman_api.json

Large diffs are not rendered by default.

44 changes: 43 additions & 1 deletion test/functional/activation_key/data/activation_key.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,47 @@
"name": "Library",
"id": 1
},
"purpose_addons": "Test Addon1, Test Addon2"
"purpose_addons": "Test Addon1, Test Addon2",
"multi_content_view_environment": true,
"organization": {
"name": "Default Organization",
"label": "Default_Organization",
"id": 1
},
"content_view_environments": [
{
"content_view": {
"id": 2,
"name": "RHEL-8",
"composite": false,
"content_view_version": "1.0",
"content_view_version_id": 4,
"content_view_version_latest": true,
"content_view_default": false
},
"lifecycle_environment": {
"id": 1,
"name": "Library",
"lifecycle_environment_library": true
},
"candlepin_name": "Library/RHEL-8"
},
{
"content_view": {
"id": 4,
"name": "Zoo",
"composite": false,
"content_view_version": "1.0",
"content_view_version_id": 2,
"content_view_version_latest": true,
"content_view_default": false
},
"lifecycle_environment": {
"id": 2,
"name": "Dev",
"lifecycle_environment_library": false
},
"candlepin_name": "Dev/Zoo"
}
]
}
30 changes: 28 additions & 2 deletions test/functional/activation_key/info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,37 @@

result = run_cmd(@cmd + params)

expected_fields = [['Description', 'Activation key'],
expected_fields = [['Name', 'test key2'],
['Id', '1'],
['Description', 'Activation key'],
['Purpose Usage', 'Usage'],
['Purpose Role', 'Role'],
['Purpose Addons', 'Test Addon1, Test Addon2'],
['Lifecycle Environment', 'Library']]
['Multi Content View Environment', 'yes'],
['Organization', ''],
['Id', '1'],
['Name', 'Default Organization'],
['Content view environments', ''],
['Content view', ''],
['Id', '2'],
['Name', 'RHEL-8'],
['Version', '1.0'],
['Content view version Id', '4'],
['Composite', 'no'],
['Lifecycle environment', ''],
['Id', '1'],
['Name', 'Library'],
['Candlepin Name', 'Library/RHEL-8'],
['Content view', ''],
['Id', '4'],
['Name', 'Zoo'],
['Version', '1.0'],
['Content view version Id', '2'],
['Composite', 'no'],
['Lifecycle environment', ''],
['Id', '2'],
['Name', 'Dev'],
['Candlepin Name', 'Dev/Zoo']]

expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
expected_results.each { |expected| assert_cmd(expected, result) }
Expand Down
1 change: 0 additions & 1 deletion test/functional/repository/update_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module HammerCLIKatello # rubocop:disable Metrics/ModuleLength
}
end
it "adds a tag to an image" do
skip "Until we https://projects.theforeman.org/issues/34817 is resolved"
ex = api_expects(:content_uploads, :create)
.with_params('repository_id' => repo_id, :size => 0)

Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'hammer_cli'
require 'ostruct'

KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.10')
KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.14')

if HammerCLI.context[:api_connection]
HammerCLI.context[:api_connection].create('foreman') do
Expand Down

0 comments on commit c07a1f0

Please sign in to comment.