forked from openshift/rosa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags_test.go
59 lines (51 loc) · 1.79 KB
/
flags_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package breakglasscredential
import (
"time"
. "github.com/onsi/ginkgo/v2/dsl/core"
. "github.com/onsi/gomega"
"github.com/openshift/rosa/pkg/test"
)
var _ = Describe("Break glass credential", func() {
Context("CreateBreakGlassConfig", func() {
It("Returns the value with nil arg", func() {
args := BreakGlassCredentialArgs{}
credential, err := CreateBreakGlassConfig(&args)
Expect(err).NotTo(HaveOccurred())
Expect(credential).NotTo(BeNil())
})
It("Returns the expected value with just username set", func() {
args := BreakGlassCredentialArgs{
username: "abc",
}
credential, err := CreateBreakGlassConfig(&args)
Expect(err).NotTo(HaveOccurred())
Expect(credential.Username()).To(Equal("abc"))
})
It("Returns the expected value with just expirationDuration set", func() {
args := BreakGlassCredentialArgs{
expirationDuration: time.Hour,
}
credential, err := CreateBreakGlassConfig(&args)
Expect(err).NotTo(HaveOccurred())
Expect(credential.Username()).To(Equal(""))
Expect(credential.ExpirationTimestamp()).To(Equal(time.Now().Add(time.Hour).Round(time.Second)))
})
It("Returns the expected value with both username and expirationDuration set", func() {
args := BreakGlassCredentialArgs{
username: "abc",
expirationDuration: time.Hour,
}
credential, err := CreateBreakGlassConfig(&args)
Expect(err).NotTo(HaveOccurred())
Expect(credential.Username()).To(Equal("abc"))
Expect(credential.ExpirationTimestamp()).To(Equal(time.Now().Add(time.Hour).Round(time.Second)))
})
})
Context("FormatBreakGlassCredentialOutput", func() {
It("Should not fail", func() {
credential := test.BuildBreakGlassCredential()
_, err := FormatBreakGlassCredentialOutput(credential)
Expect(err).To(Not(HaveOccurred()))
})
})
})