6 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
7 . "github.com/onsi/ginkgo/v2"
8 . "github.com/onsi/gomega"
11var _ = Describe("Common", func() {
12 var validSecretSourceValue []byte
13 const validSecretSourceEnv = "OAUTH2_PROXY_TEST_SECRET_SOURCE_ENV"
14 var validSecretSourceFile string
17 validSecretSourceValue = []byte("This is a secret source value")
18 Expect(os.Setenv(validSecretSourceEnv, "This is a secret source env")).To(Succeed())
19 tmp, err := os.CreateTemp("", "oauth2-proxy-secret-source-test")
20 Expect(err).ToNot(HaveOccurred())
23 _, err = tmp.Write([]byte("This is a secret source file"))
24 Expect(err).ToNot(HaveOccurred())
26 validSecretSourceFile = tmp.Name()
30 Expect(os.Unsetenv(validSecretSourceEnv)).To(Succeed())
31 Expect(os.Remove(validSecretSourceFile)).To(Succeed())
34 type validateSecretSourceTableInput struct {
35 source func() options.SecretSource
39 DescribeTable("validateSecretSource should",
40 func(in validateSecretSourceTableInput) {
41 Expect(validateSecretSource(in.source())).To(Equal(in.expectedMsg))
43 Entry("with no entries", validateSecretSourceTableInput{
44 source: func() options.SecretSource {
45 return options.SecretSource{}
47 expectedMsg: multipleValuesForSecretSource,
49 Entry("with a Value and FromEnv", validateSecretSourceTableInput{
50 source: func() options.SecretSource {
51 return options.SecretSource{
52 Value: validSecretSourceValue,
53 FromEnv: validSecretSourceEnv,
56 expectedMsg: multipleValuesForSecretSource,
58 Entry("with a Value and FromFile", validateSecretSourceTableInput{
59 source: func() options.SecretSource {
60 return options.SecretSource{
61 Value: validSecretSourceValue,
62 FromFile: validSecretSourceFile,
65 expectedMsg: multipleValuesForSecretSource,
67 Entry("with FromEnv and FromFile", validateSecretSourceTableInput{
68 source: func() options.SecretSource {
69 return options.SecretSource{
70 FromEnv: validSecretSourceEnv,
71 FromFile: validSecretSourceFile,
74 expectedMsg: multipleValuesForSecretSource,
76 Entry("with a Value, FromEnv and FromFile", validateSecretSourceTableInput{
77 source: func() options.SecretSource {
78 return options.SecretSource{
79 Value: validSecretSourceValue,
80 FromEnv: validSecretSourceEnv,
81 FromFile: validSecretSourceFile,
84 expectedMsg: multipleValuesForSecretSource,
86 Entry("with a valid Value", validateSecretSourceTableInput{
87 source: func() options.SecretSource {
88 return options.SecretSource{
89 Value: validSecretSourceValue,
94 Entry("with a valid FromEnv", validateSecretSourceTableInput{
95 source: func() options.SecretSource {
96 return options.SecretSource{
97 FromEnv: validSecretSourceEnv,
102 Entry("with a valid FromFile", validateSecretSourceTableInput{
103 source: func() options.SecretSource {
104 return options.SecretSource{
105 FromFile: validSecretSourceFile,
110 Entry("with an invalid FromEnv", validateSecretSourceTableInput{
111 source: func() options.SecretSource {
112 return options.SecretSource{
113 FromEnv: "INVALID_ENV",
116 expectedMsg: "error loading secret from environent: no value for for key \"INVALID_ENV\"",
118 Entry("with an invalid FromFile", validateSecretSourceTableInput{
119 source: func() options.SecretSource {
120 return options.SecretSource{
121 FromFile: "invalidFile",
124 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