-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix credential provider handling (#611)
* fix crednetial provider handling * add consumer type for signing service
- Loading branch information
1 parent
fade9c4
commit dce53f2
Showing
11 changed files
with
221 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package genericocireg_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/open-component-model/ocm/pkg/common" | ||
"github.com/open-component-model/ocm/pkg/contexts/credentials" | ||
ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" | ||
"github.com/open-component-model/ocm/pkg/contexts/datacontext" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ocireg" | ||
. "github.com/open-component-model/ocm/pkg/testutils" | ||
|
||
"github.com/open-component-model/ocm/pkg/contexts/ocm" | ||
"github.com/open-component-model/ocm/pkg/finalizer" | ||
) | ||
|
||
var _ = Describe("consumer id handling", func() { | ||
It("creates a dummy component", func() { | ||
var finalize finalizer.Finalizer | ||
defer Defer(finalize.Finalize) | ||
|
||
ctx := ocm.New(datacontext.MODE_EXTENDED) | ||
credctx := ctx.CredentialsContext() | ||
|
||
creds := ociidentity.SimpleCredentials("test", "password") | ||
spec := ocireg.NewRepositorySpec("ghcr.io/open-component-model/test") | ||
|
||
id := credentials.GetProvidedConsumerId(spec, credentials.StringUsageContext(COMPONENT)) | ||
Expect(id).To(Equal(credentials.NewConsumerIdentity(ociidentity.CONSUMER_TYPE, ociidentity.ID_HOSTNAME, "ghcr.io", ociidentity.ID_PATHPREFIX, "open-component-model/test/component-descriptors/"+COMPONENT))) | ||
|
||
id = credentials.GetProvidedConsumerId(spec) | ||
Expect(id).To(Equal(credentials.NewConsumerIdentity(ociidentity.CONSUMER_TYPE, ociidentity.ID_HOSTNAME, "ghcr.io", ociidentity.ID_PATHPREFIX, "open-component-model/test"))) | ||
|
||
credctx.SetCredentialsForConsumer(id, creds) | ||
|
||
repo := finalizer.ClosingWith(&finalize, Must(DefaultContext.RepositoryForSpec(spec))) | ||
|
||
id = credentials.GetProvidedConsumerId(repo, credentials.StringUsageContext(COMPONENT)) | ||
Expect(id).To(Equal(credentials.NewConsumerIdentity(ociidentity.CONSUMER_TYPE, ociidentity.ID_HOSTNAME, "ghcr.io", ociidentity.ID_PATHPREFIX, "open-component-model/test/component-descriptors/"+COMPONENT))) | ||
|
||
creds = Must(credentials.CredentialsForConsumer(credctx, id)) | ||
|
||
Expect(creds.Properties()).To(Equal(common.Properties{ | ||
ociidentity.ATTR_USERNAME: "test", | ||
ociidentity.ATTR_PASSWORD: "password", | ||
})) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.