Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Ensure KV flags are passed through to Consul on update #7216

Merged
merged 3 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui-v2/app/adapters/kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default Adapter.extend({
requestForUpdateRecord: function(request, serialized, data) {
const params = {
...this.formatDatacenter(data[DATACENTER_KEY]),
flags: data.Flags,
...this.formatNspace(data[NSPACE_KEY]),
};
return request`
Expand Down
16 changes: 10 additions & 6 deletions ui-v2/tests/acceptance/dc/kvs/update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml
---
Key: "[Name]"
Flags: 12
---
When I visit the kv page for yaml
---
Expand All @@ -21,7 +22,7 @@ Feature: dc / kvs / update: KV Update
value: [Value]
---
And I submit
Then a PUT request was made to "/v1/kv/[EncodedName]?dc=datacenter&ns=@!namespace" with the body "[Value]"
Then a PUT request was made to "/v1/kv/[EncodedName]?dc=datacenter&flags=12&ns=@!namespace" with the body "[Value]"
And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class
Where:
Expand All @@ -37,6 +38,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml
---
Key: key
Flags: 12
---
When I visit the kv page for yaml
---
Expand All @@ -51,7 +53,7 @@ Feature: dc / kvs / update: KV Update
value: ' '
---
And I submit
Then a PUT request was made to "/v1/kv/key?dc=datacenter&ns=@!namespace" with the body " "
Then a PUT request was made to "/v1/kv/key?dc=datacenter&flags=12&ns=@!namespace" with the body " "
Then the url should be /datacenter/kv
And the title should be "Key/Value - Consul"
And "[data-notification]" has the "notification-update" class
Expand All @@ -60,6 +62,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml
---
Key: key
Flags: 12
---
When I visit the kv page for yaml
---
Expand All @@ -74,15 +77,16 @@ Feature: dc / kvs / update: KV Update
value: ''
---
And I submit
Then a PUT request was made to "/v1/kv/key?dc=datacenter&ns=@!namespace" with no body
Then a PUT request was made to "/v1/kv/key?dc=datacenter&flags=12&ns=@!namespace" with no body
Then the url should be /datacenter/kv
And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class
Scenario: Update to a key when the value is empty
And 1 kv model from yaml
---
Key: key
Value: ~
Key: key
Value: ~
Flags: 12
---
When I visit the kv page for yaml
---
Expand All @@ -91,7 +95,7 @@ Feature: dc / kvs / update: KV Update
---
Then the url should be /datacenter/kv/key/edit
And I submit
Then a PUT request was made to "/v1/kv/key?dc=datacenter&ns=@!namespace" with no body
Then a PUT request was made to "/v1/kv/key?dc=datacenter&flags=12&ns=@!namespace" with no body
Then the url should be /datacenter/kv
And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class
Expand Down
4 changes: 3 additions & 1 deletion ui-v2/tests/integration/adapters/kv-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ module('Integration | Adapter | kv', function(hooks) {
test(`requestForUpdateRecord returns the correct url/method when nspace is ${nspace}`, function(assert) {
const adapter = this.owner.lookup('adapter:kv');
const client = this.owner.lookup('service:client/http');
const expected = `PUT /v1/kv/${id}?dc=${dc}${
const flags = 12;
const expected = `PUT /v1/kv/${id}?dc=${dc}&flags=${flags}${
typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``
}`;
let actual = adapter
Expand All @@ -70,6 +71,7 @@ module('Integration | Adapter | kv', function(hooks) {
Key: id,
Value: '',
Namespace: nspace,
Flags: flags,
}
)
.split('\n')
Expand Down