Skip to content

Added Unit tests for CI helpers#2177

Merged
J12934 merged 17 commits intomainfrom
feature/scan-helpers-unittests
Feb 7, 2024
Merged

Added Unit tests for CI helpers#2177
J12934 merged 17 commits intomainfrom
feature/scan-helpers-unittests

Conversation

@Ilyesbdlala
Copy link
Member

Description

Checklist

  • Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests.
  • Make sure that all your commits are signed-off and that you are added to the Contributors file.
  • Make sure that all CI finish successfully.
  • Optional (but appreciated): Make sure that all commits are Verified.

@Ilyesbdlala Ilyesbdlala added the testing Improvements or additions regarding the test setup label Jan 12, 2024
@Ilyesbdlala Ilyesbdlala self-assigned this Jan 12, 2024
@netlify
Copy link

netlify bot commented Jan 12, 2024

Deploy Preview for docs-securecodebox ready!

Name Link
🔨 Latest commit f338473
🔍 Latest deploy log https://app.netlify.com/sites/docs-securecodebox/deploys/65c2372976f0e100085f13e3
😎 Deploy Preview https://deploy-preview-2177--docs-securecodebox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Jan 12, 2024

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
⚠️ ACTION actionlint 1 5 0.36s
⚠️ JAVASCRIPT eslint 2 1 0.53s
✅ JSON eslint-plugin-jsonc 11 0 1.06s
⚠️ YAML prettier 1 1 0.74s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@Ilyesbdlala Ilyesbdlala force-pushed the feature/scan-helpers-unittests branch from e150c7c to c46e163 Compare January 16, 2024 16:26
@J12934
Copy link
Member

J12934 commented Jan 19, 2024

is this already running / tested in the CI?

@Ilyesbdlala Ilyesbdlala force-pushed the feature/scan-helpers-unittests branch from c46e163 to 30862fa Compare January 19, 2024 15:42
@Ilyesbdlala
Copy link
Member Author

is this already running / tested in the CI?

Now it is :)

@Ilyesbdlala Ilyesbdlala force-pushed the feature/scan-helpers-unittests branch from 30862fa to 481893c Compare February 2, 2024 17:47
@Ilyesbdlala Ilyesbdlala changed the title feature/scan-helpers-unittests Added Unit tests for CI helpers Feb 2, 2024
@Ilyesbdlala Ilyesbdlala force-pushed the feature/scan-helpers-unittests branch from 2c0a029 to 85b1994 Compare February 2, 2024 18:31
@Ilyesbdlala Ilyesbdlala marked this pull request as ready for review February 2, 2024 19:03
Ilyesbdlala and others added 17 commits February 6, 2024 14:41
basic mockup for @kubernetes/client-node
current issue:  k8s API calls are still being made

Signed-off-by: Ilyes Ben Dlala <[email protected]>
This allows passing in the APIs to the respective functions, instead of using a static variable. This simplifies the testing processing and in particular the mocking.

Signed-off-by: Ilyes Ben Dlala <[email protected]>
…ing in Mocked APIs

Only a basic test is done for now, A higher call/function coverage is TODO

Signed-off-by: Ilyes Ben Dlala <[email protected]>
 Allowed functions helpers.js to take in k8s API instances as optional parameters. If not set, a "singleton" of the instance type is created, and used as of then.

Signed-off-by: Ilyes Ben Dlala <[email protected]>
* Made use of parameterable k8s API, by mocking them
* Included more test cases for cascading scan and failed scans

Signed-off-by: Ilyes Ben Dlala <[email protected]>
excluded __snapshots__ and __testFiles from the helm-unit-tests makefile target

Signed-off-by: Ilyes Ben Dlala <[email protected]>
…rsions to fit upstream version

Signed-off-by: Ilyes Ben Dlala <[email protected]>
Better visibility in the GitHub UI logs

Co-authored-by: Jannik Hollenbach <[email protected]>
Signed-off-by: Ilyes Ben Dlala <[email protected]>
 instead of individual k8sApi (CRD, Batch,Pods)

 Co-authored-by: Jannik Hollenbach <[email protected]>

Signed-off-by: Ilyes Ben Dlala <[email protected]>
This is because the test would pass when there is not exception thrown.
ref: https://jestjs.io/docs/expect#rejects
Co-authored-by: Jannik Hollenbach <[email protected]>

Signed-off-by: Ilyes Ben Dlala <[email protected]>
@Ilyesbdlala Ilyesbdlala force-pushed the feature/scan-helpers-unittests branch from 1cc20f1 to f338473 Compare February 6, 2024 13:42
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

3 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@J12934 J12934 merged commit 679d07d into main Feb 7, 2024
@J12934 J12934 deleted the feature/scan-helpers-unittests branch February 7, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Improvements or additions regarding the test setup

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants