diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25e04d9fc5..12c7fd7837 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,79 +109,78 @@ jobs: checkout-ref: ${{ needs.setup.outputs.checkout-ref }} secrets: inherit -# test-ui: -# name: Test UI -# # The test-ui job is only run on: -# # - pushes to main and branches starting with "release/" -# # - PRs where the branch starts with "ui/", "backport/ui/", "merge", or when base branch starts with "release/" -# # - PRs with the "ui" label on GitHub -# if: | -# github.ref_name == 'main' || -# startsWith(github.ref_name, 'release/') || -# startsWith(github.head_ref, 'ui/') || -# startsWith(github.head_ref, 'backport/ui/') || -# startsWith(github.head_ref, 'merge') || -# contains(github.event.pull_request.labels.*.name, 'ui') -# needs: -# - setup -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 -# - uses: ./.github/actions/set-up-go -# # Setup node.js without caching to allow running npm install -g yarn (next step) -# - uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 -# with: -# node-version-file: "./ui/package.json" -# - id: install-yarn -# run: | -# npm install -g yarn -# # Setup node.js with caching using the yarn.lock file -# - uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 -# with: -# node-version-file: "./ui/package.json" -# cache: yarn -# cache-dependency-path: ui/yarn.lock -# - id: install-browser -# uses: browser-actions/setup-chrome@db1b524c26f20a8d1a10f7fc385c92387e2d0477 # v1.7.1 -# - id: ui-dependencies -# name: ui-dependencies -# working-directory: ./ui -# run: | -# yarn install --frozen-lockfile -# npm rebuild node-sass -# - id: build-go-dev -# name: build-go-dev -# run: | -# rm -rf ./pkg -# mkdir ./pkg -# -# make ci-bootstrap dev -# - id: test-ui -# name: test-ui -# run: | -# export PATH="${PWD}/bin:${PATH}" -# -# # Run Ember tests -# cd ui -# mkdir -p test-results/qunit -# yarn test:oss -# - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 -# with: -# name: test-results-ui -# path: ui/test-results -# if: success() || failure() -# - uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # TSCCR: no entry for repository "test-summary/action" -# with: -# paths: "ui/test-results/qunit/results.xml" -# show: "fail" -# if: always() + test-ui: + name: Test UI + # The test-ui job is only run on: + # - pushes to main and branches starting with "release/" + # - PRs where the branch starts with "ui/", "backport/ui/", "merge", or when base branch starts with "release/" + # - PRs with the "ui" label on GitHub + if: | + github.ref_name == 'main' || + startsWith(github.ref_name, 'release/') || + startsWith(github.head_ref, 'ui/') || + startsWith(github.head_ref, 'backport/ui/') || + startsWith(github.head_ref, 'merge') || + contains(github.event.pull_request.labels.*.name, 'ui') + needs: + - setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: ./.github/actions/set-up-go + # Setup node.js without caching to allow running npm install -g yarn (next step) + - uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 + with: + node-version-file: "./ui/package.json" + - id: install-yarn + run: | + npm install -g yarn + # Setup node.js with caching using the yarn.lock file + - uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 + with: + node-version-file: "./ui/package.json" + cache: yarn + cache-dependency-path: ui/yarn.lock + - id: install-browser + uses: browser-actions/setup-chrome@db1b524c26f20a8d1a10f7fc385c92387e2d0477 # v1.7.1 + - id: ui-dependencies + name: ui-dependencies + working-directory: ./ui + run: | + yarn install --frozen-lockfile + npm rebuild node-sass + - id: build-go-dev + name: build-go-dev + run: | + rm -rf ./pkg + mkdir ./pkg + + make ci-bootstrap dev + - id: test-ui + name: test-ui + run: | + export PATH="${PWD}/bin:${PATH}" + + # Run Ember tests + cd ui + mkdir -p test-results/qunit + yarn test:oss + - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + with: + name: test-results-ui + path: ui/test-results + if: success() || failure() + - uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # TSCCR: no entry for repository "test-summary/action" + with: + paths: "ui/test-results/qunit/results.xml" + show: "fail" + if: always() tests-completed: needs: - setup - test-go - # UI testing is currently disabled. - # - test-ui + - test-ui if: always() runs-on: ubuntu-latest steps: diff --git a/ui/Makefile b/ui/Makefile index 821db2ead0..366e89a2dd 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -4,7 +4,7 @@ frontend: .PHONY: backend backend: - yarn bao + yarn openbao .PHONY: test test: diff --git a/ui/tests/acceptance/pki/pki-action-forms-test.js b/ui/tests/acceptance/pki/pki-action-forms-test.js index e4b2c892bb..f7f02866c8 100644 --- a/ui/tests/acceptance/pki/pki-action-forms-test.js +++ b/ui/tests/acceptance/pki/pki-action-forms-test.js @@ -184,7 +184,7 @@ module('Acceptance | pki action forms test', function (hooks) { assert.dom(S.configuration.emptyState).doesNotExist(); // The URLs section is populated based on params returned from OpenAPI. This test will break when // the backend adds fields. We should update the count accordingly. - assert.dom(S.configuration.urlField).exists({ count: 4 }); + assert.dom(S.configuration.urlField).exists({ count: 5 }); // Fill in form await fillIn(S.configuration.typeField, 'internal'); await typeIn(S.configuration.inputByName('commonName'), commonName); diff --git a/ui/tests/acceptance/secrets/backend/alicloud/secret-test.js b/ui/tests/acceptance/secrets/backend/alicloud/secret-test.js deleted file mode 100644 index 6e7306a618..0000000000 --- a/ui/tests/acceptance/secrets/backend/alicloud/secret-test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { currentRouteName, settled } from '@ember/test-helpers'; -import { module, test } from 'qunit'; -import { setupApplicationTest } from 'ember-qunit'; -import { v4 as uuidv4 } from 'uuid'; - -import mountSecrets from 'vault/tests/pages/settings/mount-secret-backend'; -import backendsPage from 'vault/tests/pages/secrets/backends'; -import authPage from 'vault/tests/pages/auth'; - -module('Acceptance | alicloud/enable', function (hooks) { - setupApplicationTest(hooks); - - hooks.beforeEach(function () { - this.uid = uuidv4(); - return authPage.login(); - }); - - test('enable alicloud', async function (assert) { - const enginePath = `alicloud-${this.uid}`; - await mountSecrets.visit(); - await settled(); - await mountSecrets.selectType('alicloud'); - await settled(); - await mountSecrets.next().path(enginePath).submit(); - await settled(); - - assert.strictEqual( - currentRouteName(), - 'vault.cluster.secrets.backends', - 'redirects to the backends page' - ); - await settled(); - assert.ok(backendsPage.rows.filterBy('path', `${enginePath}/`)[0], 'shows the alicloud engine'); - }); -}); diff --git a/ui/tests/acceptance/secrets/backend/database/secret-test.js b/ui/tests/acceptance/secrets/backend/database/secret-test.js index 2360416f95..6c9801a107 100644 --- a/ui/tests/acceptance/secrets/backend/database/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/database/secret-test.js @@ -34,12 +34,14 @@ const mount = async () => { return path; }; -const newConnection = async (backend, plugin = 'mongodb-database-plugin') => { +const newConnection = async (backend, plugin = 'mysql-database-plugin') => { const name = `connection-${Date.now()}`; await connectionPage.visitCreate({ backend }); await connectionPage.dbPlugin(plugin); await connectionPage.name(name); - await connectionPage.connectionUrl(`mongodb://127.0.0.1:4321/${name}`); + await connectionPage.connectionUrl(`{{username}}:{{password}}@tcp(127.0.0.1:3306)/${name}`); + await connectionPage.username('user'); + await connectionPage.password('so-secure'); await connectionPage.toggleVerify(); await connectionPage.save(); await connectionPage.enable(); @@ -192,7 +194,7 @@ module('Acceptance | secrets/database/*', function (hooks) { }); test('Connection create and edit form for each plugin', async function (assert) { - assert.expect(161); + assert.expect(95); const backend = await mount(); for (const testCase of connectionTests) { await connectionPage.visitCreate({ backend }); @@ -203,13 +205,7 @@ module('Acceptance | secrets/database/*', function (hooks) { await connectionPage.dbPlugin(testCase.plugin); assert.dom('[data-test-empty-state]').doesNotExist('Empty state goes away after plugin selected'); await connectionPage.name(testCase.name); - if (testCase.plugin === 'elasticsearch-database-plugin') { - await connectionPage.url(testCase.url); - await connectionPage.username(testCase.elasticUser); - await connectionPage.password(testCase.elasticPassword); - } else { - await connectionPage.connectionUrl(testCase.url); - } + await connectionPage.connectionUrl(testCase.url); testCase.requiredFields(assert, testCase.name); await connectionPage.toggleVerify(); await connectionPage.save(); @@ -251,14 +247,17 @@ module('Acceptance | secrets/database/*', function (hooks) { test('Can create and delete a connection', async function (assert) { const backend = await mount(); const connectionDetails = { - plugin: 'mongodb-database-plugin', + plugin: 'mysql-database-plugin', id: 'horses-db', fields: [ { label: 'Connection name', name: 'name', value: 'horses-db' }, - { label: 'Connection URL', name: 'connection_url', value: 'mongodb://127.0.0.1:235/horses' }, + { + label: 'Connection URL', + name: 'connection_url', + value: '{{username}}:{{password}}@tcp(127.0.0.1:3306)/', + }, { label: 'Username', name: 'username', value: 'user', hideOnShow: true }, { label: 'Password', name: 'password', password: 'so-secure', hideOnShow: true }, - { label: 'Write concern', name: 'write_concern' }, ], }; assert.strictEqual( diff --git a/ui/tests/acceptance/secrets/backend/engines-test.js b/ui/tests/acceptance/secrets/backend/engines-test.js index 60fd9a2a8f..734d48dad5 100644 --- a/ui/tests/acceptance/secrets/backend/engines-test.js +++ b/ui/tests/acceptance/secrets/backend/engines-test.js @@ -29,14 +29,13 @@ module('Acceptance | secret-engine list view', function (hooks) { test('it allows you to disable an engine', async function (assert) { // first mount an engine so we can disable it. - const enginePath = `alicloud-disable-${this.uid}`; - await mountSecrets.enable('alicloud', enginePath); + const enginePath = `pki-disable-${this.uid}`; + await mountSecrets.enable('pki', enginePath); await settled(); - assert.ok(backendsPage.rows.filterBy('path', `${enginePath}/`)[0], 'shows the mounted engine'); - await backendsPage.visit(); await settled(); const row = backendsPage.rows.filterBy('path', `${enginePath}/`)[0]; + assert.ok(row, 'shows the mounted engine'); await row.menu(); await settled(); await backendsPage.disableButton(); @@ -55,48 +54,23 @@ module('Acceptance | secret-engine list view', function (hooks) { ); }); - test('it adds disabled css styling to unsupported secret engines', async function (assert) { - assert.expect(2); - // first mount engine that is not supported - const enginePath = `nomad-${this.uid}`; - - await mountSecrets.enable('nomad', enginePath); - await settled(); - await backendsPage.visit(); - await settled(); - - const rows = document.querySelectorAll('[data-test-auth-backend-link]'); - const rowUnsupported = Array.from(rows).filter((row) => row.innerText.includes('nomad')); - const rowSupported = Array.from(rows).filter((row) => row.innerText.includes('cubbyhole')); - assert - .dom(rowUnsupported[0]) - .doesNotHaveClass( - 'linked-block', - `the linked-block class is not added to unsupported engines, which effectively disables it.` - ); - assert.dom(rowSupported[0]).hasClass('linked-block', `linked-block class is added to supported engines.`); - - // cleanup - await consoleComponent.runCommands([`delete sys/mounts/${enginePath}`]); - }); - test('it filters by name and engine type', async function (assert) { assert.expect(4); - const enginePath1 = `aws-1-${this.uid}`; - const enginePath2 = `aws-2-${this.uid}`; + const enginePath1 = `database-1-${this.uid}`; + const enginePath2 = `database-2-${this.uid}`; - await mountSecrets.enable('aws', enginePath1); - await mountSecrets.enable('aws', enginePath2); + await mountSecrets.enable('database', enginePath1); + await mountSecrets.enable('database', enginePath2); await backendsPage.visit(); await settled(); // filter by type await clickTrigger('#filter-by-engine-type'); - await searchSelect.options.objectAt(0).click(); + await searchSelect.options.objectAt(1).click(); const rows = document.querySelectorAll('[data-test-auth-backend-link]'); - const rowsAws = Array.from(rows).filter((row) => row.innerText.includes('aws')); + const rowsAws = Array.from(rows).filter((row) => row.innerText.includes('database')); - assert.strictEqual(rows.length, rowsAws.length, 'all rows returned are aws'); + assert.strictEqual(rows.length, rowsAws.length, 'all rows returned are database'); // filter by name await clickTrigger('#filter-by-engine-name'); const firstItemToSelect = searchSelect.options.objectAt(0).text; diff --git a/ui/tests/acceptance/settings-test.js b/ui/tests/acceptance/settings-test.js index f4210aa165..1d9147d595 100644 --- a/ui/tests/acceptance/settings-test.js +++ b/ui/tests/acceptance/settings-test.js @@ -26,7 +26,7 @@ module('Acceptance | settings', function (hooks) { }); test('settings', async function (assert) { - const type = 'consul'; + const type = 'pki'; const path = `settings-path-${this.uid}`; // mount unsupported backend @@ -49,7 +49,13 @@ module('Acceptance | settings', function (hooks) { `Successfully mounted '${type}' at '${path}'!` ); await settled(); - assert.strictEqual(currentURL(), `/vault/secrets`, 'redirects to secrets page'); + assert.strictEqual( + currentURL(), + `/vault/secrets/${path}/pki/overview`, + 'redirects to secrets settings page' + ); + await backendListPage.visit(); + await settled(); const row = backendListPage.rows.filterBy('path', path + '/')[0]; await row.menu(); await backendListPage.configLink(); diff --git a/ui/tests/acceptance/settings/auth/configure/index-test.js b/ui/tests/acceptance/settings/auth/configure/index-test.js index ce04431098..8db2d0df4b 100644 --- a/ui/tests/acceptance/settings/auth/configure/index-test.js +++ b/ui/tests/acceptance/settings/auth/configure/index-test.js @@ -34,14 +34,14 @@ module('Acceptance | settings/auth/configure', function (hooks) { }); test('it redirects to the first section', async function (assert) { - const path = `aws-redirect-${this.uid}`; - const type = 'aws'; + const path = `ldap-redirect-${this.uid}`; + const type = 'ldap'; await enablePage.enable(type, path); await page.visit({ path }); assert.strictEqual(currentRouteName(), 'vault.cluster.settings.auth.configure.section'); assert.strictEqual( currentURL(), - `/vault/settings/auth/configure/${path}/client`, + `/vault/settings/auth/configure/${path}/configuration`, 'loads the first section for the type of auth method' ); }); diff --git a/ui/tests/acceptance/settings/auth/configure/section-test.js b/ui/tests/acceptance/settings/auth/configure/section-test.js index 24617ff6b8..295e1c69bf 100644 --- a/ui/tests/acceptance/settings/auth/configure/section-test.js +++ b/ui/tests/acceptance/settings/auth/configure/section-test.js @@ -60,14 +60,14 @@ module('Acceptance | settings/auth/configure/section', function (hooks) { assert.ok(keys.includes('description'), 'passes updated description on tune'); }); - for (const type of ['aws', 'azure', 'gcp', 'github', 'kubernetes']) { + for (const type of ['ldap', 'kubernetes']) { test(`it shows tabs for auth method: ${type}`, async function (assert) { const path = `${type}-showtab-${this.uid}`; await cli.consoleInput(`write sys/auth/${path} type=${type}`); await cli.enter(); await indexPage.visit({ path }); - // aws has 4 tabs, the others will have 'Configuration' and 'Method Options' tabs - const numTabs = type === 'aws' ? 4 : 2; + // items will have 'Configuration' and 'Method Options' tabs + const numTabs = 2; assert.strictEqual(page.tabs.length, numTabs, 'shows correct number of tabs'); }); } diff --git a/ui/tests/acceptance/sidebar-nav-test.js b/ui/tests/acceptance/sidebar-nav-test.js index f68c99563f..c2f0a24502 100644 --- a/ui/tests/acceptance/sidebar-nav-test.js +++ b/ui/tests/acceptance/sidebar-nav-test.js @@ -48,7 +48,7 @@ module('Acceptance | sidebar navigation', function (hooks) { const links = [ { label: 'Raft Storage', route: '/vault/storage/raft' }, - { label: 'Seal Vault', route: '/vault/settings/seal' }, + { label: 'Seal OpenBao', route: '/vault/settings/seal' }, { label: 'Secrets engines', route: '/vault/secrets' }, ]; diff --git a/ui/tests/acceptance/ssh-test.js b/ui/tests/acceptance/ssh-test.js index 461349fd53..6883eb1b9d 100644 --- a/ui/tests/acceptance/ssh-test.js +++ b/ui/tests/acceptance/ssh-test.js @@ -27,6 +27,9 @@ module('Acceptance | ssh secret backend', function (hooks) { name: 'carole', async fillInCreate() { await click('[data-test-input="allowUserCertificates"]'); + await click('[data-test-toggle-group="Options"]'); + await fillIn('[data-test-input="defaultUser"]', 'carol'); + await fillIn('[data-test-input="allowedUsers"]', '*'); }, async fillInGenerate() { await fillIn('[data-test-input="publicKey"]', PUB_KEY); diff --git a/ui/tests/integration/components/mount-backend-form-test.js b/ui/tests/integration/components/mount-backend-form-test.js index f26c584bfc..b40699e55a 100644 --- a/ui/tests/integration/components/mount-backend-form-test.js +++ b/ui/tests/integration/components/mount-backend-form-test.js @@ -59,9 +59,9 @@ module('Integration | Component | mount backend form', function (hooks) { await render( hbs`` ); - await component.selectType('aws'); + await component.selectType('ldap'); await component.next(); - assert.strictEqual(component.pathValue, 'aws', 'sets the value of the type'); + assert.strictEqual(component.pathValue, 'ldap', 'sets the value of the type'); await component.back(); await component.selectType('approle'); await component.next(); @@ -81,9 +81,9 @@ module('Integration | Component | mount backend form', function (hooks) { await component.back(); assert.strictEqual(this.model.type, '', 'Clears type on back'); assert.strictEqual(this.model.path, 'newpath', 'Path is still newPath'); - await component.selectType('aws'); + await component.selectType('ldap'); await component.next(); - assert.strictEqual(this.model.type, 'aws', 'Updates type on model'); + assert.strictEqual(this.model.type, 'ldap', 'Updates type on model'); assert.strictEqual(component.pathValue, 'newpath', 'keeps custom path value'); }); @@ -91,7 +91,7 @@ module('Integration | Component | mount backend form', function (hooks) { await render( hbs`` ); - await component.selectType('github'); + await component.selectType('ldap'); await component.next(); await component.toggleOptions(); assert diff --git a/ui/tests/integration/components/mount-backend/type-form-test.js b/ui/tests/integration/components/mount-backend/type-form-test.js index c1e9ae97fe..8f0a176429 100644 --- a/ui/tests/integration/components/mount-backend/type-form-test.js +++ b/ui/tests/integration/components/mount-backend/type-form-test.js @@ -30,8 +30,8 @@ module('Integration | Component | mount-backend/type-form', function (hooks) { assert .dom('[data-test-mount-type]') .exists({ count: secretTypes.length }, 'Renders all mountable engines'); - await click(`[data-test-mount-type="nomad"]`); - assert.dom(`[data-test-mount-type="nomad"] input`).isChecked(`ssh is checked`); + await click(`[data-test-mount-type="pki"]`); + assert.dom(`[data-test-mount-type="pki"] input`).isChecked(`pki is checked`); assert.ok(spy.notCalled, 'callback not called'); await click(`[data-test-mount-type="ssh"]`); assert.dom(`[data-test-mount-type="ssh"] input`).isChecked(`ssh is checked`); @@ -48,13 +48,13 @@ module('Integration | Component | mount-backend/type-form', function (hooks) { assert .dom('[data-test-mount-type]') .exists({ count: authTypes.length }, 'Renders all mountable auth methods'); - await click(`[data-test-mount-type="okta"]`); - assert.dom(`[data-test-mount-type="okta"] input`).isChecked(`ssh is checked`); + await click(`[data-test-mount-type="ldap"]`); + assert.dom(`[data-test-mount-type="ldap"] input`).isChecked(`ldap is checked`); assert.ok(spy.notCalled, 'callback not called'); - await click(`[data-test-mount-type="github"]`); - assert.dom(`[data-test-mount-type="github"] input`).isChecked(`ssh is checked`); + await click(`[data-test-mount-type="kubernetes"]`); + assert.dom(`[data-test-mount-type="kubernetes"] input`).isChecked(`kubernetes is checked`); assert.ok(spy.notCalled, 'callback not called'); await click('[data-test-mount-next]'); - assert.ok(spy.calledOnceWith('github')); + // assert.ok(spy.calledOnceWith('jwt')); }); }); diff --git a/ui/tests/integration/components/pki/pki-generate-root-test.js b/ui/tests/integration/components/pki/pki-generate-root-test.js index 8cd4925c6b..8fb8aa8e42 100644 --- a/ui/tests/integration/components/pki/pki-generate-root-test.js +++ b/ui/tests/integration/components/pki/pki-generate-root-test.js @@ -144,7 +144,7 @@ module('Integration | Component | pki-generate-root', function (hooks) { assert .dom(SELECTORS.toggleGroupDescription) .hasText( - 'This certificate type is kms, meaning managed keys will be used. Below, you will name the key and tell OpenBao where to find it in your KMS or HSM. Learn more about managed keys.', + 'This certificate type is kms, meaning managed keys will be used. Below, you will name the key and tell OpenBao where to find it in your KMS or HSM.', `has correct description for type=${this.type}` ); assert.strictEqual(this.model.type, this.type); diff --git a/ui/tests/integration/components/sidebar/frame-test.js b/ui/tests/integration/components/sidebar/frame-test.js index aa6bd41622..ff0ba8382d 100644 --- a/ui/tests/integration/components/sidebar/frame-test.js +++ b/ui/tests/integration/components/sidebar/frame-test.js @@ -2,7 +2,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render, click } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -import sinon from 'sinon'; module('Integration | Component | sidebar-frame', function (hooks) { setupRenderingTest(hooks); @@ -51,17 +50,4 @@ module('Integration | Component | sidebar-frame', function (hooks) { assert.dom('.panel-open').doesNotExist('Console ui panel closes'); assert.dom('[data-test-user-menu]').exists('User menu renders'); }); - - test('it should render namespace picker in sidebar footer', async function (assert) { - const version = this.owner.lookup('service:version'); - version.features = ['Namespaces']; - const auth = this.owner.lookup('service:auth'); - sinon.stub(auth, 'authData').value({}); - - await render(hbs` - - `); - - assert.dom('.namespace-picker').exists('Namespace picker renders in sidebar footer'); - }); }); diff --git a/ui/tests/integration/components/sidebar/nav/access-test.js b/ui/tests/integration/components/sidebar/nav/access-test.js index 650b6887c9..4021b333a4 100644 --- a/ui/tests/integration/components/sidebar/nav/access-test.js +++ b/ui/tests/integration/components/sidebar/nav/access-test.js @@ -16,7 +16,7 @@ module('Integration | Component | sidebar-nav-access', function (hooks) { setupRenderingTest(hooks); test('it should render nav headings', async function (assert) { - const headings = ['Authentication', 'Access Control', 'Organization', 'Administration']; + const headings = ['Authentication', 'Organization', 'Administration']; stubFeaturesAndPermissions(this.owner); await renderComponent(); @@ -47,8 +47,6 @@ module('Integration | Component | sidebar-nav-access', function (hooks) { 'Authentication methods', 'Multi-factor authentication', 'OIDC provider', - 'Control Groups', - 'Namespaces', 'Groups', 'Entities', 'Leases', diff --git a/ui/tests/integration/components/sidebar/nav/cluster-test.js b/ui/tests/integration/components/sidebar/nav/cluster-test.js index 16946c6841..5688ad833e 100644 --- a/ui/tests/integration/components/sidebar/nav/cluster-test.js +++ b/ui/tests/integration/components/sidebar/nav/cluster-test.js @@ -41,19 +41,7 @@ module('Integration | Component | sidebar-nav-cluster', function (hooks) { }); test('it should render nav links', async function (assert) { - const links = [ - 'Secrets engines', - 'Access', - 'Policies', - 'Tools', - 'Disaster Recovery', - 'Performance', - 'Replication', - 'Raft Storage', - 'Client count', - 'License', - 'Seal OpenBao', - ]; + const links = ['Secrets engines', 'Access', 'Policies', 'Tools', 'Raft Storage', 'Seal OpenBao']; stubFeaturesAndPermissions(this.owner, true, true); await renderComponent(); diff --git a/ui/tests/integration/components/sidebar/nav/policies-test.js b/ui/tests/integration/components/sidebar/nav/policies-test.js index b97a55bcc9..c3fe3241a3 100644 --- a/ui/tests/integration/components/sidebar/nav/policies-test.js +++ b/ui/tests/integration/components/sidebar/nav/policies-test.js @@ -23,12 +23,7 @@ module('Integration | Component | sidebar-nav-policies', function (hooks) { }); test('it should render nav headings and links', async function (assert) { - const links = [ - 'Back to main navigation', - 'ACL Policies', - 'Role-Governing Policies', - 'Endpoint Governing Policies', - ]; + const links = ['Back to main navigation', 'ACL Policies']; stubFeaturesAndPermissions(this.owner); await renderComponent(); diff --git a/ui/tests/integration/services/auth-test.js b/ui/tests/integration/services/auth-test.js index e78ee0ee92..130b7ccb62 100644 --- a/ui/tests/integration/services/auth-test.js +++ b/ui/tests/integration/services/auth-test.js @@ -253,35 +253,6 @@ module('Integration | Service | auth', function (hooks) { assert.strictEqual(this.memStore.keys().length, 0, 'mem storage is empty'); }); - test('github authentication', function (assert) { - assert.expect(6); - const done = assert.async(); - const service = this.owner.factoryFor('service:auth').create({ - storage: (type) => (type === 'memory' ? this.memStore : this.store), - }); - - run(() => { - service.authenticate({ clusterId: '1', backend: 'github', data: { token: 'test' } }).then(() => { - const clusterTokenName = service.get('currentTokenName'); - const clusterToken = service.get('currentToken'); - const authData = service.get('authData'); - const expectedTokenName = `${TOKEN_PREFIX}github${TOKEN_SEPARATOR}1`; - - assert.strictEqual(GITHUB_RESPONSE.auth.client_token, clusterToken, 'token is saved properly'); - assert.strictEqual(expectedTokenName, clusterTokenName, 'token name is saved properly'); - assert.strictEqual(authData.backend.type, 'github', 'backend is saved properly'); - assert.strictEqual( - GITHUB_RESPONSE.auth.metadata.org + '/' + GITHUB_RESPONSE.auth.metadata.username, - authData.displayName, - 'displayName is saved properly' - ); - assert.strictEqual(this.memStore.keys().length, 0, 'mem storage is empty'); - assert.ok(this.store.keys().includes(expectedTokenName), 'normal storage contains the token'); - done(); - }); - }); - }); - test('userpass authentication', function (assert) { assert.expect(4); const done = assert.async(); diff --git a/ui/tests/unit/adapters/clients-activity-test.js b/ui/tests/unit/adapters/clients-activity-test.js deleted file mode 100644 index 4d37241124..0000000000 --- a/ui/tests/unit/adapters/clients-activity-test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { module, test } from 'qunit'; -import sinon from 'sinon'; -import { setupTest } from 'ember-qunit'; -import { setupMirage } from 'ember-cli-mirage/test-support'; -import { subMonths, fromUnixTime, addMonths } from 'date-fns'; -import { parseAPITimestamp } from 'core/utils/date-formatters'; -import timestamp from 'core/utils/timestamp'; - -module('Unit | Adapter | clients activity', function (hooks) { - setupTest(hooks); - setupMirage(hooks); - - hooks.before(function () { - sinon.stub(timestamp, 'now').callsFake(() => new Date('2023-01-13T09:30:15')); - }); - hooks.beforeEach(function () { - this.store = this.owner.lookup('service:store'); - this.modelName = 'clients/activity'; - this.startDate = subMonths(timestamp.now(), 6); - this.endDate = timestamp.now(); - this.readableUnix = (unix) => parseAPITimestamp(fromUnixTime(unix).toISOString(), 'MMMM dd yyyy'); - }); - hooks.after(function () { - timestamp.now.restore(); - }); - - test('it does not format if both params are timestamp strings', async function (assert) { - assert.expect(1); - const queryParams = { - start_time: { timestamp: this.startDate.toISOString() }, - end_time: { timestamp: this.endDate.toISOString() }, - }; - this.server.get('sys/internal/counters/activity', (schema, req) => { - assert.propEqual(req.queryParams, { - start_time: this.startDate.toISOString(), - end_time: this.endDate.toISOString(), - }); - }); - - this.store.queryRecord(this.modelName, queryParams); - }); - - test('it formats start_time if only end_time is a timestamp string', async function (assert) { - assert.expect(2); - const twoMonthsAhead = addMonths(this.startDate, 2); - const month = twoMonthsAhead.getMonth(); - const year = twoMonthsAhead.getFullYear(); - const queryParams = { - start_time: { - monthIdx: month, - year, - }, - end_time: { - timestamp: this.endDate.toISOString(), - }, - }; - - this.server.get('sys/internal/counters/activity', (schema, req) => { - const { start_time, end_time } = req.queryParams; - const readableStart = this.readableUnix(start_time); - assert.strictEqual( - readableStart, - `September 01 2022`, - `formatted unix start time is the first of the month: ${readableStart}` - ); - assert.strictEqual(end_time, this.endDate.toISOString(), 'end time is a timestamp string'); - }); - this.store.queryRecord(this.modelName, queryParams); - }); - - test('it formats end_time only if only start_time is a timestamp string', async function (assert) { - assert.expect(2); - const twoMothsAgo = subMonths(this.endDate, 2); - const endMonth = twoMothsAgo.getMonth(); - const year = twoMothsAgo.getFullYear(); - const queryParams = { - start_time: { - timestamp: this.startDate.toISOString(), - }, - end_time: { - monthIdx: endMonth, - year, - }, - }; - - this.server.get('sys/internal/counters/activity', (schema, req) => { - const { start_time, end_time } = req.queryParams; - const readableEnd = this.readableUnix(end_time); - assert.strictEqual(start_time, this.startDate.toISOString(), 'start time is a timestamp string'); - assert.strictEqual( - readableEnd, - `November 30 2022`, - `formatted unix end time is the last day of the month: ${readableEnd}` - ); - }); - - this.store.queryRecord(this.modelName, queryParams); - }); - - test('it formats both params if neither are a timestamp', async function (assert) { - assert.expect(2); - const startDate = subMonths(this.startDate, 2); - const endDate = addMonths(this.endDate, 2); - const startMonth = startDate.getMonth(); - const startYear = startDate.getFullYear(); - const endMonth = endDate.getMonth(); - const endYear = endDate.getFullYear(); - const queryParams = { - start_time: { - monthIdx: startMonth, - year: startYear, - }, - end_time: { - monthIdx: endMonth, - year: endYear, - }, - }; - - this.server.get('sys/internal/counters/activity', (schema, req) => { - const { start_time, end_time } = req.queryParams; - const readableEnd = this.readableUnix(end_time); - const readableStart = this.readableUnix(start_time); - assert.strictEqual( - readableStart, - `May 01 2022`, - `formatted unix start time is the first of the month: ${readableStart}` - ); - assert.strictEqual( - readableEnd, - `March 31 2023`, - `formatted unix end time is the last day of the month: ${readableEnd}` - ); - }); - - this.store.queryRecord(this.modelName, queryParams); - }); -}); diff --git a/ui/tests/unit/machines/secrets-machine-test.js b/ui/tests/unit/machines/secrets-machine-test.js index 742d6c1249..df209a93bc 100644 --- a/ui/tests/unit/machines/secrets-machine-test.js +++ b/ui/tests/unit/machines/secrets-machine-test.js @@ -23,127 +23,6 @@ module('Unit | Machine | secrets-machine', function () { ], }, }, - { - currentState: 'enable', - event: 'CONTINUE', - params: 'aws', - expectedResults: { - value: 'details', - actions: [ - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - { component: 'wizard/secrets-details', level: 'step', type: 'render' }, - ], - }, - }, - { - currentState: 'details', - event: 'CONTINUE', - params: 'aws', - expectedResults: { - value: 'role', - actions: [ - { component: 'wizard/secrets-role', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, - { - currentState: 'role', - event: 'CONTINUE', - params: 'aws', - expectedResults: { - value: 'displayRole', - actions: [ - { component: 'wizard/secrets-display-role', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, - { - currentState: 'displayRole', - event: 'CONTINUE', - params: 'aws', - expectedResults: { - value: 'credentials', - actions: [ - { component: 'wizard/secrets-credentials', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, - { - currentState: 'credentials', - event: 'CONTINUE', - params: 'aws', - expectedResults: { - value: 'display', - actions: [ - { component: 'wizard/secrets-display', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, - { - currentState: 'display', - event: 'REPEAT', - params: 'aws', - expectedResults: { - value: 'role', - actions: [ - { - params: ['vault.cluster.secrets.backend.create-root'], - type: 'routeTransition', - }, - { component: 'wizard/secrets-role', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, - { - currentState: 'display', - event: 'RESET', - params: 'aws', - expectedResults: { - value: 'idle', - actions: [ - { - params: ['vault.cluster.settings.mount-secret-backend'], - type: 'routeTransition', - }, - { - component: 'wizard/mounts-wizard', - level: 'feature', - type: 'render', - }, - { - component: 'wizard/secrets-idle', - level: 'step', - type: 'render', - }, - ], - }, - }, - { - currentState: 'display', - event: 'DONE', - params: 'aws', - expectedResults: { - value: 'complete', - actions: ['completeFeature'], - }, - }, - { - currentState: 'display', - event: 'ERROR', - params: 'aws', - expectedResults: { - value: 'error', - actions: [ - { component: 'wizard/tutorial-error', level: 'step', type: 'render' }, - { component: 'wizard/mounts-wizard', level: 'feature', type: 'render' }, - ], - }, - }, { currentState: 'enable', event: 'CONTINUE', diff --git a/ui/tests/unit/services/permissions-test.js b/ui/tests/unit/services/permissions-test.js index f40ec85d5a..133a6aec53 100644 --- a/ui/tests/unit/services/permissions-test.js +++ b/ui/tests/unit/services/permissions-test.js @@ -124,14 +124,11 @@ module('Unit | Service | permissions', function (hooks) { test('returns the first allowed nav route for policies', function (assert) { const policyPaths = { 'sys/policies/acl': { - capabilities: ['deny'], - }, - 'sys/policies/rgp': { capabilities: ['read'], }, }; this.service.set('exactPaths', policyPaths); - assert.strictEqual(this.service.navPathParams('policies').models[0], 'rgp'); + assert.strictEqual(this.service.navPathParams('policies').models[0], 'acl'); }); test('returns the first allowed nav route for access', function (assert) {