7 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
8 . "github.com/onsi/ginkgo"
9 . "github.com/onsi/ginkgo/extensions/table"
10 . "github.com/onsi/gomega"
13var _ = Describe("Common", func() {
14 var validSecretSourceValue []byte
15 const validSecretSourceEnv = "OAUTH2_PROXY_TEST_SECRET_SOURCE_ENV"
16 var validSecretSourceFile string
19 validSecretSourceValue = []byte("This is a secret source value")
20 Expect(os.Setenv(validSecretSourceEnv, "This is a secret source env")).To(Succeed())
21 tmp, err := ioutil.TempFile("", "oauth2-proxy-secret-source-test")
22 Expect(err).ToNot(HaveOccurred())
25 _, err = tmp.Write([]byte("This is a secret source file"))
26 Expect(err).ToNot(HaveOccurred())
28 validSecretSourceFile = tmp.Name()
32 Expect(os.Unsetenv(validSecretSourceEnv)).To(Succeed())
33 Expect(os.Remove(validSecretSourceFile)).To(Succeed())
36 type validateSecretSourceTableInput struct {
37 source func() options.SecretSource
41 DescribeTable("validateSecretSource should",
42 func(in validateSecretSourceTableInput) {
43 Expect(validateSecretSource(in.source())).To(Equal(in.expectedMsg))
45 Entry("with no entries", validateSecretSourceTableInput{
46 source: func() options.SecretSource {
47 return options.SecretSource{}
49 expectedMsg: multipleValuesForSecretSource,
51 Entry("with a Value and FromEnv", validateSecretSourceTableInput{
52 source: func() options.SecretSource {
53 return options.SecretSource{
54 Value: validSecretSourceValue,
55 FromEnv: validSecretSourceEnv,
58 expectedMsg: multipleValuesForSecretSource,
60 Entry("with a Value and FromFile", validateSecretSourceTableInput{
61 source: func() options.SecretSource {
62 return options.SecretSource{
63 Value: validSecretSourceValue,
64 FromFile: validSecretSourceFile,
67 expectedMsg: multipleValuesForSecretSource,
69 Entry("with FromEnv and FromFile", validateSecretSourceTableInput{
70 source: func() options.SecretSource {
71 return options.SecretSource{
72 FromEnv: validSecretSourceEnv,
73 FromFile: validSecretSourceFile,
76 expectedMsg: multipleValuesForSecretSource,
78 Entry("with a Value, FromEnv and FromFile", validateSecretSourceTableInput{
79 source: func() options.SecretSource {
80 return options.SecretSource{
81 Value: validSecretSourceValue,
82 FromEnv: validSecretSourceEnv,
83 FromFile: validSecretSourceFile,
86 expectedMsg: multipleValuesForSecretSource,
88 Entry("with a valid Value", validateSecretSourceTableInput{
89 source: func() options.SecretSource {
90 return options.SecretSource{
91 Value: validSecretSourceValue,
96 Entry("with a valid FromEnv", validateSecretSourceTableInput{
97 source: func() options.SecretSource {
98 return options.SecretSource{
99 FromEnv: validSecretSourceEnv,
104 Entry("with a valid FromFile", validateSecretSourceTableInput{
105 source: func() options.SecretSource {
106 return options.SecretSource{
107 FromFile: validSecretSourceFile,
112 Entry("with an invalid FromEnv", validateSecretSourceTableInput{
113 source: func() options.SecretSource {
114 return options.SecretSource{
115 FromEnv: "INVALID_ENV",
118 expectedMsg: "error loading secret from environent: no value for for key \"INVALID_ENV\"",
120 Entry("with an invalid FromFile", validateSecretSourceTableInput{
121 source: func() options.SecretSource {
122 return options.SecretSource{
123 FromFile: "invalidFile",
126 expectedMsg: "error loadig secret from file: stat invalidFile: no such file or directory",
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list