mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-28 16:00:22 +00:00
5fba89f783
Instead of the hand-rolled Vault usage, use the libopenstorage/secrets package that provides a nice API. The support for Vault becomes much simpler and maintainable that way. Signed-off-by: Niels de Vos <ndevos@redhat.com>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
/*
|
|
Copyright 2020 The Ceph-CSI Authors.
|
|
|
|
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 util
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestDetectAuthMountPath(t *testing.T) {
|
|
authMountPath, err := detectAuthMountPath(vaultDefaultAuthPath)
|
|
if err != nil {
|
|
t.Errorf("detectAuthMountPath() failed: %s", err)
|
|
}
|
|
if authMountPath != "kubernetes" {
|
|
t.Errorf("authMountPath should be set to 'kubernetes', but is: %s", authMountPath)
|
|
}
|
|
|
|
authMountPath, err = detectAuthMountPath("kubernetes")
|
|
if err != nil {
|
|
t.Errorf("detectAuthMountPath() failed: %s", err)
|
|
}
|
|
if authMountPath != "kubernetes" {
|
|
t.Errorf("authMountPath should be set to 'kubernetes', but is: %s", authMountPath)
|
|
}
|
|
}
|
|
|
|
func TestCreateTempFile(t *testing.T) {
|
|
data := []byte("Hello World!")
|
|
tmpfile, err := createTempFile("my-file", data)
|
|
if err != nil {
|
|
t.Errorf("createTempFile() failed: %s", err)
|
|
}
|
|
if tmpfile == "" {
|
|
t.Errorf("createTempFile() returned an empty filename")
|
|
}
|
|
|
|
err = os.Remove(tmpfile)
|
|
if err != nil {
|
|
t.Errorf("failed to remove tmpfile (%s): %s", tmpfile, err)
|
|
}
|
|
}
|