Skip to content

Commit 0afd822

Browse files
Mitch DennyCopilot
andcommitted
test(audit): fix branch coverage and snapshot for include-attestations
Add test exercising the human-readable output path with --include-attestations set, covering the false branch of the hint message check at verify-signatures.js:96. Update type-description snapshot to include the new include-attestations config definition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6d32757 commit 0afd822

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/lib/commands/audit.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,34 @@ t.test('audit signatures', async t => {
18541854
t.matchSnapshot(joinedOutput())
18551855
})
18561856

1857+
t.test('with valid attestations and --include-attestations (human-readable)', async t => {
1858+
const { npm, joinedOutput } = await loadMockNpm(t, {
1859+
prefixDir: installWithValidAttestations,
1860+
config: {
1861+
'include-attestations': true,
1862+
},
1863+
mocks: {
1864+
pacote: t.mock('pacote', {
1865+
sigstore: { verify: async () => true },
1866+
}),
1867+
},
1868+
})
1869+
const registry = new MockRegistry({ tap: t, registry: npm.config.get('registry') })
1870+
await manifestWithValidAttestations({ registry })
1871+
const fixture = fs.readFileSync(
1872+
path.resolve(__dirname, '../../fixtures/sigstore/valid-sigstore-attestations.json'),
1873+
'utf8'
1874+
)
1875+
registry.nock.get('/-/npm/v1/attestations/sigstore@1.0.0').reply(200, fixture)
1876+
mockTUF({ npm, target: TUF_VALID_KEYS_TARGET })
1877+
1878+
await npm.exec('audit', ['signatures'])
1879+
1880+
t.notOk(process.exitCode, 'should exit successfully')
1881+
t.match(joinedOutput(), /1 package has a verified attestation/)
1882+
t.notMatch(joinedOutput(), /use --json --include-attestations to view attestation details/)
1883+
})
1884+
18571885
t.test('with valid attestations --json --include-attestations', async t => {
18581886
const { npm, joinedOutput } = await loadMockNpm(t, {
18591887
prefixDir: installWithValidAttestations,

workspaces/config/tap-snapshots/test/type-description.js.test.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ Object {
221221
"optional",
222222
"peer",
223223
],
224+
"include-attestations": Array [
225+
"boolean value (true or false)",
226+
],
224227
"include-staged": Array [
225228
"boolean value (true or false)",
226229
],

0 commit comments

Comments
 (0)