fix(GOV-009): 完成最终复审整改
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { assertImmutableImageReferences } from './verify-image-references.mjs';
|
||||
|
||||
const digest = `sha256:${'a'.repeat(64)}`;
|
||||
|
||||
test('接受包含仓库名和 sha256 摘要的不可变镜像', () => {
|
||||
assert.doesNotThrow(() =>
|
||||
assertImmutableImageReferences({
|
||||
A_SHARE_WEB_IMAGE: `registry.invalid/web@${digest}`,
|
||||
A_SHARE_SERVER_IMAGE: `registry.invalid/server@${digest}`,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
for (const [name, image] of [
|
||||
['latest', 'registry.invalid/web:latest'],
|
||||
['普通 tag', 'registry.invalid/web:3a8120a'],
|
||||
['裸摘要', digest],
|
||||
['空值', ''],
|
||||
]) {
|
||||
test(`拒绝 Web ${name} 镜像引用`, () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
assertImmutableImageReferences({
|
||||
A_SHARE_WEB_IMAGE: image,
|
||||
A_SHARE_SERVER_IMAGE: `registry.invalid/server@${digest}`,
|
||||
}),
|
||||
/A_SHARE_WEB_IMAGE 必须使用仓库名@sha256摘要/,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user