You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-12-19 23:52:17 +02:00
introduce mapstructure decoder for yaml parsing
remove color output in tests for better readability in github actions bugfix: remove google as default provider for alpha options fix conversion flow for toml to yaml revert ginkgo color deactivation revert claim- and secret source back to pointers regenerate alpha config Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -355,15 +355,15 @@ var _ = Describe("Load", func() {
|
||||
var _ = Describe("LoadYAML", func() {
|
||||
Context("with a testOptions structure", func() {
|
||||
type TestOptionSubStruct struct {
|
||||
StringSliceOption []string `yaml:"stringSliceOption,omitempty"`
|
||||
StringSliceOption []string `json:"stringSliceOption,omitempty"`
|
||||
}
|
||||
|
||||
type TestOptions struct {
|
||||
StringOption string `yaml:"stringOption,omitempty"`
|
||||
Sub TestOptionSubStruct `yaml:"sub,omitempty"`
|
||||
StringOption string `json:"stringOption,omitempty"`
|
||||
Sub TestOptionSubStruct `json:"sub,omitempty"`
|
||||
|
||||
// Check that embedded fields can be unmarshalled
|
||||
TestOptionSubStruct `yaml:",inline,squash"`
|
||||
TestOptionSubStruct `json:",inline,squash"`
|
||||
}
|
||||
|
||||
var testOptionsConfigBytesFull = []byte(`
|
||||
@@ -416,7 +416,7 @@ sub:
|
||||
|
||||
err := LoadYAML(configFileName, input)
|
||||
if in.expectedErr != nil {
|
||||
Expect(err).To(MatchError(in.expectedErr.Error()))
|
||||
Expect(err).To(MatchError(ContainSubstring(in.expectedErr.Error())))
|
||||
} else {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
@@ -459,13 +459,13 @@ sub:
|
||||
StringSliceOption: []string{"a", "b", "c"},
|
||||
},
|
||||
},
|
||||
expectedErr: errors.New("error unmarshalling config: error unmarshaling JSON: while decoding JSON: json: unknown field \"foo\""),
|
||||
expectedErr: errors.New("has invalid keys: foo"),
|
||||
}),
|
||||
Entry("with an incorrect type for a string field", loadYAMLTableInput{
|
||||
configFile: []byte(`stringOption: ["a", "b"]`),
|
||||
input: &TestOptions{},
|
||||
expectedOutput: &TestOptions{},
|
||||
expectedErr: errors.New("error unmarshalling config: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field TestOptions.StringOption of type string"),
|
||||
expectedErr: errors.New("'stringOption' expected type 'string', got unconvertible type"),
|
||||
}),
|
||||
Entry("with an incorrect type for an array field", loadYAMLTableInput{
|
||||
configFile: []byte(`stringSliceOption: "a"`),
|
||||
@@ -526,11 +526,13 @@ upstreamConfig:
|
||||
injectRequestHeaders:
|
||||
- name: X-Forwarded-User
|
||||
values:
|
||||
- claim: user
|
||||
- claimSource:
|
||||
claim: user
|
||||
injectResponseHeaders:
|
||||
- name: X-Secret
|
||||
values:
|
||||
- value: c2VjcmV0
|
||||
- secretSource:
|
||||
value: secret
|
||||
`)
|
||||
|
||||
By("Creating a config file")
|
||||
@@ -548,7 +550,7 @@ injectResponseHeaders:
|
||||
into := &AlphaOptions{}
|
||||
Expect(LoadYAML(configFileName, into)).To(Succeed())
|
||||
|
||||
flushInterval := Duration(500 * time.Millisecond)
|
||||
flushInterval := 500 * time.Millisecond
|
||||
|
||||
Expect(into).To(Equal(&AlphaOptions{
|
||||
UpstreamConfig: UpstreamConfig{
|
||||
@@ -579,7 +581,7 @@ injectResponseHeaders:
|
||||
Values: []HeaderValue{
|
||||
{
|
||||
SecretSource: &SecretSource{
|
||||
Value: []byte("secret"),
|
||||
Value: "secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user