diff --git a/pkg/types/alpine/alpine_test.go b/pkg/types/alpine/alpine_test.go index a1e5741e7cfc84db0be4b52d0375d7e84eb26616..1128db30db5b2cf989dbb41190ad1263aff8a31f 100644 --- a/pkg/types/alpine/alpine_test.go +++ b/pkg/types/alpine/alpine_test.go @@ -16,7 +16,6 @@ package alpine import ( - "context" "errors" "testing" @@ -28,50 +27,11 @@ import ( type UnmarshalTester struct { models.Alpine -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/hashedrekord/hashedrekord_test.go b/pkg/types/hashedrekord/hashedrekord_test.go index 0abde63299cd390f2ce1c3439464db5212bc864a..5dda7f57c36a0608dab5ae6a5d81886bb9d5d39e 100644 --- a/pkg/types/hashedrekord/hashedrekord_test.go +++ b/pkg/types/hashedrekord/hashedrekord_test.go @@ -16,7 +16,6 @@ package hashedrekord import ( - "context" "errors" "testing" @@ -28,46 +27,11 @@ import ( type UnmarshalTester struct { models.Hashedrekord -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/helm/helm_test.go b/pkg/types/helm/helm_test.go index e628a5783b2af299ef1d7f4c740dc3da8ae4f6fd..72cba153bc1b3a284c98693a13cb78b7ef41c674 100644 --- a/pkg/types/helm/helm_test.go +++ b/pkg/types/helm/helm_test.go @@ -16,7 +16,6 @@ package helm import ( - "context" "errors" "testing" @@ -28,50 +27,11 @@ import ( type UnmarshalTester struct { models.Helm -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/intoto/intoto_test.go b/pkg/types/intoto/intoto_test.go index 7ff7cfdb02204989a66fdd65ac690bd497052dbe..69a9bbb8523ade8e9f396cbb561117892cdd68d2 100644 --- a/pkg/types/intoto/intoto_test.go +++ b/pkg/types/intoto/intoto_test.go @@ -16,7 +16,6 @@ package intoto import ( - "context" "errors" "testing" @@ -28,50 +27,11 @@ import ( type UnmarshalTester struct { models.Intoto -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/jar/jar_test.go b/pkg/types/jar/jar_test.go index 92ee515ac1c65efa236e0c72a4bdfe35c557d04a..b602141862f24e95f428d83b001b3881e290e3e4 100644 --- a/pkg/types/jar/jar_test.go +++ b/pkg/types/jar/jar_test.go @@ -16,7 +16,6 @@ package jar import ( - "context" "errors" "testing" @@ -27,50 +26,11 @@ import ( type UnmarshalTester struct { models.Jar -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/rekord/rekord_test.go b/pkg/types/rekord/rekord_test.go index 1f781eb31363582be6cb4006efd55f643196efca..7b77db62b861dc9baeb070d453f3a047ef394a8a 100644 --- a/pkg/types/rekord/rekord_test.go +++ b/pkg/types/rekord/rekord_test.go @@ -16,7 +16,6 @@ package rekord import ( - "context" "errors" "testing" @@ -28,50 +27,11 @@ import ( type UnmarshalTester struct { models.Rekord -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/rfc3161/rfc3161_test.go b/pkg/types/rfc3161/rfc3161_test.go index dd8c6e642f946c4fb0b246a87bd94f3ea47b6acb..fda59023ee606a4cb7926e51b777b7caadb74f92 100644 --- a/pkg/types/rfc3161/rfc3161_test.go +++ b/pkg/types/rfc3161/rfc3161_test.go @@ -16,7 +16,6 @@ package rfc3161 import ( - "context" "errors" "testing" @@ -28,53 +27,11 @@ import ( type UnmarshalTester struct { models.Rfc3161 -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalFailsTester) Attestation() (string, []byte) { - return "", nil -} -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/rpm/rpm_test.go b/pkg/types/rpm/rpm_test.go index df276d5ac485e2d789a592d0d37180fc4979e18c..9fa25edcc1f34e8ab601f867040a90f24f014c8c 100644 --- a/pkg/types/rpm/rpm_test.go +++ b/pkg/types/rpm/rpm_test.go @@ -16,7 +16,6 @@ package rpm import ( - "context" "errors" "testing" @@ -28,50 +27,11 @@ import ( type UnmarshalTester struct { models.Rpm -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Validate() error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl { diff --git a/pkg/types/test_util.go b/pkg/types/test_util.go new file mode 100644 index 0000000000000000000000000000000000000000..bd663e0ee529300d6174f89c62bbb7140e7f97b4 --- /dev/null +++ b/pkg/types/test_util.go @@ -0,0 +1,57 @@ +/* +Copyright © 2021 The Sigstore Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +import ( + "context" + + "github.com/sigstore/rekor/pkg/generated/models" +) + +type BaseUnmarshalTester struct{} + +func (u BaseUnmarshalTester) NewEntry() EntryImpl { + return &BaseUnmarshalTester{} +} + +func (u BaseUnmarshalTester) APIVersion() string { + return "2.0.1" +} + +func (u BaseUnmarshalTester) IndexKeys() ([]string, error) { + return []string{}, nil +} + +func (u BaseUnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { + return nil, nil +} + +func (u BaseUnmarshalTester) Unmarshal(pe models.ProposedEntry) error { + return nil +} + +func (u BaseUnmarshalTester) Validate() error { + return nil +} + +func (u BaseUnmarshalTester) Attestation() (string, []byte) { + return "", nil +} + +func (u BaseUnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ ArtifactProperties) (models.ProposedEntry, error) { + return nil, nil +} diff --git a/pkg/types/tuf/tuf_test.go b/pkg/types/tuf/tuf_test.go index 172d0cb3ca36b9a68db019bb3c442c1edc46ba53..572947fb237d5476d3666639b80dc0cb776fadfe 100644 --- a/pkg/types/tuf/tuf_test.go +++ b/pkg/types/tuf/tuf_test.go @@ -17,7 +17,6 @@ limitations under the License. package tuf import ( - "context" "errors" "testing" @@ -28,46 +27,11 @@ import ( type UnmarshalTester struct { models.TUF -} - -func (u UnmarshalTester) NewEntry() types.EntryImpl { - return &UnmarshalTester{} -} - -func (u UnmarshalTester) APIVersion() string { - return "2.0.1" -} - -func (u UnmarshalTester) IndexKeys() ([]string, error) { - return []string{}, nil -} - -func (u UnmarshalTester) Canonicalize(ctx context.Context) ([]byte, error) { - return nil, nil -} - -func (u UnmarshalTester) HasExternalEntities() bool { - return false -} - -func (u *UnmarshalTester) FetchExternalEntities(ctx context.Context) error { - return nil -} - -func (u UnmarshalTester) Unmarshal(pe models.ProposedEntry) error { - return nil -} - -func (u UnmarshalTester) Attestation() (string, []byte) { - return "", nil -} - -func (u UnmarshalTester) CreateFromArtifactProperties(_ context.Context, _ types.ArtifactProperties) (models.ProposedEntry, error) { - return nil, nil + types.BaseUnmarshalTester } type UnmarshalFailsTester struct { - UnmarshalTester + types.BaseUnmarshalTester } func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {