trafficcontrol icon indicating copy to clipboard operation
trafficcontrol copied to clipboard

Can update a user's username to contain spaces

Open ericholguin opened this issue 5 years ago • 7 comments

I'm submitting a ...

  • [X] bug report
  • [ ] new feature / enhancement request
  • [ ] improvement request (usability, performance, tech debt, etc.)
  • [ ] other

Traffic Control components affected ...

  • [ ] CDN in a Box
  • [ ] Documentation
  • [ ] Grove
  • [ ] Traffic Control Client
  • [ ] Traffic Monitor
  • [ ] Traffic Ops
  • [ ] Traffic Ops ORT
  • [x] Traffic Portal
  • [ ] Traffic Router
  • [ ] Traffic Stats
  • [ ] Traffic Vault
  • [ ] unknown

Current behavior:

When making a PUT request to /user/current with the following request body:

{
    "user": {
        "username": "space   test"
    }
}

The response returned is:

HTTP/1.1 200 OK
{
    "alerts": [
        {
            "text": "User profile was successfully updated",
            "level": "success"
        }
    ],
    "response": {
        "username": "space    test",
         .
         .
    }
}

Expected / new behavior:

Should not be allowed to update a username that contains spaces. Should return:

HTTP/1.1 400 Bad Request
{
    "alerts": [
        {
            "text": "Couldn't parse request: username: cannot contain spaces",
            "level": "error"
        }
    ]
}

Minimal reproduction of the problem with instructions:

Anything else:

ericholguin avatar Dec 27 '19 21:12 ericholguin

trying to think if a username with spaces would cause problems. is it weird? yes. does it cause real problems? not sure. so not sure whether to mark this as a bug or improvement or "works as designed".

mitchell852 avatar Dec 30 '19 16:12 mitchell852

I think you can also create a user having a username with spaces, though the TP form doesn't like it. In any case I think changing this would break compatibility with the Perl; that is, if memory serves. I can check in a day or two to be sure.

ocket8888 avatar Jan 01 '20 05:01 ocket8888

Yeah, the Perl would let you do that and you can also create users with spaces in their username. I think this is so far "works as designed".

ocket8888 avatar Jan 02 '20 20:01 ocket8888

@ocket8888 - maybe rather than closing this, it should be reopened and the "fix" is to make TP and the TO API consistent. Meaning that TP should allow spaces as well. Thoughts?

mitchell852 avatar Jan 03 '20 15:01 mitchell852

Yeah, that sounds appropriate to me.

ocket8888 avatar Jan 03 '20 16:01 ocket8888

Whoops, that PR referenced the wrong Issue. This is still open.

ocket8888 avatar Jan 29 '20 16:01 ocket8888

@ocket8888 @mitchell852 - I've included a fix for this issue in my PR #6895

Could you please review it?

hritvikpatel4 avatar Jun 10 '22 15:06 hritvikpatel4