Skip to content

test(kubernetes): cover attribute handler's main paths - #416

Open
afsuyadi wants to merge 1 commit into
StackGuardian:mainfrom
afsuyadi:test-numeric-comparison
Open

afsuyadi wants to merge 1 commit into
StackGuardian:mainfrom
afsuyadi:test-numeric-comparison

Conversation

@afsuyadi

Copy link
Copy Markdown

Description

What changes are being made?
I add some unit tests for Kubernetes with 4 cases:
a. test_kind_not_found: Ask the handler for a ConfigMap, but input.yml has no ConfigMap in it.
-> Expects: an error ("kind:ConfigMap is not found") plus a ProviderError with severity_value == 1.

b. test_plain_path: Asks for metadata.name on the Role resource (a path with no *), and there is exactly one Role.
-> Expects: a single plain value back, "access-role", not wrapped in a list.

c. test_wildcard_path: Asks for spec.selector.matchLabels.* on the Deployment resource. The * symbol means "give me every value at this level".
-> Expects: a list of all matched values, ["wfs-demo", "wfs-demp"].

d. test_missing_attribute: Asks for metadata.labels on RoleBinding, but that resource has no labels key at all.
-> Expects: None. Proving the handler doesn't crash on a missing field, it just reports "nothing here".

Which issues or tickets does this PR close or relate to?
Related issue: fixes #405

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Other (please specify): Test cases for Kubernetes

Checklist

  • Code has been linted.
  • Documentation has been updated (if needed).
  • Tests have been added or updated (if needed).
  • Any breaking changes have been communicated to the team.

Screenshots or Recordings (if applicable)

Additional Information

This branch has not been deployed

No deployments
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.

test(kubernetes): cover the provider's main paths

1 participant