-
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.
- Loading branch information
1 parent
4051d89
commit 0769cff
Showing
4 changed files
with
109 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package identity | ||
|
||
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" | ||
"github.com/open-component-model/ocm/pkg/contexts/datacontext" | ||
"github.com/open-component-model/ocm/pkg/contexts/oci" | ||
ociidentity "github.com/open-component-model/ocm/pkg/contexts/oci/identity" | ||
) | ||
|
||
var _ = Describe("consumer id handling", func() { | ||
Context("id deternation", func() { | ||
It("handles helm repos", func() { | ||
id := GetConsumerId("https://acme.org/charts", "demo:v1") | ||
Expect(id).To(Equal(credentials.NewConsumerIdentity(CONSUMER_TYPE, | ||
"pathprefix", "charts", | ||
"port", "443", | ||
"hostname", "acme.org", | ||
"scheme", "https", | ||
))) | ||
}) | ||
|
||
It("handles oci repos", func() { | ||
id := GetConsumerId("oci://acme.org/charts", "demo:v1") | ||
Expect(id).To(Equal(credentials.NewConsumerIdentity(ociidentity.CONSUMER_TYPE, | ||
"pathprefix", "charts/demo", | ||
"hostname", "acme.org", | ||
))) | ||
}) | ||
}) | ||
|
||
Context("query credentials", func() { | ||
var ctx oci.Context | ||
var credctx credentials.Context | ||
|
||
BeforeEach(func() { | ||
ctx = oci.New(datacontext.MODE_EXTENDED) | ||
credctx = ctx.CredentialsContext() | ||
}) | ||
|
||
It("queries helm credentials", func() { | ||
id := GetConsumerId("https://acme.org/charts", "demo:v1") | ||
credctx.SetCredentialsForConsumer(id, | ||
credentials.DirectCredentials{ | ||
ATTR_USERNAME: "helm", | ||
ATTR_PASSWORD: "helmpass", | ||
}, | ||
) | ||
|
||
creds := GetCredentials(ctx, "https://acme.org/charts", "demo:v1") | ||
Expect(creds).To(Equal(common.Properties{ | ||
ATTR_USERNAME: "helm", | ||
ATTR_PASSWORD: "helmpass", | ||
})) | ||
}) | ||
|
||
It("queries oci credentials", func() { | ||
id := GetConsumerId("oci://acme.org/charts", "demo:v1") | ||
credctx.SetCredentialsForConsumer(id, | ||
credentials.DirectCredentials{ | ||
ATTR_USERNAME: "oci", | ||
ATTR_PASSWORD: "ocipass", | ||
}, | ||
) | ||
|
||
creds := GetCredentials(ctx, "oci://acme.org/charts", "demo:v1") | ||
Expect(creds).To(Equal(common.Properties{ | ||
ATTR_USERNAME: "oci", | ||
ATTR_PASSWORD: "ocipass", | ||
})) | ||
}) | ||
}) | ||
}) |
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,17 @@ | ||
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package identity_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Helm Identity Suite") | ||
} |