-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #911 from tylercreller/OCM-4966
Migrate keychain to use non-CGO libraries
- Loading branch information
Showing
16 changed files
with
487 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
/* | ||
Copyright (c) 2019 Red Hat, Inc. | ||
|
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,71 @@ | ||
//go:build darwin | ||
// +build darwin | ||
|
||
/* | ||
Copyright (c) 2024 Red Hat, Inc. | ||
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 securestore | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" // nolint | ||
. "github.com/onsi/gomega" // nolint | ||
|
||
. "github.com/openshift-online/ocm-sdk-go/testing" // nolint | ||
) | ||
|
||
var _ = Describe("Keychain", func() { | ||
const backend = "keychain" | ||
|
||
BeforeEach(func() { | ||
err := RemoveConfigFromKeyring(backend) | ||
Expect(err).To(BeNil()) | ||
}) | ||
|
||
When("Listing Keyrings", func() { | ||
It("Lists keychain as a valid keyring", func() { | ||
backends := AvailableBackends() | ||
Expect(backends).To(ContainElement(backend)) | ||
}) | ||
}) | ||
|
||
When("Using Keychain", func() { | ||
It("Stores/Removes via Keychain", func() { | ||
// Create the token | ||
accessToken := MakeTokenString("Bearer", 15*time.Minute) | ||
|
||
// Run insert | ||
err := UpsertConfigToKeyring(backend, []byte(accessToken)) | ||
|
||
Expect(err).To(BeNil()) | ||
|
||
// Check the content of the keyring | ||
result, err := GetConfigFromKeyring(backend) | ||
Expect(result).To(Equal([]byte(accessToken))) | ||
Expect(err).To(BeNil()) | ||
|
||
// Remove the configuration from the keyring | ||
err = RemoveConfigFromKeyring(backend) | ||
Expect(err).To(BeNil()) | ||
|
||
// Ensure the keyring is empty | ||
result, err = GetConfigFromKeyring(backend) | ||
Expect(result).To(Equal([]byte(""))) | ||
Expect(err).To(BeNil()) | ||
}) | ||
}) | ||
}) |
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.