-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Watcher: Fix put watch action (#31524)
If no version is specified when putting a watch, the index API should be used instead of the update API, so that the whole watch gets overwritten instead of being merged with the existing one. Merging only happens when a version is specified, so that credentials can be omitted, which is important for the watcher UI.
- Loading branch information
Showing
3 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...rest-api-spec/test/watcher/put_watch/90_ensure_watch_gets_overwritten_without_version.yml
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,73 @@ | ||
--- | ||
"Test put watch api without version overwrites watch": | ||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
- do: | ||
xpack.watcher.put_watch: | ||
id: "my_watch" | ||
body: > | ||
{ | ||
"trigger": { | ||
"schedule": { | ||
"hourly": { | ||
"minute": [ 0, 5 ] | ||
} | ||
} | ||
}, | ||
"input": { | ||
"simple": { | ||
"foo": "bar" | ||
} | ||
}, | ||
"actions": { | ||
"logging": { | ||
"logging": { | ||
"text": "yaml test" | ||
} | ||
} | ||
} | ||
} | ||
- match: { _id: "my_watch" } | ||
|
||
- do: | ||
xpack.watcher.get_watch: | ||
id: "my_watch" | ||
- match: { watch.input.simple.foo: "bar" } | ||
|
||
# change the simple input fields, then ensure the old | ||
# field does not exist on get | ||
- do: | ||
xpack.watcher.put_watch: | ||
id: "my_watch" | ||
body: > | ||
{ | ||
"trigger": { | ||
"schedule": { | ||
"hourly": { | ||
"minute": [ 0, 5 ] | ||
} | ||
} | ||
}, | ||
"input": { | ||
"simple": { | ||
"spam": "eggs" | ||
} | ||
}, | ||
"actions": { | ||
"logging": { | ||
"logging": { | ||
"text": "yaml test" | ||
} | ||
} | ||
} | ||
} | ||
- match: { _id: "my_watch" } | ||
|
||
- do: | ||
xpack.watcher.get_watch: | ||
id: "my_watch" | ||
- match: { watch.input.simple.spam: "eggs" } | ||
- is_false: watch.input.simple.foo | ||
|
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