Merge pull request #2651 from mikebrow/manifest-version-test-on-put
adds validation testing for schema version values
This commit is contained in:
commit
53bd46af5c
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 {
|
||||
var errs distribution.ErrManifestVerification
|
||||
|
||||
if mnfst.SchemaVersion != 2 {
|
||||
return fmt.Errorf("unrecognized manifest list schema version %d", mnfst.SchemaVersion)
|
||||
}
|
||||
|
||||
if !skipDependencyVerification {
|
||||
// This manifest service is different from the blob service
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
|
|
|
@ -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 {
|
||||
var errs distribution.ErrManifestVerification
|
||||
|
||||
if mnfst.Manifest.SchemaVersion != 2 {
|
||||
return fmt.Errorf("unrecognized manifest schema version %d", mnfst.Manifest.SchemaVersion)
|
||||
}
|
||||
|
||||
if skipDependencyVerification {
|
||||
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 {
|
||||
var errs distribution.ErrManifestVerification
|
||||
|
||||
if mnfst.Manifest.SchemaVersion != 2 {
|
||||
return fmt.Errorf("unrecognized manifest schema version %d", mnfst.Manifest.SchemaVersion)
|
||||
}
|
||||
|
||||
if skipDependencyVerification {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue