-
Notifications
You must be signed in to change notification settings - Fork 131
fix(KFLUXBUGS-1581): force releaseNotes.type when cves defined #619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
109 changes: 109 additions & 0 deletions
109
tasks/create-advisory/tests/test-create-advisory-fail-rhsa-no-cve.yaml
This file contains hidden or 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,109 @@ | ||
| --- | ||
| apiVersion: tekton.dev/v1 | ||
| kind: Pipeline | ||
| metadata: | ||
| name: test-create-advisory-fail-rhsa-no-cve | ||
| annotations: | ||
| test/assert-task-failure: "run-task" | ||
| spec: | ||
| description: | | ||
| Run the create-advisory task with releaseNotes.type set to RHSA but no CVEs in releaseNotes. | ||
| The task should fail. | ||
| workspaces: | ||
| - name: tests-workspace | ||
| tasks: | ||
| - name: setup | ||
| taskSpec: | ||
| steps: | ||
| - name: create-crs | ||
| image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
| script: | | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| mkdir "$(workspaces.data.path)"/results | ||
|
|
||
| cat > "$(workspaces.data.path)"/test_release_plan_admission.json << EOF | ||
| { | ||
| "apiVersion": "appstudio.redhat.com/v1alpha1", | ||
| "kind": "ReleasePlanAdmission", | ||
| "metadata": { | ||
| "name": "test", | ||
| "namespace": "default" | ||
| }, | ||
| "spec": { | ||
| "applications": [ | ||
| "app" | ||
| ], | ||
| "policy": "policy", | ||
| "pipeline": { | ||
| "pipelineRef": { | ||
| "resolver": "git", | ||
| "params": [ | ||
| { | ||
| "name": "url", | ||
| "value": "github.com" | ||
| }, | ||
| { | ||
| "name": "revision", | ||
| "value": "main" | ||
| }, | ||
| { | ||
| "name": "pathInRepo", | ||
| "value": "pipeline.yaml" | ||
| } | ||
| ] | ||
| }, | ||
| "serviceAccountName": "sa" | ||
| }, | ||
| "origin": "dev" | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| cat > "$(workspaces.data.path)"/test_snapshot_spec.json << EOF | ||
| { | ||
| "application": "myapp", | ||
| "components": [ | ||
| { | ||
| "name": "comp", | ||
| "repository": "quay.io/redhat-prod/repo" | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
|
|
||
| cat > "$(workspaces.data.path)"/data.json << EOF | ||
| { | ||
| "releaseNotes": { | ||
| "type": "RHSA" | ||
| }, | ||
| "sign": { | ||
| "configMapName": "cm" | ||
| } | ||
| } | ||
| EOF | ||
| workspaces: | ||
| - name: data | ||
| workspace: tests-workspace | ||
| - name: run-task | ||
| taskRef: | ||
| name: create-advisory | ||
| params: | ||
| - name: releasePlanAdmissionPath | ||
| value: "test_release_plan_admission.json" | ||
| - name: snapshotPath | ||
| value: "test_snapshot_spec.json" | ||
| - name: dataPath | ||
| value: "data.json" | ||
| - name: resultsDirPath | ||
| value: "results" | ||
| - name: synchronously | ||
| value: "false" | ||
| - name: pipelineRunUid | ||
| value: $(context.pipelineRun.uid) | ||
| runAfter: | ||
| - setup | ||
| workspaces: | ||
| - name: data | ||
| workspace: tests-workspace |
174 changes: 174 additions & 0 deletions
174
tasks/create-advisory/tests/test-create-advisory-overwrite-type.yaml
This file contains hidden or 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,174 @@ | ||
| --- | ||
| apiVersion: tekton.dev/v1 | ||
| kind: Pipeline | ||
| metadata: | ||
| name: test-create-advisory-overwrite-type | ||
| spec: | ||
| description: | | ||
| Run the create-advisory task with a releaseNotes.type that is not RHSA, but CVEs present in releaseNotes. | ||
| The type should be overwritten to RHSA. | ||
| workspaces: | ||
| - name: tests-workspace | ||
| tasks: | ||
| - name: setup | ||
| taskSpec: | ||
| steps: | ||
| - name: create-crs | ||
| image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
| script: | | ||
| #!/usr/bin/env bash | ||
| set -eux | ||
|
|
||
| mkdir "$(workspaces.data.path)"/results | ||
|
|
||
| cat > "$(workspaces.data.path)"/test_release_plan_admission.json << EOF | ||
| { | ||
| "apiVersion": "appstudio.redhat.com/v1alpha1", | ||
| "kind": "ReleasePlanAdmission", | ||
| "metadata": { | ||
| "name": "test", | ||
| "namespace": "default" | ||
| }, | ||
| "spec": { | ||
| "applications": [ | ||
| "app" | ||
| ], | ||
| "policy": "policy", | ||
| "pipeline": { | ||
| "pipelineRef": { | ||
| "resolver": "git", | ||
| "params": [ | ||
| { | ||
| "name": "url", | ||
| "value": "github.com" | ||
| }, | ||
| { | ||
| "name": "revision", | ||
| "value": "main" | ||
| }, | ||
| { | ||
| "name": "pathInRepo", | ||
| "value": "pipeline.yaml" | ||
| } | ||
| ] | ||
| }, | ||
| "serviceAccountName": "sa" | ||
| }, | ||
| "origin": "dev" | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| cat > "$(workspaces.data.path)"/test_snapshot_spec.json << EOF | ||
| { | ||
| "application": "myapp", | ||
| "components": [ | ||
| { | ||
| "name": "comp", | ||
| "repository": "quay.io/redhat-prod/repo" | ||
| } | ||
| ] | ||
| } | ||
| EOF | ||
|
|
||
| cat > "$(workspaces.data.path)"/data.json << EOF | ||
| { | ||
| "releaseNotes": { | ||
| "type": "RHEA", | ||
| "content": { | ||
| "images": [ | ||
| { | ||
| "containerImage": "foo", | ||
| "cves": { | ||
| "fixed": { | ||
| "CVE-123": { | ||
| "components": [ | ||
| "pkg:rpm/foo" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "sign": { | ||
| "configMapName": "cm" | ||
| } | ||
| } | ||
| EOF | ||
| workspaces: | ||
| - name: data | ||
| workspace: tests-workspace | ||
| - name: run-task | ||
| taskRef: | ||
| name: create-advisory | ||
| params: | ||
| - name: releasePlanAdmissionPath | ||
| value: "test_release_plan_admission.json" | ||
| - name: snapshotPath | ||
| value: "test_snapshot_spec.json" | ||
| - name: dataPath | ||
| value: "data.json" | ||
| - name: resultsDirPath | ||
| value: "results" | ||
| - name: synchronously | ||
| value: "false" | ||
| - name: pipelineRunUid | ||
| value: $(context.pipelineRun.uid) | ||
| runAfter: | ||
| - setup | ||
| workspaces: | ||
| - name: data | ||
| workspace: tests-workspace | ||
| - name: check-result | ||
| workspaces: | ||
| - name: data | ||
| workspace: tests-workspace | ||
| runAfter: | ||
| - run-task | ||
| taskSpec: | ||
| workspaces: | ||
| - name: data | ||
| steps: | ||
| - name: check-result | ||
| image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
| script: | | ||
| #!/usr/bin/env bash | ||
| set -ex | ||
|
|
||
| # Count the number of InternalRequests | ||
| requestsCount=$(kubectl get InternalRequest -o json | jq -r '.items | length') | ||
|
|
||
| # Check if the number of InternalRequests is as expected | ||
| if [ "$requestsCount" -ne 1 ]; then | ||
| echo "Unexpected number of InternalRequests. Expected: 1, Found: $requestsCount" | ||
| exit 1 | ||
| fi | ||
|
|
||
| internalRequest=$(kubectl get InternalRequest -o json | jq -r '.items[0]') | ||
|
|
||
| # Check the request field | ||
| if [ "$(echo "$internalRequest" | jq -r '.spec.request' )" != "create-advisory" ]; then | ||
| echo "InternalRequest doesn't contain 'create-advisory' in 'request' field" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check the advisory_json parameter | ||
| if [[ "$(echo "$internalRequest" | jq -r '.spec.params.advisory_json' )" != \ | ||
| '{"type":"RHSA"'* ]]; then | ||
| echo "The advisory_json should have had its type overwritten to RHSA because there were CVEs" | ||
| echo "in the releaseNotes. However, it was not" | ||
| exit 1 | ||
| fi | ||
| finally: | ||
| - name: cleanup | ||
| taskSpec: | ||
| steps: | ||
| - name: delete-crs | ||
| image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f | ||
| script: | | ||
| #!/usr/bin/env sh | ||
| set -eux | ||
|
|
||
| kubectl delete internalrequests --all |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.