-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: returning a validation error in case of wrong configuration. (#157)
* fix: returning a validation error in case of wrong configuration. As of now, while using deck to create a route-scoped plugin with a `service` field defined, the sync goes through the first time but errors out subsequently. Under a route, we do not want the user to add the `service` field for a plugin. Thus, we are checking for this specific scenario and erroring out, instead of letting the sync action go through. For: Kong/deck#1353 * fix: added checks for all conflicting nested configs in plugins. A foreign key nested under a plugin of a different scope would error out. This would make sure that a sync does not go through when wrong configurations are passed via deck. An example would be adding a `service` field in a plugin, nested under a route. This change ensures more such issues do not come up. * test: added integration test for validations related to scoped plugins * chore: removed redundant code lines * chore: removed stray code lines from test * test: fixed tests and added more for kong <3.0 * chore: addressed PR comments
- Loading branch information
1 parent
1f4216e
commit ae9c42b
Showing
8 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/integration/testdata/sync/036-scoped-plugins-validation/3x/consumer-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
_format_version: "3.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 | ||
consumers: | ||
- username: foo | ||
plugins: | ||
- name: request-transformer | ||
route: example-route | ||
service: example-service | ||
config: | ||
add: | ||
querystring: | ||
- test |
16 changes: 16 additions & 0 deletions
16
tests/integration/testdata/sync/036-scoped-plugins-validation/3x/route-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_format_version: "3.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 | ||
plugins: | ||
- name: request-transformer | ||
service: example-service | ||
config: | ||
add: | ||
querystring: | ||
- test |
17 changes: 17 additions & 0 deletions
17
tests/integration/testdata/sync/036-scoped-plugins-validation/3x/service-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
_format_version: "3.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
plugins: | ||
- name: request-transformer | ||
route: example-route | ||
consumer: foo | ||
config: | ||
add: | ||
querystring: | ||
- test | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 |
19 changes: 19 additions & 0 deletions
19
tests/integration/testdata/sync/036-scoped-plugins-validation/consumer-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
_format_version: "1.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 | ||
consumers: | ||
- username: foo | ||
plugins: | ||
- name: request-transformer | ||
route: example-route | ||
service: example-service | ||
config: | ||
add: | ||
querystring: | ||
- test |
16 changes: 16 additions & 0 deletions
16
tests/integration/testdata/sync/036-scoped-plugins-validation/route-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_format_version: "1.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 | ||
plugins: | ||
- name: request-transformer | ||
service: example-service | ||
config: | ||
add: | ||
querystring: | ||
- test |
17 changes: 17 additions & 0 deletions
17
tests/integration/testdata/sync/036-scoped-plugins-validation/service-plugins.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
_format_version: "1.0" | ||
services: | ||
- name: example-service | ||
port: 3200 | ||
protocol: http | ||
plugins: | ||
- name: request-transformer | ||
route: example-route | ||
consumer: foo | ||
config: | ||
add: | ||
querystring: | ||
- test | ||
routes: | ||
- name: example-route | ||
paths: | ||
- ~/r1 |