-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from FNNDSC/dev
Add helm-unittest and auto-set value of `pman.setSecurityContext` depending on whether OpenShift is detected
- Loading branch information
Showing
10 changed files
with
126 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
test: | ||
name: Unit Tests | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Discover tests | ||
id: find | ||
run: | | ||
test_dirs="$(find -mindepth 3 -maxdepth 3 -type d -name tests)" | ||
if [ -z "$test_dirs" ]; then | ||
echo "::error ::No test directories found." | ||
exit 1 | ||
fi | ||
chart_dirs="$(echo "$test_dirs" | xargs dirname | tr '[:space:]' ',' | sed 's/,*$//')" | ||
echo "chart_dirs=$chart_dirs" >> "$GITHUB_OUTPUT" | ||
- name: Update Helm dependencies | ||
run: | | ||
printf '%s' '${{ steps.find.outputs.chart_dirs }}' \ | ||
| xargs -d , -L 1 helm dependency update \ | ||
2> >(grep -v 'found symbolic link' >&2) | ||
- name: Install helm-unittest | ||
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v0.6.3 | ||
- name: Run unit tests | ||
run: | | ||
printf '%s' '${{ steps.find.outputs.chart_dirs }}' \ | ||
| xargs -d , -L 1 helm unittest --color \ | ||
2> >(grep -v 'found symbolic link' >&2) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ | |
.idea/ | ||
*.tmproj | ||
.vscode/ | ||
|
||
/tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
charts/pfcon/tests/set_security_context_in_openshift_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
suite: pman-config.yml setSecurityContext (OpenShift) | ||
capabilities: | ||
apiVersions: | ||
- security.openshift.io/v1/SecurityContextConstraints | ||
templates: | ||
- pman-config.yml | ||
tests: | ||
- it: should not set CONTAINER_USER in OpenShift | ||
asserts: | ||
- notExists: | ||
path: data.CONTAINER_USER | ||
- it: should set CONTAINER_USER to the value of global.podSecurityContext when setSecurityContext=true | ||
set: | ||
global.podSecurityContext.runAsUser: 50505 | ||
global.podSecurityContext.runAsGroup: 303 | ||
pman.setSecurityContext: true | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '50505:303' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
suite: pman-config.yml setSecurityContext | ||
templates: | ||
- pman-config.yml | ||
tests: | ||
- it: should set CONTAINER_USER to '1001:0' by default (non-OpenShift) | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '1001:0' | ||
- it: should set CONTAINER_USER to '1001:0' when setSecurityContext=true and global.podSecurityContext is undefined | ||
set: | ||
pman.setSecurityContext: true | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '1001:0' | ||
- it: should set CONTAINER_USER to the value of global.podSecurityContext when setSecurityContext=true | ||
set: | ||
global.podSecurityContext.runAsUser: 50505 | ||
global.podSecurityContext.runAsGroup: 303 | ||
pman.setSecurityContext: true | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '50505:303' | ||
- it: should allow CONTAINER_USER to be set when setSecurityContext is unset | ||
set: | ||
pman.config.CONTAINER_USER: '20202:0' | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '20202:0' | ||
- it: should allow CONTAINER_USER to be set when setSecurityContext=true | ||
set: | ||
pman.config.CONTAINER_USER: '20202:0' | ||
pman.setSecurityContext: true | ||
asserts: | ||
- equal: | ||
path: data.CONTAINER_USER | ||
value: '20202:0' | ||
- it: should disallow setting of CONTAINER_USER when setSecurityContext=false | ||
set: | ||
pman.config.CONTAINER_USER: '20202:0' | ||
pman.setSecurityContext: false | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Cannot set value for .Values.pman.config.CONTAINER_USER because .Values.pman.setSecurityContext=false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters