Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cd copy + rsa-pss-signingserver #670

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions pkg/contexts/ocm/compdesc/copy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package compdesc_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/open-component-model/ocm/pkg/testutils"

"github.com/go-test/deep"

"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc"
v1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1"
"github.com/open-component-model/ocm/pkg/contexts/ocm/valuemergehandler/handlers/defaultmerge"
"github.com/open-component-model/ocm/pkg/runtime"
)

var _ = Describe("Component Descripor Copy Test Suitet", func() {
Context("compdesc copy", func() {
It("copies CD", func() {

labels := v1.Labels{
*Must(v1.NewLabel("label", "value",
v1.WithVersion("v1"),
v1.WithSigning(true),
v1.WithMerging(defaultmerge.ALGORITHM, defaultmerge.NewConfig(defaultmerge.MODE_LOCAL)))),
}
cd := compdesc.New("mandelsoft.org/test", "1.0.0")
cd.Metadata.ConfiguredVersion = "xxx"
cd.ObjectMeta.CreationTime = compdesc.NewTimestampP()
cd.ObjectMeta.Provider = v1.Provider{
Name: "mandelsoft",
Labels: labels,
}
cd.ObjectMeta.Labels = labels
cd.RepositoryContexts = runtime.UnstructuredTypedObjectList{
runtime.NewEmptyUnstructured("repo"),
}
cd.Resources = compdesc.Resources{
compdesc.Resource{
ResourceMeta: compdesc.ResourceMeta{
ElementMeta: compdesc.ElementMeta{
Name: "resc1",
Version: "v1",
ExtraIdentity: v1.NewExtraIdentity("id", "a"),
Labels: labels,
},
Type: "rsc",
Relation: v1.LocalRelation,
SourceRefs: nil,
Digest: &v1.DigestSpec{
HashAlgorithm: "hashalgo",
NormalisationAlgorithm: "normalgo",
Value: "digest",
},
},
Access: ociartifact.New("oci.com/image"),
},
}
cd.Sources = compdesc.Sources{
compdesc.Source{
SourceMeta: compdesc.SourceMeta{
ElementMeta: compdesc.ElementMeta{
Name: "src1",
Version: "v2",
ExtraIdentity: v1.NewExtraIdentity("id", "b"),
Labels: labels,
},
Type: "src",
},
Access: ociartifact.New("oci.com/otherimage"),
},
}
cd.References = compdesc.References{
compdesc.ComponentReference{
ElementMeta: compdesc.ElementMeta{},
ComponentName: "",
Digest: nil,
},
}

cd.Signatures = v1.Signatures{
v1.Signature{
Name: "sig",
Digest: v1.DigestSpec{
HashAlgorithm: "hashalgo2",
NormalisationAlgorithm: "normalgo2",
Value: "digest2",
},
Signature: v1.SignatureSpec{
Algorithm: "sigalgo",
Value: "sig",
MediaType: "media",
Issuer: "issuer",
},
Timestamp: &v1.TimestampSpec{
Value: "ts",
Time: compdesc.NewTimestampP(),
},
},
}
cp := cd.Copy()

Expect(deep.Equal(cd, cp)).To(BeNil())
})
})
})
9 changes: 5 additions & 4 deletions pkg/contexts/ocm/compdesc/meta/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ func (o *ObjectMeta) SetLabels(labels []Label) {
// GetName returns the name of the object.
func (o *ObjectMeta) Copy() *ObjectMeta {
return &ObjectMeta{
Name: o.Name,
Version: o.Version,
Labels: o.Labels.Copy(),
Provider: *o.Provider.Copy(),
Name: o.Name,
Version: o.Version,
Labels: o.Labels.Copy(),
Provider: *o.Provider.Copy(),
CreationTime: o.CreationTime.DeepCopy(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/signing/handlers/rsa-pss-signingservice/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ package rsa_pss_signingservice

import (
"github.com/open-component-model/ocm/pkg/signing"
"github.com/open-component-model/ocm/pkg/signing/handlers/rsa"
"github.com/open-component-model/ocm/pkg/signing/handlers/rsa-pss"
rsa_signingservice "github.com/open-component-model/ocm/pkg/signing/handlers/rsa-signingservice"
)

// Algorithm defines the type for the RSA PKCS #1 v1.5 signature algorithm.
const (
Algorithm = rsa.Algorithm
Algorithm = rsa_pss.Algorithm
Name = "rsapss-signingservice"
)

Expand Down
Loading