• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jtblin / kube2iam / 171
58%
master: 8%

Build:
Build:
LAST BUILD BRANCH: feature/5-increase-coverage-and-add-integration-and-e2e-tests
DEFAULT BRANCH: master
Ran 03 May 2026 09:51PM UTC
Jobs 1
Files 10
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

03 May 2026 09:46PM UTC coverage: 57.998% (+42.8%) from 15.208%
171

push

circleci

jtblin

test: add unit, integration, and E2E test infrastructure (closes #5)

Coverage grew from ~7.7% to 55% across all packages. All tests pass
with no changes to production behavior.

## Refactoring for testability

- iam/iam.go: extract IMDSClient interface over *imds.Client with
GetMetadata and GetIAMInfo methods; add IMDS field to iam.Client
for dependency injection; refactor GetInstanceId and doHealthcheck
to use the injected client
- iam/arn.go: add GetBaseArnWithClient(IMDSClient) accepting a mock;
GetBaseArn() delegates to it with the real client
- server: add iam and roleMapper fields to *Server so HTTP handlers
can receive injected mocks without interface proliferation

## Unit tests

iam/iam_test.go (+340 lines):
- AssumeRole: cache hit, external ID, STS error, region validation
- GetInstanceId: success and IMDS error paths
- GetHash, sessionName, GetEndpointFromRegion, GetIAMCode helpers

iam/arn_test.go (+130 lines):
- IsValidBaseARN, RoleARN, GetBaseArnWithClient with mock IMDS

k8s/k8s_test.go (new, +155 lines):
- PodByIP, NamespaceByName, ListPodIPs/Namespaces
- Duplicate IP handling (hostNetwork pods)
- Uses fake client-go Indexers; no live cluster required

server/server_test.go (new, +350 lines):
- parseRemoteAddr (table-driven, 6 cases)
- healthHandler: healthy and unhealthy (HealthcheckFailReason set)
- securityCredentialsHandler: role found, cross-account ARN, pod
not found
- roleHandler: match, mismatch (403), mapping error (404), STS
error (500)
- reverseProxyHandler: IMDSv2 PUT token, IMDSv2 GET with token,
standard GET (XFF header behavior)
- debugStoreHandler, doHealthcheck success/failure, NewServer
defaults

mappings/mapper_test.go (+115 lines):
- GetRoleMapping: no annotation + no default (error), with default
role, pod not found
- GetExternalIDMapping: with and without annotation
- DumpDebugInfo: key presence and role-by-IP value verification
- Extend storeMock to support configurable pods and namespaces

namespace_test.go (... (continued)

9 of 26 new or added lines in 2 files covered. (34.62%)

533 of 919 relevant lines covered (58.0%)

3.09 hits per line

Uncovered Changes

Lines Coverage ∆ File
10
69.46
26.09% iam/iam.go
7
71.43
58.93% iam/arn.go
Jobs
ID Job ID Ran Files Coverage
1 171.1 03 May 2026 09:51PM UTC 10
58.0
CircleCI Job
Source Files on build 171
  • Tree
  • List 10
  • Changed 7
  • Source Changed 0
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • CircleCI Build #171
  • 1a2adf35 on github
  • Prev Build on main (#163)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc