diff --git a/ui/app/components/link-status.js b/ui/app/components/link-status.js index 50f6407fc..153d4667c 100644 --- a/ui/app/components/link-status.js +++ b/ui/app/components/link-status.js @@ -36,23 +36,25 @@ export default class LinkStatus extends Component { get message() { if (this.args.status) { - const error = this.args.status.split('error:')[1]; - const time = `[${this.timestamp}]`; + const error = this.args.status.split('error:')[1] || ''; + const timestamp = this.timestamp ? ` [${this.timestamp}]` : ''; + const sinceTimestamp = timestamp ? ` since${timestamp}` : ''; if (this.state === 'disconnected') { // if generally disconnected hide the banner return !error || error.includes('UNKNOWN') ? null - : `Vault has been disconnected from the Hashicorp Cloud Platform since ${time}. Error: ${error}`; + : `Vault has been disconnected from HCP${sinceTimestamp}. Error: ${error}`; } else if (this.state === 'connecting') { if (error.includes('connection refused')) { - return `Vault has been trying to connect to the Hashicorp Cloud Platform since ${time}, but the Scada provider is down. Vault will try again soon.`; + return `Vault has been trying to connect to HCP${sinceTimestamp}, but HCP is not reachable. Vault will try again soon.`; } else if (error.includes('principal does not have permission to register as provider')) { - return `Vault tried connecting to the Hashicorp Cloud Platform, but the Resource ID is invalid. Check your resource ID. ${time}`; + return `Vault tried connecting to HCP, but the Resource ID is invalid. Check your resource ID.${timestamp}`; } else if (error.includes('cannot fetch token: 401 Unauthorized')) { - return `Vault tried connecting to the Hashicorp Cloud Platform, but the authorization information is wrong. Update it and try again. ${time}`; + return `Vault tried connecting to HCP, but the authorization information is wrong. Update it and try again.${timestamp}`; } else { - // catch all for any unknown errors - return `Vault has been trying to connect to the Hashicorp Cloud Platform since ${time}. Vault will try again soon. Error: ${error}`; + // catch all for any unknown errors or missing error + const errorMessage = error ? ` Error: ${error}` : ''; + return `Vault has been trying to connect to HCP${sinceTimestamp}. Vault will try again soon.${errorMessage}`; } } } @@ -64,7 +66,7 @@ export default class LinkStatus extends Component { if (!this.version.isEnterprise || !this.args.status) { return false; } - if (this.state === 'disconnected' && !this.message) { + if (this.state !== 'connected' && !this.message) { return false; } return true; diff --git a/ui/app/templates/components/link-status.hbs b/ui/app/templates/components/link-status.hbs index e12676e04..ba89101a9 100644 --- a/ui/app/templates/components/link-status.hbs +++ b/ui/app/templates/components/link-status.hbs @@ -3,9 +3,9 @@

{{#if (eq this.state "connected")}} - This self-managed Vault is linked to the + This self-managed Vault is linked to - HashiCorp Cloud Platform. + HCP. {{else}} {{this.message}} diff --git a/ui/tests/integration/components/link-status-test.js b/ui/tests/integration/components/link-status-test.js index d5b9787d4..0f3315bb3 100644 --- a/ui/tests/integration/components/link-status-test.js +++ b/ui/tests/integration/components/link-status-test.js @@ -17,16 +17,27 @@ module('Integration | Component | link-status', function (hooks) { this.statuses = statuses; }); + test('it does not render banner or error when status is not present', async function (assert) { + await render(hbs``); + + assert.dom('.navbar-status').doesNotExist('Banner is hidden for disconnected state'); + }); + + test('it does not render banner if not enterprise version', async function (assert) { + this.owner.lookup('service:version').set('isEnterprise', false); + + await render(hbs``); + + assert.dom('.navbar-status').doesNotExist('Banner is hidden for disconnected state'); + }); + test('it renders connected status', async function (assert) { await render(hbs``); assert.dom('.navbar-status').hasClass('connected', 'Correct class renders for connected state'); assert .dom('[data-test-link-status]') - .hasText( - 'This self-managed Vault is linked to the HashiCorp Cloud Platform.', - 'Copy renders for connected state' - ); + .hasText('This self-managed Vault is linked to HCP.', 'Copy renders for connected state'); assert .dom('[data-test-link-status] a') .hasAttribute('href', 'https://portal.cloud.hashicorp.com/sign-in', 'HCP sign in link renders'); @@ -45,7 +56,7 @@ module('Integration | Component | link-status', function (hooks) { assert .dom('[data-test-link-status]') .hasText( - `Vault has been disconnected from the Hashicorp Cloud Platform since ${timestamp}. Error: some other error other than unknown`, + `Vault has been disconnected from HCP since ${timestamp}. Error: some other error other than unknown`, 'Copy renders for disconnected error state' ); }); @@ -59,7 +70,7 @@ module('Integration | Component | link-status', function (hooks) { assert .dom('[data-test-link-status]') .hasText( - `Vault has been trying to connect to the Hashicorp Cloud Platform since ${timestamp}, but the Scada provider is down. Vault will try again soon.`, + `Vault has been trying to connect to HCP since ${timestamp}, but HCP is not reachable. Vault will try again soon.`, 'Copy renders for connection refused error state' ); }); @@ -71,7 +82,7 @@ module('Integration | Component | link-status', function (hooks) { assert .dom('[data-test-link-status]') .hasText( - `Vault tried connecting to the Hashicorp Cloud Platform, but the Resource ID is invalid. Check your resource ID. ${timestamp}`, + `Vault tried connecting to HCP, but the Resource ID is invalid. Check your resource ID. ${timestamp}`, 'Copy renders for resource id error state' ); }); @@ -83,7 +94,7 @@ module('Integration | Component | link-status', function (hooks) { assert .dom('[data-test-link-status]') .hasText( - `Vault tried connecting to the Hashicorp Cloud Platform, but the authorization information is wrong. Update it and try again. ${timestamp}`, + `Vault tried connecting to HCP, but the authorization information is wrong. Update it and try again. ${timestamp}`, 'Copy renders for unauthorized error state' ); }); @@ -95,7 +106,21 @@ module('Integration | Component | link-status', function (hooks) { assert .dom('[data-test-link-status]') .hasText( - `Vault has been trying to connect to the Hashicorp Cloud Platform since ${timestamp}. Vault will try again soon. Error: connection error we are unaware of`, + `Vault has been trying to connect to HCP since ${timestamp}. Vault will try again soon. Error: connection error we are unaware of`, + 'Copy renders for unknown error state' + ); + }); + + // connecting state should always be returned with timestamp and error + // this case came up in manual testing and should be fixed on the backend but additional checks were added just in case + test('it renders generic message for connecting state with no timestamp or error', async function (assert) { + await render(hbs``); + + assert.dom('.navbar-status').hasClass('warning', 'Correct class renders for unknown error state'); + assert + .dom('[data-test-link-status]') + .hasText( + `Vault has been trying to connect to HCP. Vault will try again soon.`, 'Copy renders for unknown error state' ); });