ui: Topology notices testing/refactor prep (#14575)

* ui: Topology notices testing/refactor prep

* ui: During testing ensure that when global-config=true can be mocked to false (#14578)
This commit is contained in:
John Cowen 2022-09-20 15:49:31 +01:00 committed by GitHub
parent 443f5c3e5e
commit f75804c3bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 13 deletions

View File

@ -42,5 +42,5 @@ export default class ServiceAdapter extends Adapter {
index,
}}
`;
}
}
}

View File

@ -280,10 +280,12 @@ export default function (config = {}, win = window, doc = document) {
case 'CONSUL_SERVICE_DASHBOARD_URL':
case 'CONSUL_BASE_UI_URL':
case 'CONSUL_HTTP_PROTOCOL':
case 'CONSUL_HTTP_MAX_CONNECTIONS':
case 'CONSUL_HTTP_MAX_CONNECTIONS': {
// We allow the operator to set these ones via various methods
// although UI developer config is preferred
return ui(str) || operator(str, env);
const _ui = ui(str);
return typeof _ui !== 'undefined' ? _ui : operator(str, env);
}
default:
return ui(str);
}

View File

@ -1,5 +1,5 @@
@setupApplicationTest
Feature: dc / services / show-topology: Show Topology tab for Service
Feature: dc / services / show / topology / index: Show Topology tab for Service
Scenario: Given a service, the Topology tab should display
Given 1 datacenter model with the value "dc1"
And 1 node models
@ -35,6 +35,6 @@ Feature: dc / services / show-topology: Show Topology tab for Service
dc: dc1
service: service-0
---
And I don't see topology on the tabs
And I don't see topologyIsVisible on the tabs
Then the url should be /dc1/services/service-0/instances

View File

@ -48,7 +48,7 @@ Feature: dc / services / show / topology / metrics
service: web
---
And I see the "[data-test-sparkline]" element
Scenario: Metrics enabled but serivce source is Consul API Gateway
Scenario: Metrics enabled but service source is Consul API Gateway
Given 1 datacenter model with the value "datacenter"
And the local datacenter is "datacenter"
And 1 service model from yaml

View File

@ -1,5 +1,5 @@
@setupApplicationTest
Feature: dc / services / show / topology / tproxy
Feature: dc / services / show / topology / notices
Background:
Given 1 datacenter model with the value "datacenter"
And the local datacenter is "datacenter"
@ -18,7 +18,7 @@ Feature: dc / services / show / topology / tproxy
Name: web
Kind: ~
---
Scenario: Default allow is set to true
Scenario: default ACL policy is set to "allow"
Given 1 topology model from yaml
---
FilteredByACLs: false
@ -47,7 +47,7 @@ Feature: dc / services / show / topology / tproxy
Scenario: A Downstream service has a wildcard intention
Given 1 topology model from yaml
---
FilteredByACLs: true
FilteredByACLs: false
TransparentProxy: false
Downstreams:
- Name: db-1
@ -69,9 +69,34 @@ Feature: dc / services / show / topology / tproxy
service: web
---
Then the url should be /datacenter/services/web/topology
And I see the tabs.topologyTab.filteredByACLs object
And I see the tabs.topologyTab.wildcardIntention object
Scenario: TProxy for a downstream is set to false
Scenario: Response is filtered by ACLs
Given 1 topology model from yaml
---
FilteredByACLs: true
TransparentProxy: false
Downstreams:
- Name: db-1
Namespace: default
Datacenter: datacenter
Intention:
Allowed: false
Upstreams:
- Name: db-2
Namespace: default
Datacenter: datacenter
Intention:
Allowed: false
---
When I visit the service page for yaml
---
dc: datacenter
service: web
---
Then the url should be /datacenter/services/web/topology
And I see the tabs.topologyTab.filteredByACLs object
Scenario: TProxy for a downstream is set to false and globally false
Given 1 topology model from yaml
---
FilteredByACLs: false
@ -94,7 +119,7 @@ Feature: dc / services / show / topology / tproxy
---
Then the url should be /datacenter/services/web/topology
And I see the tabs.topologyTab.notDefinedIntention object
Scenario: TProxy for a downstream is set to true
Scenario: TProxy for a downstream is set to true and globally false
Given 1 topology model from yaml
---
FilteredByACLs: false

View File

@ -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

View File

@ -207,4 +207,17 @@ module('Unit | Utility | getEnvironment', function () {
env = getEnvironment(config, win, doc);
assert.ok(env('CONSUL_NSPACES_ENABLED'));
});
test('it returns the correct dev value when already set via config and is reset to false', function (assert) {
const config = {
environment: 'test',
};
const doc = {
cookie: 'CONSUL_ACLS_ENABLE=0',
getElementsByTagName: makeGetElementsBy(''),
getElementsByName: makeGetElementsBy('{}'),
querySelector: () => makeOperatorConfig({ ACLsEnabled: true }),
};
let env = getEnvironment(config, win, doc);
assert.notOk(env('CONSUL_ACLS_ENABLED'));
});
});