Bug 859936

Summary: Consumer update API call cannot consume JSON produced by Consumer get API call
Product: [Community] Candlepin Reporter: Dmitri Dolguikh <dmitri>
Component: candlepinAssignee: Jesus M. Rodriguez <jesusr>
Status: CLOSED NOTABUG QA Contact: Eric Sammons <esammons>
Severity: high Docs Contact:
Priority: unspecified    
Version: 0.9CC: bkearney, jesusr
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-19 19:46:14 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:
Bug Depends On:    
Bug Blocks: 771481, 833466    

Description Dmitri Dolguikh 2012-09-24 12:36:00 UTC
Consumer UPDATE chokes on json produced by Consumer GET.

SHould be reproducible via curl:

curl -u admin:admin http://localhost:8080/candlepin/consumers/<uuid>

curl -u admin:admin -H "Content-type: application/json" -X PUT <json from the previous step> http://localhost:8080/candlepin/consumers/<uuid>

Comment 1 Jesus M. Rodriguez 2012-12-19 19:41:36 UTC
the above PUT command is incorrect, it requires --data BEFORE the <json from the previous step>. Without --data, I get the following error:

{"displayMessage":"Runtime Error java.io.EOFException: No content to map to Object due to end of input at org.codehaus.jackson.map.ObjectMapper._initForReading:2,766"}

This is expected. If you want to PUT or POST please use --data from curl.

Comment 2 Jesus M. Rodriguez 2012-12-19 19:45:42 UTC
Using --data, the following scenarios worked:

GET:
curl -u admin:admin http://localhost:8080/candlepin/consumers/<uuid> > consumer.json
curl -k -u admin:admin https://localhost:8443/candlepin/consumers/<uuid> > consumer.json

PUT:
curl -k -u admin:admin -H "Content-type: application/json" -X PUT --data @consumer.json https://localhost:8443/candlepin/consumers/<uuid>

curl -u admin:admin -H "Content-type: application/json" -X PUT --data @consumer.json http://localhost:8080/candlepin/consumers/<uuid>

The following requires single quotes (') around the JSON:
curl -k -u admin:admin -H "Content-type: application/json" -X PUT --data 'PASTED JSON DIRECTLY INTO TERMINAL' https://localhost:8443/candlepin/consumers/<uuid>

curl -u admin:admin -H "Content-type: application/json" -X PUT --data 'PASTED JSON DIRECTLY INTO TERMINAL' http://localhost:8080/candlepin/consumers/<uuid>

None of the above produced an error. Then I MODIFIED the consumer.json to change the name and autoheal values BEFORE executing the PUT. After modifying the input the PUT calls resulted in updated consumer records in the database, as expected.

Comment 3 Jesus M. Rodriguez 2012-12-19 19:46:14 UTC
I'm going to close this bug as NOTABUG because it works as of candlepin 0.7.23