Skip to content

Commit

Permalink
Merge branch 'master' into id-token-check
Browse files Browse the repository at this point in the history
  • Loading branch information
johakoch authored Nov 25, 2021
2 parents 496b48a + 61f5b9e commit b5d6ca5
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 34 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Unreleased changes are available as `avenga/couper:edge` container.
* Log file descriptor limit at startup ([#383](https://github.com/avenga/couper/pull/383))
* [`error_handler`](/docs/ERRORS.md) block support for `api` and `endpoint` blocks ([#317](https://github.com/avenga/couper/pull/317))
* Enables reacting to additional [error types](/docs/ERRORS.md#error-types): `beta_scope`, `beta_insufficient_scope` and `beta_operation_denied`
* `split()` and `substr()`[./docs/REFERENCE.md#functions] ([#390](https://github.com/avenga/couper/pull/390))
* `split()` and `substr()` [functions](./docs/REFERENCE.md#functions) ([#390](https://github.com/avenga/couper/pull/390))
* hcl syntax verification for our configuration file ([#296](https://github.com/avenga/couper/pull/296)), ([#168](https://github.com/avenga/couper/issues/168)), ([#188](https://github.com/avenga/couper/issues/188))
* validate against the schema and additional requirements
* available as [`verify`](docs/CLI.md) command too

* **Changed**
* [`server` block](./docs/REFERENCE.md#server-block) label is now optional, [`api` block](./docs/REFERENCE.md#api-block) may be labelled ([#358](https://github.com/avenga/couper/pull/358))
Expand All @@ -34,7 +37,6 @@ Unreleased changes are available as `avenga/couper:edge` container.

* **Added**
* `Accept: application/json` request header to the OAuth2 token request, in order to make the Github token endpoint respond with a JSON token response ([#307](https://github.com/avenga/couper/pull/307))
* [`verify`](docs/CLI.md) command to be able to check the syntax of a configuration file w/o starting the server ([#296](https://github.com/avenga/couper/pull/296)), ([#168](https://github.com/avenga/couper/issues/168)), ([#188](https://github.com/avenga/couper/issues/188))
* Documentation of [logs](docs/LOGS.md) ([#310](https://github.com/avenga/couper/pull/310))
* `signing_ttl` and `signing_key`/`signing_key_file` to [`jwt` block](./docs/REFERENCE.md#jwt-block) for use with [`jwt_sign()` function](#functions) ([#309](https://github.com/avenga/couper/pull/309))
* `jwks_url` and `jwks_ttl` to [`jwt` block](./docs/REFERENCE.md#jwt-block) ([#312](https://github.com/avenga/couper/pull/312))
Expand Down
2 changes: 1 addition & 1 deletion accesscontrol/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func TestJwtConfig(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
conf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
conf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if conf != nil {
_, err = runtime.NewServerConfiguration(conf, log.WithContext(context.TODO()), nil)
}
Expand Down
4 changes: 2 additions & 2 deletions command/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestNewRun(t *testing.T) {
return
}

couperFile, err := configload.LoadFile(filepath.Join(wd, "testdata/settings", tt.file), false)
couperFile, err := configload.LoadFile(filepath.Join(wd, "testdata/settings", tt.file))
if err != nil {
subT.Error(err)
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestAcceptForwarded(t *testing.T) {
return
}

couperFile, err := configload.LoadFile(filepath.Join(wd, "testdata/settings", tt.file), false)
couperFile, err := configload.LoadFile(filepath.Join(wd, "testdata/settings", tt.file))
if err != nil {
subT.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion command/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (v Verify) Execute(args Args, _ *config.Couper, logger *logrus.Entry) error
return err
}

cf, err := configload.LoadFile(args[0], true)
cf, err := configload.LoadFile(args[0])
if diags, ok := err.(hcl.Diagnostics); ok {
for _, diag := range diags {
logger.WithError(diag).Error()
Expand Down
10 changes: 5 additions & 5 deletions config/configload/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func SetWorkingDirectory(configFile string) (string, error) {
return os.Getwd()
}

func LoadFile(filePath string, verifyOnly bool) (*config.Couper, error) {
func LoadFile(filePath string) (*config.Couper, error) {
_, err := SetWorkingDirectory(filePath)
if err != nil {
return nil, err
Expand All @@ -67,19 +67,19 @@ func LoadFile(filePath string, verifyOnly bool) (*config.Couper, error) {
return nil, fmt.Errorf("failed to load configuration: %w", err)
}

return LoadBytes(src, filename, verifyOnly)
return LoadBytes(src, filename)
}

func LoadBytes(src []byte, filename string, verifyOnly bool) (*config.Couper, error) {
func LoadBytes(src []byte, filename string) (*config.Couper, error) {
hclBody, diags := parser.Load(src, filename)
if diags.HasErrors() {
return nil, diags
}

return LoadConfig(hclBody, src, filename, verifyOnly)
return LoadConfig(hclBody, src, filename)
}

func LoadConfig(body hcl.Body, src []byte, filename string, verifyOnly bool) (*config.Couper, error) {
func LoadConfig(body hcl.Body, src []byte, filename string) (*config.Couper, error) {
if diags := ValidateConfigSchema(body, &config.Couper{}); diags.HasErrors() {
return nil, diags
}
Expand Down
2 changes: 1 addition & 1 deletion config/configload/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestLabels(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
conf, err := LoadBytes([]byte(tt.hcl), "couper.hcl", false)
conf, err := LoadBytes([]byte(tt.hcl), "couper.hcl")
if conf != nil {
_, err = runtime.NewServerConfiguration(conf, log, nil)
}
Expand Down
2 changes: 1 addition & 1 deletion config/runtime/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestACDefinitions_errors(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err != nil {
subT.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions eval/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestDefaultEnvVariables(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err != nil {
subT.Fatal(err)
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestCouperVariables(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err != nil {
subT.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions eval/lib/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ BShcGHZl9nzWDtEZzgdX7cbG5nRUo1+whzBQdYoQmg==

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err != nil {
subT.Fatal(err)
}
Expand Down Expand Up @@ -546,7 +546,7 @@ func TestJwtSignDynamic(t *testing.T) {
t.Run(tt.name, func(subT *testing.T) {
helper := test.New(subT)

cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
helper.Must(err)

claims, err := stdlib.JSONDecode(cty.StringVal(tt.claims))
Expand Down Expand Up @@ -846,7 +846,7 @@ func TestJwtSignConfigError(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
_, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
_, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err == nil {
subT.Fatalf("expected an error '%s', got nothing", tt.wantErr)
}
Expand Down Expand Up @@ -957,7 +957,7 @@ func TestJwtSignError(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
helper := test.New(subT)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
helper.Must(err)
claims, err := stdlib.JSONDecode(cty.StringVal(tt.claims))
helper.Must(err)
Expand Down
4 changes: 2 additions & 2 deletions eval/lib/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestMerge(t *testing.T) {
helper := test.New(t)

cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl")
helper.Must(err)

tests := []struct {
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestMerge(t *testing.T) {
func TestMergeErrors(t *testing.T) {
helper := test.New(t)

cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl")
helper.Must(err)

tests := []struct {
Expand Down
2 changes: 1 addition & 1 deletion eval/lib/saml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Test_SamlSsoUrl(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(subT *testing.T) {
h := test.New(subT)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
if err != nil {
if tt.wantErr {
return
Expand Down
2 changes: 1 addition & 1 deletion eval/lib/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestUnixtime(t *testing.T) {
helper := test.New(t)

cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl")
helper.Must(err)

hclContext := cf.Context.Value(request.ContextType).(*eval.Context).HCLContext()
Expand Down
4 changes: 2 additions & 2 deletions eval/lib/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestUrlEncode(t *testing.T) {
helper := test.New(t)

cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl")
helper.Must(err)

hclContext := cf.Context.Value(request.ContextType).(*eval.Context).HCLContext()
Expand All @@ -38,7 +38,7 @@ func TestUrlEncode(t *testing.T) {
func TestRelativeUrl(t *testing.T) {
helper := test.New(t)

cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl", false)
cf, err := configload.LoadBytes([]byte(`server "test" {}`), "couper.hcl")
helper.Must(err)

hclContext := cf.Context.Value(request.ContextType).(*eval.Context).HCLContext()
Expand Down
2 changes: 1 addition & 1 deletion fuzz/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ settings {
}
`, upstream.Addr(), upstream.Addr())

configFile, err := configload.LoadBytes([]byte(configFileContent), "fuzz_http.hcl", false)
configFile, err := configload.LoadBytes([]byte(configFileContent), "fuzz_http.hcl")
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func realmain(arguments []string) int {
return 0
}

confFile, err := configload.LoadFile(flags.FilePath, false)
confFile, err := configload.LoadFile(flags.FilePath)
if err != nil {
newLogger(flags.LogFormat, flags.LogLevel, flags.LogPretty).WithError(err).Error()
return 1
Expand Down Expand Up @@ -188,7 +188,7 @@ func realmain(arguments []string) int {
errRetries = 0 // reset
logger.Info("reloading couper configuration")

cf, reloadErr := configload.LoadFile(confFile.Filename, false) // we are at wd, just filename
cf, reloadErr := configload.LoadFile(confFile.Filename) // we are at wd, just filename
if reloadErr != nil {
logger.WithError(reloadErr).Error("reload failed")
time.Sleep(flags.FileWatchRetryDelay)
Expand Down
2 changes: 1 addition & 1 deletion server/http_error_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestAccessControl_ErrorHandler_BasicAuth_Wildcard(t *testing.T) {

func TestAccessControl_ErrorHandler_Configuration_Error(t *testing.T) {
helper := test.New(t)
couperConfig, err := configload.LoadFile("testdata/integration/error_handler/03_couper.hcl", false)
couperConfig, err := configload.LoadFile("testdata/integration/error_handler/03_couper.hcl")
helper.Must(err)

log, _ := logrustest.NewNullLogger()
Expand Down
6 changes: 3 additions & 3 deletions server/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func teardown() {
testBackend.Close()
}
func newCouper(file string, helper *test.Helper) (func(), *logrustest.Hook) {
couperConfig, err := configload.LoadFile(filepath.Join(testWorkingDir, file), false)
couperConfig, err := configload.LoadFile(filepath.Join(testWorkingDir, file))
helper.Must(err)

return newCouperWithConfig(couperConfig, helper)
Expand Down Expand Up @@ -110,7 +110,7 @@ func newCouperWithTemplate(file string, helper *test.Helper, vars map[string]int
}

func newCouperWithBytes(file []byte, helper *test.Helper) (func(), *logrustest.Hook) {
couperConfig, err := configload.LoadBytes(file, "couper-bytes.hcl", false)
couperConfig, err := configload.LoadBytes(file, "couper-bytes.hcl")
helper.Must(err)

return newCouperWithConfig(couperConfig, helper)
Expand Down Expand Up @@ -3136,7 +3136,7 @@ func TestJWTAccessControl(t *testing.T) {

func TestJWTAccessControlSourceConfig(t *testing.T) {
helper := test.New(t)
couperConfig, err := configload.LoadFile("testdata/integration/config/05_couper.hcl", false)
couperConfig, err := configload.LoadFile("testdata/integration/config/05_couper.hcl")
helper.Must(err)

log, _ := logrustest.NewNullLogger()
Expand Down
4 changes: 2 additions & 2 deletions server/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestHTTPServer_ServeHTTP_Files(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

conf, err := configload.LoadBytes(confBytes.Bytes(), "conf_test.hcl", false)
conf, err := configload.LoadBytes(confBytes.Bytes(), "conf_test.hcl")
helper.Must(err)
conf.Settings.DefaultPort = 0

Expand Down Expand Up @@ -156,7 +156,7 @@ func TestHTTPServer_ServeHTTP_Files2(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

conf, err := configload.LoadBytes(confBytes.Bytes(), "conf_fileserving.hcl", false)
conf, err := configload.LoadBytes(confBytes.Bytes(), "conf_fileserving.hcl")
helper.Must(err)

error404Content := []byte("<html><body><h1>route not found error: My custom error template</h1></body></html>")
Expand Down

0 comments on commit b5d6ca5

Please sign in to comment.