adds validation testing for schema version values
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
5f37adaa41
commit
2fdb2ac270
4 changed files with 26 additions and 1 deletions
|
@ -64,6 +64,10 @@ func (ms *manifestListHandler) Put(ctx context.Context, manifestList distributio
|
||||||
func (ms *manifestListHandler) verifyManifest(ctx context.Context, mnfst manifestlist.DeserializedManifestList, skipDependencyVerification bool) error {
|
func (ms *manifestListHandler) verifyManifest(ctx context.Context, mnfst manifestlist.DeserializedManifestList, skipDependencyVerification bool) error {
|
||||||
var errs distribution.ErrManifestVerification
|
var errs distribution.ErrManifestVerification
|
||||||
|
|
||||||
|
if mnfst.SchemaVersion != 2 {
|
||||||
|
return fmt.Errorf("unrecognized manifest list schema version %d", mnfst.SchemaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
if !skipDependencyVerification {
|
if !skipDependencyVerification {
|
||||||
// This manifest service is different from the blob service
|
// This manifest service is different from the blob service
|
||||||
// returned by Blob. It uses a linked blob store to ensure that
|
// returned by Blob. It uses a linked blob store to ensure that
|
||||||
|
|
|
@ -424,9 +424,22 @@ func testOCIManifestStorage(t *testing.T, testname string, includeMediaTypes boo
|
||||||
t.Fatalf("%s: unexpected error generating manifest: %v", testname, err)
|
t.Fatalf("%s: unexpected error generating manifest: %v", testname, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// before putting the manifest test for proper handling of SchemaVersion
|
||||||
|
|
||||||
|
if manifest.(*ocischema.DeserializedManifest).Manifest.SchemaVersion != 2 {
|
||||||
|
t.Fatalf("%s: unexpected error generating default version for oci manifest", testname)
|
||||||
|
}
|
||||||
|
manifest.(*ocischema.DeserializedManifest).Manifest.SchemaVersion = 0
|
||||||
|
|
||||||
var manifestDigest digest.Digest
|
var manifestDigest digest.Digest
|
||||||
if manifestDigest, err = ms.Put(ctx, manifest); err != nil {
|
if manifestDigest, err = ms.Put(ctx, manifest); err != nil {
|
||||||
t.Fatalf("%s: unexpected error putting manifest: %v", testname, err)
|
if err.Error() != "unrecognized manifest schema version 0" {
|
||||||
|
t.Fatalf("%s: unexpected error putting manifest: %v", testname, err)
|
||||||
|
}
|
||||||
|
manifest.(*ocischema.DeserializedManifest).Manifest.SchemaVersion = 2
|
||||||
|
if manifestDigest, err = ms.Put(ctx, manifest); err != nil {
|
||||||
|
t.Fatalf("%s: unexpected error putting manifest: %v", testname, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also create an image index that contains the manifest
|
// Also create an image index that contains the manifest
|
||||||
|
|
|
@ -66,6 +66,10 @@ func (ms *ocischemaManifestHandler) Put(ctx context.Context, manifest distributi
|
||||||
func (ms *ocischemaManifestHandler) verifyManifest(ctx context.Context, mnfst ocischema.DeserializedManifest, skipDependencyVerification bool) error {
|
func (ms *ocischemaManifestHandler) verifyManifest(ctx context.Context, mnfst ocischema.DeserializedManifest, skipDependencyVerification bool) error {
|
||||||
var errs distribution.ErrManifestVerification
|
var errs distribution.ErrManifestVerification
|
||||||
|
|
||||||
|
if mnfst.Manifest.SchemaVersion != 2 {
|
||||||
|
return fmt.Errorf("unrecognized manifest schema version %d", mnfst.Manifest.SchemaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
if skipDependencyVerification {
|
if skipDependencyVerification {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,10 @@ func (ms *schema2ManifestHandler) Put(ctx context.Context, manifest distribution
|
||||||
func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst schema2.DeserializedManifest, skipDependencyVerification bool) error {
|
func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst schema2.DeserializedManifest, skipDependencyVerification bool) error {
|
||||||
var errs distribution.ErrManifestVerification
|
var errs distribution.ErrManifestVerification
|
||||||
|
|
||||||
|
if mnfst.Manifest.SchemaVersion != 2 {
|
||||||
|
return fmt.Errorf("unrecognized manifest schema version %d", mnfst.Manifest.SchemaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
if skipDependencyVerification {
|
if skipDependencyVerification {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue