Skip to content

Commit

Permalink
test more of the security error scenarios (#9039)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman authored Feb 12, 2024
1 parent 7e9d395 commit d63dd7e
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
37 changes: 37 additions & 0 deletions silent/tests/testdata/su-err-dependency-not-found.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
! dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr security_update_dependency_not_found
stdout '{"data":{"error-type":"security_update_dependency_not_found","error-details":{}},"type":"record_update_job_error"}'
! stdout create_pull_request

# Since 'not-found' is not in the manifest, it errors with security_update_dependency_not_found.

-- manifest.json --
{
"dependency-a": { "version": "1.2.3" }
}

-- dependency-a --
{
"versions": [
"1.2.3"
]
}

-- input.yml --
job:
package-manager: "silent"
dependencies:
- not-found
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: not-found
affected-versions:
- <= 1.2.3
patched-versions: []
unaffected-versions: []
security-updates-only: true
37 changes: 37 additions & 0 deletions silent/tests/testdata/su-err-not-needed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
! dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr security_update_not_needed
stdout '{"data":{"error-type":"security_update_not_needed","error-details":{"dependency-name":"dependency-a"}},"type":"record_update_job_error"}'

# The security update is not needed because 1.2.3 is not vulnerable according to the advisory given.

-- manifest.json --
{
"dependency-a": { "version": "1.2.3" }
}

-- dependency-a --
{
"versions": [
"1.2.3",
"1.2.4"
]
}

-- input.yml --
job:
package-manager: "silent"
dependencies:
- dependency-a
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: dependency-a
affected-versions:
- < 1.0.0
patched-versions: []
unaffected-versions: []
security-updates-only: true
41 changes: 41 additions & 0 deletions silent/tests/testdata/su-err-pr-exists-latest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
! dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr pull_request_exists_for_latest_version
stdout '{"data":{"error-type":"pull_request_exists_for_latest_version","error-details":{"dependency-name":"dependency-a","dependency-version":"1.2.5"}},"type":"record_update_job_error"}'

# An existing pull request exists for 1.2.5 which is the latest version of dependency-a.

-- manifest.json --
{
"dependency-a": { "version": "1.2.3" }
}

-- dependency-a --
{
"versions": [
"1.2.3",
"1.2.4",
"1.2.5"
]
}

-- input.yml --
job:
package-manager: "silent"
dependencies:
- dependency-a
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: dependency-a
affected-versions:
- <= 1.2.3
patched-versions: []
unaffected-versions: []
security-updates-only: true
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.5
41 changes: 41 additions & 0 deletions silent/tests/testdata/su-err-pr-exists-security.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
! dependabot update -f input.yml --local . --updater-image ghcr.io/dependabot/dependabot-updater-silent
stderr pull_request_exists_for_security_update
stdout '{"data":{"error-type":"pull_request_exists_for_security_update","error-details":{"updated-dependencies":\[{"dependency-name":"dependency-a","dependency-version":"1.2.4"}\]}},"type":"record_update_job_error"}'

# An existing pull request exists for 1.2.4, which is the security version required, but not the latest.

-- manifest.json --
{
"dependency-a": { "version": "1.2.3" }
}

-- dependency-a --
{
"versions": [
"1.2.3",
"1.2.4",
"1.2.5"
]
}

-- input.yml --
job:
package-manager: "silent"
dependencies:
- dependency-a
source:
directory: "/"
provider: example
hostname: example.com
api-endpoint: https://example.com/api/v3
repo: dependabot/smoke-tests
security-advisories:
- dependency-name: dependency-a
affected-versions:
- <= 1.2.3
patched-versions: []
unaffected-versions: []
security-updates-only: true
existing-pull-requests:
- - dependency-name: dependency-a
dependency-version: 1.2.4

0 comments on commit d63dd7e

Please sign in to comment.