2019-03-13 17:23:00 +00:00
|
|
|
/*
|
|
|
|
Copyright 2019 the Velero contributors.
|
|
|
|
|
|
|
|
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 install
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestResources(t *testing.T) {
|
2020-10-13 23:13:42 +00:00
|
|
|
bsl := BackupStorageLocation(DefaultVeleroNamespace, "test", "test", "", make(map[string]string), []byte("test"))
|
2019-03-13 17:23:00 +00:00
|
|
|
|
|
|
|
assert.Equal(t, "velero", bsl.ObjectMeta.Namespace)
|
|
|
|
assert.Equal(t, "test", bsl.Spec.Provider)
|
|
|
|
assert.Equal(t, "test", bsl.Spec.StorageType.ObjectStorage.Bucket)
|
|
|
|
assert.Equal(t, make(map[string]string), bsl.Spec.Config)
|
2020-03-31 20:48:16 +00:00
|
|
|
assert.Equal(t, []byte("test"), bsl.Spec.ObjectStorage.CACert)
|
2019-03-13 17:23:00 +00:00
|
|
|
|
2020-10-13 23:13:42 +00:00
|
|
|
vsl := VolumeSnapshotLocation(DefaultVeleroNamespace, "test", make(map[string]string))
|
2019-03-13 17:23:00 +00:00
|
|
|
|
|
|
|
assert.Equal(t, "velero", vsl.ObjectMeta.Namespace)
|
|
|
|
assert.Equal(t, "test", vsl.Spec.Provider)
|
|
|
|
assert.Equal(t, make(map[string]string), vsl.Spec.Config)
|
|
|
|
|
|
|
|
ns := Namespace("velero")
|
|
|
|
|
|
|
|
assert.Equal(t, "velero", ns.Name)
|
|
|
|
|
2020-10-13 23:13:42 +00:00
|
|
|
crb := ClusterRoleBinding(DefaultVeleroNamespace)
|
2019-03-13 17:23:00 +00:00
|
|
|
// The CRB is a cluster-scoped resource
|
|
|
|
assert.Equal(t, "", crb.ObjectMeta.Namespace)
|
2020-10-13 23:13:42 +00:00
|
|
|
assert.Equal(t, "velero", crb.ObjectMeta.Name)
|
2019-03-13 17:23:00 +00:00
|
|
|
assert.Equal(t, "velero", crb.Subjects[0].Namespace)
|
|
|
|
|
2020-10-13 23:13:42 +00:00
|
|
|
customNamespaceCRB := ClusterRoleBinding("foo")
|
|
|
|
// The CRB is a cluster-scoped resource
|
|
|
|
assert.Equal(t, "", customNamespaceCRB.ObjectMeta.Namespace)
|
|
|
|
assert.Equal(t, "velero-foo", customNamespaceCRB.ObjectMeta.Name)
|
|
|
|
assert.Equal(t, "foo", customNamespaceCRB.Subjects[0].Namespace)
|
|
|
|
|
|
|
|
sa := ServiceAccount(DefaultVeleroNamespace, map[string]string{"abcd": "cbd"})
|
2019-03-13 17:23:00 +00:00
|
|
|
assert.Equal(t, "velero", sa.ObjectMeta.Namespace)
|
2019-10-03 20:45:18 +00:00
|
|
|
assert.Equal(t, "cbd", sa.ObjectMeta.Annotations["abcd"])
|
2019-03-13 17:23:00 +00:00
|
|
|
}
|