ctdk / goiardi

A Chef server written in Go, able to run entirely in memory, with optional persistence with saving the in-memory data to disk or using MySQL or Postgres as the data storage backend. Docs: http://goiardi.readthedocs.io/en/latest/index.html
http://goiardi.gl
Apache License 2.0
280 stars 39 forks source link

Knife upload user doesn't work properly #75

Closed alekc closed 4 years ago

alekc commented 4 years ago

Describe the bug When doing knife upload user, goiardi wont permit the operation because knife adds several fields which are not recognised by goiardi.

I.e. given this user.json file

{
"name": "user",
"email": "user@example.com",
"public_key": "-----BEGIN PUBLIC KEY-----xxx-----END PUBLIC KEY-----\n\n"
}

knife upload user will attempt following upload

{
   "name":"user",
   "username":"user",
   "display_name":"user",
   "admin":false,
   "json_class":"Chef::WebUIUser",
   "chef_type":"webui_user",
   "salt":null,
   "password":null,
   "openid":null,
   "email":"user@example.com",
   "public_key":"-----BEGIN PUBLIC KEY-----xxxxxx-----END PUBLIC KEY-----\n\n"
}

which will trigger at least 2 different failures:

  1. password cannot be null (validation fails, it would not fail with "")
  2. following fields are not recognised: "chef_type", "display_name", "json_class", "openid" (goiardi has a very strict validation rules, if there are any extra fields in request, it would be refused.

Expected behavior standard operation such as knife upload working

Additional context This was observed on both cinc (15) and chefdk (3.9) knife versions

ctdk commented 4 years ago

Thanks for the PR for this. This issue is a little interesting, because the Chef 11 behavior the goiardi master branch still emulates is beginning to break more and more often. The chef pedant tests would flip out if you tried uploading extra fields, I remember, so this may be a bit delicate.

There's also a possibility that the 1.0.0-dev and related branches may already work better. Obviously things are a bit fluid there though.

alekc commented 4 years ago

I can imagine. However in this case if we are forced to choose between pedant tests and real world usage (using official tool like knife for example) I am not sure it’s worth choosing theory over the real world.

We found this issue when migrating old chef server to gloat do through knife backup tool. In order to make it work, several fields had to be dropped (and we dealt with it with sed help) but what we didn’t expect is that it would add extra fields preventing actual functionality.

On Thu, 23 Jul 2020 at 17:49, Jeremy Bingham notifications@github.com wrote:

Thanks for the PR for this. This issue is a little interesting, because the Chef 11 behavior the goiardi master branch still emulates is beginning to break more and more often. The chef pedant tests would flip out if you tried uploading extra fields, I remember, so this may be a bit delicate.

There's also a possibility that the 1.0.0-dev and related branches may already work better. Obviously things are a bit fluid there though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ctdk/goiardi/issues/75#issuecomment-663114977, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJ5V7WMQNO4WVW6K5KMBDR5BSZZANCNFSM4PFTQ6RA .

alekc commented 4 years ago

Closed via https://github.com/ctdk/goiardi/pull/76