cmd/snap: fix JSON keys not being validated on snap set -t
When passing JSON in the snap set -t command, the keys were not being validated.
- Add: Reusable function to validate snap set keys
- tests: Write tests to demonstrate functionality
- fixes: https://bugs.launchpad.net/snapd/+bug/2072331
@zyga - I was wrong in my comment about the boolean stuff, but when I saw these results of the unit tests, I realized that I wasn't just wrong; I was hugely wrong. So as it can be many possible types, I decide to just check if it's the type that I'm interested: map[string]interface{}
@olivercalder - It's interested that you pointed my attention to this value type validation, because I could realize that I wasn't checking for this edge case: When the value type is: []interface{} what means that the user passed an JSON that contains an array in one of its objects, now my previous commit adds the logic to handle this. Thank you very much.
@olivercalder I suspect that the access denied error comes from the fact that when testing "happy" cases, the mocking structure for the API server reaches its limit.
Because, it happens when I tried to use ParseArgs for testing happy cases, and also happens when some unhappy case also using ParseArgs fail to trigger an error.
Since this commit, a conflict has been introduced because the logic for this execution was moved to another function. I will rebase my changes on top of the master branch, but for now, please consider this a draft.
Sorry for the delay, now it's ready again! :)
Hello! @olivercalder, @andrewphelpsj this is ready for review now!
@andrewphelpsj, @bboozzoo, @olivercalder, do you have any additional reviews or feedback on this?