diff --git a/.changelog/11937.txt b/.changelog/11937.txt new file mode 100644 index 000000000..abd223496 --- /dev/null +++ b/.changelog/11937.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes an issue saving intentions when editing per service intentions +``` diff --git a/ui/packages/consul-ui/app/templates/dc/services/show/intentions/edit.hbs b/ui/packages/consul-ui/app/templates/dc/services/show/intentions/edit.hbs index 44bbc9d03..719190902 100644 --- a/ui/packages/consul-ui/app/templates/dc/services/show/intentions/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/services/show/intentions/edit.hbs @@ -1,17 +1,44 @@ -{{#let (not (can "write intention for service" item=item.Service)) as |readOnly|}} - + as |loader|> + + + + + + +{{#let + loader.data +as |item|}} + +{{/let}} + + {{/let}} diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/create.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/create.feature new file mode 100644 index 000000000..e95b03d62 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/create.feature @@ -0,0 +1,108 @@ +@setupApplicationTest +Feature: dc / services / intentions / create: Intention Create per Service + @onlyNamespaceable + Scenario: with namespaces enabled + Given 1 datacenter model with the value "datacenter" + And 3 service models from yaml + --- + - Name: web + Kind: ~ + - Name: db + Kind: ~ + - Name: cache + Kind: ~ + --- + And 1 instance model from yaml + --- + - Service: + ID: db + Service: db + Kind: ~ + --- + And 1 nspace model from yaml + --- + - Name: nspace-0 + --- + When I visit the intention page for yaml + --- + dc: datacenter + service: db + --- + Then the url should be /datacenter/services/db/intentions/create + # Set source + And I click "[data-test-source-element] .ember-power-select-trigger" + And I type "web" into ".ember-power-select-search-input" + And I click ".ember-power-select-option:first-child" + Then I see the text "web" in "[data-test-source-element] .ember-power-select-selected-item" + # Set destination + And I click "[data-test-destination-element] .ember-power-select-trigger" + And I type "db" into ".ember-power-select-search-input" + And I click ".ember-power-select-option:first-child" + Then I see the text "db" in "[data-test-destination-element] .ember-power-select-selected-item" + # Set source nspace + And I click "[data-test-source-nspace] .ember-power-select-trigger" + And I click ".ember-power-select-option:last-child" + Then I see the text "nspace-0" in "[data-test-source-nspace] .ember-power-select-selected-item" + # Set destination nspace + And I click "[data-test-destination-nspace] .ember-power-select-trigger" + And I click ".ember-power-select-option:last-child" + Then I see the text "nspace-0" in "[data-test-destination-nspace] .ember-power-select-selected-item" + # Specifically set deny + And I click ".value-deny" + And I submit + Then a PUT request was made to "/v1/connect/intentions/exact?source=default%2Fnspace-0%2Fweb&destination=default%2Fnspace-0%2Fdb&dc=datacenter" from yaml + --- + body: + SourceName: web + DestinationName: db + SourceNS: nspace-0 + DestinationNS: nspace-0 + SourcePartition: default + DestinationPartition: default + Action: deny + --- + Then the url should be /datacenter/services/db/intentions + And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "success" class + @notNamespaceable + Scenario: with namespaces disabled + Given 1 datacenter model with the value "datacenter" + And 3 instance models from yaml + --- + - Service: + ID: web + Service: web + Kind: ~ + - Service: + ID: db + Service: db + Kind: ~ + - Service: + ID: cache + Service: cache + Kind: ~ + --- + When I visit the intention page for yaml + --- + dc: datacenter + service: db + --- + Then the url should be /datacenter/services/db/intentions/create + # Set source + And I click "[data-test-source-element] .ember-power-select-trigger" + And I type "web" into ".ember-power-select-search-input" + And I click ".ember-power-select-option:first-child" + Then I see the text "web" in "[data-test-source-element] .ember-power-select-selected-item" + # Specifically set deny + And I click ".value-deny" + And I submit + Then a PUT request was made to "/v1/connect/intentions/exact?source=default%2Fdefault%2Fweb&destination=default%2Fdefault%2Fdb&dc=datacenter" from yaml + --- + body: + SourceName: web + DestinationName: db + Action: deny + --- + Then the url should be /datacenter/services/db/intentions + And "[data-notification]" has the "notification-update" class + And "[data-notification]" has the "success" class diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/index.feature similarity index 95% rename from ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions.feature rename to ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/index.feature index 61bd40ea7..53c5fe54b 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/show/intentions/index.feature @@ -1,5 +1,5 @@ @setupApplicationTest -Feature: dc / services / show / intentions: Intentions per service +Feature: dc / services / show / intentions / index: Intentions per service Background: Given 1 datacenter model with the value "dc1" And 1 node models diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/create-steps.js similarity index 86% rename from ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions-steps.js rename to ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/create-steps.js index 3231912b9..f2aad107e 100644 --- a/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions-steps.js +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/create-steps.js @@ -1,4 +1,4 @@ -import steps from '../../../steps'; +import steps from '../../../../steps'; // step definitions that are shared between features should be moved to the // tests/acceptance/steps/steps.js file diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/index-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/index-steps.js new file mode 100644 index 000000000..f2aad107e --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/intentions/index-steps.js @@ -0,0 +1,10 @@ +import steps from '../../../../steps'; + +// step definitions that are shared between features should be moved to the +// tests/acceptance/steps/steps.js file + +export default function(assert) { + return steps(assert).then('I should find a file', function() { + assert.ok(true, this.step); + }); +} diff --git a/ui/packages/consul-ui/tests/helpers/type-to-url.js b/ui/packages/consul-ui/tests/helpers/type-to-url.js index aa45c3fb3..d35cce0c9 100644 --- a/ui/packages/consul-ui/tests/helpers/type-to-url.js +++ b/ui/packages/consul-ui/tests/helpers/type-to-url.js @@ -5,9 +5,11 @@ export default function(type) { requests = ['/v1/catalog/datacenters']; break; case 'service': - case 'instance': requests = ['/v1/internal/ui/services', '/v1/health/service/']; break; + case 'instance': + requests = ['/v1/health/service/']; + break; case 'proxy': requests = ['/v1/catalog/connect']; break; diff --git a/ui/packages/consul-ui/tests/pages/dc/intentions/edit.js b/ui/packages/consul-ui/tests/pages/dc/intentions/edit.js index 53503232a..23071d1ec 100644 --- a/ui/packages/consul-ui/tests/pages/dc/intentions/edit.js +++ b/ui/packages/consul-ui/tests/pages/dc/intentions/edit.js @@ -10,7 +10,12 @@ export default function( ) { return { scope: 'main', - visit: visitable(['/:dc/intentions/:intention', '/:dc/intentions/create']), + visit: visitable([ + '/:dc/intentions/:intention', + '/:dc/services/:service/intentions/:intention', + '/:dc/services/:service/intentions/create', + '/:dc/intentions/create', + ]), permissions: { create: { scope: '[data-test-create-permission]',