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

Use PHP array form encoding when sending multiple authorized_key #113

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

jooola
Copy link
Contributor

@jooola jooola commented Jun 17, 2024

SUMMARY

PHP required arrays to contains [] in the parameters key. Without the brackets, only a single value will be parsed. See as example:

$ php -r "echo http_build_query(array('authorized_key' => array('key1', 'key2', 'key3')));"
authorized_key%5B0%5D=key1&authorized_key%5B1%5D=key2&authorized_key%5B2%5D=key3%

More about this array syntax: https://www.php.net/manual/en/function.parse-str.php#76792

Closes #112

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.hrobot.boot

jooola added 2 commits June 17, 2024 15:38
PHP required arrays to contains `[]` in the parameters key. Without the brackets, only a single value will be parsed. See as example:

$ php -r "echo http_build_query(array('authorized_key' => array('key1', 'key2', 'key3')));"
authorized_key%5B0%5D=key1&authorized_key%5B1%5D=key2&authorized_key%5B2%5D=key3%
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.22%. Comparing base (caadae2) to head (4bfd44f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #113   +/-   ##
=======================================
  Coverage   98.22%   98.22%           
=======================================
  Files          34       34           
  Lines        2427     2427           
  Branches      274      274           
=======================================
  Hits         2384     2384           
  Misses         20       20           
  Partials       23       23           
Flag Coverage Δ
sanity 27.52% <0.00%> (ø)
units 98.09% <100.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -404,7 +404,7 @@ def main():
if should is None:
continue
# unfold the return object for the idempotence check to work correctly
has = existing.get(data_key)
has = existing.get(result_key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing I noticed that it should be using result_key here, not data_key - this so far didn't make a difference since the values were equal, but now they're not :)

@felixfontein felixfontein merged commit 2c3977d into ansible-collections:main Jun 17, 2024
22 checks passed
@felixfontein
Copy link
Collaborator

@jooola thanks for fixing this!

felixfontein pushed a commit that referenced this pull request Jun 17, 2024
)

* Use PHP array form encoding when sending multiple `authorized_key`

PHP required arrays to contains `[]` in the parameters key. Without the brackets, only a single value will be parsed. See as example:

$ php -r "echo http_build_query(array('authorized_key' => array('key1', 'key2', 'key3')));"
authorized_key%5B0%5D=key1&authorized_key%5B1%5D=key2&authorized_key%5B2%5D=key3%

* fix changelog

* test: fix unit tests

* Update changelog fragment.

* Use the correct key for idempotency.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 2c3977d)
@jooola jooola deleted the fix-array-form branch June 18, 2024 07:49
@jooola
Copy link
Contributor Author

jooola commented Jun 18, 2024

Awesome, I appreciate the quick response and release 🫶

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.

Only one authorized_keys is uploaded when booting to rescue
2 participants