grnet / synnefo

Synnefo is open source cloud software, used to create massively scalable IaaS clouds.
GNU General Public License v3.0
133 stars 45 forks source link

cyclades: Add keypair name validation #387

Closed kpelelis closed 7 years ago

kpelelis commented 7 years ago

According to Open Stack's specifications, the name of a keypair should have at least one non whitespace character and only printable characters. For the time being Synnefo could create a keypair with any name but the URL /os-keypairs/{key_name} would match only if the key_name contained, letters(A-Z, a-z), numbers(0-9), dashes(-) and/or underscores(_).

With the new changes the name is compliant to Open Stack specifications and it will prevent a user of creating a keypair with an invalid name by returning him a 400 Bad Request error. Also the underlying URL now matches the new format.

skalkoto commented 7 years ago

Please add some more tests of valid and not valid non-ASCII names. We are doing the tests to test the key_name_regexp. Just testing a space is not enough.

kpelelis commented 7 years ago

I just added some more tests(not pushed yet). I have a question. Should the string u'\u0000 foo' be acceptable or not? based on the regular expression I think it shouldn't

skalkoto commented 7 years ago

Null character is a control character. Any string that contains this character is invalid.

skalkoto commented 7 years ago

LGTM I'll fix the conflict and merge it to develop