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

* ui: always pass KV flags through on update

* ui: Integration test to prove the flags queryParams gets passed through

* ui: Add Flags to the KV updating acceptance tests
This commit is contained in:
John Cowen 2020-02-05 09:37:45 +00:00 committed by GitHub
parent 773b092a64
commit 279cd874cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -53,6 +53,7 @@ export default Adapter.extend({
requestForUpdateRecord: function(request, serialized, data) { requestForUpdateRecord: function(request, serialized, data) {
const params = { const params = {
...this.formatDatacenter(data[DATACENTER_KEY]), ...this.formatDatacenter(data[DATACENTER_KEY]),
flags: data.Flags,
...this.formatNspace(data[NSPACE_KEY]), ...this.formatNspace(data[NSPACE_KEY]),
}; };
return request` return request`

View File

@ -6,6 +6,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml And 1 kv model from yaml
--- ---
Key: "[Name]" Key: "[Name]"
Flags: 12
--- ---
When I visit the kv page for yaml When I visit the kv page for yaml
--- ---
@ -21,7 +22,7 @@ Feature: dc / kvs / update: KV Update
value: [Value] value: [Value]
--- ---
And I submit 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 "notification-update" class
And "[data-notification]" has the "success" class And "[data-notification]" has the "success" class
Where: Where:
@ -37,6 +38,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml And 1 kv model from yaml
--- ---
Key: key Key: key
Flags: 12
--- ---
When I visit the kv page for yaml When I visit the kv page for yaml
--- ---
@ -51,7 +53,7 @@ Feature: dc / kvs / update: KV Update
value: ' ' value: ' '
--- ---
And I submit 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 Then the url should be /datacenter/kv
And the title should be "Key/Value - Consul" And the title should be "Key/Value - Consul"
And "[data-notification]" has the "notification-update" class And "[data-notification]" has the "notification-update" class
@ -60,6 +62,7 @@ Feature: dc / kvs / update: KV Update
And 1 kv model from yaml And 1 kv model from yaml
--- ---
Key: key Key: key
Flags: 12
--- ---
When I visit the kv page for yaml When I visit the kv page for yaml
--- ---
@ -74,7 +77,7 @@ Feature: dc / kvs / update: KV Update
value: '' value: ''
--- ---
And I submit 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 Then the url should be /datacenter/kv
And "[data-notification]" has the "notification-update" class And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class And "[data-notification]" has the "success" class
@ -83,6 +86,7 @@ Feature: dc / kvs / update: KV Update
--- ---
Key: key Key: key
Value: ~ Value: ~
Flags: 12
--- ---
When I visit the kv page for yaml When I visit the kv page for yaml
--- ---
@ -91,7 +95,7 @@ Feature: dc / kvs / update: KV Update
--- ---
Then the url should be /datacenter/kv/key/edit Then the url should be /datacenter/kv/key/edit
And I submit 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 Then the url should be /datacenter/kv
And "[data-notification]" has the "notification-update" class And "[data-notification]" has the "notification-update" class
And "[data-notification]" has the "success" class And "[data-notification]" has the "success" class

View File

@ -58,7 +58,8 @@ module('Integration | Adapter | kv', function(hooks) {
test(`requestForUpdateRecord returns the correct url/method when nspace is ${nspace}`, function(assert) { test(`requestForUpdateRecord returns the correct url/method when nspace is ${nspace}`, function(assert) {
const adapter = this.owner.lookup('adapter:kv'); const adapter = this.owner.lookup('adapter:kv');
const client = this.owner.lookup('service:client/http'); 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}` : `` typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``
}`; }`;
let actual = adapter let actual = adapter
@ -70,6 +71,7 @@ module('Integration | Adapter | kv', function(hooks) {
Key: id, Key: id,
Value: '', Value: '',
Namespace: nspace, Namespace: nspace,
Flags: flags,
} }
) )
.split('\n') .split('\n')