Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(put-policy): update policy without delete-create #107

Merged
merged 11 commits into from
Sep 20, 2019
Merged

Conversation

vpsx
Copy link
Contributor

@vpsx vpsx commented Sep 13, 2019

Previously Arborist's PUT policy endpoint would just delete and (re)create a policy. But this changed the policy's pkey in the db, which breaks links in [usr, grp, client]_policy. New PUT policy handler will just delete the relevant entries in the policy_[resource, role] tables and make new ones.

Additionally this PR:

  1. Overwrites policy name in json with policy name from URL after unmarshaling is done, to correctly prefer the name from the URL

Expected behavior post-Arborist 3.0.0:

  • PUT /policy endpoint deprecated and only PUT /policy/{policyID} used
  • get policy name from url and ignore id field from request json if given

Behavior in the meantime (2.x.x):

  • Both PUT /policy and PUT /policy/{policyID} supported
  • If policy name in url, then overwrite policy name in request json, if latter is present; if policy name not in url, then use policy name from request json.

Bug Fixes

  • fix PUT policy behavior so that it does not unexpectedly remove usr/grp/client-policy relationships
  • lowercase id field name in unmarshalJSON's optional fields
  • validate id field in policy validate fn (error if policy id not in policy json or is empty string)
  • overwrite policy name from json if policy name was present in url (overwrite should be done after unmarshal, not before)

@coveralls
Copy link

coveralls commented Sep 17, 2019

Coverage Status

Coverage decreased (-0.2%) to 74.784% when pulling 7cdf6fb on fix/policy into c58e30b on master.

@vpsx vpsx changed the title fix(put-policy): overwrite policy name from json fix(put-policy): update policy without delete-create Sep 18, 2019
arborist/policy.go Outdated Show resolved Hide resolved
arborist/policy.go Outdated Show resolved Hide resolved
arborist/policy.go Outdated Show resolved Hide resolved
@vpsx vpsx merged commit afc69a0 into master Sep 20, 2019
@vpsx vpsx deleted the fix/policy branch September 20, 2019 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants