Bug 728624

Summary: activation keys are successfully being created with invalid chars
Product: [Community] Candlepin Reporter: John Sefler <jsefler>
Component: candlepinAssignee: William Poteat <wpoteat>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.5CC: jmolet, spandey, wpoteat
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 13:15:27 UTC Type: ---
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: 682238    

Description John Sefler 2011-08-05 20:45:54 UTC
Description of problem:
According to the following error message, the creation of activation keys has restrictions on the characters that can be used in the activation key name:

Activation key names must be alphanumeric or the characters '-' or '_'.

However some character attempts are succeeding....

Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62candlepin candlepin]# git show-ref | grep master
895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/heads/master
895fdff46e33a607d63350df9bdd7bdd275b9e17 refs/remotes/origin/master


How reproducible:


Steps to Reproduce:

# curl -k --request POST --user testuser1:password --data '{"name":"[OpeningBracket["}' --header 'accept: application/json' --header 'content-type: application/json'  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
109   275  100   275    0    27    578     56 --:--:-- --:--:-- --:--:--   757
{
    "created": "2011-08-05T20:33:09.521+0000", 
    "id": "8a90f8c63196bb2001319ba641913a1e", 
    "name": "[OpeningBracket[", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f8c63196bb20013196bb9e210006", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-08-05T20:33:09.521+0000"
}


^^^ EXPECTED THAT TO FAIL
name "[OpeningBracket[" DOES NOT SATISFY "Activation key names must be alphanumeric or the characters '-' or '_'."

Other names that are also successfully creating activation keys that don't satisfy this restriction are:

[OpeningBracket[
]ClosingBracket]
`BackTick`
^Caret^
\Backslash\


Actual results:


Expected results:


Additional info:

Comment 1 John Sefler 2011-08-05 21:01:13 UTC
An empty name value appears to be ok too.  I would assume this is acceptable.  Please confirm.  

[jsefler@jseflerT510 ~]$ curl -k --request POST --user testuser1:password --data '{"name":""}' --header 'accept: application/json' --header 'content-type: application/json'  https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
104   259  100   259    0    11    539     22 --:--:-- --:--:-- --:--:--   701
{
    "created": "2011-08-05T20:55:41.106+0000", 
    "id": "8a90f8c63196bb2001319bbae1323a24", 
    "name": "", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f8c63196bb20013196bb9e210006", 
        "key": "admin"
    }, 
    "pools": [], 
    "updated": "2011-08-05T20:55:41.106+0000"
}

Comment 2 J.C. Molet 2011-08-18 17:51:36 UTC
Works as expected now, all above cases fail as they should:

[jmolet@jmolet ~]$ for NAME in "" [OpeningBracket[ ]ClosingBracket] \`BackTick\` ^Caret^ \\Backslash\\; do echo "name: $NAME"; curl -k --request POST --user testuser1:password --data '{"name":"$NAME"}' --header 'accept: application/json' --header 'content-type: application/json' https://mgmt5.rhq.lab.eng.bos.redhat.com:8443/candlepin/owners/admin/activation_keys | python -mjson.tool; echo; done
name: 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    306     49 --:--:-- --:--:-- --:--:--   393
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}

name: [OpeningBracket[
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    300     48 --:--:-- --:--:-- --:--:--   400
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}

name: ]ClosingBracket]
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    311     49 --:--:-- --:--:-- --:--:--   398
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}

name: `BackTick`
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    296     47 --:--:-- --:--:-- --:--:--   390
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}

name: ^Caret^
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    304     48 --:--:-- --:--:-- --:--:--   392
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}

name: \Backslash\
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   116  100   100  100    16    310     49 --:--:-- --:--:-- --:--:--   398
{
    "displayMessage": "Activation key names must be alphanumeric or the characters '-' or '_'. [$NAME]"
}



Tested against: "version": "0.4.10"

marking VERIFIED