Bug 1133799

Summary: nil allowed as user parameter at user creation
Product: Red Hat Satellite Reporter: Tomas Lestach <tlestach>
Component: APIAssignee: Shlomi Zadok <szadok>
Status: CLOSED ERRATA QA Contact: Tazim Kolhar <tkolhar>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.0.4CC: cwelton, dcleal, sthirugn, tkolhar
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/7261
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-12 05:13:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomas Lestach 2014-08-26 07:39:41 UTC
Description of problem:
API documentation of POST /api/users says:
user / optional , nil allowed

Version-Release number of selected component (if applicable):
Satellite-6.0.4-RHEL-6-20140823.0-Satellite-x86_64

How reproducible:
always

Steps to Reproduce:
1. Check the API documentation of POST /api/users
https://<sat6-hostname>/apidoc/v2/users/create.html

Actual results:
The 1st parameter user
is
optional , nil allowed

Expected results:
It does not make sense to allow nil for (or not to include) the user parameter at user creation. What user should be created?

Additional info:
curl "$(hostname)/api/users" -u admin:changeme -H "Accept: application/json" -H "Content-Type: application/json" -d '{"user":nil}'
{"status":400,"error":"There was a problem in the JSON you submitted: 784: unexpected token at '{\"user\":nil}'"}
The API documentation does not match with the behavior.

Comment 2 Tomas Lestach 2014-08-26 08:26:50 UTC
Actually, it's not just the "POST /api/users" API, but there're another 26 APIs affected.

Comment 3 Dominic Cleal 2014-08-26 09:53:11 UTC
nil is not valid JSON, hence the JSON validity error: "null" is the correct term.

I'll accept that the top level hash may be marked as required rather than optional.

Comment 5 Dominic Cleal 2014-08-26 09:54:23 UTC
Created redmine issue http://projects.theforeman.org/issues/7261 from this bug

Comment 6 Tomas Lestach 2014-08-26 10:09:08 UTC
(In reply to Dominic Cleal from comment #3)
> nil is not valid JSON, hence the JSON validity error: "null" is the correct
> term.
> 
> I'll accept that the top level hash may be marked as required rather than
> optional.

Right, I copy&pasted wrong line into the reproducer, the correct one shall be:

$ curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -X POST -d '{"user":null}' http://localhost/api/users
{
  "error": {"id":null,"errors":{"login":["can't be blank"],"auth_source_id":["can't be blank"]},"full_messages":["Username can't be blank","Auth source can't be blank"]}
}

Comment 7 Bryan Kearney 2014-09-02 10:04:28 UTC
Upstream bug assigned to jmagen

Comment 8 Bryan Kearney 2014-09-03 10:04:33 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7261 has been closed
-------------
Joseph Magen
Applied in changeset commit:fb5ac6168beaad3e205a113a92361066e14355f3.

Comment 9 Bryan Kearney 2015-01-09 14:49:36 UTC
Upstream bug assigned to szadok

Comment 12 Tazim Kolhar 2015-03-04 08:04:30 UTC
VERIFIED :

# rpm -qa | grep foreman
foreman-1.7.2.8-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.2-1.el6_6sat.noarch
foreman-compute-1.7.2.8-1.el6_6sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.2-1.el6_6sat.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el6_6sat.noarch
ruby193-rubygem-foreman-tasks-0.6.12.1-1.el6_6sat.noarch
foreman-proxy-1.7.2.3-1.el6_6sat.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-client-1.0-1.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-proxy-client-1.0-1.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.5-1.el6_6sat.noarch
foreman-vmware-1.7.2.8-1.el6_6sat.noarch
foreman-libvirt-1.7.2.8-1.el6_6sat.noarch
ruby193-rubygem-foreman_abrt-0.0.5-2.el6_6sat.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-proxy-1.0-2.noarch
rubygem-hammer_cli_foreman-0.1.4.6-1.el6_6sat.noarch
foreman-selinux-1.7.2.8-1.el6_6sat.noarch
foreman-debug-1.7.2.8-1.el6_6sat.noarch
foreman-gce-1.7.2.8-1.el6_6sat.noarch
ruby193-rubygem-foreman-redhat_access-0.0.8-2.el6_6sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.5-1.el6_6sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el6_6sat.noarch
foreman-postgresql-1.7.2.8-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.3-1.el6_6sat.noarch
foreman-ovirt-1.7.2.8-1.el6_6sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.8-1.el6_6sat.noarch

Username can't be blank

Comment 13 Bryan Kearney 2015-08-11 13:32:25 UTC
This bug is slated to be released with Satellite 6.1.

Comment 14 errata-xmlrpc 2015-08-12 05:13:08 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/RHSA-2015:1592