github.com/openshift-online/ocm-sdk-go@v0.1.473/authentication/securestore/main_test.go (about) 1 /* 2 Copyright (c) 2024 Red Hat, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // This file contains tests for the functions that extract authentication and authorization 18 // information from contexts. 19 20 package securestore 21 22 import ( 23 "testing" 24 25 . "github.com/onsi/ginkgo/v2/dsl/core" // nolint 26 . "github.com/onsi/gomega" // nolint 27 ) 28 29 func TestSecurestore(t *testing.T) { 30 RegisterFailHandler(Fail) 31 RunSpecs(t, "Authentication.Securestore") 32 } 33 34 var _ = Describe("Validation", func() { 35 It("Validates an invalid backend", func() { 36 err := ValidateBackend("invalid") 37 Expect(err).To(Equal(ErrKeyringInvalid)) 38 39 err = UpsertConfigToKeyring("invalid", []byte("test")) 40 Expect(err).To(Equal(ErrKeyringInvalid)) 41 42 bytes, err := GetConfigFromKeyring("invalid") 43 Expect(err).To(Equal(ErrKeyringInvalid)) 44 Expect(bytes).To(BeNil()) 45 46 err = RemoveConfigFromKeyring("invalid") 47 Expect(err).To(Equal(ErrKeyringInvalid)) 48 }) 49 50 It("Validates an empty backend", func() { 51 err := ValidateBackend("") 52 Expect(err).To(Equal(ErrKeyringInvalid)) 53 54 err = UpsertConfigToKeyring("", []byte("test")) 55 Expect(err).To(Equal(ErrKeyringInvalid)) 56 57 bytes, err := GetConfigFromKeyring("") 58 Expect(err).To(Equal(ErrKeyringInvalid)) 59 Expect(bytes).To(BeNil()) 60 61 err = RemoveConfigFromKeyring("") 62 Expect(err).To(Equal(ErrKeyringInvalid)) 63 }) 64 65 })