Skip to content

add imdsv2 mocking to instance_metadata endpoints#9891

Open
markjm wants to merge 2 commits intogetmoto:masterfrom
markjm:markjm/add-imdsv2
Open

add imdsv2 mocking to instance_metadata endpoints#9891
markjm wants to merge 2 commits intogetmoto:masterfrom
markjm:markjm/add-imdsv2

Conversation

@markjm
Copy link
Copy Markdown

@markjm markjm commented Mar 21, 2026

Thank you for this great project. Reporting and fixing a few missing endpoints when IMDSv2 is enabled! Please let me know if im missing something (i read through the contributing guide and think i did everything by the book)


I added a gist with some repro tests here https://gist.github.com/markjm/efae7f71c8dd58d0e3c118097140b0d9 (claude helped with a quick repro creation)

Basically, when IMDSv2 is enabled, there are expected calls to /latest/api/token which we want to return a fake token, then also some extra metadata paths which we may care about

Added the imdsv2 path + those extra possible metadata. And added tests for the same.

Thank you for this great project. Reporting and fixing a few missing endpoints when IMDSv2 is enabled! Please let me know if im missing something.

-----

I added a gist with some repro tests here https://gist.github.com/markjm/efae7f71c8dd58d0e3c118097140b0d9 (claude helped with a quick repro creation)

Basically, when IMDSv2 is enabled, there are expected calls to `/latest/api/token` which we want to return a fake token, then also some extra metadata paths which we may care about

Added the imdsv2 path + those extra possible metadata. And added tests for the same.
@markjm
Copy link
Copy Markdown
Author

markjm commented Mar 21, 2026

I presume most cases under mock wouldnt even try to get credentials, but we have code specifically using requests to hit these endpoints to get metadata directly which we would like mocked!

@markjm
Copy link
Copy Markdown
Author

markjm commented Mar 24, 2026

thanks @bblommers for kicking off the tests. didnt initially notice the servertests, so fixed that up as well!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (f69b6e7) to head (d0fe987).
⚠️ Report is 31 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #9891    +/-   ##
========================================
  Coverage   93.12%   93.12%            
========================================
  Files        1314     1314            
  Lines      119307   119436   +129     
========================================
+ Hits       111102   111230   +128     
- Misses       8205     8206     +1     
Flag Coverage Δ
servertests 29.21% <14.28%> (+0.05%) ⬆️
unittests 93.10% <100.00%> (+<0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant