Bug 1156536 - hammer activation-key allows bad max-content-hosts value when unlimited-content-hosts is true
Summary: hammer activation-key allows bad max-content-hosts value when unlimited-conte...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Management
Version: Nightly
Hardware: Unspecified
OS: Unspecified
unspecified
low vote
Target Milestone: Unspecified
Assignee: Christine Fouant
QA Contact: Corey Welton
URL: http://projects.theforeman.org/issues...
Whiteboard: Verified in Upstream
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-24 16:00 UTC by jaudet
Modified: 2019-09-25 20:49 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 09:11:33 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 12270 None None None 2016-04-22 16:40:53 UTC
Red Hat Product Errata RHBA-2016:1501 normal SHIPPED_LIVE Red Hat Satellite 6.2 Capsule and Server 2016-07-27 12:28:58 UTC

Description jaudet 2014-10-24 16:00:46 UTC
Description of problem:
This command fails, as it should:

    hammer activation-key create \
        --organization-id X \
        --name Y \
        --max-content-hosts -5

However, this command succeeds:

    hammer activation-key create \
        --organization-id X \
        --name Y \
        --max-content-hosts -5 \
        --unlimited-content-hosts true

As demonstrated above, `hammer activation-key` allows an invalid value for the `--max-content-hosts` option when `--unlimited-content-hosts` is true. Some invalid values are correctly disallowed, such as alphanumeric strings. However, any negative number appears to be OK. Here's a more concrete example:

    $ hammer activation-key create \
        --organization-id 5 \
        --name foobar4 \
        --max-content-hosts -1 \
        --unlimited-content-hosts true
    Activation key created
    $ hammer activation-key info \
        --organization-id 5 \
        --name foobar4
    name:                  foobar4
    ID:                    53
    Description:
    Lifecycle Environment:
    Content View:
    Host Collections:

The `max-content-hosts` option is entirely ignored.

    >>> attrs = ActivationKey(id=53).read_json()
    >>> for attr in ('unlimited_content_hosts', 'max_content_hosts'):
    ...     print(attrs[attr])
    ...
    True
    None

Version-Release number of selected component (if applicable):
Tested against a nightly build of Satellite 6 on a machine with the following packages installed:

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.32-1.el6.noarch
* candlepin-common-1.0.8-1.el6.noarch
* candlepin-selinux-0.9.32-1.el6.noarch
* candlepin-tomcat6-0.9.32-1.el6.noarch
* elasticsearch-0.90.10-7.el6.noarch
* foreman-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-compute-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-gce-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-libvirt-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-ovirt-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-postgresql-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-proxy-1.7.0-0.develop.201410221520gitccd77aa.el6.noarch
* foreman-release-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* foreman-selinux-1.7.0-0.develop.201410210825gitaab37c6.el6.noarch
* foreman-vmware-1.7.0-0.develop.201410232354git5e8706d.el6.noarch
* katello-2.1.0-1.201410231000gitac15899.el6.noarch
* katello-certs-tools-2.0.1-1.el6.noarch
* katello-default-ca-1.0-1.noarch
* katello-installer-2.1.0-1.201410162242git33b9fc3.el6.noarch
* katello-repos-2.1.1-1.el6.noarch
* katello-server-ca-1.0-1.noarch
* openldap-2.4.23-32.el6_4.1.x86_64
* pulp-docker-plugins-0.2.1-0.2.beta.el6.noarch
* pulp-katello-0.3-3.el6.noarch
* pulp-nodes-common-2.5.0-0.7.beta.el6.noarch
* pulp-nodes-parent-2.5.0-0.7.beta.el6.noarch
* pulp-puppet-plugins-2.5.0-0.7.beta.el6.noarch
* pulp-puppet-tools-2.5.0-0.7.beta.el6.noarch
* pulp-rpm-plugins-2.5.0-0.7.beta.el6.noarch
* pulp-selinux-2.5.0-0.7.beta.el6.noarch
* pulp-server-2.5.0-0.7.beta.el6.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-ldap_fluff-0.3.2-1.el6.noarch
* ruby193-rubygem-net-ldap-0.3.1-2.el6.noarch
* ruby193-rubygem-runcible-1.2.0-1.el6.noarch

How reproducible:
100%

Steps to Reproduce:
See "Description of problem" section at top of post.

Actual results:
An activation key is created.

Expected results:
No activation key is created.

Additional info:
The API exhibits a similar bug, though its behaviour is not identical.

Comment 1 RHEL Program Management 2014-10-24 16:13:09 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Christine Fouant 2015-10-22 18:00:59 UTC
Created redmine issue http://projects.theforeman.org/issues/12270 from this bug

Comment 4 Bryan Kearney 2015-10-22 20:00:21 UTC
Upstream bug component is Content Management

Comment 5 Bryan Kearney 2015-10-29 18:00:23 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/12270 has been closed
-------------
Christine Fouant
Applied in changeset commit:hammer-cli-katello|773e9d892f0c60036adf69c45d7d3a40acf6eb28.

Comment 7 Tazim Kolhar 2015-11-16 13:13:32 UTC
VERIFIED:
# rpm -qa | grep foreman
dell-pem600-01.rhts.eng.bos.redhat.com-foreman-proxy-client-1.0-1.noarch
foreman-release-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-ovirt-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-libvirt-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-postgresql-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-selinux-1.11.0-0.develop.201510071426git6234447.el7.noarch
tfm-rubygem-foreman_hooks-0.3.9-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.8-1.el7.noarch
tfm-rubygem-foreman_gutterball-0.0.1-3.el7.noarch
dell-pem600-01.rhts.eng.bos.redhat.com-foreman-client-1.0-1.noarch
dell-pem600-01.rhts.eng.bos.redhat.com-foreman-proxy-1.0-2.noarch
tfm-rubygem-foreman_discovery-4.1.2-1.fm1_11.el7.noarch
foreman-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
tfm-rubygem-foreman_docker-1.4.1-2.fm1_10.el7.noarch
tfm-rubygem-hammer_cli_foreman_bootdisk-0.1.3-3.el7.noarch
foreman-debug-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-proxy-1.11.0-0.develop.201511111339git7cbe47a.el7.noarch
foreman-compute-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
tfm-rubygem-hammer_cli_foreman_docker-0.0.3-4.el7.noarch
tfm-rubygem-foreman_bootdisk-6.0.0-2.fm1_10.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.4.0-1.201511111650gitdda13df.el7.noarch
foreman-gce-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
foreman-release-scl-1-1.el7.x86_64
foreman-vmware-1.11.0-0.develop.201511111740gitb2a959e.el7.noarch
tfm-rubygem-foreman-tasks-0.7.6-1.fm1_10.el7.noarch

steps:
# hammer activation-key create --organization-id 1 --name Y --max-content-hosts -5
Could not create the activation key:
  Error: undefined method `match' for -5:Fixnum

# hammer activation-key create --organization-id 1 --name Y --max-content-hosts -5 --unlimited-content-hosts true
Could not create the activation key:
  Error: undefined method `match' for -5:Fixnum

No activation key is created

Comment 11 errata-xmlrpc 2016-07-27 09:11:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501


Note You need to log in before you can comment on or make changes to this bug.