From 82eda875ddb9852d6c52bf80e511f1bd0e81e718 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:01:35 -0500 Subject: [PATCH] UI: Test reorganization (#26340) --- ui/app/helpers/supported-auth-backends.js | 2 +- ui/app/serializers/clients/activity.js | 2 +- ui/docs/tests.md | 35 +++ .../components/page/pki-configure-create.hbs | 12 +- .../page/pki-issuer-generate-intermediate.hbs | 2 +- .../page/pki-issuer-generate-root.hbs | 2 +- .../components/page/pki-issuer-import.hbs | 2 +- .../addon/components/page/pki-issuer-list.hbs | 2 +- .../page/pki-issuer-rotate-root.hbs | 6 +- .../addon/components/pki-generate-root.hbs | 4 +- .../components/pki-issuer-cross-sign.hbs | 4 +- ui/lib/pki/addon/components/pki-key-form.hbs | 4 +- .../pki/addon/components/pki-key-import.hbs | 2 +- ui/lib/pki/addon/components/pki-role-form.hbs | 4 +- .../addon/components/pki-role-generate.hbs | 4 +- .../templates/issuers/issuer/cross-sign.hbs | 2 +- .../templates/issuers/issuer/details.hbs | 2 +- .../addon/templates/issuers/issuer/edit.hbs | 2 +- .../addon/templates/issuers/issuer/sign.hbs | 2 +- .../pki/addon/templates/keys/key/details.hbs | 2 +- ui/lib/pki/addon/templates/keys/key/edit.hbs | 2 +- ui/lib/pki/addon/templates/roles/create.hbs | 2 +- .../addon/templates/roles/role/details.hbs | 2 +- .../pki/addon/templates/roles/role/edit.hbs | 2 +- .../addon/templates/roles/role/generate.hbs | 2 +- .../pki/addon/templates/roles/role/sign.hbs | 2 +- .../access/identity/entities/index-test.js | 2 +- ui/tests/acceptance/auth-list-test.js | 180 ++++++------ ui/tests/acceptance/auth-test.js | 147 ++++++---- ui/tests/acceptance/clients/counts-test.js | 17 +- .../clients/counts/overview-test.js | 115 ++++---- .../acceptance/clients/counts/sync-test.js | 15 +- .../config-ui/messages/messages-test.js | 199 ++++++------- .../messages/messages-unauth-auth-test.js | 69 ++--- ui/tests/acceptance/dashboard-test.js | 166 +++++------ ui/tests/acceptance/oidc-auth-method-test.js | 2 +- .../oidc-config/clients-assignments-test.js | 16 +- .../oidc-config/clients-keys-test.js | 31 +- .../oidc-config/providers-scopes-test.js | 35 +-- .../acceptance/open-api-path-help-test.js | 52 +++- .../acceptance/pki/pki-action-forms-test.js | 179 ++++++------ .../acceptance/pki/pki-configuration-test.js | 151 +++++----- .../acceptance/pki/pki-cross-sign-test.js | 56 ++-- .../pki/pki-engine-route-cleanup-test.js | 157 +++++----- .../pki/pki-engine-workflow-test.js | 269 +++++++++--------- ui/tests/acceptance/pki/pki-overview-test.js | 40 +-- ui/tests/acceptance/pki/pki-tidy-test.js | 101 ++++--- ui/tests/acceptance/policies/index-test.js | 6 +- .../acceptance/reduced-disclosure-test.js | 2 +- .../secrets/backend/cubbyhole/secret-test.js | 2 +- .../secrets/backend/generic/secret-test.js | 15 +- .../backend/kubernetes/overview-test.js | 11 +- .../backend/kv/kv-v2-workflow-create-test.js | 2 +- .../backend/kv/kv-v2-workflow-delete-test.js | 2 +- .../kv/kv-v2-workflow-edge-cases-test.js | 2 +- .../kv/kv-v2-workflow-navigation-test.js | 2 +- ...-v2-workflow-version-history-paths-test.js | 2 +- .../secrets/backend/kv/secret-test.js | 7 +- .../secrets/backend/ldap/libraries-test.js | 2 +- .../secrets/backend/ldap/overview-test.js | 2 +- .../secrets/backend/ldap/roles-test.js | 2 +- .../settings/auth/configure/section-test.js | 28 +- ui/tests/acceptance/tools-test.js | 33 ++- ui/tests/acceptance/transit-test.js | 12 +- ui/tests/acceptance/unseal-test.js | 2 +- .../client-count-helpers.js} | 121 +------- .../helpers/clients/client-count-selectors.ts | 87 ++++++ ui/tests/helpers/codemirror.js | 22 +- .../dashboard/dashboard-selectors.js | 2 +- .../{ => components}/secret-edit-toolbar.js | 2 +- .../{shamir.js => shamir-selectors.ts} | 0 ui/tests/helpers/components/sidebar-nav.js | 8 + ...{ttl-picker.js => ttl-picker-selectors.ts} | 10 +- .../helpers/config-ui/message-selectors.js | 31 -- .../helpers/config-ui/message-selectors.ts | 28 ++ ui/tests/helpers/general-selectors.js | 87 ------ ui/tests/helpers/general-selectors.ts | 75 +++++ .../{overview.js => kubernetes-selectors.ts} | 6 +- .../kv.js => kv/policy-generator.js} | 0 .../helpers/{ldap.js => ldap/ldap-helpers.js} | 0 ui/tests/helpers/mirage-to-models.js | 17 -- ui/tests/helpers/noop-all-api-requests.js | 23 -- ui/tests/helpers/oidc-config.js | 46 +-- ...l-attributes.js => expected-auth-attrs.js} | 4 + ...attributes.js => expected-secret-attrs.js} | 0 ui/tests/helpers/openapi/test-helpers.js | 56 ---- ui/tests/helpers/pagination.js | 10 + ui/tests/helpers/pki.js | 23 -- ui/tests/helpers/pki/overview.js | 27 -- .../pki/page/pki-configuration-edit.js | 25 -- ui/tests/helpers/pki/page/pki-keys.js | 26 -- ui/tests/helpers/pki/page/pki-role-details.js | 12 - ui/tests/helpers/pki/page/pki-tidy-form.js | 18 -- ui/tests/helpers/pki/page/pki-tidy.js | 30 -- ui/tests/helpers/pki/pki-configure-create.js | 30 -- .../helpers/pki/pki-delete-all-issuers.js | 11 - ui/tests/helpers/pki/pki-generate-root.js | 35 --- ui/tests/helpers/pki/pki-helpers.ts | 251 ++++++++++++++++ ui/tests/helpers/pki/pki-issuer-cross-sign.js | 23 -- ui/tests/helpers/pki/pki-issuer-details.js | 21 -- ui/tests/helpers/pki/pki-key-form.js | 15 - .../helpers/pki/pki-not-valid-after-form.js | 15 - ui/tests/helpers/pki/pki-role-form.js | 36 --- ui/tests/helpers/pki/pki-role-generate.js | 19 -- ui/tests/helpers/pki/pki-run-commands.js | 22 -- ui/tests/helpers/pki/pki-selectors.ts | 237 +++++++++++++++ .../pki.js => pki/policy-generator.ts} | 6 +- ui/tests/helpers/pki/values.js | 204 ------------- ui/tests/helpers/pki/workflow.js | 82 ------ ui/tests/helpers/stubs.js | 27 +- ui/tests/helpers/sync/sync-selectors.js | 2 +- .../auth-config-form/options-test.js | 56 ++-- .../components/certificate-card-test.js | 3 +- .../components/clients/page/counts-test.js | 70 +++-- .../components/clients/page/sync-test.js | 13 +- .../components/clients/page/token-test.js | 61 ++-- .../components/clients/running-total-test.js | 42 +-- .../messages/page/create-and-edit-test.js | 153 +++++----- .../config-ui/messages/page/list-test.js | 20 +- .../components/console/log-json-test.js | 2 +- .../dashboard/client-count-card-test.js | 2 +- .../components/dashboard/overview-test.js | 72 ++--- .../dashboard/quick-actions-card-test.js | 50 ++-- .../dashboard/replication-card-test.js | 76 ++--- .../dashboard/secrets-engines-card-test.js | 16 +- .../kubernetes/page/overview-test.js | 29 +- .../components/kv-suggestion-input-test.js | 4 +- .../ldap/page/configuration-test.js | 2 +- .../components/ldap/page/configure-test.js | 2 +- .../components/ldap/page/libraries-test.js | 2 +- .../components/ldap/page/overview-test.js | 2 +- .../components/ldap/page/roles-test.js | 2 +- .../components/oidc/assignment-form-test.js | 10 +- .../components/oidc/client-form-test.js | 12 +- .../components/oidc/client-list-test.js | 7 +- .../components/oidc/key-form-test.js | 15 +- .../components/oidc/provider-form-test.js | 17 +- .../components/oidc/provider-list-test.js | 7 +- .../components/oidc/scope-form-test.js | 5 +- .../components/pki-paginated-list-test.js | 2 +- .../pki/page/pki-configuration-edit-test.js | 136 ++++----- .../pki/page/pki-configure-create-test.js | 29 +- .../pki-issuer-generate-intermediate-test.js | 18 +- .../pki/page/pki-issuer-generate-root-test.js | 24 +- .../pki/page/pki-issuer-import-test.js | 17 +- .../pki/page/pki-issuer-list-test.js | 2 +- .../pki/page/pki-issuer-rotate-root-test.js | 80 +++--- .../pki/page/pki-key-details-test.js | 29 +- .../components/pki/page/pki-key-list-test.js | 29 +- .../components/pki/page/pki-overview-test.js | 28 +- .../pki/page/pki-role-details-test.js | 18 +- .../pki/page/pki-tidy-status-test.js | 22 +- .../components/pki/pki-generate-root-test.js | 81 +++--- .../pki/pki-import-pem-bundle-test.js | 10 +- .../pki/pki-issuer-cross-sign-test.js | 76 +++-- .../components/pki/pki-issuer-details-test.js | 78 ++--- .../components/pki/pki-key-form-test.js | 41 +-- .../components/pki/pki-key-parameters-test.js | 20 +- .../components/pki/pki-key-usage-test.js | 19 +- .../pki/pki-not-valid-after-form-test.js | 48 ++-- .../components/pki/pki-role-form-test.js | 85 +++--- .../components/pki/pki-role-generate-test.js | 23 +- .../components/pki/pki-tidy-form-test.js | 72 ++--- .../components/secret-edit-test.js | 22 +- .../components/secret-list-header-test.js | 14 +- .../components/shamir/flow-test.js | 2 +- .../components/shamir/form-test.js | 2 +- .../integration/components/text-file-test.js | 3 +- .../components/transit-key-actions-test.js | 18 +- .../integration/components/ttl-picker-test.js | 94 +++--- .../utils/client-count-utils-test.js | 8 +- .../integration/utils/parse-pki-cert-test.js | 10 +- ui/tests/unit/adapters/aws-credential-test.js | 81 +++--- .../adapters/identity/entity-alias-test.js | 36 +-- .../unit/adapters/identity/entity-test.js | 36 +-- .../adapters/identity/group-alias-test.js | 36 +-- ui/tests/unit/adapters/identity/group-test.js | 36 +-- ui/tests/unit/adapters/pki/action-test.js | 4 +- .../adapters/pki/certificate/sign-test.js | 3 +- ui/tests/unit/adapters/secret-engine-test.js | 75 ++--- ui/tests/unit/serializers/pki/action-test.js | 4 +- 181 files changed, 3078 insertions(+), 3219 deletions(-) create mode 100644 ui/docs/tests.md rename ui/tests/helpers/{clients.js => clients/client-count-helpers.js} (85%) create mode 100644 ui/tests/helpers/clients/client-count-selectors.ts rename ui/tests/helpers/{ => components}/secret-edit-toolbar.js (85%) rename ui/tests/helpers/components/{shamir.js => shamir-selectors.ts} (100%) rename ui/tests/helpers/components/{ttl-picker.js => ttl-picker-selectors.ts} (56%) delete mode 100644 ui/tests/helpers/config-ui/message-selectors.js create mode 100644 ui/tests/helpers/config-ui/message-selectors.ts delete mode 100644 ui/tests/helpers/general-selectors.js create mode 100644 ui/tests/helpers/general-selectors.ts rename ui/tests/helpers/kubernetes/{overview.js => kubernetes-selectors.ts} (74%) rename ui/tests/helpers/{policy-generator/kv.js => kv/policy-generator.js} (100%) rename ui/tests/helpers/{ldap.js => ldap/ldap-helpers.js} (100%) delete mode 100644 ui/tests/helpers/mirage-to-models.js delete mode 100644 ui/tests/helpers/noop-all-api-requests.js rename ui/tests/helpers/openapi/{auth-model-attributes.js => expected-auth-attrs.js} (99%) rename ui/tests/helpers/openapi/{secret-model-attributes.js => expected-secret-attrs.js} (100%) delete mode 100644 ui/tests/helpers/openapi/test-helpers.js create mode 100644 ui/tests/helpers/pagination.js delete mode 100644 ui/tests/helpers/pki.js delete mode 100644 ui/tests/helpers/pki/overview.js delete mode 100644 ui/tests/helpers/pki/page/pki-configuration-edit.js delete mode 100644 ui/tests/helpers/pki/page/pki-keys.js delete mode 100644 ui/tests/helpers/pki/page/pki-role-details.js delete mode 100644 ui/tests/helpers/pki/page/pki-tidy-form.js delete mode 100644 ui/tests/helpers/pki/page/pki-tidy.js delete mode 100644 ui/tests/helpers/pki/pki-configure-create.js delete mode 100644 ui/tests/helpers/pki/pki-delete-all-issuers.js delete mode 100644 ui/tests/helpers/pki/pki-generate-root.js create mode 100644 ui/tests/helpers/pki/pki-helpers.ts delete mode 100644 ui/tests/helpers/pki/pki-issuer-cross-sign.js delete mode 100644 ui/tests/helpers/pki/pki-issuer-details.js delete mode 100644 ui/tests/helpers/pki/pki-key-form.js delete mode 100644 ui/tests/helpers/pki/pki-not-valid-after-form.js delete mode 100644 ui/tests/helpers/pki/pki-role-form.js delete mode 100644 ui/tests/helpers/pki/pki-role-generate.js delete mode 100644 ui/tests/helpers/pki/pki-run-commands.js create mode 100644 ui/tests/helpers/pki/pki-selectors.ts rename ui/tests/helpers/{policy-generator/pki.js => pki/policy-generator.ts} (86%) delete mode 100644 ui/tests/helpers/pki/values.js delete mode 100644 ui/tests/helpers/pki/workflow.js diff --git a/ui/app/helpers/supported-auth-backends.js b/ui/app/helpers/supported-auth-backends.js index a5e77ae28798..4c9185cf48ea 100644 --- a/ui/app/helpers/supported-auth-backends.js +++ b/ui/app/helpers/supported-auth-backends.js @@ -90,7 +90,7 @@ const ENTERPRISE_AUTH_METHODS = [ ]; export function supportedAuthBackends() { - return SUPPORTED_AUTH_BACKENDS; + return [...SUPPORTED_AUTH_BACKENDS]; } export function allSupportedAuthBackends() { diff --git a/ui/app/serializers/clients/activity.js b/ui/app/serializers/clients/activity.js index 7229ed9382e0..87eda421c5e1 100644 --- a/ui/app/serializers/clients/activity.js +++ b/ui/app/serializers/clients/activity.js @@ -8,7 +8,7 @@ import { formatISO } from 'date-fns'; import { formatByMonths, formatByNamespace, destructureClientCounts } from 'core/utils/client-count-utils'; import timestamp from 'core/utils/timestamp'; -// see tests/helpers/clients for sample API response (ACTIVITY_RESPONSE_STUB) +// see tests/helpers/clients/client-count-helpers for sample API response (ACTIVITY_RESPONSE_STUB) // and transformed by_namespace and by_month examples (SERIALIZED_ACTIVITY_RESPONSE) export default class ActivitySerializer extends ApplicationSerializer { normalizeResponse(store, primaryModelClass, payload, id, requestType) { diff --git a/ui/docs/tests.md b/ui/docs/tests.md new file mode 100644 index 000000000000..13821bec1415 --- /dev/null +++ b/ui/docs/tests.md @@ -0,0 +1,35 @@ +# Test Helpers Organization + +Our test are constantly evolving, but here's a general overview of how we set up and organize tests. + +## Folder organization + +### /acceptance + +Acceptance tests should test the overall workflows and navigation within Vault. When possible, they should use the real API instead of mocked so that breaking changes from the backend can be caught. Reasons you may opt to use a mocked backend instead of the real one: + +- Using the real backend would cause instability in concurrently-running tests (eg. seal/unseal flow) +- There isn't a way to set up a 3rd party dependency that the backend needs to run correctly (Database Secrets Engine, Sync Secrets) + +### /helpers + +Shared helpers such as selectors, common interactions, WebREPL commands, and API response stubs live in this folder. When selectors are only used for a single test, they should be defined on the same file where they are used for the test. Once the selectors are being used for multiple tests, they should be moved to this folder so they can be defined in a single place and shared to wherever they are needed. + +Often we will need a set of selectors for "workflow" tests, or acceptance tests that navigate through an area of the app. For these, the helpers should be organized as such: + +- `/helpers//-selectors.ts` - exports selector consts (never default) for each page -- eg. for PKI we would have PKI_OVERVIEW, PKI_ROLE, etc. +- `/helpers//-helpers.js` - exports methods and consts which are otherwise helpful in the tests -- eg. example API responses, common interactions (eg. writeVersionedSecret for KV v2) + +Whenever possible we should try to use the general selectors exported from `/helpers/general-selectors.ts`. + +### integration + +Integration tests are most often used to test specific components out of context from the rest of the app. Be sure to mock anything that the component needs to work correctly -- for example, if the component has a certain behavior in enterprise than community edition, in your tests for each scenario it should not assume that the underlying Vault binary is in one state or the other, and mock the enterprise/community state in all the scenarios. The exports in `helpers/stubs.js` might be helpful for these tests, particularly when the component uses a model which fetches capabilities. + +### pages + +[DEPRECATED] This file should be removed in favor of selectors within the "helpers" folder. We are moving away from ember-page-object selectors toward simple strings + +### unit + +Unit tests are most often used to test utils, adapters, serializers, routes, and services functionality. diff --git a/ui/lib/pki/addon/components/page/pki-configure-create.hbs b/ui/lib/pki/addon/components/page/pki-configure-create.hbs index f03b78749f7f..bf16a7166e26 100644 --- a/ui/lib/pki/addon/components/page/pki-configure-create.hbs +++ b/ui/lib/pki/addon/components/page/pki-configure-create.hbs @@ -8,7 +8,7 @@ -

+

{{this.title}}

@@ -85,14 +85,10 @@ @onComplete={{transition-to "vault.cluster.secrets.backend.pki.overview"}} /> {{else}} - +
- - + + {{/if}} \ No newline at end of file diff --git a/ui/lib/pki/addon/components/page/pki-issuer-generate-intermediate.hbs b/ui/lib/pki/addon/components/page/pki-issuer-generate-intermediate.hbs index 619f30948262..cd24d00afd21 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-generate-intermediate.hbs +++ b/ui/lib/pki/addon/components/page/pki-issuer-generate-intermediate.hbs @@ -8,7 +8,7 @@ -

+

{{this.title}}

diff --git a/ui/lib/pki/addon/components/page/pki-issuer-generate-root.hbs b/ui/lib/pki/addon/components/page/pki-issuer-generate-root.hbs index 2282b24e40d8..660bc6215fcc 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-generate-root.hbs +++ b/ui/lib/pki/addon/components/page/pki-issuer-generate-root.hbs @@ -8,7 +8,7 @@ -

+

{{this.title}}

diff --git a/ui/lib/pki/addon/components/page/pki-issuer-import.hbs b/ui/lib/pki/addon/components/page/pki-issuer-import.hbs index da3e2ef2d5f9..9cb54cd46379 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-import.hbs +++ b/ui/lib/pki/addon/components/page/pki-issuer-import.hbs @@ -8,7 +8,7 @@ -

+

{{this.title}}

diff --git a/ui/lib/pki/addon/components/page/pki-issuer-list.hbs b/ui/lib/pki/addon/components/page/pki-issuer-list.hbs index 407b8a2690fe..b6e08fab9269 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-list.hbs +++ b/ui/lib/pki/addon/components/page/pki-issuer-list.hbs @@ -95,7 +95,7 @@ @text="Details" @route="issuers.issuer.details" @model={{pkiIssuer.id}} - data-test-popup-menu-details + data-test-pki-issuer-details /> diff --git a/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.hbs b/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.hbs index 50af0c7d23ab..1db87358b11c 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.hbs +++ b/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.hbs @@ -8,7 +8,7 @@ -

+

{{if @newRootModel.id "View Issuer Certificate" "Generate New Root"}}

@@ -166,8 +166,8 @@
- - + + {{#if this.invalidFormAlert}}
diff --git a/ui/lib/pki/addon/components/pki-generate-root.hbs b/ui/lib/pki/addon/components/pki-generate-root.hbs index 8980ef11462b..b81edf3251be 100644 --- a/ui/lib/pki/addon/components/pki-generate-root.hbs +++ b/ui/lib/pki/addon/components/pki-generate-root.hbs @@ -97,8 +97,8 @@
- - + + {{#if this.invalidFormAlert}}
diff --git a/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs b/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs index 0f4cf53e7566..a0269c4a802f 100644 --- a/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs +++ b/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs @@ -93,14 +93,14 @@ @icon={{if this.submit.isRunning "loading"}} type="submit" disabled={{this.submit.isRunning}} - data-test-cross-sign-submit + data-test-save /> diff --git a/ui/lib/pki/addon/components/pki-key-form.hbs b/ui/lib/pki/addon/components/pki-key-form.hbs index 881492a512bf..d70b538a867e 100644 --- a/ui/lib/pki/addon/components/pki-key-form.hbs +++ b/ui/lib/pki/addon/components/pki-key-form.hbs @@ -41,14 +41,14 @@ @icon={{if this.save.isRunning "loading"}} type="submit" disabled={{this.save.isRunning}} - data-test-pki-key-save + data-test-save /> {{#if this.invalidFormAlert}} diff --git a/ui/lib/pki/addon/components/pki-key-import.hbs b/ui/lib/pki/addon/components/pki-key-import.hbs index 882149985a7b..27cc60f9c83e 100644 --- a/ui/lib/pki/addon/components/pki-key-import.hbs +++ b/ui/lib/pki/addon/components/pki-key-import.hbs @@ -30,7 +30,7 @@ @color="secondary" disabled={{this.submitForm.isRunning}} {{on "click" this.cancel}} - data-test-pki-key-cancel + data-test-cancel /> {{#if this.invalidFormAlert}} diff --git a/ui/lib/pki/addon/components/pki-role-form.hbs b/ui/lib/pki/addon/components/pki-role-form.hbs index ccd2e0a36fa2..652a6acb4277 100644 --- a/ui/lib/pki/addon/components/pki-role-form.hbs +++ b/ui/lib/pki/addon/components/pki-role-form.hbs @@ -124,14 +124,14 @@ @icon={{if this.save.isRunning "loading"}} type="submit" disabled={{this.save.isRunning}} - data-test-pki-role-save + data-test-save /> {{#if this.modelValidations.targets.errors}} diff --git a/ui/lib/pki/addon/components/pki-role-generate.hbs b/ui/lib/pki/addon/components/pki-role-generate.hbs index a5db88ff6557..bf8aa50819b1 100644 --- a/ui/lib/pki/addon/components/pki-role-generate.hbs +++ b/ui/lib/pki/addon/components/pki-role-generate.hbs @@ -31,14 +31,14 @@ @icon={{if this.save.isRunning "loading"}} type="submit" disabled={{this.save.isRunning}} - data-test-pki-generate-button + data-test-save /> diff --git a/ui/lib/pki/addon/templates/issuers/issuer/cross-sign.hbs b/ui/lib/pki/addon/templates/issuers/issuer/cross-sign.hbs index 3992ab61bb27..a5820f5a981b 100644 --- a/ui/lib/pki/addon/templates/issuers/issuer/cross-sign.hbs +++ b/ui/lib/pki/addon/templates/issuers/issuer/cross-sign.hbs @@ -8,7 +8,7 @@ -

+

Cross-Sign Issuers

diff --git a/ui/lib/pki/addon/templates/issuers/issuer/details.hbs b/ui/lib/pki/addon/templates/issuers/issuer/details.hbs index b0f836d3c9e5..663e430a2842 100644 --- a/ui/lib/pki/addon/templates/issuers/issuer/details.hbs +++ b/ui/lib/pki/addon/templates/issuers/issuer/details.hbs @@ -8,7 +8,7 @@ -

+

View Issuer Certificate

diff --git a/ui/lib/pki/addon/templates/issuers/issuer/edit.hbs b/ui/lib/pki/addon/templates/issuers/issuer/edit.hbs index c8b7f8492259..1992befdbdd9 100644 --- a/ui/lib/pki/addon/templates/issuers/issuer/edit.hbs +++ b/ui/lib/pki/addon/templates/issuers/issuer/edit.hbs @@ -8,7 +8,7 @@ -

+

Update Issuer

diff --git a/ui/lib/pki/addon/templates/issuers/issuer/sign.hbs b/ui/lib/pki/addon/templates/issuers/issuer/sign.hbs index 013a281a5128..5c418dc4c247 100644 --- a/ui/lib/pki/addon/templates/issuers/issuer/sign.hbs +++ b/ui/lib/pki/addon/templates/issuers/issuer/sign.hbs @@ -8,7 +8,7 @@ -

+

Sign Intermediate

diff --git a/ui/lib/pki/addon/templates/keys/key/details.hbs b/ui/lib/pki/addon/templates/keys/key/details.hbs index 3c46a40f2c36..1c4f0cb98b65 100644 --- a/ui/lib/pki/addon/templates/keys/key/details.hbs +++ b/ui/lib/pki/addon/templates/keys/key/details.hbs @@ -8,7 +8,7 @@ -

+

View Key

diff --git a/ui/lib/pki/addon/templates/keys/key/edit.hbs b/ui/lib/pki/addon/templates/keys/key/edit.hbs index 9e31f382470b..2adefb4a486d 100644 --- a/ui/lib/pki/addon/templates/keys/key/edit.hbs +++ b/ui/lib/pki/addon/templates/keys/key/edit.hbs @@ -8,7 +8,7 @@ -

+

Edit Key

diff --git a/ui/lib/pki/addon/templates/roles/create.hbs b/ui/lib/pki/addon/templates/roles/create.hbs index 93bae5535041..0d133c6b1aac 100644 --- a/ui/lib/pki/addon/templates/roles/create.hbs +++ b/ui/lib/pki/addon/templates/roles/create.hbs @@ -8,7 +8,7 @@ -

+

Create a PKI Role

diff --git a/ui/lib/pki/addon/templates/roles/role/details.hbs b/ui/lib/pki/addon/templates/roles/role/details.hbs index d90c0b0d068e..643e4ecfc668 100644 --- a/ui/lib/pki/addon/templates/roles/role/details.hbs +++ b/ui/lib/pki/addon/templates/roles/role/details.hbs @@ -8,7 +8,7 @@ -

+

PKI Role {{this.model.name}} diff --git a/ui/lib/pki/addon/templates/roles/role/edit.hbs b/ui/lib/pki/addon/templates/roles/role/edit.hbs index d9e9a71dbcc7..18eac794a988 100644 --- a/ui/lib/pki/addon/templates/roles/role/edit.hbs +++ b/ui/lib/pki/addon/templates/roles/role/edit.hbs @@ -8,7 +8,7 @@ -

+

Edit Role

diff --git a/ui/lib/pki/addon/templates/roles/role/generate.hbs b/ui/lib/pki/addon/templates/roles/role/generate.hbs index 737907514a61..55f97ec59477 100644 --- a/ui/lib/pki/addon/templates/roles/role/generate.hbs +++ b/ui/lib/pki/addon/templates/roles/role/generate.hbs @@ -8,7 +8,7 @@ -

+

{{if this.hasSubmitted "View Generated Certificate" "Generate Certificate"}}

diff --git a/ui/lib/pki/addon/templates/roles/role/sign.hbs b/ui/lib/pki/addon/templates/roles/role/sign.hbs index 9faa7b12a452..fdff2ef0f346 100644 --- a/ui/lib/pki/addon/templates/roles/role/sign.hbs +++ b/ui/lib/pki/addon/templates/roles/role/sign.hbs @@ -8,7 +8,7 @@ -

+

{{if this.hasSubmitted "View Signed Certificate" "Sign Certificate"}}

diff --git a/ui/tests/acceptance/access/identity/entities/index-test.js b/ui/tests/acceptance/access/identity/entities/index-test.js index 8bb80fb28fab..5ede89efcfc4 100644 --- a/ui/tests/acceptance/access/identity/entities/index-test.js +++ b/ui/tests/acceptance/access/identity/entities/index-test.js @@ -9,7 +9,7 @@ import { setupApplicationTest } from 'ember-qunit'; import page from 'vault/tests/pages/access/identity/index'; import authPage from 'vault/tests/pages/auth'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS as GENERAL } from 'vault/tests/helpers/general-selectors'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { v4 as uuidv4 } from 'uuid'; const SELECTORS = { diff --git a/ui/tests/acceptance/auth-list-test.js b/ui/tests/acceptance/auth-list-test.js index ffbe95400975..2f11fffc488d 100644 --- a/ui/tests/acceptance/auth-list-test.js +++ b/ui/tests/acceptance/auth-list-test.js @@ -73,109 +73,95 @@ module('Acceptance | auth backend list', function (hooks) { assert.dom(SELECTORS.listItem).hasText(this.user1, 'user1 exists in the list'); }); - test('auth methods are linkable and link to correct view', async function (assert) { - assert.expect(45); - const uid = uuidv4(); - await visit('/vault/access'); + module('auth methods are linkable and link to correct view', function (hooks) { + hooks.beforeEach(async function () { + this.uid = uuidv4(); + await visit('/vault/access'); + }); - const supportManaged = supportedManagedAuthBackends(); // Test all auth methods, not just those you can log in with - const backends = methods().map((backend) => backend.type); - assert.deepEqual( - backends, - [ - 'alicloud', - 'approle', - 'aws', - 'azure', - 'gcp', - 'github', - 'jwt', - 'oidc', - 'kubernetes', - 'ldap', - 'okta', - 'radius', - 'cert', - 'userpass', - ], - 'non-enterprise auth methods are available' - ); - for (const type of backends) { - const path = type === 'token' ? 'token' : `auth-list-${type}-${uid}`; - if (type !== 'token') { - await enablePage.enable(type, path); - } - await settled(); + methods() + .map((backend) => backend.type) + .forEach((type) => { + test(`${type} auth method`, async function (assert) { + const supportManaged = supportedManagedAuthBackends(); + const path = type === 'token' ? 'token' : `auth-list-${type}-${this.uid}`; + if (type !== 'token') { + await enablePage.enable(type, path); + } + await settled(); + await visit('/vault/access'); + + // check popup menu + const itemCount = type === 'token' ? 2 : 3; + await click(`[data-test-auth-backend-link="${path}"] [data-test-popup-menu-trigger]`); + assert + .dom('.hds-dropdown-list-item') + .exists({ count: itemCount }, `shows ${itemCount} dropdown items for ${type}`); + + // all auth methods should be linkable + await click(`[data-test-auth-backend-link="${path}"]`); + if (!supportManaged.includes(type)) { + assert.dom('[data-test-auth-section-tab]').exists({ count: 1 }); + assert + .dom('[data-test-auth-section-tab]') + .hasText('Configuration', `only shows configuration tab for ${type} auth method`); + assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`); + } else { + let expectedTabs = 2; + if (type === 'ldap' || type === 'okta') { + expectedTabs = 3; + } + assert + .dom('[data-test-auth-section-tab]') + .exists({ count: expectedTabs }, `has management tabs for ${type} auth method`); + } + if (type !== 'token') { + // cleanup method + await runCmd(deleteAuthCmd(path)); + } + }); + }); + }); + + module('enterprise', function () { + test('ent-only auth methods are linkable and link to correct view', async function (assert) { + assert.expect(3); + const uid = uuidv4(); await visit('/vault/access'); - // check popup menu - const itemCount = type === 'token' ? 2 : 3; - await click(`[data-test-auth-backend-link="${path}"] [data-test-popup-menu-trigger]`); - assert - .dom('.hds-dropdown-list-item') - .exists({ count: itemCount }, `shows ${itemCount} dropdown items for ${type}`); + // Only SAML is enterprise-only for now + const type = 'saml'; + const path = `auth-list-${type}-${uid}`; + await enablePage.enable(type, path); + await settled(); + await visit('/vault/access'); // all auth methods should be linkable await click(`[data-test-auth-backend-link="${path}"]`); - if (!supportManaged.includes(type)) { - assert.dom('[data-test-auth-section-tab]').exists({ count: 1 }); - assert - .dom('[data-test-auth-section-tab]') - .hasText('Configuration', `only shows configuration tab for ${type} auth method`); - assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`); - } else { - let expectedTabs = 2; - if (type == 'ldap' || type === 'okta') { - expectedTabs = 3; - } - assert - .dom('[data-test-auth-section-tab]') - .exists({ count: expectedTabs }, `has management tabs for ${type} auth method`); - } - if (type !== 'token') { - // cleanup method - await runCmd(deleteAuthCmd(path)); - } - } - }); - - test('enterprise: auth methods are linkable and link to correct view', async function (assert) { - assert.expect(3); - const uid = uuidv4(); - await visit('/vault/access'); - - // Only SAML is enterprise-only for now - const type = 'saml'; - const path = `auth-list-${type}-${uid}`; - await enablePage.enable(type, path); - await settled(); - await visit('/vault/access'); - - // all auth methods should be linkable - await click(`[data-test-auth-backend-link="${path}"]`); - assert.dom('[data-test-auth-section-tab]').exists({ count: 1 }); - assert - .dom('[data-test-auth-section-tab]') - .hasText('Configuration', `only shows configuration tab for ${type} auth method`); - assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`); - await runCmd(deleteAuthCmd(path)); - }); - - test('enterprise: token config within namespace', async function (assert) { - const ns = 'ns-wxyz'; - await runCmd(createNS(ns), false); - await settled(); - await authPage.loginNs(ns); - // go directly to token configure route - await visit('/vault/settings/auth/configure/token/options'); - await fillIn('[data-test-input="description"]', 'My custom description'); - await click('[data-test-save-config="true"]'); - assert.strictEqual(currentURL(), '/vault/access', 'successfully saves and navigates away'); - await click('[data-test-auth-backend-link="token"]'); - assert - .dom('[data-test-row-value="Description"]') - .hasText('My custom description', 'description was saved'); - await runCmd(`delete sys/namespaces/${ns}`); + assert.dom('[data-test-auth-section-tab]').exists({ count: 1 }); + assert + .dom('[data-test-auth-section-tab]') + .hasText('Configuration', `only shows configuration tab for ${type} auth method`); + assert.dom('[data-test-doc-link] .doc-link').exists(`includes doc link for ${type} auth method`); + await runCmd(deleteAuthCmd(path)); + }); + + test('token config within namespace', async function (assert) { + const ns = 'ns-wxyz'; + await runCmd(createNS(ns), false); + await settled(); + await authPage.loginNs(ns); + // go directly to token configure route + await visit('/vault/settings/auth/configure/token/options'); + await fillIn('[data-test-input="description"]', 'My custom description'); + await click('[data-test-save-config="true"]'); + assert.strictEqual(currentURL(), '/vault/access', 'successfully saves and navigates away'); + await click('[data-test-auth-backend-link="token"]'); + assert + .dom('[data-test-row-value="Description"]') + .hasText('My custom description', 'description was saved'); + await runCmd(`delete sys/namespaces/${ns}`); + }); }); }); diff --git a/ui/tests/acceptance/auth-test.js b/ui/tests/acceptance/auth-test.js index ab48fe5d339a..c0f8c6d1aca7 100644 --- a/ui/tests/acceptance/auth-test.js +++ b/ui/tests/acceptance/auth-test.js @@ -3,35 +3,21 @@ * SPDX-License-Identifier: BUSL-1.1 */ -/* eslint qunit/no-conditional-assertions: "warn" */ import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; -import sinon from 'sinon'; import { click, currentURL, visit, waitUntil, find } from '@ember/test-helpers'; import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends'; import authForm from '../pages/components/auth-form'; import jwtForm from '../pages/components/auth-jwt'; import { create } from 'ember-cli-page-object'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; const component = create(authForm); const jwtComponent = create(jwtForm); module('Acceptance | auth', function (hooks) { setupApplicationTest(hooks); - - hooks.beforeEach(function () { - this.clock = sinon.useFakeTimers({ - now: Date.now(), - shouldAdvanceTime: true, - }); - this.server = apiStub({ usePassthrough: true }); - }); - - hooks.afterEach(function () { - this.clock.restore(); - this.server.shutdown(); - }); + setupMirage(hooks); test('auth query params', async function (assert) { const backends = supportedAuthBackends(); @@ -55,53 +41,102 @@ module('Acceptance | auth', function (hooks) { assert.strictEqual(component.tokenValue, '', 'it clears the token value when toggling methods'); }); - test('it sends the right attributes when authenticating', async function (assert) { - assert.expect(8); - const backends = supportedAuthBackends(); - await visit('/vault/auth'); - for (const backend of backends.reverse()) { - await component.selectMethod(backend.type); - if (backend.type === 'github') { - await component.token('token'); - } - if (backend.type === 'jwt' || backend.type === 'oidc') { - await jwtComponent.role('test'); - } - await component.login(); - const lastRequest = this.server.passthroughRequests[this.server.passthroughRequests.length - 1]; - const body = JSON.parse(lastRequest.requestBody); + module('it sends the right attributes when authenticating', function (hooks) { + hooks.beforeEach(function () { + this.assertReq = () => {}; + this.server.get('/auth/token/lookup-self', (schema, req) => { + this.assertReq(req); + req.passthrough(); + }); + this.server.post('/auth/github/login', (schema, req) => { + // This one is for github only + this.assertReq(req); + req.passthrough(); + }); + this.server.post('/auth/:mount/oidc/auth_url', (schema, req) => { + // For JWT and OIDC + this.assertReq(req); + req.passthrough(); + }); + this.server.post('/auth/:mount/login/:username', (schema, req) => { + this.assertReq(req); + req.passthrough(); + }); + this.expected = { + token: { + included: 'X-Vault-Token', + url: '/v1/auth/token/lookup-self', + }, + userpass: { + included: 'password', + url: '/v1/auth/userpass/login/null', + }, + ldap: { + included: 'password', + url: '/v1/auth/ldap/login/null', + }, + okta: { + included: 'password', + url: '/v1/auth/okta/login/null', + }, + jwt: { + included: 'role', + url: '/v1/auth/jwt/oidc/auth_url', + }, + oidc: { + included: 'role', + url: '/v1/auth/oidc/oidc/auth_url', + }, + radius: { + included: 'password', + url: '/v1/auth/radius/login/null', + }, + github: { + included: 'token', + url: '/v1/auth/github/login', + }, + }; + }); - let keys; - let included; - if (backend.type === 'token') { - keys = lastRequest.requestHeaders; - included = 'x-vault-token'; - } else if (backend.type === 'github') { - keys = body; - included = 'token'; - } else if (backend.type === 'jwt' || backend.type === 'oidc') { - const authReq = this.server.passthroughRequests[this.server.passthroughRequests.length - 2]; - keys = JSON.parse(authReq.requestBody); - included = 'role'; - } else { - keys = body; - included = 'password'; - } - assert.ok(Object.keys(keys).includes(included), `${backend.type} includes ${included}`); + for (const backend of supportedAuthBackends().reverse()) { + test(`for ${backend.type}`, async function (assert) { + const { type } = backend; + const isOidc = ['jwt', 'oidc'].includes(type); + // OIDC types make 3 requests, each time the role changes + assert.expect(isOidc ? 6 : 2); + this.assertReq = (req) => { + const body = type === 'token' ? req.requestHeaders : JSON.parse(req.requestBody); + const { included, url } = this.expected[type]; + assert.true(Object.keys(body).includes(included), `${type} includes ${included}`); + assert.strictEqual(req.url, url, `${type} calls the correct URL`); + }; + await visit('/vault/auth'); + await component.selectMethod(type); + if (type === 'github') { + await component.token('token'); + } + if (isOidc) { + await jwtComponent.role('test'); + } + await component.login(); + }); } }); test('it shows the push notification warning after submit', async function (assert) { assert.expect(1); - this.server.get('/v1/auth/token/lookup-self', async () => { - assert.ok( - await waitUntil(() => find('[data-test-auth-message="push"]')), - 'shows push notification message' - ); - return [204, { 'Content-Type': 'application/json' }, JSON.stringify({})]; - }); - + this.server.get( + '/auth/token/lookup-self', + async () => { + assert.ok( + await waitUntil(() => find('[data-test-auth-message="push"]')), + 'shows push notification message' + ); + return {}; + }, + { timing: 1000 } + ); await visit('/vault/auth'); await component.selectMethod('token'); await click('[data-test-auth-submit]'); diff --git a/ui/tests/acceptance/clients/counts-test.js b/ui/tests/acceptance/clients/counts-test.js index dcf81c7014cc..69d6edbd9294 100644 --- a/ui/tests/acceptance/clients/counts-test.js +++ b/ui/tests/acceptance/clients/counts-test.js @@ -10,7 +10,8 @@ import clientsHandler, { STATIC_NOW } from 'vault/mirage/handlers/clients'; import sinon from 'sinon'; import { visit, click, currentURL } from '@ember/test-helpers'; import authPage from 'vault/tests/pages/auth'; -import { SELECTORS as ts } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; import timestamp from 'core/utils/timestamp'; module('Acceptance | clients | counts', function (hooks) { @@ -36,8 +37,8 @@ module('Acceptance | clients | counts', function (hooks) { this.owner.lookup('service:version').type = 'community'; await visit('/vault/clients/counts/overview'); - assert.dom(ts.emptyStateTitle).hasText('No data received'); - assert.dom(ts.emptyStateMessage).hasText('Select a start date above to query client count data.'); + assert.dom(GENERAL.emptyStateTitle).hasText('No data received'); + assert.dom(GENERAL.emptyStateMessage).hasText('Select a start date above to query client count data.'); }); test('it should redirect to counts overview route for transitions to parent', async function (assert) { @@ -47,19 +48,19 @@ module('Acceptance | clients | counts', function (hooks) { test('it should persist filter query params between child routes', async function (assert) { await visit('/vault/clients/counts/overview'); - await click(ts.rangeDropdown); - await click(ts.currentBillingPeriod); + await click(CLIENT_COUNT.rangeDropdown); + await click(CLIENT_COUNT.currentBillingPeriod); const timeQueryRegex = /end_time=\d+&start_time=\d+/g; assert.ok(currentURL().match(timeQueryRegex).length, 'Start and end times added as query params'); - await click(ts.tab('token')); + await click(GENERAL.tab('token')); assert.ok( currentURL().match(timeQueryRegex).length, 'Start and end times persist through child route change' ); - await click(ts.navLink('Dashboard')); - await click(ts.navLink('Client Count')); + await click(GENERAL.navLink('Dashboard')); + await click(GENERAL.navLink('Client Count')); assert.strictEqual( currentURL(), '/vault/clients/counts/overview', diff --git a/ui/tests/acceptance/clients/counts/overview-test.js b/ui/tests/acceptance/clients/counts/overview-test.js index 2d136961a972..db1b06edeb10 100644 --- a/ui/tests/acceptance/clients/counts/overview-test.js +++ b/ui/tests/acceptance/clients/counts/overview-test.js @@ -11,7 +11,8 @@ import sinon from 'sinon'; import { visit, click, findAll, settled } from '@ember/test-helpers'; import authPage from 'vault/tests/pages/auth'; import { ARRAY_OF_MONTHS } from 'core/utils/date-formatters'; -import { SELECTORS } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; import { create } from 'ember-cli-page-object'; import { clickTrigger } from 'ember-power-select/test-support/helpers'; import { formatNumber } from 'core/helpers/format-number'; @@ -40,24 +41,24 @@ module('Acceptance | clients | overview', function (hooks) { }); test('it should render the correct tabs', async function (assert) { - assert.dom(SELECTORS.tab('overview')).exists(); - assert.dom(SELECTORS.tab('token')).exists(); - assert.dom(SELECTORS.tab('config')).exists(); + assert.dom(GENERAL.tab('overview')).exists(); + assert.dom(GENERAL.tab('token')).exists(); + assert.dom(GENERAL.tab('config')).exists(); }); test('it should render charts', async function (assert) { assert - .dom(SELECTORS.counts.startMonth) + .dom(CLIENT_COUNT.counts.startMonth) .hasText('July 2023', 'billing start month is correctly parsed from license'); assert - .dom(SELECTORS.rangeDropdown) + .dom(CLIENT_COUNT.rangeDropdown) .hasText('Jul 2023 - Jan 2024', 'Date range shows dates correctly parsed activity response'); - assert.dom(SELECTORS.attributionBlock).exists('Shows attribution area'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('Shows attribution area'); assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .exists('Shows running totals with monthly breakdown charts'); assert - .dom(SELECTORS.charts.line.xAxisLabel) + .dom(CLIENT_COUNT.charts.line.xAxisLabel) .hasText('7/23', 'x-axis labels start with billing start date'); assert.strictEqual( findAll('[data-test-line-chart="plot-point"]').length, @@ -68,17 +69,17 @@ module('Acceptance | clients | overview', function (hooks) { test('it should update charts when querying date ranges', async function (assert) { // query for single, historical month with no new counts (July 2023) - await click(SELECTORS.rangeDropdown); + await click(CLIENT_COUNT.rangeDropdown); await click('[data-test-show-calendar]'); await click('[data-test-previous-year]'); await click(`[data-test-calendar-month=${ARRAY_OF_MONTHS[LICENSE_START.getMonth()]}]`); assert - .dom(SELECTORS.runningTotalMonthStats) + .dom(CLIENT_COUNT.runningTotalMonthStats) .doesNotExist('running total single month stat boxes do not show'); assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .doesNotExist('running total month over month charts do not show'); - assert.dom(SELECTORS.attributionBlock).exists('attribution area shows'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('attribution area shows'); assert .dom('[data-test-chart-container="new-clients"] [data-test-component="empty-state"]') .exists('new client attribution has empty state'); @@ -88,22 +89,22 @@ module('Acceptance | clients | overview', function (hooks) { assert.dom('[data-test-chart-container="total-clients"]').exists('total client attribution chart shows'); // reset to billing period - await click(SELECTORS.rangeDropdown); + await click(CLIENT_COUNT.rangeDropdown); await click('[data-test-current-billing-period]'); // change billing start to month/year of upgrade to 1.10 - await click(SELECTORS.counts.startEdit); - await click(SELECTORS.monthDropdown); + await click(CLIENT_COUNT.counts.startEdit); + await click(CLIENT_COUNT.monthDropdown); await click(`[data-test-dropdown-month="${ARRAY_OF_MONTHS[UPGRADE_DATE.getMonth()]}"]`); - await click(SELECTORS.yearDropdown); + await click(CLIENT_COUNT.yearDropdown); await click(`[data-test-dropdown-year="${UPGRADE_DATE.getFullYear()}"]`); await click('[data-test-date-dropdown-submit]'); - assert.dom(SELECTORS.attributionBlock).exists('Shows attribution area'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('Shows attribution area'); assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .exists('Shows running totals with monthly breakdown charts'); assert - .dom(SELECTORS.charts.line.xAxisLabel) + .dom(CLIENT_COUNT.charts.line.xAxisLabel) .hasText('9/23', 'x-axis labels start with queried start month (upgrade date)'); assert.strictEqual( findAll('[data-test-line-chart="plot-point"]').length, @@ -112,50 +113,50 @@ module('Acceptance | clients | overview', function (hooks) { ); // query for single, historical month (upgrade month) - await click(SELECTORS.rangeDropdown); + await click(CLIENT_COUNT.rangeDropdown); await click('[data-test-show-calendar]'); assert.dom('[data-test-display-year]').hasText('2024'); await click('[data-test-previous-year]'); await click('[data-test-calendar-month="September"]'); - assert.dom(SELECTORS.runningTotalMonthStats).exists('running total single month stat boxes show'); + assert.dom(CLIENT_COUNT.runningTotalMonthStats).exists('running total single month stat boxes show'); assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .doesNotExist('running total month over month charts do not show'); - assert.dom(SELECTORS.attributionBlock).exists('attribution area shows'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('attribution area shows'); assert.dom('[data-test-chart-container="new-clients"]').exists('new client attribution chart shows'); assert.dom('[data-test-chart-container="total-clients"]').exists('total client attribution chart shows'); // query historical date range (from September 2023 to December 2023) - await click(SELECTORS.rangeDropdown); + await click(CLIENT_COUNT.rangeDropdown); await click('[data-test-show-calendar]'); await click('[data-test-calendar-month="December"]'); - assert.dom(SELECTORS.attributionBlock).exists('Shows attribution area'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('Shows attribution area'); assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .exists('Shows running totals with monthly breakdown charts'); assert.strictEqual( findAll('[data-test-line-chart="plot-point"]').length, 4, 'line chart plots 4 points to match query' ); - const xAxisLabels = findAll(SELECTORS.charts.line.xAxisLabel); + const xAxisLabels = findAll(CLIENT_COUNT.charts.line.xAxisLabel); assert .dom(xAxisLabels[xAxisLabels.length - 1]) .hasText('12/23', 'x-axis labels end with queried end month'); // reset to billing period - await click(SELECTORS.rangeDropdown); + await click(CLIENT_COUNT.rangeDropdown); await click('[data-test-current-billing-period]'); // query month older than count start date - await click(SELECTORS.counts.startEdit); - await click(SELECTORS.monthDropdown); + await click(CLIENT_COUNT.counts.startEdit); + await click(CLIENT_COUNT.monthDropdown); await click(`[data-test-dropdown-month="${ARRAY_OF_MONTHS[LICENSE_START.getMonth()]}"]`); - await click(SELECTORS.yearDropdown); + await click(CLIENT_COUNT.yearDropdown); await click(`[data-test-dropdown-year="${LICENSE_START.getFullYear() - 3}"]`); await click('[data-test-date-dropdown-submit]'); assert - .dom(SELECTORS.counts.startDiscrepancy) + .dom(CLIENT_COUNT.counts.startDiscrepancy) .hasTextContaining( 'You requested data from July 2020. We only have data from January 2023, and that is what is being shown here.', 'warning banner displays that date queried was prior to count start date' @@ -164,9 +165,9 @@ module('Acceptance | clients | overview', function (hooks) { test('totals filter correctly with full data', async function (assert) { assert - .dom(SELECTORS.charts.chart('running total')) + .dom(CLIENT_COUNT.charts.chart('running total')) .exists('Shows running totals with monthly breakdown charts'); - assert.dom(SELECTORS.attributionBlock).exists('Shows attribution area'); + assert.dom(CLIENT_COUNT.attributionBlock).exists('Shows attribution area'); const response = await this.store.peekRecord('clients/activity', 'some-activity-id'); // FILTER BY NAMESPACE @@ -176,19 +177,19 @@ module('Acceptance | clients | overview', function (hooks) { const topNamespace = response.byNamespace[0]; const topMount = topNamespace.mounts[0]; - assert.dom(SELECTORS.selectedNs).hasText(topNamespace.label, 'selects top namespace'); + assert.dom(CLIENT_COUNT.selectedNs).hasText(topNamespace.label, 'selects top namespace'); assert.dom('[data-test-top-attribution]').includesText('Top auth method'); assert - .dom(SELECTORS.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .includesText(`${formatNumber([topNamespace.entity_clients])}`, 'total entity clients is accurate'); assert - .dom(SELECTORS.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .includesText( `${formatNumber([topNamespace.non_entity_clients])}`, 'total non-entity clients is accurate' ); assert - .dom(SELECTORS.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .includesText(`${formatNumber([topNamespace.secret_syncs])}`, 'total sync clients is accurate'); assert .dom('[data-test-attribution-clients] p') @@ -200,35 +201,35 @@ module('Acceptance | clients | overview', function (hooks) { await settled(); assert.ok(true, 'Filter by first auth method'); - assert.dom(SELECTORS.selectedAuthMount).hasText(topMount.label, 'selects top mount'); + assert.dom(CLIENT_COUNT.selectedAuthMount).hasText(topMount.label, 'selects top mount'); assert - .dom(SELECTORS.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .includesText(`${formatNumber([topMount.entity_clients])}`, 'total entity clients is accurate'); assert - .dom(SELECTORS.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .includesText(`${formatNumber([topMount.non_entity_clients])}`, 'total non-entity clients is accurate'); assert - .dom(SELECTORS.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .includesText(`${formatNumber([topMount.secret_syncs])}`, 'total sync clients is accurate'); - assert.dom(SELECTORS.attributionBlock).doesNotExist('Does not show attribution block'); + assert.dom(CLIENT_COUNT.attributionBlock).doesNotExist('Does not show attribution block'); await click('#namespace-search-select [data-test-selected-list-button="delete"]'); assert.ok(true, 'Remove namespace filter without first removing auth method filter'); assert.dom('[data-test-top-attribution]').includesText('Top namespace'); assert - .dom(SELECTORS.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .hasTextContaining( `${formatNumber([response.total.entity_clients])}`, 'total entity clients is back to unfiltered value' ); assert - .dom(SELECTORS.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .hasTextContaining( `${formatNumber([formatNumber([response.total.non_entity_clients])])}`, 'total non-entity clients is back to unfiltered value' ); assert - .dom(SELECTORS.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .hasTextContaining( `${formatNumber([formatNumber([response.total.secret_syncs])])}`, 'total sync clients is back to unfiltered value' @@ -270,19 +271,19 @@ module('Acceptance | clients | overview | sync in license, activated', function }); test('it should render the correct tabs', async function (assert) { - assert.dom(SELECTORS.tab('sync')).exists(); + assert.dom(GENERAL.tab('sync')).exists(); }); test('it should show secrets sync data in overview and tab', async function (assert) { assert - .dom(SELECTORS.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .exists('shows secret sync data on overview'); - await click(SELECTORS.tab('sync')); + await click(GENERAL.tab('sync')); - assert.dom(SELECTORS.tab('sync')).hasClass('active'); - assert.dom(SELECTORS.emptyStateTitle).doesNotExist(); + assert.dom(GENERAL.tab('sync')).hasClass('active'); + assert.dom(GENERAL.emptyStateTitle).doesNotExist(); assert - .dom(SELECTORS.charts.chart('Secrets sync usage')) + .dom(CLIENT_COUNT.charts.chart('Secrets sync usage')) .exists('chart is shown because feature is active and has data'); }); }); @@ -300,12 +301,12 @@ module('Acceptance | clients | overview | sync in license, not activated', funct }); test('it should show the secrets sync tab', async function (assert) { - assert.dom(SELECTORS.tab('sync')).exists('sync tab is shown because feature is in license'); + assert.dom(GENERAL.tab('sync')).exists('sync tab is shown because feature is in license'); }); test('it should hide secrets sync charts', async function (assert) { assert - .dom(SELECTORS.charts.chart('Secrets sync usage')) + .dom(CLIENT_COUNT.charts.chart('Secrets sync usage')) .doesNotExist('chart is hidden because feature is not activated'); assert.dom('[data-test-stat-text="secret-syncs"]').doesNotExist(); @@ -326,11 +327,11 @@ module('Acceptance | clients | overview | sync not in license', function (hooks) }); test('it should hide the secrets sync tab', async function (assert) { - assert.dom(SELECTORS.tab('sync')).doesNotExist(); + assert.dom(GENERAL.tab('sync')).doesNotExist(); }); test('it should hide secrets sync charts', async function (assert) { - assert.dom(SELECTORS.charts.chart('Secrets sync usage')).doesNotExist(); + assert.dom(CLIENT_COUNT.charts.chart('Secrets sync usage')).doesNotExist(); assert.dom('[data-test-stat-text="secret-syncs"]').doesNotExist(); }); diff --git a/ui/tests/acceptance/clients/counts/sync-test.js b/ui/tests/acceptance/clients/counts/sync-test.js index 4fc5ffa8dc65..87bfe2725889 100644 --- a/ui/tests/acceptance/clients/counts/sync-test.js +++ b/ui/tests/acceptance/clients/counts/sync-test.js @@ -12,7 +12,8 @@ import { visit, click, currentURL } from '@ember/test-helpers'; import sinon from 'sinon'; import timestamp from 'core/utils/timestamp'; import authPage from 'vault/tests/pages/auth'; -import { SELECTORS } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; module('Acceptance | clients | sync | activated', function (hooks) { setupApplicationTest(hooks); @@ -35,9 +36,11 @@ module('Acceptance | clients | sync | activated', function (hooks) { test('it should render charts when secrets sync is activated', async function (assert) { syncHandler(this.server); - assert.dom(SELECTORS.charts.chart('Secrets sync usage')).exists('Secrets sync usage chart is rendered'); - assert.dom(SELECTORS.syncTab.total).exists('Total sync clients chart is rendered'); - assert.dom(SELECTORS.emptyStateTitle).doesNotExist(); + assert + .dom(CLIENT_COUNT.charts.chart('Secrets sync usage')) + .exists('Secrets sync usage chart is rendered'); + assert.dom(CLIENT_COUNT.syncTab.total).exists('Total sync clients chart is rendered'); + assert.dom(GENERAL.emptyStateTitle).doesNotExist(); }); }); @@ -84,9 +87,9 @@ module('Acceptance | clients | sync | not activated', function (hooks) { }; }); - assert.dom(SELECTORS.emptyStateTitle).exists('Shows empty state when secrets-sync is not activated'); + assert.dom(GENERAL.emptyStateTitle).exists('Shows empty state when secrets-sync is not activated'); - await click(`${SELECTORS.emptyStateActions} .hds-link-standalone`); + await click(`${GENERAL.emptyStateActions} .hds-link-standalone`); assert.strictEqual( currentURL(), '/vault/sync/secrets/overview', diff --git a/ui/tests/acceptance/config-ui/messages/messages-test.js b/ui/tests/acceptance/config-ui/messages/messages-test.js index ee9837549064..da0c64291b0d 100644 --- a/ui/tests/acceptance/config-ui/messages/messages-test.js +++ b/ui/tests/acceptance/config-ui/messages/messages-test.js @@ -6,13 +6,14 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { click, visit, fillIn, currentRouteName } from '@ember/test-helpers'; +import { click, visit, fillIn, currentRouteName, currentURL } from '@ember/test-helpers'; import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import { format, addDays, startOfDay } from 'date-fns'; import { datetimeLocalStringFormat } from 'core/utils/date-formatters'; -import { PAGE } from 'vault/tests/helpers/config-ui/message-selectors'; +import { CUSTOM_MESSAGES } from 'vault/tests/helpers/config-ui/message-selectors'; import { clickTrigger } from 'ember-power-select/test-support/helpers'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; module('Acceptance | Community | config-ui/messages', function (hooks) { setupApplicationTest(hooks); @@ -48,7 +49,7 @@ module('Acceptance | Community | config-ui/messages', function (hooks) { test('it should hide the sidebar settings section on community', async function (assert) { assert.expect(1); - assert.dom(PAGE.navLink).doesNotExist(); + assert.dom(CUSTOM_MESSAGES.navLink).doesNotExist(); }); }); @@ -57,40 +58,44 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { + this.messageDetailId = () => { + return currentURL().match(/messages\/(.*)\/details/)[1]; + }; this.createMessage = async (messageType = 'banner', endTime = '2023-12-12', authenticated = true) => { - await click(PAGE.navLink); - + await click(CUSTOM_MESSAGES.navLink); if (authenticated) { - await click(PAGE.tab('After user logs in')); - await click(PAGE.button('create message')); + await click(CUSTOM_MESSAGES.tab('After user logs in')); } else { - await click(PAGE.tab('On login page')); - await click(PAGE.button('create message')); + await click(CUSTOM_MESSAGES.tab('On login page')); } + await click(CUSTOM_MESSAGES.button('create message')); - await visit(`vault/config-ui/messages?authenticated=${authenticated}`); - await click(PAGE.button('create message')); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); - await click(PAGE.radio(messageType)); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); + await click(CUSTOM_MESSAGES.radio(messageType)); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn( - PAGE.input('startTime'), + CUSTOM_MESSAGES.input('startTime'), format(addDays(startOfDay(new Date('2023-12-12')), 1), datetimeLocalStringFormat) ); if (endTime) { await click('#specificDate'); await fillIn( - PAGE.input('endTime'), + CUSTOM_MESSAGES.input('endTime'), format(addDays(startOfDay(new Date('2023-12-12')), 10), datetimeLocalStringFormat) ); } await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('create-message')); + await click(CUSTOM_MESSAGES.button('create-message')); + }; + this.deleteMessage = async (id) => { + await visit(`vault/config-ui/messages/${id}/details`); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); }; this.server.get('/sys/health', function () { return { @@ -120,25 +125,25 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { }); test('it should show an empty state when no messages are created', async function (assert) { assert.expect(4); - await click(PAGE.navLink); + await click(CUSTOM_MESSAGES.navLink); assert.dom('[data-test-component="empty-state"]').exists(); - assert.dom(PAGE.emptyStateTitle).hasText('No messages yet'); - await click(PAGE.tab('On login page')); + assert.dom(GENERAL.emptyStateTitle).hasText('No messages yet'); + await click(CUSTOM_MESSAGES.tab('On login page')); assert.dom('[data-test-component="empty-state"]').exists(); - assert.dom(PAGE.emptyStateTitle).hasText('No messages yet'); + assert.dom(GENERAL.emptyStateTitle).hasText('No messages yet'); }); module('Authenticated messages', function () { test('it should create, edit, view, and delete a message', async function (assert) { assert.expect(3); await this.createMessage(); - assert.dom(PAGE.title).hasText('Awesome custom message title', 'on the details screen'); + assert.dom(GENERAL.title).hasText('Awesome custom message title', 'on the details screen'); await click('[data-test-link="edit"]'); - await fillIn(PAGE.input('title'), 'Edited custom message title'); - await click(PAGE.button('create-message')); - assert.dom(PAGE.title).hasText('Edited custom message title'); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Edited custom message title'); + await click(CUSTOM_MESSAGES.button('create-message')); + assert.dom(GENERAL.title).hasText('Edited custom message title'); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); assert.strictEqual( currentRouteName(), 'vault.cluster.config-ui.messages.index', @@ -149,23 +154,24 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { test('it should show multiple messages modal', async function (assert) { assert.expect(4); await this.createMessage('modal', null); - assert.dom(PAGE.title).hasText('Awesome custom message title'); + assert.dom(GENERAL.title).hasText('Awesome custom message title'); await this.createMessage('modal', null); - assert.dom(PAGE.modal('multiple modal messages')).exists(); + assert.dom(CUSTOM_MESSAGES.modal('multiple modal messages')).exists(); assert - .dom(PAGE.modalTitle('Warning: more than one modal')) + .dom(CUSTOM_MESSAGES.modalTitle('Warning: more than one modal')) .hasText('Warning: more than one modal after the user logs in'); - await click(PAGE.modalButton('cancel')); + await click(CUSTOM_MESSAGES.modalButton('cancel')); await visit('vault/config-ui/messages'); - await click(PAGE.listItem('Awesome custom message title')); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); + await click(CUSTOM_MESSAGES.listItem('Awesome custom message title')); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); assert.dom('[data-test-component="empty-state"]').exists('Message was deleted'); }); test('it should filter by type and status', async function (assert) { - assert.expect(6); await this.createMessage('banner', null); + const msg1 = this.messageDetailId(); await this.createMessage('banner'); + const msg2 = this.messageDetailId(); await visit('vault/config-ui/messages'); // check number of messages with status filters @@ -192,49 +198,44 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { assert.dom('.linked-block').exists({ count: 2 }, 'no filters selected'); // clean up custom messages - await click(PAGE.listItem('Awesome custom message title')); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); - await click(PAGE.listItem('Awesome custom message title')); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); - assert.dom('[data-test-component="empty-state"]').exists('Message was deleted'); + await this.deleteMessage(msg1); + await this.deleteMessage(msg2); }); test('it should display preview a message when all required fields are filled out', async function (assert) { assert.expect(2); - await click(PAGE.navLink); - await click(PAGE.tab('After user logs in')); - await click(PAGE.button('create message')); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); - await click(PAGE.radio('banner')); + await click(CUSTOM_MESSAGES.navLink); + await click(CUSTOM_MESSAGES.tab('After user logs in')); + await click(CUSTOM_MESSAGES.button('create message')); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); + await click(CUSTOM_MESSAGES.radio('banner')); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview image')).exists(); - await click(PAGE.modalButton('Close')); - await click(PAGE.radio('modal')); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview modal')).exists(); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).exists(); + await click(CUSTOM_MESSAGES.modalButton('Close')); + await click(CUSTOM_MESSAGES.radio('modal')); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview modal')).exists(); }); test('it should not display preview a message when all required fields are not filled out', async function (assert) { assert.expect(2); - await click(PAGE.navLink); - await click(PAGE.tab('After user logs in')); - await click(PAGE.button('create message')); - await click(PAGE.radio('banner')); + await click(CUSTOM_MESSAGES.navLink); + await click(CUSTOM_MESSAGES.tab('After user logs in')); + await click(CUSTOM_MESSAGES.button('create message')); + await click(CUSTOM_MESSAGES.radio('banner')); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview image')).doesNotExist(); - assert.dom(PAGE.input('title')).hasClass('has-error-border'); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).doesNotExist(); + assert.dom(CUSTOM_MESSAGES.input('title')).hasClass('has-error-border'); }); }); @@ -242,13 +243,13 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { test('it should create, edit, view, and delete a message', async function (assert) { assert.expect(3); await this.createMessage('banner', null, false); - assert.dom(PAGE.title).hasText('Awesome custom message title', 'on the details screen'); + assert.dom(GENERAL.title).hasText('Awesome custom message title', 'on the details screen'); await click('[data-test-link="edit"]'); - await fillIn(PAGE.input('title'), 'Edited custom message title'); - await click(PAGE.button('create-message')); - assert.dom(PAGE.title).hasText('Edited custom message title'); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Edited custom message title'); + await click(CUSTOM_MESSAGES.button('create-message')); + assert.dom(GENERAL.title).hasText('Edited custom message title'); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); assert.strictEqual( currentRouteName(), 'vault.cluster.config-ui.messages.index', @@ -258,65 +259,65 @@ module('Acceptance | Enterprise | config-ui/message', function (hooks) { test('it should show multiple messages modal', async function (assert) { assert.expect(4); await this.createMessage('modal', null, false); - assert.dom(PAGE.title).hasText('Awesome custom message title'); + assert.dom(GENERAL.title).hasText('Awesome custom message title'); await this.createMessage('modal', null, false); - assert.dom(PAGE.modal('multiple modal messages')).exists(); + assert.dom(CUSTOM_MESSAGES.modal('multiple modal messages')).exists(); assert - .dom(PAGE.modalTitle('Warning: more than one modal')) + .dom(CUSTOM_MESSAGES.modalTitle('Warning: more than one modal')) .hasText('Warning: more than one modal on the login page'); - await click(PAGE.modalButton('cancel')); + await click(CUSTOM_MESSAGES.modalButton('cancel')); await visit('vault/config-ui/messages?authenticated=false'); - await click(PAGE.listItem('Awesome custom message title')); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); + await click(CUSTOM_MESSAGES.listItem('Awesome custom message title')); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); assert.dom('[data-test-component="empty-state"]').exists('Message was deleted'); }); test('it should show info message on create and edit form', async function (assert) { assert.expect(1); - await click(PAGE.navLink); - await click(PAGE.tab('On login page')); - await click(PAGE.button('create message')); + await click(CUSTOM_MESSAGES.navLink); + await click(CUSTOM_MESSAGES.tab('On login page')); + await click(CUSTOM_MESSAGES.button('create message')); assert - .dom(PAGE.unauthCreateFormInfo) + .dom(CUSTOM_MESSAGES.unauthCreateFormInfo) .hasText( 'Note: Do not include sensitive information in this message since users are unauthenticated at this stage.' ); }); test('it should display preview a message when all required fields are filled out', async function (assert) { assert.expect(2); - await click(PAGE.navLink); - await click(PAGE.tab('On login page')); - await click(PAGE.button('create message')); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); - await click(PAGE.radio('banner')); + await click(CUSTOM_MESSAGES.navLink); + await click(CUSTOM_MESSAGES.tab('On login page')); + await click(CUSTOM_MESSAGES.button('create message')); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); + await click(CUSTOM_MESSAGES.radio('banner')); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview image')).exists(); - await click(PAGE.modalButton('Close')); - await click(PAGE.radio('modal')); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview modal')).exists(); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).exists(); + await click(CUSTOM_MESSAGES.modalButton('Close')); + await click(CUSTOM_MESSAGES.radio('modal')); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview modal')).exists(); }); test('it should not display preview a message when all required fields are not filled out', async function (assert) { assert.expect(2); - await click(PAGE.navLink); - await click(PAGE.tab('On login page')); - await click(PAGE.button('create message')); - await click(PAGE.radio('banner')); + await click(CUSTOM_MESSAGES.navLink); + await click(CUSTOM_MESSAGES.tab('On login page')); + await click(CUSTOM_MESSAGES.button('create message')); + await click(CUSTOM_MESSAGES.radio('banner')); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview image')).doesNotExist(); - assert.dom(PAGE.input('title')).hasClass('has-error-border'); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).doesNotExist(); + assert.dom(CUSTOM_MESSAGES.input('title')).hasClass('has-error-border'); }); }); }); diff --git a/ui/tests/acceptance/config-ui/messages/messages-unauth-auth-test.js b/ui/tests/acceptance/config-ui/messages/messages-unauth-auth-test.js index 9a962b8e85f6..a617d255b0e2 100644 --- a/ui/tests/acceptance/config-ui/messages/messages-unauth-auth-test.js +++ b/ui/tests/acceptance/config-ui/messages/messages-unauth-auth-test.js @@ -6,7 +6,8 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { click, visit, fillIn, currentRouteName } from '@ember/test-helpers'; -import { PAGE } from 'vault/tests/helpers/config-ui/message-selectors'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CUSTOM_MESSAGES } from 'vault/tests/helpers/config-ui/message-selectors'; import { setupMirage } from 'ember-cli-mirage/test-support'; import authPage from 'vault/tests/pages/auth'; @@ -68,14 +69,14 @@ module('Acceptance | auth custom messages auth tests', function (hooks) { await visit('/vault/auth'); const modalId = 'some-awesome-id-1'; const alertId = 'some-awesome-id-2'; - assert.dom(PAGE.modal(modalId)).exists(); - assert.dom(PAGE.modalTitle(modalId)).hasText('Modal title'); - assert.dom(PAGE.modalBody(modalId)).exists(); - assert.dom(PAGE.modalBody(modalId)).hasText('here is a cool message'); - await click(PAGE.modalButton(modalId)); - assert.dom(PAGE.alertTitle(alertId)).hasText('Banner title'); - assert.dom(PAGE.alertDescription(alertId)).hasText('hello world hello wolrd'); - assert.dom(PAGE.alertAction('link')).hasText('some alert link'); + assert.dom(CUSTOM_MESSAGES.modal(modalId)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalId)).hasText('Modal title'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalId)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalId)).hasText('here is a cool message'); + await click(CUSTOM_MESSAGES.modalButton(modalId)); + assert.dom(CUSTOM_MESSAGES.alertTitle(alertId)).hasText('Banner title'); + assert.dom(CUSTOM_MESSAGES.alertDescription(alertId)).hasText('hello world hello wolrd'); + assert.dom(CUSTOM_MESSAGES.alertAction('link')).hasText('some alert link'); }); test('it shows the multiple modal messages', async function (assert) { const modalIdOne = 'some-awesome-id-2'; @@ -89,16 +90,16 @@ module('Acceptance | auth custom messages auth tests', function (hooks) { return unauthenticatedMessageResponse; }); await visit('/vault/auth'); - assert.dom(PAGE.modal(modalIdOne)).exists(); - assert.dom(PAGE.modalTitle(modalIdOne)).hasText('Modal title 1'); - assert.dom(PAGE.modalBody(modalIdOne)).exists(); - assert.dom(PAGE.modalBody(modalIdOne)).hasText('hello world hello wolrd some alert link'); - await click(PAGE.modalButton(modalIdOne)); - assert.dom(PAGE.modal(modalIdTwo)).exists(); - assert.dom(PAGE.modalTitle(modalIdTwo)).hasText('Modal title 2'); - assert.dom(PAGE.modalBody(modalIdTwo)).exists(); - assert.dom(PAGE.modalBody(modalIdTwo)).hasText('here is a cool message'); - await click(PAGE.modalButton(modalIdTwo)); + assert.dom(CUSTOM_MESSAGES.modal(modalIdOne)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalIdOne)).hasText('Modal title 1'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdOne)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdOne)).hasText('hello world hello wolrd some alert link'); + await click(CUSTOM_MESSAGES.modalButton(modalIdOne)); + assert.dom(CUSTOM_MESSAGES.modal(modalIdTwo)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalIdTwo)).hasText('Modal title 2'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdTwo)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdTwo)).hasText('here is a cool message'); + await click(CUSTOM_MESSAGES.modalButton(modalIdTwo)); }); test('it shows the multiple banner messages', async function (assert) { const bannerIdOne = 'some-awesome-id-2'; @@ -112,11 +113,11 @@ module('Acceptance | auth custom messages auth tests', function (hooks) { return unauthenticatedMessageResponse; }); await visit('/vault/auth'); - assert.dom(PAGE.alertTitle(bannerIdOne)).hasText('Banner title 1'); - assert.dom(PAGE.alertDescription(bannerIdOne)).hasText('hello world hello wolrd'); - assert.dom(PAGE.alertTitle(bannerIdTwo)).hasText('Banner title 2'); - assert.dom(PAGE.alertDescription(bannerIdTwo)).hasText('here is a cool message'); - assert.dom(PAGE.alertAction('link')).hasText('some alert link'); + assert.dom(CUSTOM_MESSAGES.alertTitle(bannerIdOne)).hasText('Banner title 1'); + assert.dom(CUSTOM_MESSAGES.alertDescription(bannerIdOne)).hasText('hello world hello wolrd'); + assert.dom(CUSTOM_MESSAGES.alertTitle(bannerIdTwo)).hasText('Banner title 2'); + assert.dom(CUSTOM_MESSAGES.alertDescription(bannerIdTwo)).hasText('here is a cool message'); + assert.dom(CUSTOM_MESSAGES.alertAction('link')).hasText('some alert link'); }); }); @@ -124,29 +125,29 @@ module('Acceptance | auth custom messages auth tests', function (hooks) { assert.expect(4); await authPage.login(); await visit('vault/config-ui/messages'); - await click(PAGE.button('create message')); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); - await click(PAGE.radio('banner')); + await click(CUSTOM_MESSAGES.button('create message')); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); + await click(CUSTOM_MESSAGES.radio('banner')); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn( - PAGE.input('startTime'), + CUSTOM_MESSAGES.input('startTime'), format(addDays(startOfDay(new Date('2023-12-12')), 1), datetimeLocalStringFormat) ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('create-message')); - assert.dom(PAGE.title).hasText('Awesome custom message title', 'on the details screen'); + await click(CUSTOM_MESSAGES.button('create-message')); + assert.dom(GENERAL.title).hasText('Awesome custom message title', 'on the details screen'); assert.dom('.hds-alert').exists('active custom message displays on authenticated.'); await runCmd(createNS('world'), false); await visit('vault/config-ui/messages'); assert.dom('.hds-alert').exists('active custom message displays on namespace authenticated.'); - await click(PAGE.listItem('Awesome custom message title')); - await click(PAGE.confirmActionButton('Delete message')); - await click(PAGE.confirmButton); + await click(CUSTOM_MESSAGES.listItem('Awesome custom message title')); + await click(CUSTOM_MESSAGES.confirmActionButton('Delete message')); + await click(GENERAL.confirmButton); assert.strictEqual( currentRouteName(), 'vault.cluster.config-ui.messages.index', diff --git a/ui/tests/acceptance/dashboard-test.js b/ui/tests/acceptance/dashboard-test.js index 0dc00b5e07fe..acdb8e984c20 100644 --- a/ui/tests/acceptance/dashboard-test.js +++ b/ui/tests/acceptance/dashboard-test.js @@ -27,8 +27,8 @@ import connectionPage from 'vault/tests/pages/secrets/backend/database/connectio import { v4 as uuidv4 } from 'uuid'; import { runCmd, deleteEngineCmd, createNS } from 'vault/tests/helpers/commands'; -import { SELECTORS } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; -import { PAGE } from 'vault/tests/helpers/config-ui/message-selectors'; +import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; +import { CUSTOM_MESSAGES } from 'vault/tests/helpers/config-ui/message-selectors'; const authenticatedMessageResponse = { request_id: '664fbad0-fcd8-9023-4c5b-81a7962e9f4b', @@ -87,7 +87,7 @@ module('Acceptance | landing page dashboard', function (hooks) { ? `Vault ${version.versionDisplay} root` : `Vault ${version.versionDisplay}`; - assert.dom(SELECTORS.cardHeader('Vault version')).hasText(versionText); + assert.dom(DASHBOARD.cardHeader('Vault version')).hasText(versionText); }); module('secrets engines card', function (hooks) { @@ -100,7 +100,7 @@ module('Acceptance | landing page dashboard', function (hooks) { await mountSecrets.enable('pki', 'pki'); await settled(); await visit('/vault/dashboard'); - assert.dom(SELECTORS.cardHeader('Secrets engines')).hasText('Secrets engines'); + assert.dom(DASHBOARD.cardHeader('Secrets engines')).hasText('Secrets engines'); // cleanup engine mount await runCmd(deleteEngineCmd('pki')); }); @@ -221,26 +221,26 @@ module('Acceptance | landing page dashboard', function (hooks) { await visit('/vault/dashboard'); const version = this.owner.lookup('service:version'); assert.true(version.isEnterprise, 'vault is enterprise'); - assert.dom(SELECTORS.cardName('configuration-details')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).exists(); await runCmd(createNS('world'), false); await visit('/vault/dashboard?namespace=world'); - assert.dom(SELECTORS.cardName('configuration-details')).doesNotExist(); + assert.dom(DASHBOARD.cardName('configuration-details')).doesNotExist(); }); test('shows the configuration details card', async function (assert) { assert.expect(8); await authPage.login(); await visit('/vault/dashboard'); - assert.dom(SELECTORS.cardHeader('configuration')).hasText('Configuration details'); + assert.dom(DASHBOARD.cardHeader('configuration')).hasText('Configuration details'); assert - .dom(SELECTORS.vaultConfigurationCard.configDetailsField('api_addr')) + .dom(DASHBOARD.vaultConfigurationCard.configDetailsField('api_addr')) .hasText('http://127.0.0.1:8200'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('default_lease_ttl')).hasText('0'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('max_lease_ttl')).hasText('2 days'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('tls')).hasText('Disabled'); // tls_disable=true - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('log_format')).hasText('None'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('log_level')).hasText('debug'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('type')).hasText('raft'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('default_lease_ttl')).hasText('0'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('max_lease_ttl')).hasText('2 days'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('tls')).hasText('Disabled'); // tls_disable=true + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('log_format')).hasText('None'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('log_level')).hasText('debug'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('type')).hasText('raft'); }); test('it should show tls as enabled if tls_disable, tls_cert_file and tls_key_file are in the config', async function (assert) { @@ -251,7 +251,7 @@ module('Acceptance | landing page dashboard', function (hooks) { await authPage.login(); await visit('/vault/dashboard'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('tls')).hasText('Enabled'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('tls')).hasText('Enabled'); }); test('it should show tls as enabled if only cert and key exist in config', async function (assert) { @@ -261,7 +261,7 @@ module('Acceptance | landing page dashboard', function (hooks) { this.data.listeners[0].config.tls_key_file = './key.pem'; await authPage.login(); await visit('/vault/dashboard'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('tls')).hasText('Enabled'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('tls')).hasText('Enabled'); }); test('it should show tls as disabled if there is no tls information in the config', async function (assert) { @@ -269,7 +269,7 @@ module('Acceptance | landing page dashboard', function (hooks) { this.data.listeners = []; await authPage.login(); await visit('/vault/dashboard'); - assert.dom(SELECTORS.vaultConfigurationCard.configDetailsField('tls')).hasText('Disabled'); + assert.dom(DASHBOARD.vaultConfigurationCard.configDetailsField('tls')).hasText('Disabled'); }); }); @@ -280,7 +280,7 @@ module('Acceptance | landing page dashboard', function (hooks) { test('shows the default state of the quick actions card', async function (assert) { assert.expect(1); - assert.dom(SELECTORS.emptyState('no-mount-selected')).exists(); + assert.dom(DASHBOARD.emptyState('no-mount-selected')).exists(); }); test('shows the correct actions and links associated with pki', async function (assert) { @@ -297,25 +297,25 @@ module('Acceptance | landing page dashboard', function (hooks) { await runCmd([`write ${backend}/root/generate/internal issuer_name="Hashicorp" common_name="Hello"`]); await settled(); await visit('/vault/dashboard'); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), backend); - await fillIn(SELECTORS.selectEl, 'Issue certificate'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - assert.dom(SELECTORS.subtitle('param')).hasText('Role to use'); - - await selectChoose(SELECTORS.searchSelect('params'), 'some-role'); - assert.dom(SELECTORS.actionButton('Issue leaf certificate')).exists({ count: 1 }); - await click(SELECTORS.actionButton('Issue leaf certificate')); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), backend); + await fillIn(DASHBOARD.selectEl, 'Issue certificate'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + assert.dom(DASHBOARD.subtitle('param')).hasText('Role to use'); + + await selectChoose(DASHBOARD.searchSelect('params'), 'some-role'); + assert.dom(DASHBOARD.actionButton('Issue leaf certificate')).exists({ count: 1 }); + await click(DASHBOARD.actionButton('Issue leaf certificate')); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.roles.role.generate'); await visit('/vault/dashboard'); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), backend); - await fillIn(SELECTORS.selectEl, 'View certificate'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - assert.dom(SELECTORS.subtitle('param')).hasText('Certificate serial number'); - assert.dom(SELECTORS.actionButton('View certificate')).exists({ count: 1 }); - await selectChoose(SELECTORS.searchSelect('params'), '.ember-power-select-option', 0); - await click(SELECTORS.actionButton('View certificate')); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), backend); + await fillIn(DASHBOARD.selectEl, 'View certificate'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + assert.dom(DASHBOARD.subtitle('param')).hasText('Certificate serial number'); + assert.dom(DASHBOARD.actionButton('View certificate')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('params'), '.ember-power-select-option', 0); + await click(DASHBOARD.actionButton('View certificate')); assert.strictEqual( currentRouteName(), 'vault.cluster.secrets.backend.pki.certificates.certificate.details' @@ -323,13 +323,13 @@ module('Acceptance | landing page dashboard', function (hooks) { await visit('/vault/dashboard'); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), backend); - await fillIn(SELECTORS.selectEl, 'View issuer'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - assert.dom(SELECTORS.subtitle('param')).hasText('Issuer'); - assert.dom(SELECTORS.actionButton('View issuer')).exists({ count: 1 }); - await selectChoose(SELECTORS.searchSelect('params'), '.ember-power-select-option', 0); - await click(SELECTORS.actionButton('View issuer')); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), backend); + await fillIn(DASHBOARD.selectEl, 'View issuer'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + assert.dom(DASHBOARD.subtitle('param')).hasText('Issuer'); + assert.dom(DASHBOARD.actionButton('View issuer')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('params'), '.ember-power-select-option', 0); + await click(DASHBOARD.actionButton('View issuer')); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.issuers.issuer.details'); // cleanup engine mount @@ -362,13 +362,13 @@ module('Acceptance | landing page dashboard', function (hooks) { ]); await settled(); await visit('/vault/dashboard'); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), databaseBackend); - await fillIn(SELECTORS.selectEl, 'Generate credentials for database'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - assert.dom(SELECTORS.subtitle('param')).hasText('Role to use'); - assert.dom(SELECTORS.actionButton('Generate credentials')).exists({ count: 1 }); - await selectChoose(SELECTORS.searchSelect('params'), '.ember-power-select-option', 0); - await click(SELECTORS.actionButton('Generate credentials')); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), databaseBackend); + await fillIn(DASHBOARD.selectEl, 'Generate credentials for database'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + assert.dom(DASHBOARD.subtitle('param')).hasText('Role to use'); + assert.dom(DASHBOARD.actionButton('Generate credentials')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('params'), '.ember-power-select-option', 0); + await click(DASHBOARD.actionButton('Generate credentials')); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.credentials'); await runCmd(deleteEngineCmd(databaseBackend)); }); @@ -401,7 +401,7 @@ module('Acceptance | landing page dashboard', function (hooks) { const version = this.owner.lookup('service:version'); assert.true(version.isEnterprise, 'version is enterprise'); assert.strictEqual(currentURL(), '/vault/dashboard'); - assert.dom(SELECTORS.cardName('client-count')).exists(); + assert.dom(DASHBOARD.cardName('client-count')).exists(); const response = await this.store.peekRecord('clients/activity', 'some-activity-id'); assert.dom('[data-test-client-count-title]').hasText('Client count'); assert.dom('[data-test-stat-text="total-clients"] .stat-label').hasText('Total'); @@ -433,12 +433,12 @@ module('Acceptance | landing page dashboard', function (hooks) { await visit('/vault/dashboard'); const version = this.owner.lookup('service:version'); assert.true(version.isEnterprise, 'vault is enterprise'); - assert.dom(SELECTORS.emptyState('replication')).exists(); - assert.dom(SELECTORS.emptyStateTitle('replication')).hasText('Replication not set up'); + assert.dom(DASHBOARD.emptyState('replication')).exists(); + assert.dom(DASHBOARD.emptyStateTitle('replication')).hasText('Replication not set up'); assert - .dom(SELECTORS.emptyStateMessage('replication')) + .dom(DASHBOARD.emptyStateMessage('replication')) .hasText('Data will be listed here. Enable a primary replication cluster to get started.'); - assert.dom(SELECTORS.emptyStateActions('replication')).hasText('Enable replication'); + assert.dom(DASHBOARD.emptyStateActions('replication')).hasText('Enable replication'); }); test('hides the replication card on a non-root namespace enterprise version', async function (assert) { @@ -446,10 +446,10 @@ module('Acceptance | landing page dashboard', function (hooks) { await visit('/vault/dashboard'); const version = this.owner.lookup('service:version'); assert.true(version.isEnterprise, 'vault is enterprise'); - assert.dom(SELECTORS.cardName('replication')).exists(); + assert.dom(DASHBOARD.cardName('replication')).exists(); await runCmd(createNS('blah'), false); await visit('/vault/dashboard?namespace=blah'); - assert.dom(SELECTORS.cardName('replication')).doesNotExist(); + assert.dom(DASHBOARD.cardName('replication')).doesNotExist(); }); test('it should show replication status if both dr and performance replication are enabled as features in enterprise', async function (assert) { @@ -467,12 +467,12 @@ module('Acceptance | landing page dashboard', function (hooks) { 'details dashboard is shown' ); await visit('/vault/dashboard'); - assert.dom(SELECTORS.title('DR primary')).hasText('DR primary'); - assert.dom(SELECTORS.tooltipTitle('DR primary')).hasText('not set up'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'x-circle')).exists(); - assert.dom(SELECTORS.title('Performance primary')).hasText('Performance primary'); - assert.dom(SELECTORS.tooltipTitle('Performance primary')).hasText('running'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'check-circle')).exists(); + assert.dom(DASHBOARD.title('DR primary')).hasText('DR primary'); + assert.dom(DASHBOARD.tooltipTitle('DR primary')).hasText('not set up'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'x-circle')).exists(); + assert.dom(DASHBOARD.title('Performance primary')).hasText('Performance primary'); + assert.dom(DASHBOARD.tooltipTitle('Performance primary')).hasText('running'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'check-circle')).exists(); }); }); @@ -489,14 +489,14 @@ module('Acceptance | landing page dashboard', function (hooks) { await visit('/vault/dashboard'); const modalId = 'some-awesome-id-1'; const alertId = 'some-awesome-id-2'; - assert.dom(PAGE.modal(modalId)).exists(); - assert.dom(PAGE.modalTitle(modalId)).hasText('Modal title'); - assert.dom(PAGE.modalBody(modalId)).exists(); - assert.dom(PAGE.modalBody(modalId)).hasText('here is a cool message'); - await click(PAGE.modalButton(modalId)); - assert.dom(PAGE.alertTitle(alertId)).hasText('Banner title'); - assert.dom(PAGE.alertDescription(alertId)).hasText('hello world hello wolrd'); - assert.dom(PAGE.alertAction('link')).hasText('some link title'); + assert.dom(CUSTOM_MESSAGES.modal(modalId)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalId)).hasText('Modal title'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalId)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalId)).hasText('here is a cool message'); + await click(CUSTOM_MESSAGES.modalButton(modalId)); + assert.dom(CUSTOM_MESSAGES.alertTitle(alertId)).hasText('Banner title'); + assert.dom(CUSTOM_MESSAGES.alertDescription(alertId)).hasText('hello world hello wolrd'); + assert.dom(CUSTOM_MESSAGES.alertAction('link')).hasText('some link title'); }); test('it shows the multiple modal messages', async function (assert) { assert.expect(8); @@ -511,16 +511,16 @@ module('Acceptance | landing page dashboard', function (hooks) { return authenticatedMessageResponse; }); await visit('/vault/dashboard'); - assert.dom(PAGE.modal(modalIdOne)).exists(); - assert.dom(PAGE.modalTitle(modalIdOne)).hasText('Modal title 1'); - assert.dom(PAGE.modalBody(modalIdOne)).exists(); - assert.dom(PAGE.modalBody(modalIdOne)).hasText('hello world hello wolrd some link title'); - await click(PAGE.modalButton(modalIdOne)); - assert.dom(PAGE.modal(modalIdTwo)).exists(); - assert.dom(PAGE.modalTitle(modalIdTwo)).hasText('Modal title 2'); - assert.dom(PAGE.modalBody(modalIdTwo)).exists(); - assert.dom(PAGE.modalBody(modalIdTwo)).hasText('here is a cool message'); - await click(PAGE.modalButton(modalIdTwo)); + assert.dom(CUSTOM_MESSAGES.modal(modalIdOne)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalIdOne)).hasText('Modal title 1'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdOne)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdOne)).hasText('hello world hello wolrd some link title'); + await click(CUSTOM_MESSAGES.modalButton(modalIdOne)); + assert.dom(CUSTOM_MESSAGES.modal(modalIdTwo)).exists(); + assert.dom(CUSTOM_MESSAGES.modalTitle(modalIdTwo)).hasText('Modal title 2'); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdTwo)).exists(); + assert.dom(CUSTOM_MESSAGES.modalBody(modalIdTwo)).hasText('here is a cool message'); + await click(CUSTOM_MESSAGES.modalButton(modalIdTwo)); }); test('it shows the multiple banner messages', async function (assert) { assert.expect(5); @@ -535,11 +535,11 @@ module('Acceptance | landing page dashboard', function (hooks) { return authenticatedMessageResponse; }); await visit('/vault/dashboard'); - assert.dom(PAGE.alertTitle(bannerIdOne)).hasText('Banner title 1'); - assert.dom(PAGE.alertDescription(bannerIdOne)).hasText('hello world hello wolrd'); - assert.dom(PAGE.alertAction('link')).hasText('some link title'); - assert.dom(PAGE.alertTitle(bannerIdTwo)).hasText('Banner title 2'); - assert.dom(PAGE.alertDescription(bannerIdTwo)).hasText('here is a cool message'); + assert.dom(CUSTOM_MESSAGES.alertTitle(bannerIdOne)).hasText('Banner title 1'); + assert.dom(CUSTOM_MESSAGES.alertDescription(bannerIdOne)).hasText('hello world hello wolrd'); + assert.dom(CUSTOM_MESSAGES.alertAction('link')).hasText('some link title'); + assert.dom(CUSTOM_MESSAGES.alertTitle(bannerIdTwo)).hasText('Banner title 2'); + assert.dom(CUSTOM_MESSAGES.alertDescription(bannerIdTwo)).hasText('here is a cool message'); }); }); }); diff --git a/ui/tests/acceptance/oidc-auth-method-test.js b/ui/tests/acceptance/oidc-auth-method-test.js index cedd5899e3bb..82fb72a5e8a5 100644 --- a/ui/tests/acceptance/oidc-auth-method-test.js +++ b/ui/tests/acceptance/oidc-auth-method-test.js @@ -69,7 +69,7 @@ module('Acceptance | oidc auth method', function (hooks) { later(() => { window.postMessage(buildMessage().data, window.origin); cancelTimers(); - }, 50); + }, 100); await click('[data-test-auth-submit]'); }); diff --git a/ui/tests/acceptance/oidc-config/clients-assignments-test.js b/ui/tests/acceptance/oidc-config/clients-assignments-test.js index edf65baec06d..b82fb4e17ce9 100644 --- a/ui/tests/acceptance/oidc-config/clients-assignments-test.js +++ b/ui/tests/acceptance/oidc-config/clients-assignments-test.js @@ -17,11 +17,11 @@ import { OIDC_BASE_URL, // -> '/vault/access/oidc' SELECTORS, clearRecord, - overrideCapabilities, - overrideMirageResponse, ASSIGNMENT_LIST_RESPONSE, ASSIGNMENT_DATA_RESPONSE, } from 'vault/tests/helpers/oidc-config'; +import { capabilitiesStub, overrideResponse } from 'vault/tests/helpers/stubs'; + const searchSelect = create(ss); const flashMessage = create(fm); @@ -51,7 +51,7 @@ module('Acceptance | oidc-config clients and assignments', function (hooks) { test('it renders empty state when no clients are configured', async function (assert) { assert.expect(5); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(404)); + this.server.get('/identity/oidc/client', () => overrideResponse(404)); await visit(OIDC_BASE_URL); assert.strictEqual(currentURL(), '/vault/access/oidc'); @@ -277,10 +277,10 @@ module('Acceptance | oidc-config clients and assignments', function (hooks) { test('it navigates to and from an assignment from the list view', async function (assert) { assert.expect(6); this.server.get('/identity/oidc/assignment', () => - overrideMirageResponse(null, ASSIGNMENT_LIST_RESPONSE) + overrideResponse(200, { data: ASSIGNMENT_LIST_RESPONSE }) ); this.server.get('/identity/oidc/assignment/test-assignment', () => - overrideMirageResponse(null, ASSIGNMENT_DATA_RESPONSE) + overrideResponse(200, { data: ASSIGNMENT_DATA_RESPONSE }) ); await visit(OIDC_BASE_URL + '/assignments'); assert @@ -327,13 +327,13 @@ module('Acceptance | oidc-config clients and assignments', function (hooks) { test('it hides assignment delete and edit when no permission', async function (assert) { assert.expect(5); this.server.get('/identity/oidc/assignment', () => - overrideMirageResponse(null, ASSIGNMENT_LIST_RESPONSE) + overrideResponse(null, { data: ASSIGNMENT_LIST_RESPONSE }) ); this.server.get('/identity/oidc/assignment/test-assignment', () => - overrideMirageResponse(null, ASSIGNMENT_DATA_RESPONSE) + overrideResponse(null, { data: ASSIGNMENT_DATA_RESPONSE }) ); this.server.post('/sys/capabilities-self', () => - overrideCapabilities(OIDC_BASE_URL + '/assignment/test-assignment', ['read']) + capabilitiesStub(OIDC_BASE_URL + '/assignment/test-assignment', ['read']) ); await visit(OIDC_BASE_URL + '/assignments'); diff --git a/ui/tests/acceptance/oidc-config/clients-keys-test.js b/ui/tests/acceptance/oidc-config/clients-keys-test.js index 7a37f8c6a9e2..33e2bd7c16f8 100644 --- a/ui/tests/acceptance/oidc-config/clients-keys-test.js +++ b/ui/tests/acceptance/oidc-config/clients-keys-test.js @@ -17,11 +17,10 @@ import { OIDC_BASE_URL, // -> '/vault/access/oidc' SELECTORS, clearRecord, - overrideCapabilities, - overrideMirageResponse, CLIENT_LIST_RESPONSE, CLIENT_DATA_RESPONSE, } from 'vault/tests/helpers/oidc-config'; +import { capabilitiesStub, overrideResponse } from 'vault/tests/helpers/stubs'; const searchSelect = create(ss); const flashMessage = create(fm); @@ -177,7 +176,7 @@ module('Acceptance | oidc-config clients and keys', function (hooks) { test('it creates, rotates and deletes a key', async function (assert) { assert.expect(10); // mock client list so OIDC url does not redirect to landing page - this.server.get('/identity/oidc/client', () => overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); this.server.post('/identity/oidc/key/test-key/rotate', (schema, req) => { const json = JSON.parse(req.requestBody); assert.strictEqual(json.verification_ttl, 86400, 'request made with correct args to accurate endpoint'); @@ -240,9 +239,9 @@ module('Acceptance | oidc-config clients and keys', function (hooks) { test('it renders client details and providers', async function (assert) { assert.expect(8); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); this.server.get('/identity/oidc/client/test-app', () => - overrideMirageResponse(null, CLIENT_DATA_RESPONSE) + overrideResponse(null, { data: CLIENT_DATA_RESPONSE }) ); await visit(OIDC_BASE_URL); await click('[data-test-oidc-client-linked-block]'); @@ -264,12 +263,12 @@ module('Acceptance | oidc-config clients and keys', function (hooks) { test('it hides delete and edit client when no permission', async function (assert) { assert.expect(5); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); this.server.get('/identity/oidc/client/test-app', () => - overrideMirageResponse(null, CLIENT_DATA_RESPONSE) + overrideResponse(null, { data: CLIENT_DATA_RESPONSE }) ); this.server.post('/sys/capabilities-self', () => - overrideCapabilities(OIDC_BASE_URL + '/client/test-app', ['read']) + capabilitiesStub(OIDC_BASE_URL + '/client/test-app', ['read']) ); await visit(OIDC_BASE_URL); @@ -283,17 +282,19 @@ module('Acceptance | oidc-config clients and keys', function (hooks) { test('it hides delete and edit key when no permission', async function (assert) { assert.expect(4); - this.server.get('/identity/oidc/keys', () => overrideMirageResponse(null, { keys: ['test-key'] })); + this.server.get('/identity/oidc/keys', () => overrideResponse(null, { data: { keys: ['test-key'] } })); this.server.get('/identity/oidc/key/test-key', () => - overrideMirageResponse(null, { - algorithm: 'RS256', - allowed_client_ids: ['*'], - rotation_period: 86400, - verification_ttl: 86400, + overrideResponse(null, { + data: { + algorithm: 'RS256', + allowed_client_ids: ['*'], + rotation_period: 86400, + verification_ttl: 86400, + }, }) ); this.server.post('/sys/capabilities-self', () => - overrideCapabilities(OIDC_BASE_URL + '/key/test-key', ['read']) + capabilitiesStub(OIDC_BASE_URL + '/key/test-key', ['read']) ); await visit(OIDC_BASE_URL + '/keys'); diff --git a/ui/tests/acceptance/oidc-config/providers-scopes-test.js b/ui/tests/acceptance/oidc-config/providers-scopes-test.js index 472fa443bc02..b680a64ec0fe 100644 --- a/ui/tests/acceptance/oidc-config/providers-scopes-test.js +++ b/ui/tests/acceptance/oidc-config/providers-scopes-test.js @@ -22,9 +22,8 @@ import { PROVIDER_LIST_RESPONSE, PROVIDER_DATA_RESPONSE, clearRecord, - overrideCapabilities, - overrideMirageResponse, } from 'vault/tests/helpers/oidc-config'; +import { capabilitiesStub, overrideResponse } from 'vault/tests/helpers/stubs'; const searchSelect = create(ss); const flashMessage = create(fm); @@ -38,14 +37,14 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) { oidcConfigHandlers(this.server); this.store = this.owner.lookup('service:store'); // mock client list so OIDC BASE URL does not redirect to landing call-to-action image - this.server.get('/identity/oidc/client', () => overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); return authPage.login(); }); // LIST SCOPES EMPTY test('it navigates to scopes list view and renders empty state when no scopes are configured', async function (assert) { assert.expect(4); - this.server.get('/identity/oidc/scope', () => overrideMirageResponse(404)); + this.server.get('/identity/oidc/scope', () => overrideResponse(404)); await visit(OIDC_BASE_URL); await click('[data-test-tab="scopes"]'); assert.strictEqual(currentURL(), '/vault/access/oidc/scopes'); @@ -64,9 +63,9 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) { // LIST SCOPE EXIST test('it renders scope list when scopes exist', async function (assert) { assert.expect(11); - this.server.get('/identity/oidc/scope', () => overrideMirageResponse(null, SCOPE_LIST_RESPONSE)); + this.server.get('/identity/oidc/scope', () => overrideResponse(null, { data: SCOPE_LIST_RESPONSE })); this.server.get('/identity/oidc/scope/test-scope', () => - overrideMirageResponse(null, SCOPE_DATA_RESPONSE) + overrideResponse(null, { data: SCOPE_DATA_RESPONSE }) ); await visit(OIDC_BASE_URL + '/scopes'); assert.strictEqual( @@ -125,13 +124,15 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) { // ERROR DELETING SCOPE test('it throws error when trying to delete when scope is currently being associated with any provider', async function (assert) { assert.expect(3); - this.server.get('/identity/oidc/scope', () => overrideMirageResponse(null, SCOPE_LIST_RESPONSE)); + this.server.get('/identity/oidc/scope', () => overrideResponse(null, { data: SCOPE_LIST_RESPONSE })); this.server.get('/identity/oidc/scope/test-scope', () => - overrideMirageResponse(null, SCOPE_DATA_RESPONSE) + overrideResponse(null, { data: SCOPE_DATA_RESPONSE }) + ); + this.server.get('/identity/oidc/provider', () => + overrideResponse(null, { data: PROVIDER_LIST_RESPONSE }) ); - this.server.get('/identity/oidc/provider', () => overrideMirageResponse(null, PROVIDER_LIST_RESPONSE)); this.server.get('/identity/oidc/provider/test-provider', () => { - overrideMirageResponse(null, PROVIDER_DATA_RESPONSE); + overrideResponse(null, { data: PROVIDER_DATA_RESPONSE }); }); // throw error when trying to delete test-scope since it is associated to test-provider this.server.delete( @@ -376,17 +377,19 @@ module('Acceptance | oidc-config providers and scopes', function (hooks) { test('it hides delete and edit for a provider when no permission', async function (assert) { assert.expect(3); this.server.get('/identity/oidc/providers', () => - overrideMirageResponse(null, { providers: ['test-provider'] }) + overrideResponse(null, { data: { providers: ['test-provider'] } }) ); this.server.get('/identity/oidc/provider/test-provider', () => - overrideMirageResponse(null, { - allowed_client_ids: ['*'], - issuer: 'http://127.0.0.1:8200/v1/identity/oidc/provider/test-provider', - scopes_supported: ['test-scope'], + overrideResponse(null, { + data: { + allowed_client_ids: ['*'], + issuer: 'http://127.0.0.1:8200/v1/identity/oidc/provider/test-provider', + scopes_supported: ['test-scope'], + }, }) ); this.server.post('/sys/capabilities-self', () => - overrideCapabilities(OIDC_BASE_URL + '/provider/test-provider', ['read']) + capabilitiesStub(OIDC_BASE_URL + '/provider/test-provider', ['read']) ); await visit(OIDC_BASE_URL + '/providers'); diff --git a/ui/tests/acceptance/open-api-path-help-test.js b/ui/tests/acceptance/open-api-path-help-test.js index c2fdcf36ebca..86bfda6e874c 100644 --- a/ui/tests/acceptance/open-api-path-help-test.js +++ b/ui/tests/acceptance/open-api-path-help-test.js @@ -7,7 +7,8 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'vault/tests/helpers'; import authPage from 'vault/tests/pages/auth'; import { deleteAuthCmd, deleteEngineCmd, mountAuthCmd, mountEngineCmd, runCmd } from '../helpers/commands'; -import { authEngineHelper, secretEngineHelper } from '../helpers/openapi/test-helpers'; +import expectedSecretAttrs from 'vault/tests/helpers/openapi/expected-secret-attrs'; +import expectedAuthAttrs from 'vault/tests/helpers/openapi/expected-auth-attrs'; /** * This set of tests is for ensuring that backend changes to the OpenAPI spec @@ -56,3 +57,52 @@ module('Acceptance | OpenAPI provides expected attributes enterprise', function } ); }); + +function secretEngineHelper(test, secretEngine) { + const engineData = expectedSecretAttrs[secretEngine]; + if (!engineData) + throw new Error(`No engine attributes found in secret-model-attributes for ${secretEngine}`); + + const modelNames = Object.keys(engineData); + // A given secret engine might have multiple models that are openApi driven + modelNames.forEach((modelName) => { + test(`${modelName} model getProps returns correct attributes`, async function (assert) { + const model = this.store.createRecord(modelName, {}); + const helpUrl = model.getHelpUrl(this.backend); + const result = await this.pathHelp.getProps(helpUrl, this.backend); + const expected = engineData[modelName]; + assert.deepEqual(result, expected, `getProps returns expected attributes for ${modelName}`); + }); + }); +} + +function authEngineHelper(test, authBackend) { + const authData = expectedAuthAttrs[authBackend]; + if (!authData) throw new Error(`No auth attributes found in auth-model-attributes for ${authBackend}`); + + const itemNames = Object.keys(authData); + itemNames.forEach((itemName) => { + if (itemName.startsWith('auth-config/')) { + // Config test doesn't need to instantiate a new model + test(`${itemName} model`, async function (assert) { + const model = this.store.createRecord(itemName, {}); + const helpUrl = model.getHelpUrl(this.mount); + const result = await this.pathHelp.getProps(helpUrl, this.mount); + const expected = authData[itemName]; + assert.deepEqual(result, expected, `getProps returns expected attributes for ${itemName}`); + }); + } else { + test.skip(`generated-${itemName}-${authBackend} model`, async function (assert) { + const modelName = `generated-${itemName}-${authBackend}`; + // Generated items need to instantiate the model first via getNewModel + await this.pathHelp.getNewModel(modelName, this.mount, `auth/${this.mount}/`, itemName); + const model = this.store.createRecord(modelName, {}); + // Generated items don't have this method -- helpUrl is calculated in path-help.js line 101 + const helpUrl = model.getHelpUrl(this.mount); + const result = await this.pathHelp.getProps(helpUrl, this.mount); + const expected = authData[modelName]; + assert.deepEqual(result, expected, `getProps returns expected attributes for ${modelName}`); + }); + } + }); +} diff --git a/ui/tests/acceptance/pki/pki-action-forms-test.js b/ui/tests/acceptance/pki/pki-action-forms-test.js index adedfc46ecf0..2ba8b3dbcd18 100644 --- a/ui/tests/acceptance/pki/pki-action-forms-test.js +++ b/ui/tests/acceptance/pki/pki-action-forms-test.js @@ -13,8 +13,11 @@ import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS as S } from 'vault/tests/helpers/pki/workflow'; -import { issuerPemBundle } from 'vault/tests/helpers/pki/values'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +import { PKI_CONFIGURE_CREATE, PKI_GENERATE_ROOT } from 'vault/tests/helpers/pki/pki-selectors'; + +const { issuerPemBundle } = CERTIFICATES; module('Acceptance | pki action forms test', function (hooks) { setupApplicationTest(hooks); @@ -46,28 +49,28 @@ module('Acceptance | pki action forms test', function (hooks) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - await click(S.emptyStateLink); + await click(`${GENERAL.emptyStateActions} a`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`); - assert.dom(S.configuration.title).hasText('Configure PKI'); - assert.dom(S.configuration.emptyState).exists({ count: 1 }, 'Shows empty state by default'); - await click(S.configuration.optionByKey('import')); - assert.dom(S.configuration.emptyState).doesNotExist(); + assert.dom(GENERAL.title).hasText('Configure PKI'); + assert.dom(GENERAL.emptyStateTitle).exists({ count: 1 }, 'Shows empty state by default'); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); + assert.dom(GENERAL.emptyStateTitle).doesNotExist(); // Submit before filling out form shows an error - await click('[data-test-pki-import-pem-bundle]'); - assert.dom(S.configuration.importError).hasText('Error please upload your PEM bundle'); + await click(PKI_CONFIGURE_CREATE.importSubmit); + assert.dom(GENERAL.messageError).hasText('Error please upload your PEM bundle'); // Fill in form data await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`, 'stays on page on success' ); - assert.dom(S.configuration.title).hasText('View imported items'); - assert.dom(S.configuration.importForm).doesNotExist('import form is hidden after save'); - assert.dom(S.configuration.importMapping).exists('import mapping is shown after save'); + assert.dom(GENERAL.title).hasText('View imported items'); + assert.dom(PKI_CONFIGURE_CREATE.importForm).doesNotExist('import form is hidden after save'); + assert.dom(PKI_CONFIGURE_CREATE.importMapping).exists('import mapping is shown after save'); await click('[data-test-done]'); assert.strictEqual( currentURL(), @@ -91,22 +94,24 @@ module('Acceptance | pki action forms test', function (hooks) { }); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(S.configuration.optionByKey('import')); - assert.dom(S.configuration.importForm).exists('import form is shown save'); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); + assert.dom(PKI_CONFIGURE_CREATE.importForm).exists('import form is shown save'); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`, 'stays on page on success' ); - assert.dom(S.configuration.title).hasText('View imported items'); - assert.dom(S.configuration.importForm).doesNotExist('import form is hidden after save'); - assert.dom(S.configuration.importMapping).exists('import mapping is shown after save'); - assert.dom(S.configuration.importedIssuer).hasText('my-imported-issuer', 'Issuer value is displayed'); - assert.dom(S.configuration.importedKey).hasText('my-imported-key', 'Key value is displayed'); + assert.dom(GENERAL.title).hasText('View imported items'); + assert.dom(PKI_CONFIGURE_CREATE.importForm).doesNotExist('import form is hidden after save'); + assert.dom(PKI_CONFIGURE_CREATE.importMapping).exists('import mapping is shown after save'); + assert + .dom(PKI_CONFIGURE_CREATE.importedIssuer) + .hasText('my-imported-issuer', 'Issuer value is displayed'); + assert.dom(PKI_CONFIGURE_CREATE.importedKey).hasText('my-imported-key', 'Key value is displayed'); await click('[data-test-done]'); assert.strictEqual( currentURL(), @@ -130,16 +135,18 @@ module('Acceptance | pki action forms test', function (hooks) { }); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(S.configuration.optionByKey('import')); - assert.dom(S.configuration.importForm).exists('import form is shown save'); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); + assert.dom(PKI_CONFIGURE_CREATE.importForm).exists('import form is shown save'); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); - assert.dom(S.configuration.importForm).doesNotExist('import form is hidden after save'); - assert.dom(S.configuration.importMapping).exists('import mapping is shown after save'); - assert.dom(S.configuration.importedIssuer).hasText('my-imported-issuer', 'Issuer value is displayed'); - assert.dom(S.configuration.importedKey).hasText('None', 'Shows placeholder value for key'); + assert.dom(PKI_CONFIGURE_CREATE.importForm).doesNotExist('import form is hidden after save'); + assert.dom(PKI_CONFIGURE_CREATE.importMapping).exists('import mapping is shown after save'); + assert + .dom(PKI_CONFIGURE_CREATE.importedIssuer) + .hasText('my-imported-issuer', 'Issuer value is displayed'); + assert.dom(PKI_CONFIGURE_CREATE.importedKey).hasText('None', 'Shows placeholder value for key'); }); test('shows None for imported items if nothing new imported', async function (assert) { this.server.post(`${this.mountPath}/config/ca`, () => { @@ -154,16 +161,16 @@ module('Acceptance | pki action forms test', function (hooks) { }); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(S.configuration.optionByKey('import')); - assert.dom(S.configuration.importForm).exists('import form is shown save'); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); + assert.dom(PKI_CONFIGURE_CREATE.importForm).exists('import form is shown save'); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); - assert.dom(S.configuration.importForm).doesNotExist('import form is hidden after save'); - assert.dom(S.configuration.importMapping).exists('import mapping is shown after save'); - assert.dom(S.configuration.importedIssuer).hasText('None', 'Shows placeholder value for issuer'); - assert.dom(S.configuration.importedKey).hasText('None', 'Shows placeholder value for key'); + assert.dom(PKI_CONFIGURE_CREATE.importForm).doesNotExist('import form is hidden after save'); + assert.dom(PKI_CONFIGURE_CREATE.importMapping).exists('import mapping is shown after save'); + assert.dom(PKI_CONFIGURE_CREATE.importedIssuer).hasText('None', 'Shows placeholder value for issuer'); + assert.dom(PKI_CONFIGURE_CREATE.importedKey).hasText('None', 'Shows placeholder value for key'); }); }); @@ -175,73 +182,73 @@ module('Acceptance | pki action forms test', function (hooks) { await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - await click(S.emptyStateLink); + await click(`${GENERAL.emptyStateActions} a`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`); - assert.dom(S.configuration.title).hasText('Configure PKI'); - assert.dom(S.configuration.emptyState).exists({ count: 1 }, 'Shows empty state by default'); - await click(S.configuration.optionByKey('generate-root')); - assert.dom(S.configuration.emptyState).doesNotExist(); + assert.dom(GENERAL.title).hasText('Configure PKI'); + assert.dom(GENERAL.emptyStateTitle).exists({ count: 1 }, 'Shows empty state by default'); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); + assert.dom(GENERAL.emptyStateTitle).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(PKI_GENERATE_ROOT.urlField).exists({ count: 4 }); // Fill in form - await fillIn(S.configuration.typeField, 'internal'); - await typeIn(S.configuration.inputByName('commonName'), commonName); - await typeIn(S.configuration.inputByName('issuerName'), issuerName); - await click(S.configuration.keyParamsGroupToggle); - await typeIn(S.configuration.inputByName('keyName'), keyName); - await click(S.configuration.generateRootSave); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await typeIn(GENERAL.inputByAttr('commonName'), commonName); + await typeIn(GENERAL.inputByAttr('issuerName'), issuerName); + await click(PKI_GENERATE_ROOT.keyParamsGroupToggle); + await typeIn(GENERAL.inputByAttr('keyName'), keyName); + await click(GENERAL.saveButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`, 'stays on page on success' ); - assert.dom(S.configuration.title).hasText('View Root Certificate'); - assert.dom(S.configuration.nextStepsBanner).doesNotExist('no private key warning'); - assert.dom(S.configuration.title).hasText('View Root Certificate', 'Updates title on page'); - assert.dom(S.configuration.saved.certificate).exists('Copyable certificate exists'); - assert.dom(S.configuration.saved.issuerName).hasText(issuerName); - assert.dom(S.configuration.saved.issuerLink).exists('Issuer link exists'); - assert.dom(S.configuration.saved.keyLink).exists('Key link exists'); - assert.dom(S.configuration.saved.keyName).hasText(keyName); + assert.dom(GENERAL.title).hasText('View Root Certificate'); + assert.dom(PKI_CONFIGURE_CREATE.nextStepsBanner).doesNotExist('no private key warning'); + assert.dom(GENERAL.title).hasText('View Root Certificate', 'Updates title on page'); + assert.dom(PKI_GENERATE_ROOT.saved.certificate).exists('Copyable certificate exists'); + assert.dom(PKI_GENERATE_ROOT.saved.issuerName).hasText(issuerName); + assert.dom(PKI_GENERATE_ROOT.saved.issuerLink).exists('Issuer link exists'); + assert.dom(PKI_GENERATE_ROOT.saved.keyLink).exists('Key link exists'); + assert.dom(PKI_GENERATE_ROOT.saved.keyName).hasText(keyName); assert.dom('[data-test-done]').exists('Done button exists'); // Check that linked issuer has correct common name - await click(S.configuration.saved.issuerLink); - assert.dom(S.issuerDetails.valueByName('Common name')).hasText(commonName); + await click(PKI_GENERATE_ROOT.saved.issuerLink); + assert.dom(GENERAL.infoRowValue('Common name')).hasText(commonName); }); test('type=exported', async function (assert) { const commonName = 'my-exported-name'; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(S.configuration.optionByKey('generate-root')); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); // Fill in form - await fillIn(S.configuration.typeField, 'exported'); - await typeIn(S.configuration.inputByName('commonName'), commonName); - await click(S.configuration.generateRootSave); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await typeIn(GENERAL.inputByAttr('commonName'), commonName); + await click(GENERAL.saveButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`, 'stays on page on success' ); - assert.dom(S.configuration.title).hasText('View Root Certificate'); + assert.dom(GENERAL.title).hasText('View Root Certificate'); assert - .dom(S.configuration.nextStepsBanner) + .dom(PKI_CONFIGURE_CREATE.nextStepsBanner) .hasText('Next steps The private_key is only available once. Make sure you copy and save it now.'); - assert.dom(S.configuration.title).hasText('View Root Certificate', 'Updates title on page'); - assert.dom(S.configuration.saved.certificate).exists('Copyable certificate exists'); + assert.dom(GENERAL.title).hasText('View Root Certificate', 'Updates title on page'); + assert.dom(PKI_GENERATE_ROOT.saved.certificate).exists('Copyable certificate exists'); assert - .dom(S.configuration.saved.issuerName) + .dom(PKI_GENERATE_ROOT.saved.issuerName) .doesNotExist('Issuer name not shown because it was not named'); - assert.dom(S.configuration.saved.issuerLink).exists('Issuer link exists'); - assert.dom(S.configuration.saved.keyLink).exists('Key link exists'); - assert.dom(S.configuration.saved.privateKey).exists('Copyable private key exists'); - assert.dom(S.configuration.saved.keyName).doesNotExist('Key name not shown because it was not named'); + assert.dom(PKI_GENERATE_ROOT.saved.issuerLink).exists('Issuer link exists'); + assert.dom(PKI_GENERATE_ROOT.saved.keyLink).exists('Key link exists'); + assert.dom(PKI_GENERATE_ROOT.saved.privateKey).exists('Copyable private key exists'); + assert.dom(PKI_GENERATE_ROOT.saved.keyName).doesNotExist('Key name not shown because it was not named'); assert.dom('[data-test-done]').exists('Done button exists'); // Check that linked issuer has correct common name - await click(S.configuration.saved.issuerLink); - assert.dom(S.issuerDetails.valueByName('Common name')).hasText(commonName); + await click(PKI_GENERATE_ROOT.saved.issuerLink); + assert.dom(GENERAL.infoRowValue('Common name')).hasText(commonName); }); }); @@ -249,14 +256,14 @@ module('Acceptance | pki action forms test', function (hooks) { test('happy path', async function (assert) { await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(S.emptyStateLink); - assert.dom(S.configuration.title).hasText('Configure PKI'); - await click(S.configuration.optionByKey('generate-csr')); - await fillIn(S.configuration.typeField, 'internal'); - await fillIn(S.configuration.inputByName('commonName'), 'my-common-name'); + await click(`${GENERAL.emptyStateActions} a`); + assert.dom(GENERAL.title).hasText('Configure PKI'); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-csr')); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-common-name'); await click('[data-test-save]'); - assert.dom(S.configuration.title).hasText('View Generated CSR'); - await assert.dom(S.configuration.csrDetails).exists('renders CSR details after save'); + assert.dom(GENERAL.title).hasText('View Generated CSR'); + await assert.dom(PKI_CONFIGURE_CREATE.csrDetails).exists('renders CSR details after save'); await click('[data-test-done]'); assert.strictEqual( currentURL(), @@ -267,19 +274,19 @@ module('Acceptance | pki action forms test', function (hooks) { test('type = exported', async function (assert) { await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(S.emptyStateLink); - await click(S.configuration.optionByKey('generate-csr')); - await fillIn(S.configuration.typeField, 'exported'); - await fillIn(S.configuration.inputByName('commonName'), 'my-common-name'); + await click(`${GENERAL.emptyStateActions} a`); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-csr')); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-common-name'); await click('[data-test-save]'); - await assert.dom(S.configuration.csrDetails).exists('renders CSR details after save'); - assert.dom(S.configuration.title).hasText('View Generated CSR'); + await assert.dom(PKI_CONFIGURE_CREATE.csrDetails).exists('renders CSR details after save'); + assert.dom(GENERAL.title).hasText('View Generated CSR'); assert .dom('[data-test-next-steps-csr]') .hasText( 'Next steps Copy the CSR below for a parent issuer to sign and then import the signed certificate back into this mount. The private_key is only available once. Make sure you copy and save it now.' ); - assert.dom(S.configuration.saved.privateKey).exists('Copyable private key exists'); + assert.dom(PKI_GENERATE_ROOT.saved.privateKey).exists('Copyable private key exists'); await click('[data-test-done]'); assert.strictEqual( currentURL(), diff --git a/ui/tests/acceptance/pki/pki-configuration-test.js b/ui/tests/acceptance/pki/pki-configuration-test.js index 3e9fae9507e9..2928f3dff761 100644 --- a/ui/tests/acceptance/pki/pki-configuration-test.js +++ b/ui/tests/acceptance/pki/pki-configuration-test.js @@ -14,9 +14,16 @@ import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS } from 'vault/tests/helpers/pki/workflow'; -import { issuerPemBundle } from 'vault/tests/helpers/pki/values'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +import { + PKI_CONFIGURE_CREATE, + PKI_DELETE_ALL_ISSUERS, + PKI_GENERATE_ROOT, + PKI_ISSUER_LIST, +} from 'vault/tests/helpers/pki/pki-selectors'; +const { issuerPemBundle } = CERTIFICATES; module('Acceptance | pki configuration test', function (hooks) { setupApplicationTest(hooks); @@ -43,68 +50,66 @@ module('Acceptance | pki configuration test', function (hooks) { test('it shows the delete all issuers modal', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/configuration`); - await click(SELECTORS.configuration.configureButton); + await click(PKI_CONFIGURE_CREATE.configureButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`); await settled(); - await click(SELECTORS.configuration.generateRootOption); - await fillIn(SELECTORS.configuration.typeField, 'exported'); - await fillIn(SELECTORS.configuration.generateRootCommonNameField, 'issuer-common-0'); - await fillIn(SELECTORS.configuration.generateRootIssuerNameField, 'issuer-0'); - await click(SELECTORS.configuration.generateRootSave); - await click(SELECTORS.configuration.doneButton); + await click(PKI_CONFIGURE_CREATE.generateRootOption); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await fillIn(GENERAL.inputByAttr('commonName'), 'issuer-common-0'); + await fillIn(GENERAL.inputByAttr('issuerName'), 'issuer-0'); + await click(GENERAL.saveButton); + await click(PKI_CONFIGURE_CREATE.doneButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); await settled(); - await click(SELECTORS.configTab); + await click(GENERAL.secretTab('Configuration')); await settled(); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`); - await click(SELECTORS.configuration.issuerLink); + await click(PKI_DELETE_ALL_ISSUERS.issuerLink); await settled(); - await waitFor(SELECTORS.configuration.deleteAllIssuerModal, { timeout: 5000 }); - assert.dom(SELECTORS.configuration.deleteAllIssuerModal).exists(); - await fillIn(SELECTORS.configuration.deleteAllIssuerInput, 'delete-all'); - await click(SELECTORS.configuration.deleteAllIssuerButton); + await waitFor(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal, { timeout: 5000 }); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).exists(); + await fillIn(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerInput, 'delete-all'); + await click(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerButton); await settled(); - await waitUntil(() => !find(SELECTORS.configuration.deleteAllIssuerModal)); + await waitUntil(() => !find(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal)); - assert.dom(SELECTORS.configuration.deleteAllIssuerModal).doesNotExist(); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).doesNotExist(); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`); }); test('it shows the correct empty state message if certificates exists after delete all issuers', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/configuration`); - await click(SELECTORS.configuration.configureButton); + await click(PKI_CONFIGURE_CREATE.configureButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`, 'goes to pki configure page' ); - await click(SELECTORS.configuration.generateRootOption); - await fillIn(SELECTORS.configuration.typeField, 'exported'); - await fillIn(SELECTORS.configuration.generateRootCommonNameField, 'issuer-common-0'); - await fillIn(SELECTORS.configuration.generateRootIssuerNameField, 'issuer-0'); - await click(SELECTORS.configuration.generateRootSave); - await click(SELECTORS.configuration.doneButton); + await click(PKI_CONFIGURE_CREATE.generateRootOption); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await fillIn(GENERAL.inputByAttr('commonName'), 'issuer-common-0'); + await fillIn(GENERAL.inputByAttr('issuerName'), 'issuer-0'); + await click(GENERAL.saveButton); + await click(PKI_CONFIGURE_CREATE.doneButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`, 'goes to overview page' ); - await click(SELECTORS.configTab); + await click(GENERAL.secretTab('Configuration')); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`, 'goes to configuration page' ); - await click(SELECTORS.configuration.issuerLink); - await waitFor(SELECTORS.configuration.deleteAllIssuerModal); - assert.dom(SELECTORS.configuration.deleteAllIssuerModal).exists(); - await fillIn(SELECTORS.configuration.deleteAllIssuerInput, 'delete-all'); - await click(SELECTORS.configuration.deleteAllIssuerButton); - await waitUntil(() => !find(SELECTORS.configuration.deleteAllIssuerModal)); - assert - .dom(SELECTORS.configuration.deleteAllIssuerModal) - .doesNotExist('delete all issuers modal closes'); + await click(PKI_DELETE_ALL_ISSUERS.issuerLink); + await waitFor(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).exists(); + await fillIn(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerInput, 'delete-all'); + await click(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerButton); + await waitUntil(() => !find(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal)); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).doesNotExist('delete all issuers modal closes'); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`, @@ -119,7 +124,7 @@ module('Acceptance | pki configuration test', function (hooks) { 'goes to overview page' ); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( "This PKI mount hasn't yet been configured with a certificate issuer. There are existing certificates. Use the CLI to perform any operations with them until an issuer is configured." ); @@ -127,25 +132,25 @@ module('Acceptance | pki configuration test', function (hooks) { await visit(`/vault/secrets/${this.mountPath}/pki/roles`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText("This PKI mount hasn't yet been configured with a certificate issuer."); await visit(`/vault/secrets/${this.mountPath}/pki/issuers`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText("This PKI mount hasn't yet been configured with a certificate issuer."); await visit(`/vault/secrets/${this.mountPath}/pki/keys`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText("This PKI mount hasn't yet been configured with a certificate issuer."); await visit(`/vault/secrets/${this.mountPath}/pki/certificates`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( "This PKI mount hasn't yet been configured with a certificate issuer. There are existing certificates. Use the CLI to perform any operations with them until an issuer is configured." ); @@ -155,14 +160,14 @@ module('Acceptance | pki configuration test', function (hooks) { await authPage.login(this.pkiAdminToken); // Configure PKI await visit(`/vault/secrets/${this.mountPath}/pki/configuration`); - await click(SELECTORS.configuration.configureButton); + await click(PKI_CONFIGURE_CREATE.configureButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(SELECTORS.configuration.generateRootOption); - await fillIn(SELECTORS.configuration.typeField, 'exported'); - await fillIn(SELECTORS.configuration.generateRootCommonNameField, 'issuer-common-0'); - await fillIn(SELECTORS.configuration.generateRootIssuerNameField, 'issuer-0'); - await click(SELECTORS.configuration.generateRootSave); - await click(SELECTORS.configuration.doneButton); + await click(PKI_CONFIGURE_CREATE.generateRootOption); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await fillIn(GENERAL.inputByAttr('commonName'), 'issuer-common-0'); + await fillIn(GENERAL.inputByAttr('issuerName'), 'issuer-0'); + await click(GENERAL.saveButton); + await click(PKI_CONFIGURE_CREATE.doneButton); // Create role and root CA" await runCmd([ `write ${this.mountPath}/roles/some-role \ @@ -173,23 +178,23 @@ module('Acceptance | pki configuration test', function (hooks) { ]); await runCmd([`write ${this.mountPath}/root/generate/internal common_name="Hashicorp Test"`]); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.configTab); + await click(GENERAL.secretTab('Configuration')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`); - await click(SELECTORS.configuration.issuerLink); - await waitFor(SELECTORS.configuration.deleteAllIssuerModal); - assert.dom(SELECTORS.configuration.deleteAllIssuerModal).exists(); - await fillIn(SELECTORS.configuration.deleteAllIssuerInput, 'delete-all'); - await click(SELECTORS.configuration.deleteAllIssuerButton); - await settled(); - await waitUntil(() => !find(SELECTORS.configuration.deleteAllIssuerModal)); - assert.dom(SELECTORS.configuration.deleteAllIssuerModal).doesNotExist(); + await click(PKI_DELETE_ALL_ISSUERS.issuerLink); + await waitFor(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).exists(); + await fillIn(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerInput, 'delete-all'); + await click(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerButton); + await settled(); + await waitUntil(() => !find(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal)); + assert.dom(PKI_DELETE_ALL_ISSUERS.deleteAllIssuerModal).doesNotExist(); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`); await settled(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); await settled(); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( "This PKI mount hasn't yet been configured with a certificate issuer. There are existing roles and certificates. Use the CLI to perform any operations with them until an issuer is configured." ); @@ -197,7 +202,7 @@ module('Acceptance | pki configuration test', function (hooks) { await visit(`/vault/secrets/${this.mountPath}/pki/roles`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( "This PKI mount hasn't yet been configured with a certificate issuer. There are existing roles. Use the CLI to perform any operations with them until an issuer is configured." ); @@ -205,19 +210,19 @@ module('Acceptance | pki configuration test', function (hooks) { await visit(`/vault/secrets/${this.mountPath}/pki/issuers`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText("This PKI mount hasn't yet been configured with a certificate issuer."); await visit(`/vault/secrets/${this.mountPath}/pki/keys`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText("This PKI mount hasn't yet been configured with a certificate issuer."); await visit(`/vault/secrets/${this.mountPath}/pki/certificates`); await settled(); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( "This PKI mount hasn't yet been configured with a certificate issuer. There are existing certificates. Use the CLI to perform any operations with them until an issuer is configured." ); @@ -228,24 +233,24 @@ module('Acceptance | pki configuration test', function (hooks) { assert.expect(4); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); - await click(SELECTORS.generateIssuerDropdown); - await click(SELECTORS.generateIssuerRoot); - await fillIn(SELECTORS.configuration.inputByName('type'), 'internal'); - await fillIn(SELECTORS.configuration.inputByName('commonName'), 'my-certificate'); - await click(SELECTORS.configuration.keyParamsGroupToggle); - await fillIn(SELECTORS.configuration.inputByName('keyType'), 'ed25519'); - await click(SELECTORS.configuration.generateRootSave); - - const issuerId = find(SELECTORS.configuration.saved.issuerLink).innerHTML; + await click(GENERAL.secretTab('Issuers')); + await click(PKI_ISSUER_LIST.generateIssuerDropdown); + await click(PKI_ISSUER_LIST.generateIssuerRoot); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-certificate'); + await click(PKI_GENERATE_ROOT.keyParamsGroupToggle); + await fillIn(GENERAL.inputByAttr('keyType'), 'ed25519'); + await click(GENERAL.saveButton); + + const issuerId = find(PKI_GENERATE_ROOT.saved.issuerLink).innerHTML; await visit(`/vault/secrets/${this.mountPath}/pki/issuers`); - assert.dom(SELECTORS.issuerListItem(issuerId)).exists(); + assert.dom(PKI_ISSUER_LIST.issuerListItem(issuerId)).exists(); assert .dom('[data-test-common-name="0"]') .hasText('my-certificate', 'parses certificate metadata in the list view'); - await click(SELECTORS.issuerListItem(issuerId)); + await click(PKI_ISSUER_LIST.issuerListItem(issuerId)); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/details`); - assert.dom(SELECTORS.configuration.saved.commonName).exists('renders issuer details'); + assert.dom(PKI_GENERATE_ROOT.saved.commonName).exists('renders issuer details'); }); }); }); diff --git a/ui/tests/acceptance/pki/pki-cross-sign-test.js b/ui/tests/acceptance/pki/pki-cross-sign-test.js index b3fddb6f0b54..bd9778427358 100644 --- a/ui/tests/acceptance/pki/pki-cross-sign-test.js +++ b/ui/tests/acceptance/pki/pki-cross-sign-test.js @@ -11,8 +11,14 @@ import { v4 as uuidv4 } from 'uuid'; import authPage from 'vault/tests/pages/auth'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-issuer-cross-sign'; import { verifyCertificates } from 'vault/utils/parse-pki-cert'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { + PKI_CONFIGURE_CREATE, + PKI_CROSS_SIGN, + PKI_ISSUER_DETAILS, +} from 'vault/tests/helpers/pki/pki-selectors'; + module('Acceptance | pki/pki cross sign', function (hooks) { setupApplicationTest(hooks); @@ -43,48 +49,48 @@ module('Acceptance | pki/pki cross sign', function (hooks) { test('it cross-signs an issuer', async function (assert) { // configure parent and intermediate mounts to make them cross-signable await visit(`/vault/secrets/${this.intMountPath}/pki/configuration/create`); - await click(SELECTORS.configure.optionByKey('generate-csr')); - await fillIn(SELECTORS.inputByName('type'), 'internal'); - await fillIn(SELECTORS.inputByName('commonName'), 'Short-Lived Int R1'); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-csr')); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'Short-Lived Int R1'); await click('[data-test-save]'); - const csr = find(SELECTORS.copyButton('CSR')).getAttribute('data-test-copy-button'); + const csr = find(PKI_CROSS_SIGN.copyButton('CSR')).getAttribute('data-test-copy-button'); await visit(`vault/secrets/${this.parentMountPath}/pki/issuers/${this.oldParentIssuerName}/sign`); - await fillIn(SELECTORS.inputByName('csr'), csr); - await fillIn(SELECTORS.inputByName('format'), 'pem_bundle'); + await fillIn(GENERAL.inputByAttr('csr'), csr); + await fillIn(GENERAL.inputByAttr('format'), 'pem_bundle'); await click('[data-test-pki-sign-intermediate-save]'); - const pemBundle = find(SELECTORS.copyButton('CA Chain')) + const pemBundle = find(PKI_CROSS_SIGN.copyButton('CA Chain')) .getAttribute('data-test-copy-button') .replace(/,/, '\n'); await visit(`vault/secrets/${this.intMountPath}/pki/configuration/create`); - await click(SELECTORS.configure.optionByKey('import')); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', pemBundle); - await click(SELECTORS.configure.importSubmit); + await click(PKI_CONFIGURE_CREATE.importSubmit); await visit(`vault/secrets/${this.intMountPath}/pki/issuers`); await click('[data-test-is-default]'); // name default issuer of intermediate - const oldIntIssuerId = find(SELECTORS.rowValue('Issuer ID')).innerText; - const oldIntCert = find(SELECTORS.copyButton('Certificate')).getAttribute('data-test-copy-button'); - await click(SELECTORS.details.configure); - await fillIn(SELECTORS.inputByName('issuerName'), this.intIssuerName); + const oldIntIssuerId = find(PKI_CROSS_SIGN.rowValue('Issuer ID')).innerText; + const oldIntCert = find(PKI_CROSS_SIGN.copyButton('Certificate')).getAttribute('data-test-copy-button'); + await click(PKI_ISSUER_DETAILS.configure); + await fillIn(GENERAL.inputByAttr('issuerName'), this.intIssuerName); await click('[data-test-save]'); // perform cross-sign await visit(`vault/secrets/${this.parentMountPath}/pki/issuers/${this.parentIssuerName}/cross-sign`); - await fillIn(SELECTORS.objectListInput('intermediateMount'), this.intMountPath); - await fillIn(SELECTORS.objectListInput('intermediateIssuer'), this.intIssuerName); - await fillIn(SELECTORS.objectListInput('newCrossSignedIssuer'), this.newlySignedIssuer); - await click(SELECTORS.submitButton); + await fillIn(PKI_CROSS_SIGN.objectListInput('intermediateMount'), this.intMountPath); + await fillIn(PKI_CROSS_SIGN.objectListInput('intermediateIssuer'), this.intIssuerName); + await fillIn(PKI_CROSS_SIGN.objectListInput('newCrossSignedIssuer'), this.newlySignedIssuer); + await click(GENERAL.saveButton); assert - .dom(`${SELECTORS.signedIssuerCol('intermediateMount')} a`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol('intermediateMount')} a`) .hasAttribute('href', `/ui/vault/secrets/${this.intMountPath}/pki/overview`); assert - .dom(`${SELECTORS.signedIssuerCol('intermediateIssuer')} a`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol('intermediateIssuer')} a`) .hasAttribute('href', `/ui/vault/secrets/${this.intMountPath}/pki/issuers/${oldIntIssuerId}/details`); // get certificate data of newly signed issuer - await click(`${SELECTORS.signedIssuerCol('newCrossSignedIssuer')} a`); - const newIntCert = find(SELECTORS.copyButton('Certificate')).getAttribute('data-test-copy-button'); + await click(`${PKI_CROSS_SIGN.signedIssuerCol('newCrossSignedIssuer')} a`); + const newIntCert = find(PKI_CROSS_SIGN.copyButton('Certificate')).getAttribute('data-test-copy-button'); // verify cross-sign was accurate by creating a role to issue a leaf certificate const myRole = 'some-role'; @@ -95,10 +101,10 @@ module('Acceptance | pki/pki cross sign', function (hooks) { max_ttl="720h"`, ]); await visit(`vault/secrets/${this.intMountPath}/pki/roles/${myRole}/generate`); - await fillIn(SELECTORS.inputByName('commonName'), 'my-leaf'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-leaf'); await fillIn('[data-test-ttl-value="TTL"]', '3600'); - await click('[data-test-pki-generate-button]'); - const myLeafCert = find(SELECTORS.copyButton('Certificate')).getAttribute('data-test-copy-button'); + await click(GENERAL.saveButton); + const myLeafCert = find(PKI_CROSS_SIGN.copyButton('Certificate')).getAttribute('data-test-copy-button'); // see comments in utils/parse-pki-cert.js for step-by-step explanation of of verifyCertificates method assert.true( diff --git a/ui/tests/acceptance/pki/pki-engine-route-cleanup-test.js b/ui/tests/acceptance/pki/pki-engine-route-cleanup-test.js index d783090ac143..a81cd8b5d5d9 100644 --- a/ui/tests/acceptance/pki/pki-engine-route-cleanup-test.js +++ b/ui/tests/acceptance/pki/pki-engine-route-cleanup-test.js @@ -12,10 +12,19 @@ import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { click, currentURL, fillIn, visit } from '@ember/test-helpers'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS } from 'vault/tests/helpers/pki/workflow'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { + PKI_CONFIGURE_CREATE, + PKI_ISSUER_DETAILS, + PKI_ISSUER_LIST, + PKI_KEYS, + PKI_ROLE_DETAILS, +} from 'vault/tests/helpers/pki/pki-selectors'; +const OVERVIEW_BREADCRUMB = '[data-test-breadcrumbs] li:nth-of-type(2) > a'; /** - * This test module should test that dirty route models are cleaned up when the user leaves the page + * This test module should test that dirty route models are cleaned up when + * the user leaves the page via cancel or breadcrumb navigation */ module('Acceptance | pki engine route cleanup test', function (hooks) { setupApplicationTest(hooks); @@ -42,7 +51,7 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let configs, urls, config; await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.emptyStateLink); + await click(`${GENERAL.emptyStateActions} a`); configs = this.store.peekAll('pki/action'); urls = this.store.peekRecord('pki/config/urls', this.mountPath); config = configs.at(0); @@ -51,13 +60,13 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.true(config.hasDirtyAttributes, 'Config model is dirty'); // Cancel button rolls it back - await click(SELECTORS.configuration.cancelButton); + await click(GENERAL.cancelButton); configs = this.store.peekAll('pki/action'); urls = this.store.peekRecord('pki/config/urls', this.mountPath); assert.strictEqual(configs.length, 0, 'config model is rolled back on cancel'); assert.strictEqual(urls.id, this.mountPath, 'Urls still exists on exit'); - await click(SELECTORS.emptyStateLink); + await click(`${GENERAL.emptyStateActions} a`); configs = this.store.peekAll('pki/action'); urls = this.store.peekRecord('pki/config/urls', this.mountPath); config = configs.at(0); @@ -66,7 +75,7 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.true(config.hasDirtyAttributes, 'Config model is dirty'); // Exit page via link rolls it back - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); configs = this.store.peekAll('pki/action'); urls = this.store.peekRecord('pki/config/urls', this.mountPath); assert.strictEqual(configs.length, 0, 'config model is rolled back on cancel'); @@ -79,11 +88,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { await authPage.login(); // Configure PKI await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.emptyStateLink); - await click(SELECTORS.configuration.optionByKey('generate-root')); - await fillIn(SELECTORS.configuration.typeField, 'internal'); - await fillIn(SELECTORS.configuration.inputByName('commonName'), 'my-root-cert'); - await click(SELECTORS.configuration.generateRootSave); + await click(`${GENERAL.emptyStateActions} a`); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-root-cert'); + await click(GENERAL.saveButton); await logout.visit(); }); @@ -92,15 +101,15 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { await authPage.login(); // Create PKI await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.rolesTab); + await click(GENERAL.secretTab('Roles')); roles = this.store.peekAll('pki/role'); assert.strictEqual(roles.length, 0, 'No roles exist yet'); - await click(SELECTORS.createRoleLink); + await click(PKI_ROLE_DETAILS.createRoleLink); roles = this.store.peekAll('pki/role'); const role = roles.at(0); assert.strictEqual(roles.length, 1, 'New role exists'); assert.true(role.isNew, 'Role is new model'); - await click(SELECTORS.roleForm.roleCancelButton); + await click(GENERAL.cancelButton); roles = this.store.peekAll('pki/role'); assert.strictEqual(roles.length, 0, 'Role is removed from store'); }); @@ -109,15 +118,15 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { await authPage.login(); // Create PKI await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.rolesTab); + await click(GENERAL.secretTab('Roles')); roles = this.store.peekAll('pki/role'); assert.strictEqual(roles.length, 0, 'No roles exist yet'); - await click(SELECTORS.createRoleLink); + await click(PKI_ROLE_DETAILS.createRoleLink); roles = this.store.peekAll('pki/role'); const role = roles.at(0); assert.strictEqual(roles.length, 1, 'New role exists'); assert.true(role.isNew, 'Role is new model'); - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); roles = this.store.peekAll('pki/role'); assert.strictEqual(roles.length, 0, 'Role is removed from store'); }); @@ -127,38 +136,38 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { await authPage.login(); // Create PKI await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.rolesTab); + await click(GENERAL.secretTab('Roles')); roles = this.store.peekAll('pki/role'); assert.strictEqual(roles.length, 0, 'No roles exist yet'); - await click(SELECTORS.createRoleLink); - await fillIn(SELECTORS.roleForm.roleName, roleId); - await click(SELECTORS.roleForm.roleCreateButton); - assert.dom('[data-test-value-div="Role name"]').hasText(roleId, 'Shows correct role after create'); + await click(PKI_ROLE_DETAILS.createRoleLink); + await fillIn(GENERAL.inputByAttr('name'), roleId); + await click(GENERAL.saveButton); + assert.dom(GENERAL.infoRowValue('Role name')).hasText(roleId, 'Shows correct role after create'); roles = this.store.peekAll('pki/role'); role = roles.at(0); assert.strictEqual(roles.length, 1, 'Role is created'); assert.false(role.hasDirtyAttributes, 'Role no longer has dirty attributes'); // Edit role - await click(SELECTORS.editRoleLink); - await click(SELECTORS.roleForm.issuerRefToggle); - await fillIn(SELECTORS.roleForm.issuerRefSelect, 'foobar'); + await click(PKI_ROLE_DETAILS.editRoleLink); + await click(GENERAL.ttl.toggle('issuerRef-toggle')); + await fillIn(GENERAL.selectByAttr('issuerRef'), 'foobar'); role = this.store.peekRecord('pki/role', roleId); assert.true(role.hasDirtyAttributes, 'Role has dirty attrs'); // Exit page via cancel button - await click(SELECTORS.roleForm.roleCancelButton); + await click(GENERAL.cancelButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/${roleId}/details`); role = this.store.peekRecord('pki/role', roleId); assert.false(role.hasDirtyAttributes, 'Role dirty attrs have been rolled back'); // Edit again - await click(SELECTORS.editRoleLink); - await click(SELECTORS.roleForm.issuerRefToggle); - await fillIn(SELECTORS.roleForm.issuerRefSelect, 'foobar2'); + await click(PKI_ROLE_DETAILS.editRoleLink); + await click(GENERAL.ttl.toggle('issuerRef-toggle')); + await fillIn(GENERAL.selectByAttr('issuerRef'), 'foobar2'); role = this.store.peekRecord('pki/role', roleId); assert.true(role.hasDirtyAttributes, 'Role has dirty attrs'); // Exit page via breadcrumbs - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); role = this.store.peekRecord('pki/role', roleId); assert.false(role.hasDirtyAttributes, 'Role dirty attrs have been rolled back'); }); @@ -169,10 +178,10 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let issuers; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); issuers = this.store.peekAll('pki/issuer'); assert.strictEqual(issuers.length, 0, 'No issuer models exist yet'); - await click(SELECTORS.importIssuerLink); + await click(PKI_ISSUER_LIST.importIssuerLink); issuers = this.store.peekAll('pki/action'); assert.strictEqual(issuers.length, 1, 'Action model created'); const issuer = issuers.at(0); @@ -188,17 +197,17 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let issuers; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); issuers = this.store.peekAll('pki/issuer'); assert.strictEqual(issuers.length, 0, 'No issuers exist yet'); - await click(SELECTORS.importIssuerLink); + await click(PKI_ISSUER_LIST.importIssuerLink); issuers = this.store.peekAll('pki/action'); assert.strictEqual(issuers.length, 1, 'Action model created'); const issuer = issuers.at(0); assert.true(issuer.hasDirtyAttributes, 'Action model has dirty attrs'); assert.true(issuer.isNew, 'Action model is new'); // Exit - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); issuers = this.store.peekAll('pki/action'); assert.strictEqual(issuers.length, 0, 'Issuer is removed from store'); @@ -207,11 +216,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let actions; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'No actions exist yet'); - await click(SELECTORS.generateIssuerDropdown); - await click(SELECTORS.generateIssuerRoot); + await click(PKI_ISSUER_LIST.generateIssuerDropdown); + await click(PKI_ISSUER_LIST.generateIssuerRoot); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 1, 'Action model for generate-root created'); const action = actions.at(0); @@ -219,7 +228,7 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.true(action.isNew, 'Action is new'); assert.strictEqual(action.actionType, 'generate-root', 'Action type is correct'); // Exit - await click(SELECTORS.configuration.generateRootCancel); + await click(GENERAL.cancelButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers`); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'Action is removed from store'); @@ -228,11 +237,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let actions; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'No actions exist yet'); - await click(SELECTORS.generateIssuerDropdown); - await click(SELECTORS.generateIssuerRoot); + await click(PKI_ISSUER_LIST.generateIssuerDropdown); + await click(PKI_ISSUER_LIST.generateIssuerRoot); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 1, 'Action model for generate-root created'); const action = actions.at(0); @@ -240,7 +249,7 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.true(action.isNew, 'Action is new'); assert.strictEqual(action.actionType, 'generate-root'); // Exit - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'Action is removed from store'); @@ -249,11 +258,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let actions; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'No actions exist yet'); - await await click(SELECTORS.generateIssuerDropdown); - await click(SELECTORS.generateIssuerIntermediate); + await await click(PKI_ISSUER_LIST.generateIssuerDropdown); + await click(PKI_ISSUER_LIST.generateIssuerIntermediate); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 1, 'Action model for generate-csr created'); const action = actions.at(0); @@ -270,11 +279,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let actions; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'No actions exist yet'); - await click(SELECTORS.generateIssuerDropdown); - await click(SELECTORS.generateIssuerIntermediate); + await click(PKI_ISSUER_LIST.generateIssuerDropdown); + await click(PKI_ISSUER_LIST.generateIssuerIntermediate); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 1, 'Action model for generate-csr created'); const action = actions.at(0); @@ -282,7 +291,7 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.true(action.isNew, 'Action is new'); assert.strictEqual(action.actionType, 'generate-csr'); // Exit - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); actions = this.store.peekAll('pki/action'); assert.strictEqual(actions.length, 0, 'Action is removed from store'); @@ -291,11 +300,11 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let issuers, issuer; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.emptyStateLink); - await click(SELECTORS.configuration.optionByKey('generate-root')); - await fillIn(SELECTORS.configuration.typeField, 'internal'); - await fillIn(SELECTORS.configuration.inputByName('commonName'), 'my-root-cert'); - await click(SELECTORS.configuration.generateRootSave); + await click(`${GENERAL.emptyStateActions} a`); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-root-cert'); + await click(GENERAL.saveButton); // Go to list view so we fetch all the issuers await visit(`/vault/secrets/${this.mountPath}/pki/issuers`); @@ -303,12 +312,12 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { const issuerId = issuers.at(0).id; assert.strictEqual(issuers.length, 1, 'Issuer exists on model in list'); await visit(`/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/details`); - await click(SELECTORS.issuerDetails.configure); + await click(PKI_ISSUER_DETAILS.configure); issuer = this.store.peekRecord('pki/issuer', issuerId); assert.false(issuer.hasDirtyAttributes, 'Model not dirty'); await fillIn('[data-test-input="issuerName"]', 'foobar'); assert.true(issuer.hasDirtyAttributes, 'Model is dirty'); - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); issuers = this.store.peekAll('pki/issuer'); assert.strictEqual(issuers.length, 1, 'Issuer exists on model in overview'); issuer = this.store.peekRecord('pki/issuer', issuerId); @@ -321,42 +330,42 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { await authPage.login(); // Configure PKI -- key creation not allowed unless configured await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.emptyStateLink); - await click(SELECTORS.configuration.optionByKey('generate-root')); - await fillIn(SELECTORS.configuration.typeField, 'internal'); - await fillIn(SELECTORS.configuration.inputByName('commonName'), 'my-root-cert'); - await click(SELECTORS.configuration.generateRootSave); + await click(`${GENERAL.emptyStateActions} a`); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'my-root-cert'); + await click(GENERAL.saveButton); await logout.visit(); }); test('create key exit', async function (assert) { let keys, key; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); keys = this.store.peekAll('pki/key'); const configKeyId = keys.at(0).id; assert.strictEqual(keys.length, 1, 'One key exists from config'); // Create key - await click(SELECTORS.keyPages.generateKey); + await click(PKI_KEYS.generateKey); keys = this.store.peekAll('pki/key'); key = keys.at(1); assert.strictEqual(keys.length, 2, 'New key exists'); assert.true(key.isNew, 'Role is new model'); // Exit - await click(SELECTORS.keyForm.keyCancelButton); + await click(GENERAL.cancelButton); keys = this.store.peekAll('pki/key'); assert.strictEqual(keys.length, 1, 'Second key is removed from store'); assert.strictEqual(keys.at(0).id, configKeyId); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys`, 'url is correct'); // Create again - await click(SELECTORS.keyPages.generateKey); + await click(PKI_KEYS.generateKey); assert.strictEqual(keys.length, 2, 'New key exists'); keys = this.store.peekAll('pki/key'); key = keys.at(1); assert.true(key.isNew, 'Key is new model'); // Exit - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`, 'url is correct'); keys = this.store.peekAll('pki/key'); assert.strictEqual(keys.length, 1, 'Key is removed from store'); @@ -365,19 +374,19 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { let keys, key; await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); keys = this.store.peekAll('pki/key'); assert.strictEqual(keys.length, 1, 'One key from config exists'); assert.dom('.list-item-row').exists({ count: 1 }, 'single row for key'); await click('.list-item-row'); // Edit - await click(SELECTORS.keyPages.keyEditLink); - await fillIn(SELECTORS.keyForm.keyNameInput, 'foobar'); + await click(PKI_KEYS.keyEditLink); + await fillIn(GENERAL.inputByAttr('keyName'), 'foobar'); keys = this.store.peekAll('pki/key'); key = keys.at(0); assert.true(key.hasDirtyAttributes, 'Key model is dirty'); // Exit - await click(SELECTORS.keyForm.keyCancelButton); + await click(GENERAL.cancelButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${key.id}/details`, @@ -388,14 +397,14 @@ module('Acceptance | pki engine route cleanup test', function (hooks) { assert.false(key.hasDirtyAttributes, 'Key dirty attrs have been rolled back'); // Edit again - await click(SELECTORS.keyPages.keyEditLink); - await fillIn(SELECTORS.keyForm.keyNameInput, 'foobar'); + await click(PKI_KEYS.keyEditLink); + await fillIn(GENERAL.inputByAttr('keyName'), 'foobar'); keys = this.store.peekAll('pki/key'); key = keys.at(0); assert.true(key.hasDirtyAttributes, 'Key model is dirty'); // Exit via breadcrumb - await click(SELECTORS.overviewBreadcrumb); + await click(OVERVIEW_BREADCRUMB); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`, 'url is correct'); keys = this.store.peekAll('pki/key'); assert.strictEqual(keys.length, 1, 'Key list has 1'); diff --git a/ui/tests/acceptance/pki/pki-engine-workflow-test.js b/ui/tests/acceptance/pki/pki-engine-workflow-test.js index 395bf41c19a4..6852ce18589e 100644 --- a/ui/tests/acceptance/pki/pki-engine-workflow-test.js +++ b/ui/tests/acceptance/pki/pki-engine-workflow-test.js @@ -11,14 +11,23 @@ import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { click, currentURL, fillIn, find, isSettled, visit } from '@ember/test-helpers'; -import { SELECTORS } from 'vault/tests/helpers/pki/workflow'; -import { adminPolicy, readerPolicy, updatePolicy } from 'vault/tests/helpers/policy-generator/pki'; -import { clearRecords } from 'vault/tests/helpers/pki/pki-run-commands'; +import { adminPolicy, readerPolicy, updatePolicy } from 'vault/tests/helpers/pki/policy-generator'; import { runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/commands'; -import { unsupportedPem } from 'vault/tests/helpers/pki/values'; import { create } from 'ember-cli-page-object'; import flashMessage from 'vault/tests/pages/components/flash-message'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CERTIFICATES, clearRecords } from 'vault/tests/helpers/pki/pki-helpers'; +import { + PKI_CONFIGURE_CREATE, + PKI_CONFIG_EDIT, + PKI_ISSUER_DETAILS, + PKI_ISSUER_LIST, + PKI_KEYS, + PKI_ROLE_DETAILS, +} from 'vault/tests/helpers/pki/pki-selectors'; + const flash = create(flashMessage); +const { unsupportedPem } = CERTIFICATES; /** * This test module should test the PKI workflow, including: * - link between pages and confirm that the url is as expected @@ -59,14 +68,14 @@ module('Acceptance | pki workflow', function (hooks) { const assertEmptyState = (assert, resource) => { assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/${resource}`); assert - .dom(SELECTORS.emptyStateTitle) + .dom(GENERAL.emptyStateTitle) .hasText( 'PKI not configured', `${resource} index renders correct empty state title when PKI not configured` ); - assert.dom(SELECTORS.emptyStateLink).hasText('Configure PKI'); + assert.dom(GENERAL.emptyStateActions).hasText('Configure PKI'); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( `This PKI mount hasn't yet been configured with a certificate issuer.`, `${resource} index empty state message correct when PKI not configured` @@ -76,17 +85,17 @@ module('Acceptance | pki workflow', function (hooks) { await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.rolesTab); + await click(GENERAL.secretTab('Roles')); assertEmptyState(assert, 'roles'); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); assertEmptyState(assert, 'issuers'); - await click(SELECTORS.certsTab); + await click(GENERAL.secretTab('Certificates')); assertEmptyState(assert, 'certificates'); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); assertEmptyState(assert, 'keys'); - await click(SELECTORS.tidyTab); + await click(GENERAL.secretTab('Tidy')); assertEmptyState(assert, 'tidy'); }); }); @@ -121,32 +130,32 @@ module('Acceptance | pki workflow', function (hooks) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesTab).exists('Roles tab is present'); - await click(SELECTORS.rolesTab); - assert.dom(SELECTORS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); + assert.dom(GENERAL.secretTab('Roles')).exists('Roles tab is present'); + await click(GENERAL.secretTab('Roles')); + assert.dom(PKI_ROLE_DETAILS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles`); assert.dom('.linked-block').exists({ count: 1 }, 'One role is in list'); await click('.linked-block'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.generateCertLink).exists('Generate cert link is shown'); - await click(SELECTORS.generateCertLink); + assert.dom(PKI_ROLE_DETAILS.generateCertLink).exists('Generate cert link is shown'); + await click(PKI_ROLE_DETAILS.generateCertLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/generate`); // Go back to details and test all the links await visit(`/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.signCertLink).exists('Sign cert link is shown'); - await click(SELECTORS.signCertLink); + assert.dom(PKI_ROLE_DETAILS.signCertLink).exists('Sign cert link is shown'); + await click(PKI_ROLE_DETAILS.signCertLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/sign`); await visit(`/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.editRoleLink).exists('Edit link is shown'); - await click(SELECTORS.editRoleLink); + assert.dom(PKI_ROLE_DETAILS.editRoleLink).exists('Edit link is shown'); + await click(PKI_ROLE_DETAILS.editRoleLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/edit`); await visit(`/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.deleteRoleButton).exists('Delete role button is shown'); - await click(SELECTORS.deleteRoleButton); + assert.dom(PKI_ROLE_DETAILS.deleteRoleButton).exists('Delete role button is shown'); + await click(PKI_ROLE_DETAILS.deleteRoleButton); await click('[data-test-confirm-button]'); assert.strictEqual( currentURL(), @@ -158,52 +167,52 @@ module('Acceptance | pki workflow', function (hooks) { test('it does not show toolbar items the user does not have permission to see', async function (assert) { await authPage.login(this.pkiRoleReader); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesTab).exists('Roles tab is present'); - await click(SELECTORS.rolesTab); - assert.dom(SELECTORS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); + assert.dom(GENERAL.secretTab('Roles')).exists('Roles tab is present'); + await click(GENERAL.secretTab('Roles')); + assert.dom(PKI_ROLE_DETAILS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles`); assert.dom('.linked-block').exists({ count: 1 }, 'One role is in list'); await click('.linked-block'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.deleteRoleButton).doesNotExist('Delete role button is not shown'); - assert.dom(SELECTORS.generateCertLink).doesNotExist('Generate cert link is not shown'); - assert.dom(SELECTORS.signCertLink).doesNotExist('Sign cert link is not shown'); - assert.dom(SELECTORS.editRoleLink).doesNotExist('Edit link is not shown'); + assert.dom(PKI_ROLE_DETAILS.deleteRoleButton).doesNotExist('Delete role button is not shown'); + assert.dom(PKI_ROLE_DETAILS.generateCertLink).doesNotExist('Generate cert link is not shown'); + assert.dom(PKI_ROLE_DETAILS.signCertLink).doesNotExist('Sign cert link is not shown'); + assert.dom(PKI_ROLE_DETAILS.editRoleLink).doesNotExist('Edit link is not shown'); }); test('it shows correct toolbar items for the user policy', async function (assert) { await authPage.login(this.pkiRoleEditor); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesTab).exists('Roles tab is present'); - await click(SELECTORS.rolesTab); - assert.dom(SELECTORS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); + assert.dom(GENERAL.secretTab('Roles')).exists('Roles tab is present'); + await click(GENERAL.secretTab('Roles')); + assert.dom(PKI_ROLE_DETAILS.createRoleLink).exists({ count: 1 }, 'Create role link is rendered'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles`); assert.dom('.linked-block').exists({ count: 1 }, 'One role is in list'); await click('.linked-block'); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/details`); - assert.dom(SELECTORS.deleteRoleButton).doesNotExist('Delete role button is not shown'); - assert.dom(SELECTORS.generateCertLink).exists('Generate cert link is shown'); - assert.dom(SELECTORS.signCertLink).exists('Sign cert link is shown'); - assert.dom(SELECTORS.editRoleLink).exists('Edit link is shown'); - await click(SELECTORS.editRoleLink); + assert.dom(PKI_ROLE_DETAILS.deleteRoleButton).doesNotExist('Delete role button is not shown'); + assert.dom(PKI_ROLE_DETAILS.generateCertLink).exists('Generate cert link is shown'); + assert.dom(PKI_ROLE_DETAILS.signCertLink).exists('Sign cert link is shown'); + assert.dom(PKI_ROLE_DETAILS.editRoleLink).exists('Edit link is shown'); + await click(PKI_ROLE_DETAILS.editRoleLink); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/edit`, 'Links to edit view' ); - await click(SELECTORS.roleForm.roleCancelButton); + await click(GENERAL.cancelButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/details`, 'Cancel from edit goes to details' ); - await click(SELECTORS.generateCertLink); + await click(PKI_ROLE_DETAILS.generateCertLink); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/generate`, 'Generate cert button goes to generate page' ); - await click(SELECTORS.generateCertForm.cancelButton); + await click(GENERAL.cancelButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/some-role/details`, @@ -216,25 +225,25 @@ module('Acceptance | pki workflow', function (hooks) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.emptyState).doesNotExist(); - await click(SELECTORS.rolesTab); + assert.dom(GENERAL.emptyStateTitle).doesNotExist(); + await click(GENERAL.secretTab('Roles')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles`); - await click(SELECTORS.createRoleLink); + await click(PKI_ROLE_DETAILS.createRoleLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/create`); - assert.dom(SELECTORS.breadcrumbContainer).exists({ count: 1 }, 'breadcrumbs are rendered'); - assert.dom(SELECTORS.breadcrumbs).exists({ count: 4 }, 'Shows 4 breadcrumbs'); - assert.dom(SELECTORS.pageTitle).hasText('Create a PKI Role'); + assert.dom(GENERAL.breadcrumbs).exists({ count: 1 }, 'breadcrumbs are rendered'); + assert.dom(GENERAL.breadcrumb).exists({ count: 4 }, 'Shows 4 breadcrumbs'); + assert.dom(GENERAL.title).hasText('Create a PKI Role'); - await fillIn(SELECTORS.roleForm.roleName, roleName); - await click(SELECTORS.roleForm.roleCreateButton); + await fillIn(GENERAL.inputByAttr('name'), roleName); + await click(GENERAL.saveButton); assert.strictEqual( flash.latestMessage, `Successfully created the role ${roleName}.`, 'renders success flash upon creation' ); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles/${roleName}/details`); - assert.dom(SELECTORS.breadcrumbs).exists({ count: 4 }, 'Shows 4 breadcrumbs'); - assert.dom(SELECTORS.pageTitle).hasText(`PKI Role ${roleName}`); + assert.dom(GENERAL.breadcrumb).exists({ count: 4 }, 'Shows 4 breadcrumbs'); + assert.dom(GENERAL.title).hasText(`PKI Role ${roleName}`); }); }); @@ -257,61 +266,61 @@ module('Acceptance | pki workflow', function (hooks) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); // index page assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys`); assert - .dom(SELECTORS.keyPages.importKey) + .dom(PKI_KEYS.importKey) .hasAttribute( 'href', `/ui/vault/secrets/${this.mountPath}/pki/keys/import`, 'import link renders with correct url' ); - let keyId = find(SELECTORS.keyPages.keyId).innerText; + let keyId = find(PKI_KEYS.keyId).innerText; assert.dom('.linked-block').exists({ count: 1 }, 'One key is in list'); await click('.linked-block'); // details page assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`); - assert.dom(SELECTORS.keyPages.downloadButton).doesNotExist('does not download button for private key'); + assert.dom(PKI_KEYS.downloadButton).doesNotExist('does not download button for private key'); // edit page - await click(SELECTORS.keyPages.keyEditLink); + await click(PKI_KEYS.keyEditLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/edit`); - await click(SELECTORS.keyForm.keyCancelButton); + await click(GENERAL.cancelButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`, 'navigates back to details on cancel' ); await visit(`/vault/secrets/${this.mountPath}/pki/keys/${keyId}/edit`); - await fillIn(SELECTORS.keyForm.keyNameInput, 'test-key'); - await click(SELECTORS.keyForm.keyCreateButton); + await fillIn(GENERAL.inputByAttr('keyName'), 'test-key'); + await click(GENERAL.saveButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`, 'navigates to details after save' ); - assert.dom(SELECTORS.keyPages.keyNameValue).hasText('test-key', 'updates key name'); + assert.dom(GENERAL.infoRowValue('Key name')).hasText('test-key', 'updates key name'); // key generate and delete navigation await visit(`/vault/secrets/${this.mountPath}/pki/keys`); - await click(SELECTORS.keyPages.generateKey); + await click(PKI_KEYS.generateKey); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/create`); - await fillIn(SELECTORS.keyForm.typeInput, 'exported'); - await fillIn(SELECTORS.keyForm.keyTypeInput, 'rsa'); - await click(SELECTORS.keyForm.keyCreateButton); - keyId = find(SELECTORS.keyPages.keyIdValue).innerText; + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + await fillIn(GENERAL.inputByAttr('keyType'), 'rsa'); + await click(GENERAL.saveButton); + keyId = find(GENERAL.infoRowValue('Key ID')).textContent?.trim(); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`); assert - .dom(SELECTORS.keyPages.nextStepsAlert) + .dom(PKI_KEYS.nextStepsAlert) .hasText( 'Next steps This private key material will only be available once. Copy or download it now.', 'renders banner to save private key' ); - assert.dom(SELECTORS.keyPages.downloadButton).exists('renders download button'); - await click(SELECTORS.keyPages.keyDeleteButton); - await click(SELECTORS.keyPages.confirmDelete); + assert.dom(PKI_KEYS.downloadButton).exists('renders download button'); + await click(PKI_KEYS.keyDeleteButton); + await click(GENERAL.confirmButton); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/keys`, @@ -322,41 +331,39 @@ module('Acceptance | pki workflow', function (hooks) { test('it hides correct actions for user with read policy', async function (assert) { await authPage.login(this.pkiKeyReader); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys`); await isSettled(); - assert.dom(SELECTORS.keyPages.importKey).doesNotExist(); - assert.dom(SELECTORS.keyPages.generateKey).doesNotExist(); + assert.dom(PKI_KEYS.importKey).doesNotExist(); + assert.dom(PKI_KEYS.generateKey).doesNotExist(); assert.dom('.linked-block').exists({ count: 1 }, 'One key is in list'); - const keyId = find(SELECTORS.keyPages.keyId).innerText; - await click(SELECTORS.keyPages.popupMenuTrigger); - assert.dom(SELECTORS.keyPages.popupMenuEdit).doesNotExist('popup menu edit link is not shown'); - await click(SELECTORS.keyPages.popupMenuDetails); + const keyId = find(PKI_KEYS.keyId).innerText; + await click(GENERAL.menuTrigger); + assert.dom(PKI_KEYS.popupMenuEdit).doesNotExist('popup menu edit link is not shown'); + await click(PKI_KEYS.popupMenuDetails); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`); - assert.dom(SELECTORS.keyPages.keyDeleteButton).doesNotExist('Delete key button is not shown'); - assert.dom(SELECTORS.keyPages.keyEditLink).doesNotExist('Edit key button does not render'); + assert.dom(PKI_KEYS.keyDeleteButton).doesNotExist('Delete key button is not shown'); + assert.dom(PKI_KEYS.keyEditLink).doesNotExist('Edit key button does not render'); }); test('it shows correct toolbar items for the user with update policy', async function (assert) { await authPage.login(this.pkiKeyEditor); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.keysTab); + await click(GENERAL.secretTab('Keys')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys`); await isSettled(); - assert.dom(SELECTORS.keyPages.importKey).exists('import action exists'); - assert.dom(SELECTORS.keyPages.generateKey).exists('generate action exists'); + assert.dom(PKI_KEYS.importKey).exists('import action exists'); + assert.dom(PKI_KEYS.generateKey).exists('generate action exists'); assert.dom('.linked-block').exists({ count: 1 }, 'One key is in list'); - const keyId = find(SELECTORS.keyPages.keyId).innerText; - await click(SELECTORS.keyPages.popupMenuTrigger); - assert - .dom(SELECTORS.keyPages.popupMenuEdit) - .doesNotHaveClass('disabled', 'popup menu edit link is not disabled'); + const keyId = find(PKI_KEYS.keyId).innerText; + await click(GENERAL.menuTrigger); + assert.dom(PKI_KEYS.popupMenuEdit).doesNotHaveClass('disabled', 'popup menu edit link is not disabled'); await click('.linked-block'); - assert.dom(SELECTORS.keyPages.keyDeleteButton).doesNotExist('Delete key button is not shown'); - await click(SELECTORS.keyPages.keyEditLink); + assert.dom(PKI_KEYS.keyDeleteButton).doesNotExist('Delete key button is not shown'); + await click(PKI_KEYS.keyEditLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/edit`); - assert.dom(SELECTORS.keyPages.title).hasText('Edit Key'); - await click(SELECTORS.keyForm.keyCancelButton); + assert.dom(GENERAL.title).hasText('Edit Key'); + await click(GENERAL.cancelButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/keys/${keyId}/details`); }); }); @@ -374,25 +381,23 @@ module('Acceptance | pki workflow', function (hooks) { clearRecords(this.store); }); test('lists the correct issuer metadata info', async function (assert) { - assert.expect(6); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.issuersTab).exists('Issuers tab is present'); - await click(SELECTORS.issuersTab); + assert.dom(GENERAL.secretTab('Issuers')).exists(); + await click(GENERAL.secretTab('Issuers')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers`); - assert.dom('.linked-block').exists({ count: 1 }, 'One issuer is in list'); + assert.dom('.linked-block').exists({ count: 1 }); assert.dom('[data-test-is-root-tag="0"]').hasText('root'); - assert.dom('[data-test-serial-number="0"]').exists({ count: 1 }, 'displays serial number tag'); - assert.dom('[data-test-common-name="0"]').exists({ count: 1 }, 'displays cert common name tag'); + assert.dom('[data-test-serial-number="0"]').exists({ count: 1 }); + assert.dom('[data-test-common-name="0"]').exists({ count: 1 }); }); test('lists the correct issuer metadata info when user has only read permission', async function (assert) { - assert.expect(2); await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); - await click(SELECTORS.issuerPopupMenu); - await click(SELECTORS.issuerPopupDetails); - const issuerId = find(SELECTORS.issuerDetails.valueByName('Issuer ID')).innerText; + await click(GENERAL.secretTab('Issuers')); + await click(GENERAL.menuTrigger); + await click(PKI_ISSUER_LIST.issuerPopupDetails); + const issuerId = find(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).innerText; const pki_issuer_denied_policy = ` path "${this.mountPath}/*" { capabilities = ["create", "read", "update", "delete", "list"] @@ -407,7 +412,7 @@ module('Acceptance | pki workflow', function (hooks) { await logout.visit(); await authPage.login(this.token); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); + await click(GENERAL.secretTab('Issuers')); assert.dom('[data-test-serial-number="0"]').exists({ count: 1 }, 'displays serial number tag'); assert.dom('[data-test-common-name="0"]').doesNotExist('does not display cert common name tag'); }); @@ -416,8 +421,8 @@ module('Acceptance | pki workflow', function (hooks) { assert.expect(13); await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.issuersTab).exists('Issuers tab is present'); - await click(SELECTORS.issuersTab); + assert.dom(GENERAL.secretTab('Issuers')).exists('Issuers tab is present'); + await click(GENERAL.secretTab('Issuers')); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers`); assert.dom('.linked-block').exists({ count: 1 }, 'One issuer is in list'); await click('.linked-block'); @@ -425,45 +430,45 @@ module('Acceptance | pki workflow', function (hooks) { currentURL().match(`/vault/secrets/${this.mountPath}/pki/issuers/.+/details`), `/vault/secrets/${this.mountPath}/pki/issuers/my-issuer/details` ); - assert.dom(SELECTORS.issuerDetails.title).hasText('View Issuer Certificate'); + assert.dom(GENERAL.title).hasText('View Issuer Certificate'); ['Certificate', 'CA Chain', 'Common name', 'Issuer name', 'Issuer ID', 'Default key ID'].forEach( (label) => { assert - .dom(`${SELECTORS.issuerDetails.defaultGroup} ${SELECTORS.issuerDetails.valueByName(label)}`) + .dom(`${PKI_ISSUER_DETAILS.defaultGroup} ${PKI_ISSUER_DETAILS.valueByName(label)}`) .exists({ count: 1 }, `${label} value rendered`); } ); assert - .dom(`${SELECTORS.issuerDetails.urlsGroup} ${SELECTORS.issuerDetails.row}`) + .dom(`${PKI_ISSUER_DETAILS.urlsGroup} ${PKI_ISSUER_DETAILS.row}`) .exists({ count: 3 }, 'Renders 3 info table items under URLs group'); - assert.dom(SELECTORS.issuerDetails.groupTitle).exists({ count: 1 }, 'only 1 group title rendered'); + assert.dom(PKI_ISSUER_DETAILS.groupTitle).exists({ count: 1 }, 'only 1 group title rendered'); }); test('toolbar links navigate to expected routes', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issuersTab); - await click(SELECTORS.issuerPopupMenu); - await click(SELECTORS.issuerPopupDetails); + await click(GENERAL.secretTab('Issuers')); + await click(GENERAL.menuTrigger); + await click(PKI_ISSUER_LIST.issuerPopupDetails); - const issuerId = find(SELECTORS.issuerDetails.valueByName('Issuer ID')).innerText; + const issuerId = find(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).innerText; assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/details`, 'it navigates to details route' ); assert - .dom(SELECTORS.issuerDetails.crossSign) + .dom(PKI_ISSUER_DETAILS.crossSign) .hasAttribute('href', `/ui/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/cross-sign`); assert - .dom(SELECTORS.issuerDetails.signIntermediate) + .dom(PKI_ISSUER_DETAILS.signIntermediate) .hasAttribute('href', `/ui/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/sign`); assert - .dom(SELECTORS.issuerDetails.configure) + .dom(PKI_ISSUER_DETAILS.configure) .hasAttribute('href', `/ui/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/edit`); - await click(SELECTORS.issuerDetails.rotateRoot); - assert.dom(SELECTORS.issuerDetails.rotateModal).exists('rotate root modal opens'); - await click(SELECTORS.issuerDetails.rotateModalGenerate); + await click(PKI_ISSUER_DETAILS.rotateRoot); + assert.dom(PKI_ISSUER_DETAILS.rotateModal).exists('rotate root modal opens'); + await click(PKI_ISSUER_DETAILS.rotateModalGenerate); assert.strictEqual( currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers/${issuerId}/rotate-root`, @@ -484,12 +489,12 @@ module('Acceptance | pki workflow', function (hooks) { test('it renders a warning banner when parent issuer has unsupported OIDs', async function (assert) { await authPage.login(); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/create`); - await click(SELECTORS.configuration.optionByKey('import')); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', unsupportedPem); - await click(SELECTORS.configuration.importSubmit); - const issuerId = find(SELECTORS.configuration.importedIssuer).innerText; - await click(`${SELECTORS.configuration.importedIssuer} a`); + await click(PKI_CONFIGURE_CREATE.importSubmit); + const issuerId = find(PKI_CONFIGURE_CREATE.importedIssuer).innerText; + await click(`${PKI_CONFIGURE_CREATE.importedIssuer} a`); // navigating directly to route because the rotate button is not visible for non-root issuers // but we're just testing that route model was parsed and passed as expected @@ -502,7 +507,7 @@ module('Acceptance | pki workflow', function (hooks) { ); assert.dom('[data-test-input="commonName"]').hasValue('fancy-cert-unsupported-subj-and-ext-oids'); await fillIn('[data-test-input="issuerName"]', 'existing-issuer'); - await click('[data-test-pki-rotate-root-save]'); + await click(GENERAL.saveButton); assert .dom('[data-test-rotate-error]') .hasText('Error issuer name already in use', 'it renders error banner'); @@ -527,18 +532,18 @@ module('Acceptance | pki workflow', function (hooks) { await authPage.login(this.mixedConfigCapabilities); await visit(`/vault/secrets/${this.mountPath}/pki/configuration/edit`); assert - .dom(`${SELECTORS.configEdit.configEditSection} [data-test-component="empty-state"]`) + .dom(`${PKI_CONFIG_EDIT.configEditSection} [data-test-component="empty-state"]`) .hasText( `You do not have permission to set this mount's the cluster config Ask your administrator if you think you should have access to: POST /${this.mountPath}/config/cluster` ); - assert.dom(SELECTORS.configEdit.acmeEditSection).exists(); - assert.dom(SELECTORS.configEdit.urlsEditSection).exists(); - assert.dom(SELECTORS.configEdit.crlEditSection).exists(); - assert.dom(`${SELECTORS.acmeEditSection} [data-test-component="empty-state"]`).doesNotExist(); - assert.dom(`${SELECTORS.urlsEditSection} [data-test-component="empty-state"]`).doesNotExist(); - assert.dom(`${SELECTORS.crlEditSection} [data-test-component="empty-state"]`).doesNotExist(); - await click(SELECTORS.configEdit.crlToggleInput('expiry')); - await click(SELECTORS.configEdit.saveButton); + assert.dom(PKI_CONFIG_EDIT.acmeEditSection).exists(); + assert.dom(PKI_CONFIG_EDIT.urlsEditSection).exists(); + assert.dom(PKI_CONFIG_EDIT.crlEditSection).exists(); + assert.dom(`${PKI_CONFIG_EDIT.acmeEditSection} [data-test-component="empty-state"]`).doesNotExist(); + assert.dom(`${PKI_CONFIG_EDIT.urlsEditSection} [data-test-component="empty-state"]`).doesNotExist(); + assert.dom(`${PKI_CONFIG_EDIT.crlEditSection} [data-test-component="empty-state"]`).doesNotExist(); + await click(PKI_CONFIG_EDIT.crlToggleInput('expiry')); + await click(PKI_CONFIG_EDIT.saveButton); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/configuration`); assert .dom('[data-test-value-div="CRL building"]') diff --git a/ui/tests/acceptance/pki/pki-overview-test.js b/ui/tests/acceptance/pki/pki-overview-test.js index 5e86d33e76c1..4281e1a1e9d1 100644 --- a/ui/tests/acceptance/pki/pki-overview-test.js +++ b/ui/tests/acceptance/pki/pki-overview-test.js @@ -11,9 +11,9 @@ import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { click, currentURL, currentRouteName, visit } from '@ember/test-helpers'; -import { SELECTORS } from 'vault/tests/helpers/pki/overview'; -import { clearRecords } from 'vault/tests/helpers/pki/pki-run-commands'; import { runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/commands'; +import { clearRecords } from 'vault/tests/helpers/pki/pki-helpers'; +import { PKI_OVERVIEW } from 'vault/tests/helpers/pki/pki-selectors'; module('Acceptance | pki overview', function (hooks) { setupApplicationTest(hooks); @@ -59,9 +59,9 @@ module('Acceptance | pki overview', function (hooks) { test('navigates to view issuers when link is clicked on issuer card', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.issuersCardTitle).hasText('Issuers'); - assert.dom(SELECTORS.issuersCardOverviewNum).hasText('1'); - await click(SELECTORS.issuersCardLink); + assert.dom(PKI_OVERVIEW.issuersCardTitle).hasText('Issuers'); + assert.dom(PKI_OVERVIEW.issuersCardOverviewNum).hasText('1'); + await click(PKI_OVERVIEW.issuersCardLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/issuers`); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); }); @@ -69,9 +69,9 @@ module('Acceptance | pki overview', function (hooks) { test('navigates to view roles when link is clicked on roles card', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesCardTitle).hasText('Roles'); - assert.dom(SELECTORS.rolesCardOverviewNum).hasText('0'); - await click(SELECTORS.rolesCardLink); + assert.dom(PKI_OVERVIEW.rolesCardTitle).hasText('Roles'); + assert.dom(PKI_OVERVIEW.rolesCardOverviewNum).hasText('0'); + await click(PKI_OVERVIEW.rolesCardLink); assert.strictEqual(currentURL(), `/vault/secrets/${this.mountPath}/pki/roles`); await runCmd([ `write ${this.mountPath}/roles/some-role \ @@ -81,14 +81,14 @@ module('Acceptance | pki overview', function (hooks) { max_ttl="720h"`, ]); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesCardOverviewNum).hasText('1'); + assert.dom(PKI_OVERVIEW.rolesCardOverviewNum).hasText('1'); }); test('hides roles card if user does not have permissions', async function (assert) { await authPage.login(this.pkiIssuersList); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - assert.dom(SELECTORS.rolesCardTitle).doesNotExist('Roles card does not exist'); - assert.dom(SELECTORS.issuersCardTitle).exists('Issuers card exists'); + assert.dom(PKI_OVERVIEW.rolesCardTitle).doesNotExist('Roles card does not exist'); + assert.dom(PKI_OVERVIEW.issuersCardTitle).exists('Issuers card exists'); }); test('navigates to generate certificate page for Issue Certificates card', async function (assert) { @@ -101,18 +101,18 @@ module('Acceptance | pki overview', function (hooks) { max_ttl="720h"`, ]); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.issueCertificatePowerSearch); - await click(SELECTORS.firstPowerSelectOption); - await click(SELECTORS.issueCertificateButton); + await click(PKI_OVERVIEW.issueCertificatePowerSearch); + await click(PKI_OVERVIEW.firstPowerSelectOption); + await click(PKI_OVERVIEW.issueCertificateButton); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.roles.role.generate'); }); test('navigates to certificate details page for View Certificates card', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.viewCertificatePowerSearch); - await click(SELECTORS.firstPowerSelectOption); - await click(SELECTORS.viewCertificateButton); + await click(PKI_OVERVIEW.viewCertificatePowerSearch); + await click(PKI_OVERVIEW.firstPowerSelectOption); + await click(PKI_OVERVIEW.viewCertificateButton); assert.strictEqual( currentRouteName(), 'vault.cluster.secrets.backend.pki.certificates.certificate.details' @@ -122,9 +122,9 @@ module('Acceptance | pki overview', function (hooks) { test('navigates to issuer details page for View Issuer card', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/overview`); - await click(SELECTORS.viewIssuerPowerSearch); - await click(SELECTORS.firstPowerSelectOption); - await click(SELECTORS.viewIssuerButton); + await click(PKI_OVERVIEW.viewIssuerPowerSearch); + await click(PKI_OVERVIEW.firstPowerSelectOption); + await click(PKI_OVERVIEW.viewIssuerButton); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.issuers.issuer.details'); }); }); diff --git a/ui/tests/acceptance/pki/pki-tidy-test.js b/ui/tests/acceptance/pki/pki-tidy-test.js index 4f16c858b58b..2c08efd22bc2 100644 --- a/ui/tests/acceptance/pki/pki-tidy-test.js +++ b/ui/tests/acceptance/pki/pki-tidy-test.js @@ -14,7 +14,8 @@ import authPage from 'vault/tests/pages/auth'; import logout from 'vault/tests/pages/logout'; import enablePage from 'vault/tests/pages/settings/mount-secret-backend'; import { runCmd } from 'vault/tests/helpers/commands'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-tidy'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_TIDY, PKI_TIDY_FORM } from 'vault/tests/helpers/pki/pki-selectors'; module('Acceptance | pki tidy', function (hooks) { setupApplicationTest(hooks); @@ -42,20 +43,20 @@ module('Acceptance | pki tidy', function (hooks) { test('it configures a manual tidy operation and shows its details and tidy states', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); - await click(SELECTORS.tidyEmptyStateConfigure); - assert.dom(SELECTORS.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); - assert.dom(SELECTORS.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); + await click(PKI_TIDY.tidyEmptyStateConfigure); + assert.dom(PKI_TIDY.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); + assert.dom(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); assert - .dom(SELECTORS.tidyConfigureModal.tidyModalManualButton) + .dom(PKI_TIDY.tidyConfigureModal.tidyModalManualButton) .exists('Configure manual tidy button exists'); - await click(SELECTORS.tidyConfigureModal.tidyModalManualButton); - assert.dom(SELECTORS.tidyForm.tidyFormName('manual')).exists('Manual tidy form exists'); - await click(SELECTORS.tidyForm.inputByAttr('tidyCertStore')); - await fillIn(SELECTORS.tidyForm.tidyPauseDuration, '10'); - await click(SELECTORS.tidyForm.tidySave); - await click(SELECTORS.cancelTidyAction); - assert.dom(SELECTORS.cancelTidyModalBackground).exists('Confirm cancel tidy modal exits'); - await click(SELECTORS.tidyConfigureModal.tidyModalCancelButton); + await click(PKI_TIDY.tidyConfigureModal.tidyModalManualButton); + assert.dom(PKI_TIDY_FORM.tidyFormName('manual')).exists('Manual tidy form exists'); + await click(PKI_TIDY_FORM.inputByAttr('tidyCertStore')); + await fillIn(PKI_TIDY_FORM.tidyPauseDuration, '10'); + await click(PKI_TIDY_FORM.tidySave); + await click(PKI_TIDY.cancelTidyAction); + assert.dom(PKI_TIDY.cancelTidyModalBackground).exists('Confirm cancel tidy modal exits'); + await click(PKI_TIDY.tidyConfigureModal.tidyModalCancelButton); // we can't properly test the background refresh fetching of tidy status in testing this.server.get(`${this.mountPath}/tidy-status`, () => { return { @@ -103,77 +104,75 @@ module('Acceptance | pki tidy', function (hooks) { }); await visit(`/vault/secrets/${this.mountPath}/pki/configuration`); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy operation cancelled'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy operation cancelled'); assert - .dom(SELECTORS.hdsAlertDescription) + .dom(PKI_TIDY.hdsAlertDescription) .hasText( 'Your tidy operation has been cancelled. If this was a mistake configure and run another tidy operation.' ); - assert.dom(SELECTORS.alertUpdatedAt).exists(); + assert.dom(PKI_TIDY.alertUpdatedAt).exists(); }); test('it configures an auto tidy operation and shows its details', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); - await click(SELECTORS.tidyEmptyStateConfigure); - assert.dom(SELECTORS.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); - assert.dom(SELECTORS.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); + await click(PKI_TIDY.tidyEmptyStateConfigure); + assert.dom(PKI_TIDY.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); + assert.dom(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); assert - .dom(SELECTORS.tidyConfigureModal.tidyModalManualButton) + .dom(PKI_TIDY.tidyConfigureModal.tidyModalManualButton) .exists('Configure manual tidy button exists'); - await click(SELECTORS.tidyConfigureModal.tidyModalAutoButton); - assert.dom(SELECTORS.tidyForm.tidyFormName('auto')).exists('Auto tidy form exists'); - await click(SELECTORS.tidyForm.tidyCancel); + await click(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton); + assert.dom(PKI_TIDY_FORM.tidyFormName('auto')).exists('Auto tidy form exists'); + await click(PKI_TIDY_FORM.tidyCancel); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.index'); - await click(SELECTORS.tidyEmptyStateConfigure); - await click(SELECTORS.tidyConfigureModal.tidyModalAutoButton); - assert.dom(SELECTORS.tidyForm.tidyFormName('auto')).exists('Auto tidy form exists'); - await click(SELECTORS.tidyForm.toggleLabel('Automatic tidy disabled')); + await click(PKI_TIDY.tidyEmptyStateConfigure); + await click(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton); + assert.dom(PKI_TIDY_FORM.tidyFormName('auto')).exists('Auto tidy form exists'); + await click(PKI_TIDY_FORM.toggleLabel('Automatic tidy disabled')); assert - .dom(SELECTORS.tidyForm.tidySectionHeader('ACME operations')) + .dom(PKI_TIDY_FORM.tidySectionHeader('ACME operations')) .exists('Auto tidy form enabled shows ACME operations field'); - await click(SELECTORS.tidyForm.inputByAttr('tidyCertStore')); - await click(SELECTORS.tidyForm.tidySave); + await click(PKI_TIDY_FORM.inputByAttr('tidyCertStore')); + await click(PKI_TIDY_FORM.tidySave); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.auto.index'); - await click(SELECTORS.tidyForm.editAutoTidyButton); + await click(PKI_TIDY_FORM.editAutoTidyButton); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.auto.configure'); - await click(SELECTORS.tidyForm.inputByAttr('tidyRevokedCerts')); - await click(SELECTORS.tidyForm.tidySave); + await click(PKI_TIDY_FORM.inputByAttr('tidyRevokedCerts')); + await click(PKI_TIDY_FORM.tidySave); assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.auto.index'); }); test('it opens a tidy modal when the user clicks on the tidy toolbar action', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); - await click(SELECTORS.tidyConfigureModal.tidyOptionsModal); - assert.dom(SELECTORS.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); - assert.dom(SELECTORS.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); + await click(PKI_TIDY.tidyConfigureModal.tidyOptionsModal); + assert.dom(PKI_TIDY.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); + assert.dom(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton).exists('Configure auto tidy button exists'); assert - .dom(SELECTORS.tidyConfigureModal.tidyModalManualButton) + .dom(PKI_TIDY.tidyConfigureModal.tidyModalManualButton) .exists('Configure manual tidy button exists'); - await click(SELECTORS.tidyConfigureModal.tidyModalCancelButton); - assert.dom(SELECTORS.tidyEmptyState).exists(); + await click(PKI_TIDY.tidyConfigureModal.tidyModalCancelButton); + assert.dom(GENERAL.emptyStateTitle).exists(); }); test('it should show correct toolbar action depending on whether auto tidy is enabled', async function (assert) { await authPage.login(this.pkiAdminToken); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); assert - .dom(SELECTORS.tidyConfigureModal.tidyOptionsModal) + .dom(PKI_TIDY.tidyConfigureModal.tidyOptionsModal) .exists('Configure tidy modal options button exists'); - await click(SELECTORS.tidyConfigureModal.tidyOptionsModal); - assert.dom(SELECTORS.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); - await click(SELECTORS.tidyConfigureModal.tidyModalAutoButton); - await click(SELECTORS.tidyForm.toggleLabel('Automatic tidy disabled')); - await click(SELECTORS.tidyForm.inputByAttr('tidyCertStore')); - await click(SELECTORS.tidyForm.inputByAttr('tidyRevokedCerts')); - await click(SELECTORS.tidyForm.tidySave); + await click(PKI_TIDY.tidyConfigureModal.tidyOptionsModal); + assert.dom(PKI_TIDY.tidyConfigureModal.configureTidyModal).exists('Configure tidy modal exists'); + await click(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton); + await click(PKI_TIDY_FORM.toggleLabel('Automatic tidy disabled')); + await click(PKI_TIDY_FORM.inputByAttr('tidyCertStore')); + await click(PKI_TIDY_FORM.inputByAttr('tidyRevokedCerts')); + await click(PKI_TIDY_FORM.tidySave); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); assert - .dom(SELECTORS.manualTidyToolbar) + .dom(PKI_TIDY.manualTidyToolbar) .exists('Manual tidy toolbar action exists if auto tidy is configured'); - assert - .dom(SELECTORS.autoTidyToolbar) - .exists('Auto tidy toolbar action exists if auto tidy is configured'); + assert.dom(PKI_TIDY.autoTidyToolbar).exists('Auto tidy toolbar action exists if auto tidy is configured'); }); }); diff --git a/ui/tests/acceptance/policies/index-test.js b/ui/tests/acceptance/policies/index-test.js index e79eb3057e58..9e2dfef83b4f 100644 --- a/ui/tests/acceptance/policies/index-test.js +++ b/ui/tests/acceptance/policies/index-test.js @@ -10,7 +10,6 @@ import { fillIn, visit, click, - find, waitFor, waitUntil, } from '@ember/test-helpers'; @@ -20,6 +19,7 @@ import { v4 as uuidv4 } from 'uuid'; import authPage from 'vault/tests/pages/auth'; import { runCmd } from 'vault/tests/helpers/commands'; +import codemirror from 'vault/tests/helpers/codemirror'; const SELECT = { policyByName: (name) => `[data-test-policy-link="${name}"]`, @@ -86,7 +86,7 @@ module('Acceptance | policies/acl', function (hooks) { await click(SELECT.createLink); await fillIn(SELECT.nameInput, policyName); - find('.CodeMirror').CodeMirror.setValue(policyString); + codemirror().setValue(policyString); await click(SELECT.save); assert.strictEqual( currentURL(), @@ -110,7 +110,7 @@ module('Acceptance | policies/acl', function (hooks) { assert .dom(SELECT.createError) .hasText(`Error 'policy' parameter not supplied or empty`, 'renders error message on save'); - find('.CodeMirror').CodeMirror.setValue(policyString); + codemirror().setValue(policyString); await click(SELECT.save); await waitUntil(() => currentURL() === `/vault/policy/acl/${encodeURIComponent(policyLower)}`); diff --git a/ui/tests/acceptance/reduced-disclosure-test.js b/ui/tests/acceptance/reduced-disclosure-test.js index a4dff8c28e1c..324dd9c03373 100644 --- a/ui/tests/acceptance/reduced-disclosure-test.js +++ b/ui/tests/acceptance/reduced-disclosure-test.js @@ -12,7 +12,7 @@ import { createTokenCmd, runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/ import { pollCluster } from 'vault/tests/helpers/poll-cluster'; import VAULT_KEYS from 'vault/tests/helpers/vault-keys'; import reducedDisclosureHandlers from 'vault/mirage/handlers/reduced-disclosure'; -import { overrideResponse } from 'vault/tests/helpers/clients'; +import { overrideResponse } from 'vault/tests/helpers/stubs'; const { unsealKeys } = VAULT_KEYS; const SELECTORS = { diff --git a/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js index 860979d6f19c..7e91fe30c770 100644 --- a/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/cubbyhole/secret-test.js @@ -13,7 +13,7 @@ import editPage from 'vault/tests/pages/secrets/backend/kv/edit-secret'; import showPage from 'vault/tests/pages/secrets/backend/kv/show'; import listPage from 'vault/tests/pages/secrets/backend/list'; import authPage from 'vault/tests/pages/auth'; -import assertSecretWrap from 'vault/tests/helpers/secret-edit-toolbar'; +import { assertSecretWrap } from 'vault/tests/helpers/components/secret-edit-toolbar'; module('Acceptance | secrets/cubbyhole/create', function (hooks) { setupApplicationTest(hooks); diff --git a/ui/tests/acceptance/secrets/backend/generic/secret-test.js b/ui/tests/acceptance/secrets/backend/generic/secret-test.js index ec6a7cdbf300..70f3b19d394e 100644 --- a/ui/tests/acceptance/secrets/backend/generic/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/generic/secret-test.js @@ -17,8 +17,7 @@ import { writeSecret } from 'vault/tests/helpers/kv/kv-run-commands'; import { PAGE } from 'vault/tests/helpers/kv/kv-selectors'; import { create } from 'ember-cli-page-object'; - -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { deleteEngineCmd, runCmd } from 'vault/tests/helpers/commands'; const cli = create(consolePanel); @@ -27,14 +26,9 @@ module('Acceptance | secrets/generic/create', function (hooks) { hooks.beforeEach(function () { this.uid = uuidv4(); - this.server = apiStub({ usePassthrough: true }); return authPage.login(); }); - hooks.afterEach(function () { - this.server.shutdown(); - }); - test('it creates and can view a secret with the generic backend', async function (assert) { const path = `generic-${this.uid}`; const kvPath = `generic-kv-${this.uid}`; @@ -55,6 +49,10 @@ module('Acceptance | secrets/generic/create', function (hooks) { 'redirects to the show page' ); assert.ok(showPage.editIsPresent, 'shows the edit button'); + + // Clean up + await runCmd(deleteEngineCmd(path)); + await runCmd(deleteEngineCmd(kvPath)); }); test('upgrading generic to version 2 lists all existing secrets, and CRUD continues to work', async function (assert) { @@ -78,5 +76,8 @@ module('Acceptance | secrets/generic/create', function (hooks) { assert.dom(PAGE.list.item(secret.path)).exists('lists both records'); }); assert.dom(PAGE.list.item()).exists({ count: 2 }, 'lists only the two secrets'); + + // Clean up + await runCmd(deleteEngineCmd(path)); }); }); diff --git a/ui/tests/acceptance/secrets/backend/kubernetes/overview-test.js b/ui/tests/acceptance/secrets/backend/kubernetes/overview-test.js index 5bb8b257b440..7d3d3820fb48 100644 --- a/ui/tests/acceptance/secrets/backend/kubernetes/overview-test.js +++ b/ui/tests/acceptance/secrets/backend/kubernetes/overview-test.js @@ -11,7 +11,8 @@ import kubernetesHandlers from 'vault/mirage/handlers/kubernetes'; import authPage from 'vault/tests/pages/auth'; import { visit, click, currentRouteName } from '@ember/test-helpers'; import { selectChoose } from 'ember-power-select/test-support'; -import { SELECTORS } from 'vault/tests/helpers/kubernetes/overview'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { KUBERNETES_OVERVIEW } from 'vault/tests/helpers/kubernetes/kubernetes-selectors'; module('Acceptance | kubernetes | overview', function (hooks) { setupApplicationTest(hooks); @@ -34,7 +35,7 @@ module('Acceptance | kubernetes | overview', function (hooks) { test('it should transition to configuration page during empty state', async function (assert) { assert.expect(1); await this.visitOverview(); - await click('[data-test-component="empty-state"] a'); + await click(`${GENERAL.emptyStateActions} a`); this.validateRoute(assert, 'configure', 'Transitions to Configure route on click'); }); @@ -42,7 +43,7 @@ module('Acceptance | kubernetes | overview', function (hooks) { assert.expect(1); this.createScenario(); await this.visitOverview(); - await click(SELECTORS.rolesCardLink); + await click(KUBERNETES_OVERVIEW.rolesCardLink); this.validateRoute(assert, 'roles.index', 'Transitions to roles route on View Roles click'); }); @@ -50,7 +51,7 @@ module('Acceptance | kubernetes | overview', function (hooks) { assert.expect(1); this.createScenario(false); await this.visitOverview(); - await click(SELECTORS.rolesCardLink); + await click(KUBERNETES_OVERVIEW.rolesCardLink); this.validateRoute(assert, 'roles.create', 'Transitions to roles route on Create Roles click'); }); @@ -59,7 +60,7 @@ module('Acceptance | kubernetes | overview', function (hooks) { await this.createScenario(); await this.visitOverview(); await selectChoose('.search-select', 'role-0'); - await click('[data-test-generate-credential-button]'); + await click(KUBERNETES_OVERVIEW.generateCredentialsCardButton); this.validateRoute(assert, 'roles.role.credentials', 'Transitions to roles route on Generate click'); }); }); diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-create-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-create-test.js index fc121a888c2f..1b84ce0bce81 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-create-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-create-test.js @@ -10,7 +10,7 @@ import { click, currentURL, fillIn, typeIn, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'vault/tests/helpers'; import authPage from 'vault/tests/pages/auth'; import { deleteEngineCmd, mountEngineCmd, runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/commands'; -import { personas } from 'vault/tests/helpers/policy-generator/kv'; +import { personas } from 'vault/tests/helpers/kv/policy-generator'; import { clearRecords, writeVersionedSecret } from 'vault/tests/helpers/kv/kv-run-commands'; import { FORM, PAGE } from 'vault/tests/helpers/kv/kv-selectors'; import { grantAccessForWrite, setupControlGroup } from 'vault/tests/helpers/control-groups'; diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-delete-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-delete-test.js index 6a5f5be9c982..d026dc2756ae 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-delete-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-delete-test.js @@ -8,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid'; import { setupApplicationTest } from 'vault/tests/helpers'; import authPage from 'vault/tests/pages/auth'; import { deleteEngineCmd, mountEngineCmd, runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/commands'; -import { personas } from 'vault/tests/helpers/policy-generator/kv'; +import { personas } from 'vault/tests/helpers/kv/policy-generator'; import { clearRecords, deleteLatestCmd, diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js index bf94b8018838..7a17ae8ae732 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js @@ -21,7 +21,7 @@ import { destroyVersionsPolicy, metadataListPolicy, metadataPolicy, -} from 'vault/tests/helpers/policy-generator/kv'; +} from 'vault/tests/helpers/kv/policy-generator'; import { clearRecords, writeSecret, writeVersionedSecret } from 'vault/tests/helpers/kv/kv-run-commands'; import { FORM, PAGE } from 'vault/tests/helpers/kv/kv-selectors'; import codemirror from 'vault/tests/helpers/codemirror'; diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-navigation-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-navigation-test.js index 015683faeca0..05c5be873432 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-navigation-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-navigation-test.js @@ -16,7 +16,7 @@ import { createTokenCmd, tokenWithPolicyCmd, } from 'vault/tests/helpers/commands'; -import { personas } from 'vault/tests/helpers/policy-generator/kv'; +import { personas } from 'vault/tests/helpers/kv/policy-generator'; import { addSecretMetadataCmd, clearRecords, diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-version-history-paths-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-version-history-paths-test.js index 82d0461ed64d..391dcd79194d 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-version-history-paths-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-version-history-paths-test.js @@ -8,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid'; import { setupApplicationTest } from 'vault/tests/helpers'; import authPage from 'vault/tests/pages/auth'; import { deleteEngineCmd, mountEngineCmd, runCmd, tokenWithPolicyCmd } from 'vault/tests/helpers/commands'; -import { personas } from 'vault/tests/helpers/policy-generator/kv'; +import { personas } from 'vault/tests/helpers/kv/policy-generator'; import { clearRecords, deleteVersionCmd, diff --git a/ui/tests/acceptance/secrets/backend/kv/secret-test.js b/ui/tests/acceptance/secrets/backend/kv/secret-test.js index ab1df0489425..c83916b07355 100644 --- a/ui/tests/acceptance/secrets/backend/kv/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/secret-test.js @@ -18,6 +18,7 @@ import logout from 'vault/tests/pages/logout'; import { writeSecret, writeVersionedSecret } from 'vault/tests/helpers/kv/kv-run-commands'; import { runCmd } from 'vault/tests/helpers/commands'; import { PAGE } from 'vault/tests/helpers/kv/kv-selectors'; +import codemirror from 'vault/tests/helpers/codemirror'; const deleteEngine = async function (enginePath, assert) { await logout.visit(); @@ -329,8 +330,7 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { await listPage.visitRoot({ backend: this.backend }); await listPage.create(); await editPage.path(secretPath).toggleJSON(); - const instance = document.querySelector('.CodeMirror').CodeMirror; - instance.setValue(content); + codemirror().setValue(content); await editPage.save(); assert.strictEqual( @@ -339,9 +339,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { 'redirects to the show page' ); assert.ok(showPage.editIsPresent, 'shows the edit button'); - const savedInstance = document.querySelector('.CodeMirror').CodeMirror; assert.strictEqual( - savedInstance.options.value, + codemirror().options.value, JSON.stringify({ bar: 'boo', foo: 'fa' }, null, 2), 'saves the content' ); diff --git a/ui/tests/acceptance/secrets/backend/ldap/libraries-test.js b/ui/tests/acceptance/secrets/backend/ldap/libraries-test.js index d8bd65b0094c..dd3d0e0725a6 100644 --- a/ui/tests/acceptance/secrets/backend/ldap/libraries-test.js +++ b/ui/tests/acceptance/secrets/backend/ldap/libraries-test.js @@ -10,7 +10,7 @@ import ldapMirageScenario from 'vault/mirage/scenarios/ldap'; import ldapHandlers from 'vault/mirage/handlers/ldap'; import authPage from 'vault/tests/pages/auth'; import { click } from '@ember/test-helpers'; -import { isURL, visitURL } from 'vault/tests/helpers/ldap'; +import { isURL, visitURL } from 'vault/tests/helpers/ldap/ldap-helpers'; module('Acceptance | ldap | libraries', function (hooks) { setupApplicationTest(hooks); diff --git a/ui/tests/acceptance/secrets/backend/ldap/overview-test.js b/ui/tests/acceptance/secrets/backend/ldap/overview-test.js index 726ff8ddbaea..8fe90cccf2e1 100644 --- a/ui/tests/acceptance/secrets/backend/ldap/overview-test.js +++ b/ui/tests/acceptance/secrets/backend/ldap/overview-test.js @@ -11,7 +11,7 @@ import ldapHandlers from 'vault/mirage/handlers/ldap'; import authPage from 'vault/tests/pages/auth'; import { click, fillIn, visit } from '@ember/test-helpers'; import { selectChoose } from 'ember-power-select/test-support'; -import { isURL, visitURL } from 'vault/tests/helpers/ldap'; +import { isURL, visitURL } from 'vault/tests/helpers/ldap/ldap-helpers'; module('Acceptance | ldap | overview', function (hooks) { setupApplicationTest(hooks); diff --git a/ui/tests/acceptance/secrets/backend/ldap/roles-test.js b/ui/tests/acceptance/secrets/backend/ldap/roles-test.js index 5c0551e36d93..15d1df74df2a 100644 --- a/ui/tests/acceptance/secrets/backend/ldap/roles-test.js +++ b/ui/tests/acceptance/secrets/backend/ldap/roles-test.js @@ -10,7 +10,7 @@ import ldapMirageScenario from 'vault/mirage/scenarios/ldap'; import ldapHandlers from 'vault/mirage/handlers/ldap'; import authPage from 'vault/tests/pages/auth'; import { click, fillIn } from '@ember/test-helpers'; -import { isURL, visitURL } from 'vault/tests/helpers/ldap'; +import { isURL, visitURL } from 'vault/tests/helpers/ldap/ldap-helpers'; module('Acceptance | ldap | roles', function (hooks) { setupApplicationTest(hooks); diff --git a/ui/tests/acceptance/settings/auth/configure/section-test.js b/ui/tests/acceptance/settings/auth/configure/section-test.js index 2db3fde772b4..318333a8962c 100644 --- a/ui/tests/acceptance/settings/auth/configure/section-test.js +++ b/ui/tests/acceptance/settings/auth/configure/section-test.js @@ -5,6 +5,7 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; +import { setupMirage } from 'ember-cli-mirage/test-support'; import { create } from 'ember-cli-page-object'; import { fillIn } from '@ember/test-helpers'; import { v4 as uuidv4 } from 'uuid'; @@ -12,7 +13,6 @@ import { v4 as uuidv4 } from 'uuid'; import enablePage from 'vault/tests/pages/settings/auth/enable'; import page from 'vault/tests/pages/settings/auth/configure/section'; import indexPage from 'vault/tests/pages/settings/auth/configure/index'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; import consolePanel from 'vault/tests/pages/components/console/ui-panel'; import authPage from 'vault/tests/pages/auth'; @@ -20,18 +20,24 @@ const cli = create(consolePanel); module('Acceptance | settings/auth/configure/section', function (hooks) { setupApplicationTest(hooks); + setupMirage(hooks); hooks.beforeEach(function () { this.uid = uuidv4(); - this.server = apiStub({ usePassthrough: true }); return authPage.login(); }); - hooks.afterEach(function () { - this.server.shutdown(); - }); - test('it can save options', async function (assert) { + assert.expect(6); + this.server.post(`/sys/mounts/auth/:path/tune`, function (schema, request) { + const body = JSON.parse(request.requestBody); + const keys = Object.keys(body); + assert.strictEqual(body.token_type, 'batch', 'passes new token type'); + assert.true(keys.includes('default_lease_ttl'), 'passes default_lease_ttl on tune'); + assert.true(keys.includes('max_lease_ttl'), 'passes max_lease_ttl on tune'); + assert.true(keys.includes('description'), 'passes updated description on tune'); + request.passthrough(); + }); const path = `approle-save-${this.uid}`; const type = 'approle'; const section = 'options'; @@ -48,16 +54,6 @@ module('Acceptance | settings/auth/configure/section', function (hooks) { `The configuration was saved successfully.`, 'success flash shows' ); - const tuneRequest = this.server.passthroughRequests.filterBy( - 'url', - `/v1/sys/mounts/auth/${path}/tune` - )[0]; - const keys = Object.keys(JSON.parse(tuneRequest.requestBody)); - const token_type = JSON.parse(tuneRequest.requestBody).token_type; - assert.strictEqual(token_type, 'batch', 'passes new token type'); - assert.ok(keys.includes('default_lease_ttl'), 'passes default_lease_ttl on tune'); - assert.ok(keys.includes('max_lease_ttl'), 'passes max_lease_ttl on tune'); - assert.ok(keys.includes('description'), 'passes updated description on tune'); }); for (const type of ['aws', 'azure', 'gcp', 'github', 'kubernetes']) { diff --git a/ui/tests/acceptance/tools-test.js b/ui/tests/acceptance/tools-test.js index 152d23a10f2d..6b5bbc09d896 100644 --- a/ui/tests/acceptance/tools-test.js +++ b/ui/tests/acceptance/tools-test.js @@ -3,13 +3,24 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import { click, fillIn, find, findAll, currentURL, visit, settled, waitUntil } from '@ember/test-helpers'; +import { + click, + fillIn, + find, + findAll, + currentURL, + visit, + settled, + waitUntil, + waitFor, +} from '@ember/test-helpers'; import Pretender from 'pretender'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { toolsActions } from 'vault/helpers/tools-actions'; import authPage from 'vault/tests/pages/auth'; import { capitalize } from '@ember/string'; +import codemirror from 'vault/tests/helpers/codemirror'; module('Acceptance | tools', function (hooks) { setupApplicationTest(hooks); @@ -48,8 +59,8 @@ module('Acceptance | tools', function (hooks) { assert.dom(`[data-test-sidebar-nav-link="${capitalize(action)}"]`).exists(`${action} link renders`); }); - const { CodeMirror } = await waitUntil(() => find('.CodeMirror')); - CodeMirror.setValue(DATA_TO_WRAP); + await waitFor('.CodeMirror'); + codemirror().setValue(DATA_TO_WRAP); // wrap await click('[data-test-tools-submit]'); @@ -86,16 +97,20 @@ module('Acceptance | tools', function (hooks) { await fillIn('[data-test-tools-input="wrapping-token"]', tokenStore.get()); await click('[data-test-tools-submit]'); + await waitFor('.CodeMirror'); assert.deepEqual( - JSON.parse(CodeMirror.getValue()), + JSON.parse(codemirror().getValue()), JSON.parse(DATA_TO_WRAP), 'unwrapped data equals input data' ); - const buttonDetails = await waitUntil(() => find('[data-test-button-details]')); - await click(buttonDetails); + await waitUntil(() => find('[data-test-button-details]')); + await click('[data-test-button-details]'); await click('[data-test-button-data]'); - assert.dom('.CodeMirror').exists(); - + assert.deepEqual( + JSON.parse(codemirror().getValue()), + JSON.parse(DATA_TO_WRAP), + 'data tab still has unwrapped data' + ); //random await click('[data-test-sidebar-nav-link="Random"]'); @@ -160,7 +175,7 @@ module('Acceptance | tools', function (hooks) { await click('[data-test-tools-submit]'); assert.deepEqual( - JSON.parse(findAll('.CodeMirror')[0].CodeMirror.getValue()), + JSON.parse(codemirror().getValue()), AUTH_RESPONSE.auth, 'unwrapped data equals input data' ); diff --git a/ui/tests/acceptance/transit-test.js b/ui/tests/acceptance/transit-test.js index 25b553a244c0..d6d826c88f65 100644 --- a/ui/tests/acceptance/transit-test.js +++ b/ui/tests/acceptance/transit-test.js @@ -11,6 +11,7 @@ import { v4 as uuidv4 } from 'uuid'; import { encodeString } from 'vault/utils/b64'; import authPage from 'vault/tests/pages/auth'; import { deleteEngineCmd, mountEngineCmd, runCmd } from 'vault/tests/helpers/commands'; +import codemirror from 'vault/tests/helpers/codemirror'; const SELECTORS = { secretLink: '[data-test-secret-link]', @@ -150,7 +151,7 @@ const testConvergentEncryption = async function (assert, keyName) { for (const testCase of tests) { await click('[data-test-transit-action-link="encrypt"]'); - find('#plaintext-control .CodeMirror').CodeMirror.setValue(testCase.plaintext); + codemirror('#plaintext-control').setValue(testCase.plaintext); await fillIn('[data-test-transit-input="context"]', testCase.context); if (!testCase.encodePlaintext) { @@ -160,7 +161,7 @@ const testConvergentEncryption = async function (assert, keyName) { if (testCase.encodeContext) { await click('[data-test-transit-b64-toggle="context"]'); } - assert.dom('[data-test-encrypt-modal]').doesNotExist(`${name}: is not open before encrypt`); + assert.dom('[data-test-encrypt-modal]').doesNotExist(`${keyName}: is not open before encrypt`); await click('[data-test-button-encrypt]'); if (testCase.assertAfterEncrypt) { @@ -171,14 +172,15 @@ const testConvergentEncryption = async function (assert, keyName) { const copiedCiphertext = find('[data-test-encrypted-value="ciphertext"]').innerText; await click('dialog button'); - assert.dom('dialog.hds-modal').doesNotExist(`${name}: Modal closes after background clicked`); + assert.dom('dialog.hds-modal').doesNotExist(`${keyName}: Modal closes after background clicked`); await click('[data-test-transit-action-link="decrypt"]'); if (testCase.assertBeforeDecrypt) { await settled(); testCase.assertBeforeDecrypt(keyName); } - find('#ciphertext-control .CodeMirror').CodeMirror.setValue(copiedCiphertext); + + codemirror('#ciphertext-control').setValue(copiedCiphertext); await click('[data-test-button-decrypt]'); if (testCase.assertAfterDecrypt) { @@ -188,7 +190,7 @@ const testConvergentEncryption = async function (assert, keyName) { await click('dialog button'); - assert.dom('dialog.hds-modal').doesNotExist(`${name}: Modal closes after background clicked`); + assert.dom('dialog.hds-modal').doesNotExist(`${keyName}: Modal closes after background clicked`); } }; diff --git a/ui/tests/acceptance/unseal-test.js b/ui/tests/acceptance/unseal-test.js index f7a1cab3ecdf..7bbf66644943 100644 --- a/ui/tests/acceptance/unseal-test.js +++ b/ui/tests/acceptance/unseal-test.js @@ -11,7 +11,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import VAULT_KEYS from 'vault/tests/helpers/vault-keys'; import authPage from 'vault/tests/pages/auth'; import { pollCluster } from 'vault/tests/helpers/poll-cluster'; -import { overrideResponse } from 'vault/tests/helpers/clients'; +import { overrideResponse } from 'vault/tests/helpers/stubs'; const { unsealKeys } = VAULT_KEYS; diff --git a/ui/tests/helpers/clients.js b/ui/tests/helpers/clients/client-count-helpers.js similarity index 85% rename from ui/tests/helpers/clients.js rename to ui/tests/helpers/clients/client-count-helpers.js index 20874b41cd40..4cab376307c7 100644 --- a/ui/tests/helpers/clients.js +++ b/ui/tests/helpers/clients/client-count-helpers.js @@ -3,131 +3,14 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import { Response } from 'miragejs'; -import { SELECTORS as GENERAL } from 'vault/tests/helpers/general-selectors'; import { click } from '@ember/test-helpers'; import { LICENSE_START } from 'vault/mirage/handlers/clients'; import { addMonths } from 'date-fns'; - -/** Scenarios - Config off, no data - Config on, no data - Config on, with data - Filtering (data with mounts) - Filtering (data without mounts) - Filtering (data without mounts) - * -- HISTORY ONLY -- - Filtering different date ranges (hist only) - Upgrade warning - No permissions for license - Version - queries available - queries unavailable - License start date this month -*/ -export const SELECTORS = { - ...GENERAL, - counts: { - startLabel: '[data-test-counts-start-label]', - description: '[data-test-counts-description]', - startMonth: '[data-test-counts-start-month]', - startEdit: '[data-test-counts-start-edit]', - startDropdown: '[data-test-counts-start-dropdown]', - configDisabled: '[data-test-counts-disabled]', - namespaces: '[data-test-counts-namespaces]', - mountPaths: '[data-test-counts-auth-mounts]', - startDiscrepancy: '[data-test-counts-start-discrepancy]', - }, - tokenTab: { - entity: '[data-test-monthly-new-entity]', - nonentity: '[data-test-monthly-new-nonentity]', - legend: '[data-test-monthly-new-legend]', - }, - syncTab: { - total: '[data-test-total-sync-clients]', - average: '[data-test-average-sync-clients]', - }, - charts: { - chart: (title) => `[data-test-chart="${title}"]`, // newer lineal charts - statTextValue: (label) => - label ? `[data-test-stat-text-container="${label}"] .stat-value` : '[data-test-stat-text-container]', - legend: '[data-test-chart-container-legend]', - legendLabel: (nth) => `.legend-label:nth-child(${nth * 2})`, // nth * 2 accounts for dots in legend - timestamp: '[data-test-chart-container-timestamp]', - dataBar: '[data-test-vertical-bar]', - xAxisLabel: '[data-test-x-axis] text', - // selectors for old d3 charts - verticalBar: '[data-test-vertical-bar-chart]', - lineChart: '[data-test-line-chart]', - bar: { - xAxisLabel: '[data-test-vertical-chart="x-axis-labels"] text', - dataBar: '[data-test-vertical-chart="data-bar"]', - }, - line: { - xAxisLabel: '[data-test-line-chart] [data-test-x-axis] text', - plotPoint: '[data-test-line-chart="plot-point"]', - }, - }, - usageStats: '[data-test-usage-stats]', - dateDisplay: '[data-test-date-display]', - attributionBlock: '[data-test-clients-attribution]', - filterBar: '[data-test-clients-filter-bar]', - rangeDropdown: '[data-test-calendar-widget-trigger]', - monthDropdown: '[data-test-toggle-month]', - yearDropdown: '[data-test-toggle-year]', - currentBillingPeriod: '[data-test-current-billing-period]', - dateDropdownSubmit: '[data-test-date-dropdown-submit]', - runningTotalMonthStats: '[data-test-running-total="single-month-stats"]', - runningTotalMonthlyCharts: '[data-test-running-total="monthly-charts"]', - selectedAuthMount: 'div#auth-method-search-select [data-test-selected-option] div', - selectedNs: 'div#namespace-search-select [data-test-selected-option] div', - upgradeWarning: '[data-test-clients-upgrade-warning]', -}; - -export const CHART_ELEMENTS = { - entityClientDataBars: '[data-test-group="entity_clients"]', - nonEntityDataBars: '[data-test-group="non_entity_clients"]', - yLabels: '[data-test-group="y-labels"]', - actionBars: '[data-test-group="action-bars"]', - labelActionBars: '[data-test-group="label-action-bars"]', - totalValues: '[data-test-group="total-values"]', -}; - -export function sendResponse(data, httpStatus = 200) { - if (httpStatus === 403) { - return [ - httpStatus, - { 'Content-Type': 'application/json' }, - JSON.stringify({ errors: ['permission denied'] }), - ]; - } - if (httpStatus === 204) { - // /activity endpoint returns 204 when no data, while - // /activity/monthly returns 200 with zero values on data - return [httpStatus, { 'Content-Type': 'application/json' }]; - } - return [httpStatus, { 'Content-Type': 'application/json' }, JSON.stringify(data)]; -} - -export function overrideResponse(httpStatus, data) { - if (httpStatus === 403) { - return new Response( - 403, - { 'Content-Type': 'application/json' }, - JSON.stringify({ errors: ['permission denied'] }) - ); - } - // /activity endpoint returns 204 when no data, while - // /activity/monthly returns 200 with zero values on data - if (httpStatus === 204) { - return new Response(204, { 'Content-Type': 'application/json' }); - } - return new Response(200, { 'Content-Type': 'application/json' }, JSON.stringify(data)); -} +import { CLIENT_COUNT } from './client-count-selectors'; export async function dateDropdownSelect(month, year) { - const { dateDropdown, counts } = SELECTORS; + const { dateDropdown, counts } = CLIENT_COUNT; await click(counts.startEdit); await click(dateDropdown.toggleMonth); await click(dateDropdown.selectMonth(month)); diff --git a/ui/tests/helpers/clients/client-count-selectors.ts b/ui/tests/helpers/clients/client-count-selectors.ts new file mode 100644 index 000000000000..3cf35befd881 --- /dev/null +++ b/ui/tests/helpers/clients/client-count-selectors.ts @@ -0,0 +1,87 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +// TODO: separate nested into distinct exported consts +export const CLIENT_COUNT = { + counts: { + startLabel: '[data-test-counts-start-label]', + description: '[data-test-counts-description]', + startMonth: '[data-test-counts-start-month]', + startEdit: '[data-test-counts-start-edit]', + startDropdown: '[data-test-counts-start-dropdown]', + configDisabled: '[data-test-counts-disabled]', + namespaces: '[data-test-counts-namespaces]', + mountPaths: '[data-test-counts-auth-mounts]', + startDiscrepancy: '[data-test-counts-start-discrepancy]', + }, + tokenTab: { + entity: '[data-test-monthly-new-entity]', + nonentity: '[data-test-monthly-new-nonentity]', + legend: '[data-test-monthly-new-legend]', + }, + syncTab: { + total: '[data-test-total-sync-clients]', + average: '[data-test-average-sync-clients]', + }, + charts: { + chart: (title: string) => `[data-test-chart="${title}"]`, // newer lineal charts + statTextValue: (label: string) => + label ? `[data-test-stat-text-container="${label}"] .stat-value` : '[data-test-stat-text-container]', + legend: '[data-test-chart-container-legend]', + legendLabel: (nth: number) => `.legend-label:nth-child(${nth * 2})`, // nth * 2 accounts for dots in legend + timestamp: '[data-test-chart-container-timestamp]', + dataBar: '[data-test-vertical-bar]', + xAxisLabel: '[data-test-x-axis] text', + // selectors for old d3 charts + verticalBar: '[data-test-vertical-bar-chart]', + lineChart: '[data-test-line-chart]', + bar: { + xAxisLabel: '[data-test-vertical-chart="x-axis-labels"] text', + dataBar: '[data-test-vertical-chart="data-bar"]', + }, + line: { + xAxisLabel: '[data-test-line-chart] [data-test-x-axis] text', + plotPoint: '[data-test-line-chart="plot-point"]', + }, + }, + usageStats: '[data-test-usage-stats]', + dateDisplay: '[data-test-date-display]', + attributionBlock: '[data-test-clients-attribution]', + filterBar: '[data-test-clients-filter-bar]', + rangeDropdown: '[data-test-calendar-widget-trigger]', + monthDropdown: '[data-test-toggle-month]', + yearDropdown: '[data-test-toggle-year]', + currentBillingPeriod: '[data-test-current-billing-period]', + dateDropdown: { + toggleMonth: '[data-test-toggle-month]', + toggleYear: '[data-test-toggle-year]', + selectMonth: (month: string) => `[data-test-dropdown-month="${month}"]`, + selectYear: (year: string) => `[data-test-dropdown-year="${year}"]`, + submit: '[data-test-date-dropdown-submit]', + }, + calendarWidget: { + trigger: '[data-test-calendar-widget-trigger]', + currentMonth: '[data-test-current-month]', + currentBillingPeriod: '[data-test-current-billing-period]', + customEndMonth: '[data-test-show-calendar]', + previousYear: '[data-test-previous-year]', + nextYear: '[data-test-next-year]', + calendarMonth: (month: string) => `[data-test-calendar-month="${month}"]`, + }, + runningTotalMonthStats: '[data-test-running-total="single-month-stats"]', + runningTotalMonthlyCharts: '[data-test-running-total="monthly-charts"]', + selectedAuthMount: 'div#auth-method-search-select [data-test-selected-option] div', + selectedNs: 'div#namespace-search-select [data-test-selected-option] div', + upgradeWarning: '[data-test-clients-upgrade-warning]', +}; + +export const CHART_ELEMENTS = { + entityClientDataBars: '[data-test-group="entity_clients"]', + nonEntityDataBars: '[data-test-group="non_entity_clients"]', + yLabels: '[data-test-group="y-labels"]', + actionBars: '[data-test-group="action-bars"]', + labelActionBars: '[data-test-group="label-action-bars"]', + totalValues: '[data-test-group="total-values"]', +}; diff --git a/ui/tests/helpers/codemirror.js b/ui/tests/helpers/codemirror.js index 247668079415..aba7e891893b 100644 --- a/ui/tests/helpers/codemirror.js +++ b/ui/tests/helpers/codemirror.js @@ -5,22 +5,22 @@ /* returns an instance of CodeMirror, see docs for callable functions https://codemirror.net/5/doc/manual.html#api_constructor +If you are targeting a specific CodeMirror instance, pass the selector of the parent element as an argument. sample use: import codemirror from 'vault/tests/helpers/codemirror'; test('it renders initial value', function (assert) { - - assert.strictEqual(codemirror.getValue(), 'some value') + // General use + assert.strictEqual(codemirror().getValue(), 'some other value') + // Specific selector + codemirror('#my-control').setValue('some value'); + assert.strictEqual(codemirror('#my-control').getValue(), 'some value') )} */ - -const invariant = (truthy, error) => { - if (!truthy) throw new Error(error); -}; - -export default function () { - const element = document.querySelector('.CodeMirror'); +export default function (parent) { + const selector = parent ? `${parent} .CodeMirror` : '.CodeMirror'; + const element = document.querySelector(selector); invariant(element, `Selector '.CodeMirror' matched no elements`); const cm = element.CodeMirror; @@ -28,3 +28,7 @@ export default function () { return cm; } + +const invariant = (truthy, error) => { + if (!truthy) throw new Error(error); +}; diff --git a/ui/tests/helpers/components/dashboard/dashboard-selectors.js b/ui/tests/helpers/components/dashboard/dashboard-selectors.js index 9f966c45490c..d7be836fff39 100644 --- a/ui/tests/helpers/components/dashboard/dashboard-selectors.js +++ b/ui/tests/helpers/components/dashboard/dashboard-selectors.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: BUSL-1.1 */ -export const SELECTORS = { +export const DASHBOARD = { cardName: (name) => `[data-test-card="${name}"]`, emptyState: (name) => `[data-test-empty-state="${name}"]`, emptyStateTitle: (name) => `[data-test-empty-state="${name}"] [data-test-empty-state-title]`, diff --git a/ui/tests/helpers/secret-edit-toolbar.js b/ui/tests/helpers/components/secret-edit-toolbar.js similarity index 85% rename from ui/tests/helpers/secret-edit-toolbar.js rename to ui/tests/helpers/components/secret-edit-toolbar.js index bb0797c28509..2c677dcf7c96 100644 --- a/ui/tests/helpers/secret-edit-toolbar.js +++ b/ui/tests/helpers/components/secret-edit-toolbar.js @@ -8,7 +8,7 @@ const SELECTORS = { dropdown: '[data-test-copy-menu-trigger]', wrapButton: '[data-test-wrap-button]', }; -export default async function assertSecretWrap(assert, server, path) { +export async function assertSecretWrap(assert, server, path) { server.get(path, () => { assert.ok(true, `request made to ${path} when wrapping secret`); }); diff --git a/ui/tests/helpers/components/shamir.js b/ui/tests/helpers/components/shamir-selectors.ts similarity index 100% rename from ui/tests/helpers/components/shamir.js rename to ui/tests/helpers/components/shamir-selectors.ts diff --git a/ui/tests/helpers/components/sidebar-nav.js b/ui/tests/helpers/components/sidebar-nav.js index cad0249fa95d..8202c9e61bd6 100644 --- a/ui/tests/helpers/components/sidebar-nav.js +++ b/ui/tests/helpers/components/sidebar-nav.js @@ -6,6 +6,14 @@ import { allFeatures } from 'vault/helpers/all-features'; import sinon from 'sinon'; +/** + * Sets up the necessary shared test context for testing sidebar nav components + * @param {TestContext.owner} owner eg this.owner from within a test + * @param {boolean} isEnterprise [default false] + * @param {boolean} setCluster [default false] if true, will set the current cluster to one with replication & raft + * @param {string[]} features if not passed, defaults to all features + * @returns {hasNavPermission: sinon.SinonStub, features: string[]} + */ export const stubFeaturesAndPermissions = (owner, isEnterprise = false, setCluster = false, features) => { const permissions = owner.lookup('service:permissions'); const hasNavPermission = sinon.stub(permissions, 'hasNavPermission'); diff --git a/ui/tests/helpers/components/ttl-picker.js b/ui/tests/helpers/components/ttl-picker-selectors.ts similarity index 56% rename from ui/tests/helpers/components/ttl-picker.js rename to ui/tests/helpers/components/ttl-picker-selectors.ts index 539a14df4480..bb5212dbf583 100644 --- a/ui/tests/helpers/components/ttl-picker.js +++ b/ui/tests/helpers/components/ttl-picker-selectors.ts @@ -3,17 +3,15 @@ * SPDX-License-Identifier: BUSL-1.1 */ -const selectors = { +export const TTL_PICKER = { ttlFormGroup: '[data-test-ttl-inputs]', toggle: '[data-test-ttl-toggle]', - toggleByLabel: (label) => `[data-test-ttl-toggle="${label}"]`, + toggleByLabel: (label: string) => `[data-test-ttl-toggle="${label}"]`, label: '[data-test-ttl-form-label]', subtext: '[data-test-ttl-form-subtext]', tooltipTrigger: `[data-test-tooltip-trigger]`, ttlValue: '[data-test-ttl-value]', ttlUnit: '[data-test-select="ttl-unit"]', - valueInputByLabel: (label) => `[data-test-ttl-value="${label}"]`, - unitInputByLabel: (label) => `[data-test-ttl-unit="${label}"] [data-test-select="ttl-unit"]`, + valueInputByLabel: (label: string) => `[data-test-ttl-value="${label}"]`, + unitInputByLabel: (label: string) => `[data-test-ttl-unit="${label}"] [data-test-select="ttl-unit"]`, }; - -export default selectors; diff --git a/ui/tests/helpers/config-ui/message-selectors.js b/ui/tests/helpers/config-ui/message-selectors.js deleted file mode 100644 index f33b433d3b83..000000000000 --- a/ui/tests/helpers/config-ui/message-selectors.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { SELECTORS as GENERAL } from 'vault/tests/helpers/general-selectors'; - -export const PAGE = { - // General selectors that are common between pages - ...GENERAL, - inlineErrorMessage: `[data-test-inline-error-message]`, - unauthCreateFormInfo: '[data-test-unauth-info]', - navLink: '[data-test-sidebar-nav-link="Custom Messages"]', - radio: (radioName) => `[data-test-radio="${radioName}"]`, - field: (fieldName) => `[data-test-field="${fieldName}"]`, - input: (input) => `[data-test-input="${input}"]`, - button: (buttonName) => `[data-test-button="${buttonName}"]`, - fieldValidation: (fieldName) => `[data-test-field-validation="${fieldName}"]`, - modal: (name) => `[data-test-modal="${name}"]`, - modalTitle: (title) => `[data-test-modal-title="${title}"]`, - modalBody: (name) => `[data-test-modal-body="${name}"]`, - modalButton: (name) => `[data-test-modal-button="${name}"]`, - alert: (name) => `data-test-custom-alert=${name}`, - alertTitle: (name) => `[data-test-custom-alert-title="${name}"]`, - alertDescription: (name) => `[data-test-custom-alert-description="${name}"]`, - alertAction: (name) => `[data-test-custom-alert-action="${name}"]`, - badge: (name) => `[data-test-badge="${name}"]`, - tab: (name) => `[data-test-custom-messages-tab="${name}"]`, - confirmActionButton: (name) => `[data-test-confirm-action="${name}"]`, - listItem: (name) => `[data-test-list-item="${name}"]`, -}; diff --git a/ui/tests/helpers/config-ui/message-selectors.ts b/ui/tests/helpers/config-ui/message-selectors.ts new file mode 100644 index 000000000000..7430ab71f169 --- /dev/null +++ b/ui/tests/helpers/config-ui/message-selectors.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +export const CUSTOM_MESSAGES = { + // General selectors that are common between custom messages + inlineErrorMessage: `[data-test-inline-error-message]`, + unauthCreateFormInfo: '[data-test-unauth-info]', + navLink: '[data-test-sidebar-nav-link="Custom Messages"]', + radio: (radioName: string) => `[data-test-radio="${radioName}"]`, + field: (fieldName: string) => `[data-test-field="${fieldName}"]`, + input: (input: string) => `[data-test-input="${input}"]`, + button: (buttonName: string) => `[data-test-button="${buttonName}"]`, + fieldValidation: (fieldName: string) => `[data-test-field-validation="${fieldName}"]`, + modal: (name: string) => `[data-test-modal="${name}"]`, + modalTitle: (title: string) => `[data-test-modal-title="${title}"]`, + modalBody: (name: string) => `[data-test-modal-body="${name}"]`, + modalButton: (name: string) => `[data-test-modal-button="${name}"]`, + alert: (name: string) => `data-test-custom-alert=${name}`, + alertTitle: (name: string) => `[data-test-custom-alert-title="${name}"]`, + alertDescription: (name: string) => `[data-test-custom-alert-description="${name}"]`, + alertAction: (name: string) => `[data-test-custom-alert-action="${name}"]`, + badge: (name: string) => `[data-test-badge="${name}"]`, + tab: (name: string) => `[data-test-custom-messages-tab="${name}"]`, + confirmActionButton: (name: string) => `[data-test-confirm-action="${name}"]`, + listItem: (name: string) => `[data-test-list-item="${name}"]`, +}; diff --git a/ui/tests/helpers/general-selectors.js b/ui/tests/helpers/general-selectors.js deleted file mode 100644 index ea736f61e08f..000000000000 --- a/ui/tests/helpers/general-selectors.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { findAll } from '@ember/test-helpers'; - -export const SELECTORS = { - breadcrumb: '[data-test-breadcrumbs] li', - breadcrumbAtIdx: (idx) => `[data-test-breadcrumbs] li:nth-child(${idx + 1}) a`, - breadcrumbs: '[data-test-breadcrumbs]', - breadcrumbLink: (label) => `[data-test-breadcrumb="${label}"] a`, - title: '[data-test-page-title]', - headerContainer: 'header.page-header', - icon: (name) => `[data-test-icon="${name}"]`, - tab: (name) => `[data-test-tab="${name}"]`, - filter: (name) => `[data-test-filter="${name}"]`, - filterInput: '[data-test-filter-input]', - confirmModalInput: '[data-test-confirmation-modal-input]', - confirmButton: '[data-test-confirm-button]', - confirmTrigger: '[data-test-confirm-action-trigger]', - emptyStateTitle: '[data-test-empty-state-title]', - emptyStateMessage: '[data-test-empty-state-message]', - emptyStateActions: '[data-test-empty-state-actions]', - menuTrigger: '[data-test-popup-menu-trigger]', - listItem: '[data-test-list-item-link]', - calendarWidget: { - trigger: '[data-test-calendar-widget-trigger]', - currentMonth: '[data-test-current-month]', - currentBillingPeriod: '[data-test-current-billing-period]', - customEndMonth: '[data-test-show-calendar]', - previousYear: '[data-test-previous-year]', - nextYear: '[data-test-next-year]', - calendarMonth: (month) => `[data-test-calendar-month="${month}"]`, - }, - dateDropdown: { - toggleMonth: '[data-test-toggle-month]', - toggleYear: '[data-test-toggle-year]', - selectMonth: (month) => `[data-test-dropdown-month="${month}"]`, - selectYear: (year) => `[data-test-dropdown-year="${year}"]`, - submit: '[data-test-date-dropdown-submit]', - }, - // FORMS - infoRowLabel: (label) => `[data-test-row-label="${label}"]`, - infoRowValue: (label) => `[data-test-value-div="${label}"]`, - inputByAttr: (attr) => `[data-test-input="${attr}"]`, - selectByAttr: (attr) => `[data-test-select="${attr}"]`, - fieldByAttr: (attr) => `[data-test-field="${attr}"]`, - enableField: (attr) => `[data-test-enable-field="${attr}"] button`, - ttl: { - toggle: (attr) => `[data-test-toggle-label="${attr}"]`, - input: (attr) => `[data-test-ttl-value="${attr}"]`, - }, - - validation: (attr) => `[data-test-field-validation=${attr}]`, - validationWarning: (attr) => `[data-test-validation-warning=${attr}]`, - messageError: '[data-test-message-error]', - kvObjectEditor: { - deleteRow: (idx = 0) => `[data-test-kv-delete-row="${idx}"]`, - }, - searchSelect: { - options: '.ember-power-select-option', - optionIndex: (text) => findAll('.ember-power-select-options li').findIndex((e) => e.innerText === text), - option: (index = 0) => `.ember-power-select-option:nth-child(${index + 1})`, - selectedOption: (index = 0) => `[data-test-selected-option="${index}"]`, - noMatch: '.ember-power-select-option--no-matches-message', - removeSelected: '[data-test-selected-list-button="delete"]', - }, - overviewCard: { - title: (title) => `[data-test-overview-card-title="${title}"]`, - description: (title) => `[data-test-overview-card-subtitle="${title}"]`, - content: (title) => `[data-test-overview-card-content="${title}"]`, - action: (title) => `[data-test-overview-card-container="${title}"] [data-test-action-text]`, - actionLink: (label) => `[data-test-action-text="${label}"]`, - }, - pagination: { - next: '.hds-pagination-nav__arrow--direction-next', - prev: '.hds-pagination-nav__arrow--direction-prev', - }, - kvSuggestion: { - input: '[data-test-kv-suggestion-input]', - select: '[data-test-kv-suggestion-select]', - }, - navLink: (label) => `[data-test-sidebar-nav-link="${label}"]`, - cancelButton: '[data-test-cancel]', - saveButton: '[data-test-save]', -}; diff --git a/ui/tests/helpers/general-selectors.ts b/ui/tests/helpers/general-selectors.ts new file mode 100644 index 000000000000..5e338bd16267 --- /dev/null +++ b/ui/tests/helpers/general-selectors.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { findAll } from '@ember/test-helpers'; + +export const GENERAL = { + breadcrumb: '[data-test-breadcrumbs] li', + breadcrumbAtIdx: (idx: string) => `[data-test-breadcrumbs] li:nth-child(${idx + 1}) a`, + breadcrumbs: '[data-test-breadcrumbs]', + breadcrumbLink: (label: string) => `[data-test-breadcrumb="${label}"] a`, + title: '[data-test-page-title]', + headerContainer: 'header.page-header', + icon: (name: string) => `[data-test-icon="${name}"]`, + tab: (name: string) => `[data-test-tab="${name}"]`, + secretTab: (name: string) => `[data-test-secret-list-tab="${name}"]`, + + filter: (name: string) => `[data-test-filter="${name}"]`, + filterInput: '[data-test-filter-input]', + confirmModalInput: '[data-test-confirmation-modal-input]', + confirmButton: '[data-test-confirm-button]', + confirmTrigger: '[data-test-confirm-action-trigger]', + emptyStateTitle: '[data-test-empty-state-title]', + emptyStateMessage: '[data-test-empty-state-message]', + emptyStateActions: '[data-test-empty-state-actions]', + menuTrigger: '[data-test-popup-menu-trigger]', + listItem: '[data-test-list-item-link]', + // FORMS + infoRowLabel: (label: string) => `[data-test-row-label="${label}"]`, + infoRowValue: (label: string) => `[data-test-value-div="${label}"]`, + inputByAttr: (attr: string) => `[data-test-input="${attr}"]`, + selectByAttr: (attr: string) => `[data-test-select="${attr}"]`, + checkboxByAttr: (attr: string) => `[data-test-checkbox="${attr}"]`, + fieldByAttr: (attr: string) => `[data-test-field="${attr}"]`, + enableField: (attr: string) => `[data-test-enable-field="${attr}"] button`, + ttl: { + toggle: (attr: string) => `[data-test-toggle-label="${attr}"]`, + input: (attr: string) => `[data-test-ttl-value="${attr}"]`, + }, + + validation: (attr: string) => `[data-test-field-validation=${attr}]`, + validationWarning: (attr: string) => `[data-test-validation-warning=${attr}]`, + messageError: '[data-test-message-error]', + kvObjectEditor: { + deleteRow: (idx = 0) => `[data-test-kv-delete-row="${idx}"]`, + }, + searchSelect: { + options: '.ember-power-select-option', + optionIndex: (text: string) => + findAll('.ember-power-select-options li').findIndex((e) => e.textContent?.trim() === text), + option: (index = 0) => `.ember-power-select-option:nth-child(${index + 1})`, + selectedOption: (index = 0) => `[data-test-selected-option="${index}"]`, + noMatch: '.ember-power-select-option--no-matches-message', + removeSelected: '[data-test-selected-list-button="delete"]', + }, + overviewCard: { + title: (title: string) => `[data-test-overview-card-title="${title}"]`, + description: (title: string) => `[data-test-overview-card-subtitle="${title}"]`, + content: (title: string) => `[data-test-overview-card-content="${title}"]`, + action: (title: string) => `[data-test-overview-card-container="${title}"] [data-test-action-text]`, + actionLink: (label: string) => `[data-test-action-text="${label}"]`, + }, + pagination: { + next: '.hds-pagination-nav__arrow--direction-next', + prev: '.hds-pagination-nav__arrow--direction-prev', + }, + kvSuggestion: { + input: '[data-test-kv-suggestion-input]', + select: '[data-test-kv-suggestion-select]', + }, + navLink: (label: string) => `[data-test-sidebar-nav-link="${label}"]`, + cancelButton: '[data-test-cancel]', + saveButton: '[data-test-save]', +}; diff --git a/ui/tests/helpers/kubernetes/overview.js b/ui/tests/helpers/kubernetes/kubernetes-selectors.ts similarity index 74% rename from ui/tests/helpers/kubernetes/overview.js rename to ui/tests/helpers/kubernetes/kubernetes-selectors.ts index 60fc2df2bb1e..38b9567d7405 100644 --- a/ui/tests/helpers/kubernetes/overview.js +++ b/ui/tests/helpers/kubernetes/kubernetes-selectors.ts @@ -3,7 +3,8 @@ * SPDX-License-Identifier: BUSL-1.1 */ -export const SELECTORS = { +export const KUBERNETES_OVERVIEW = { + // Page::Overview in the kubernetes engine rolesCardTitle: '[data-test-overview-card-title="Roles"]', rolesCardSubTitle: '[data-test-overview-card-subtitle="Roles"]', rolesCardLink: '[data-test-overview-card="Roles"] a', @@ -11,7 +12,4 @@ export const SELECTORS = { generateCredentialsCardTitle: '[data-test-overview-card-title="Generate credentials"]', generateCredentialsCardSubTitle: '[data-test-overview-card-subtitle="Generate credentials"]', generateCredentialsCardButton: '[data-test-generate-credential-button]', - emptyStateTitle: '.empty-state .empty-state-title', - emptyStateMessage: '.empty-state .empty-state-message', - emptyStateActionText: '.empty-state .empty-state-actions', }; diff --git a/ui/tests/helpers/policy-generator/kv.js b/ui/tests/helpers/kv/policy-generator.js similarity index 100% rename from ui/tests/helpers/policy-generator/kv.js rename to ui/tests/helpers/kv/policy-generator.js diff --git a/ui/tests/helpers/ldap.js b/ui/tests/helpers/ldap/ldap-helpers.js similarity index 100% rename from ui/tests/helpers/ldap.js rename to ui/tests/helpers/ldap/ldap-helpers.js diff --git a/ui/tests/helpers/mirage-to-models.js b/ui/tests/helpers/mirage-to-models.js deleted file mode 100644 index f754fa240b47..000000000000 --- a/ui/tests/helpers/mirage-to-models.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { getContext } from '@ember/test-helpers'; - -export default (data) => { - const context = getContext(); - const store = context.owner.lookup('service:store'); - const modelName = Array.isArray(data) ? data[0].modelName : data.modelName; - const json = context.server.serializerOrRegistry.serialize(data); - store.push(json); - return Array.isArray(data) - ? data.map(({ id }) => store.peekRecord(modelName, id)) - : store.peekRecord(modelName, data.id); -}; diff --git a/ui/tests/helpers/noop-all-api-requests.js b/ui/tests/helpers/noop-all-api-requests.js deleted file mode 100644 index 88e44034083f..000000000000 --- a/ui/tests/helpers/noop-all-api-requests.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Pretender from 'pretender'; -import { noopStub } from './stubs'; - -/** - * DEPRECATED prefer to use `setupMirage` along with stubs in vault/tests/helpers/stubs - */ -export default function (options = { usePassthrough: false }) { - return new Pretender(function () { - let fn = noopStub(); - if (options.usePassthrough) { - fn = this.passthrough; - } - this.post('/v1/**', fn); - this.put('/v1/**', fn); - this.get('/v1/**', fn); - this.delete('/v1/**', fn || noopStub(204)); - }); -} diff --git a/ui/tests/helpers/oidc-config.js b/ui/tests/helpers/oidc-config.js index a226d8e1df8d..f16af74b3635 100644 --- a/ui/tests/helpers/oidc-config.js +++ b/ui/tests/helpers/oidc-config.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import { Response } from 'miragejs'; +import { debug } from '@ember/debug'; export const OIDC_BASE_URL = `/vault/access/oidc`; @@ -57,49 +57,6 @@ export const SELECTORS = { providerClientsTab: '[data-test-oidc-provider-clients]', }; -export function overrideMirageResponse(httpStatus, data) { - if (httpStatus === 403) { - return new Response( - 403, - { 'Content-Type': 'application/json' }, - JSON.stringify({ errors: ['permission denied'] }) - ); - } - if (httpStatus === 404) { - return new Response(404, { 'Content-Type': 'application/json' }); - } - if (httpStatus === 200) { - return new Response(200, { 'Content-Type': 'application/json' }, JSON.stringify(data)); - } - return { - request_id: crypto.randomUUID(), - lease_id: '', - renewable: false, - lease_duration: 0, - wrap_info: null, - warnings: null, - auth: null, - data: { ...data }, - }; -} - -export function overrideCapabilities(requestPath, capabilitiesArray) { - // sample of capabilitiesArray: ['read', 'update'] - return { - request_id: '40f7e44d-af5c-9b60-bd20-df72eb17e294', - lease_id: '', - renewable: false, - lease_duration: 0, - data: { - capabilities: capabilitiesArray, - [requestPath]: capabilitiesArray, - }, - wrap_info: null, - warnings: null, - auth: null, - }; -} - export async function clearRecord(store, modelType, id) { await store .findRecord(modelType, id) @@ -107,6 +64,7 @@ export async function clearRecord(store, modelType, id) { deleteModelRecord(model); }) .catch(() => { + debug(`Clearing record failed for ${modelType} with id: ${id}`); // swallow error }); } diff --git a/ui/tests/helpers/openapi/auth-model-attributes.js b/ui/tests/helpers/openapi/expected-auth-attrs.js similarity index 99% rename from ui/tests/helpers/openapi/auth-model-attributes.js rename to ui/tests/helpers/openapi/expected-auth-attrs.js index d4ca32c3ee3f..69317a166d09 100644 --- a/ui/tests/helpers/openapi/auth-model-attributes.js +++ b/ui/tests/helpers/openapi/expected-auth-attrs.js @@ -3,6 +3,10 @@ * SPDX-License-Identifier: BUSL-1.1 */ +// The constants within this file represent the expected model attributes as parsed from OpenAPI +// if changes are made to the OpenAPI spec, that may result in changes that must be reflected +// here AND ensured to not cause breaking changes within the UI. + const userpass = { user: { username: { diff --git a/ui/tests/helpers/openapi/secret-model-attributes.js b/ui/tests/helpers/openapi/expected-secret-attrs.js similarity index 100% rename from ui/tests/helpers/openapi/secret-model-attributes.js rename to ui/tests/helpers/openapi/expected-secret-attrs.js diff --git a/ui/tests/helpers/openapi/test-helpers.js b/ui/tests/helpers/openapi/test-helpers.js deleted file mode 100644 index 04307aea4f52..000000000000 --- a/ui/tests/helpers/openapi/test-helpers.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import authModelAttributes from './auth-model-attributes'; -import secretModelAttributes from './secret-model-attributes'; - -export const secretEngineHelper = (test, secretEngine) => { - const engineData = secretModelAttributes[secretEngine]; - if (!engineData) - throw new Error(`No engine attributes found in secret-model-attributes for ${secretEngine}`); - - const modelNames = Object.keys(engineData); - // A given secret engine might have multiple models that are openApi driven - modelNames.forEach((modelName) => { - test(`${modelName} model getProps returns correct attributes`, async function (assert) { - const model = this.store.createRecord(modelName, {}); - const helpUrl = model.getHelpUrl(this.backend); - const result = await this.pathHelp.getProps(helpUrl, this.backend); - const expected = engineData[modelName]; - assert.deepEqual(result, expected, `getProps returns expected attributes for ${modelName}`); - }); - }); -}; - -export const authEngineHelper = (test, authBackend) => { - const authData = authModelAttributes[authBackend]; - if (!authData) throw new Error(`No auth attributes found in auth-model-attributes for ${authBackend}`); - - const itemNames = Object.keys(authData); - itemNames.forEach((itemName) => { - if (itemName.startsWith('auth-config/')) { - // Config test doesn't need to instantiate a new model - test(`${itemName} model`, async function (assert) { - const model = this.store.createRecord(itemName, {}); - const helpUrl = model.getHelpUrl(this.mount); - const result = await this.pathHelp.getProps(helpUrl, this.mount); - const expected = authData[itemName]; - assert.deepEqual(result, expected, `getProps returns expected attributes for ${itemName}`); - }); - } else { - test.skip(`generated-${itemName}-${authBackend} model`, async function (assert) { - const modelName = `generated-${itemName}-${authBackend}`; - // Generated items need to instantiate the model first via getNewModel - await this.pathHelp.getNewModel(modelName, this.mount, `auth/${this.mount}/`, itemName); - const model = this.store.createRecord(modelName, {}); - // Generated items don't have this method -- helpUrl is calculated in path-help.js line 101 - const helpUrl = model.getHelpUrl(this.mount); - const result = await this.pathHelp.getProps(helpUrl, this.mount); - const expected = authData[modelName]; - assert.deepEqual(result, expected, `getProps returns expected attributes for ${modelName}`); - }); - } - }); -}; diff --git a/ui/tests/helpers/pagination.js b/ui/tests/helpers/pagination.js new file mode 100644 index 000000000000..a196468ae11b --- /dev/null +++ b/ui/tests/helpers/pagination.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +export const STANDARD_META = { + total: 2, + currentPage: 1, + pageSize: 100, +}; diff --git a/ui/tests/helpers/pki.js b/ui/tests/helpers/pki.js deleted file mode 100644 index 441fa6131a32..000000000000 --- a/ui/tests/helpers/pki.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - caChain: '[data-test-value-div="CA chain"] [data-test-certificate-card]', - certificate: '[data-test-value-div="Certificate"] [data-test-certificate-card]', - commonName: '[data-test-row-value="Common name"]', - csr: '[data-test-value-div="CSR"] [data-test-certificate-card]', - expiryDate: '[data-test-row-value="Expiration date"]', - issueDate: '[data-test-row-value="Issue date"]', - issuingCa: '[data-test-value-div="Issuing CA"] [data-test-certificate-card]', - privateKey: '[data-test-value-div="Private key"] [data-test-certificate-card]', - revocationTime: '[data-test-row-value="Revocation time"]', - serialNumber: '[data-test-row-value="Serial number"]', -}; - -export const STANDARD_META = { - total: 2, - currentPage: 1, - pageSize: 100, -}; diff --git a/ui/tests/helpers/pki/overview.js b/ui/tests/helpers/pki/overview.js deleted file mode 100644 index e3cd1f251d4a..000000000000 --- a/ui/tests/helpers/pki/overview.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - issuersCardTitle: '[data-test-overview-card-title="Issuers"]', - issuersCardSubtitle: '[data-test-overview-card-subtitle="Issuers"]', - issuersCardLink: '[data-test-overview-card-container="Issuers"] a', - issuersCardOverviewNum: '[data-test-overview-card-container="Issuers"] h2', - rolesCardTitle: '[data-test-overview-card-title="Roles"]', - rolesCardSubtitle: '[data-test-overview-card-subtitle="Roles"]', - rolesCardLink: '[data-test-overview-card-container="Roles"] a', - rolesCardOverviewNum: '[data-test-overview-card-container="Roles"] h2', - issueCertificate: '[data-test-overview-card-title="Issue certificate"]', - issueCertificateInput: '[data-test-issue-certificate-input]', - issueCertificatePowerSearch: '[data-test-issue-certificate-input] span', - issueCertificateButton: '[data-test-issue-certificate-button]', - viewCertificate: '[data-test-overview-card-title="View certificate"]', - viewCertificateInput: '[data-test-view-certificate-input]', - viewCertificatePowerSearch: '[data-test-view-certificate-input] span', - viewCertificateButton: '[data-test-view-certificate-button]', - viewIssuerInput: '[data-test-issue-issuer-input]', - viewIssuerPowerSearch: '[data-test-issue-issuer-input] span', - viewIssuerButton: '[data-test-view-issuer-button]', - firstPowerSelectOption: '[data-option-index="0"]', -}; diff --git a/ui/tests/helpers/pki/page/pki-configuration-edit.js b/ui/tests/helpers/pki/page/pki-configuration-edit.js deleted file mode 100644 index ac63caf01828..000000000000 --- a/ui/tests/helpers/pki/page/pki-configuration-edit.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - errorBanner: '[data-test-config-edit-error]', - acmeEditSection: '[data-test-acme-edit-section]', - configEditSection: '[data-test-cluster-config-edit-section]', - configInput: (attr) => `[data-test-input="${attr}"]`, - stringListInput: (attr) => `[data-test-input="${attr}"] [data-test-string-list-input="0"]`, - urlsEditSection: '[data-test-urls-edit-section]', - urlFieldInput: (attr) => `[data-test-input="${attr}"] textarea`, - urlFieldLabel: (attr) => `[data-test-input="${attr}"] label`, - crlEditSection: '[data-test-crl-edit-section]', - crlToggleInput: (attr) => `[data-test-input="${attr}"] input`, - crlTtlInput: (attr) => `[data-test-ttl-value="${attr}"]`, - crlFieldLabel: (attr) => `[data-test-input="${attr}"] label`, - saveButton: '[data-test-configuration-edit-save]', - cancelButton: '[data-test-configuration-edit-cancel]', - validationAlert: '[data-test-configuration-edit-validation-alert]', - deleteButton: (attr) => `[data-test-input="${attr}"] [data-test-string-list-button="delete"]`, - groupHeader: (group) => `[data-test-crl-header="${group}"]`, - checkboxInput: (attr) => `[data-test-input="${attr}"]`, -}; diff --git a/ui/tests/helpers/pki/page/pki-keys.js b/ui/tests/helpers/pki/page/pki-keys.js deleted file mode 100644 index 6026f9bcde98..000000000000 --- a/ui/tests/helpers/pki/page/pki-keys.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - // key index - importKey: '[data-test-pki-key-import]', - generateKey: '[data-test-pki-key-generate]', - keyId: '[data-test-key="id"]', - keyName: '[data-test-key="name"]', - popupMenuTrigger: '[data-test-popup-menu-trigger]', - popupMenuDetails: '[data-test-key-menu-link="details"]', - popupMenuEdit: '[data-test-key-menu-link="edit"]', - // key details - title: '[data-test-key-details-title]', - keyIdValue: '[data-test-value-div="Key ID"]', - keyNameValue: '[data-test-value-div="Key name"]', - keyTypeValue: '[data-test-value-div="Key type"]', - keyBitsValue: '[data-test-value-div="Key bits"]', - keyDeleteButton: '[data-test-pki-key-delete]', - downloadButton: '[data-test-download-button]', - keyEditLink: '[data-test-pki-key-edit]', - confirmDelete: '[data-test-confirm-button]', - nextStepsAlert: '[data-test-pki-key-next-steps]', -}; diff --git a/ui/tests/helpers/pki/page/pki-role-details.js b/ui/tests/helpers/pki/page/pki-role-details.js deleted file mode 100644 index 52b4d0eadc18..000000000000 --- a/ui/tests/helpers/pki/page/pki-role-details.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - issuerLabel: '[data-test-row-label="Issuer"]', - noStoreValue: '[data-test-value-div="Store in storage backend"]', - keyUsageValue: '[data-test-value-div="Key usage"]', - extKeyUsageValue: '[data-test-value-div="Ext key usage"]', - customTtlValue: '[data-test-value-div="Issued certificates expire after"]', -}; diff --git a/ui/tests/helpers/pki/page/pki-tidy-form.js b/ui/tests/helpers/pki/page/pki-tidy-form.js deleted file mode 100644 index e1c4f754ceba..000000000000 --- a/ui/tests/helpers/pki/page/pki-tidy-form.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - tidyFormName: (attr) => `[data-test-tidy-form="${attr}"]`, - inputByAttr: (attr) => `[data-test-input="${attr}"]`, - toggleInput: (attr) => `[data-test-input="${attr}"] input`, - intervalDuration: '[data-test-ttl-value="Automatic tidy enabled"]', - acmeAccountSafetyBuffer: '[data-test-ttl-value="Tidy ACME enabled"]', - toggleLabel: (label) => `[data-test-toggle-label="${label}"]`, - tidySectionHeader: (header) => `[data-test-tidy-header="${header}"]`, - tidySave: '[data-test-pki-tidy-button]', - tidyCancel: '[data-test-pki-tidy-cancel]', - tidyPauseDuration: '[data-test-ttl-value="Pause duration"]', - editAutoTidyButton: '[data-test-pki-edit-tidy-auto-link]', -}; diff --git a/ui/tests/helpers/pki/page/pki-tidy.js b/ui/tests/helpers/pki/page/pki-tidy.js deleted file mode 100644 index 901c3edf4e63..000000000000 --- a/ui/tests/helpers/pki/page/pki-tidy.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ -import { SELECTORS as TIDY_FORM } from './pki-tidy-form'; - -export const SELECTORS = { - hdsAlertTitle: '[data-test-tidy-status-alert-title]', - hdsAlertDescription: '[data-test-tidy-status-alert-description]', - alertUpdatedAt: '[data-test-tidy-status-alert-updated-at]', - cancelTidyAction: '[data-test-cancel-tidy-action]', - hdsAlertButtonText: '[data-test-cancel-tidy-action] .hds-button__text', - timeStartedRow: '[data-test-value-div="Time started"]', - timeFinishedRow: '[data-test-value-div="Time finished"]', - cancelTidyModalBackground: '#pki-cancel-tidy-modal', - tidyEmptyStateConfigure: '[data-test-tidy-empty-state-configure]', - manualTidyToolbar: '[data-test-pki-manual-tidy-config]', - autoTidyToolbar: '[data-test-pki-auto-tidy-config]', - tidyConfigureModal: { - configureTidyModal: '#pki-tidy-modal', - tidyModalAutoButton: '[data-test-tidy-modal-auto-button]', - tidyModalManualButton: '[data-test-tidy-modal-manual-button]', - tidyModalCancelButton: '[data-test-tidy-modal-cancel-button]', - tidyOptionsModal: '[data-test-pki-tidy-options-modal]', - }, - tidyEmptyState: '[data-test-component="empty-state"]', - tidyForm: { - ...TIDY_FORM, - }, -}; diff --git a/ui/tests/helpers/pki/pki-configure-create.js b/ui/tests/helpers/pki/pki-configure-create.js deleted file mode 100644 index 209b32db4a33..000000000000 --- a/ui/tests/helpers/pki/pki-configure-create.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { SELECTORS as GENERATE_ROOT } from './pki-generate-root'; - -export const SELECTORS = { - // page::pki-configure-create - breadcrumbContainer: '[data-test-breadcrumbs]', - title: '[data-test-pki-engine-page-title]', - option: '[data-test-pki-config-option]', - optionByKey: (key) => `[data-test-pki-config-option="${key}"]`, - cancelButton: '[data-test-pki-config-cancel]', - saveButton: '[data-test-pki-config-save]', - doneButton: '[data-test-done]', - configureButton: '[data-test-configure-pki-button]', - // pki-generate-root - ...GENERATE_ROOT, - generateRootOption: '[data-test-pki-config-option="generate-root"]', - // pki-ca-cert-import - importForm: '[data-test-pki-import-pem-bundle-form]', - importSubmit: '[data-test-pki-import-pem-bundle]', - importSectionLabel: '[data-test-import-section-label]', - importMapping: '[data-test-imported-bundle-mapping]', - importedIssuer: '[data-test-imported-issuer]', - importedKey: '[data-test-imported-key]', - // generate-intermediate - csrDetails: '[data-test-generate-csr-result]', -}; diff --git a/ui/tests/helpers/pki/pki-delete-all-issuers.js b/ui/tests/helpers/pki/pki-delete-all-issuers.js deleted file mode 100644 index 22112e27847d..000000000000 --- a/ui/tests/helpers/pki/pki-delete-all-issuers.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - issuerLink: '[data-test-delete-all-issuers-link]', - deleteAllIssuerModal: '#confirmation-modal', - deleteAllIssuerInput: '[data-test-confirmation-modal-input="Delete all issuers?"]', - deleteAllIssuerButton: '[data-test-confirm-button="Delete all issuers?"]', -}; diff --git a/ui/tests/helpers/pki/pki-generate-root.js b/ui/tests/helpers/pki/pki-generate-root.js deleted file mode 100644 index 45cfc05f5f8c..000000000000 --- a/ui/tests/helpers/pki/pki-generate-root.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - mainSectionTitle: '[data-test-generate-root-title="Root parameters"]', - urlSectionTitle: '[data-test-generate-root-title="Issuer URLs"]', - keyParamsGroupToggle: '[data-test-toggle-group="Key parameters"]', - sanGroupToggle: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', - additionalGroupToggle: '[data-test-toggle-group="Additional subject fields"]', - toggleGroupDescription: '[data-test-toggle-group-description]', - formField: '[data-test-field]', - typeField: '[data-test-input="type"]', - inputByName: (name) => `[data-test-input="${name}"]`, - fieldByName: (name) => `[data-test-field="${name}"]`, - generateRootSave: '[data-test-pki-generate-root-save]', - generateRootCancel: '[data-test-pki-generate-root-cancel]', - generateRootCommonNameField: '[data-test-input="commonName"]', - generateRootIssuerNameField: '[data-test-input="issuerName"]', - formInvalidError: '[data-test-pki-generate-root-validation-error]', - urlsSection: '[data-test-urls-section]', - urlField: '[data-test-urls-section] [data-test-input]', - // Shown values after save - saved: { - certificate: '[data-test-value-div="Certificate"] [data-test-certificate-card]', - commonName: '[data-test-row-value="Common name"]', - issuerName: '[data-test-row-value="Issuer name"]', - issuerLink: '[data-test-value-div="Issuer ID"] a', - keyName: '[data-test-row-value="Key name"]', - keyLink: '[data-test-value-div="Key ID"] a', - privateKey: '[data-test-value-div="Private key"] [data-test-certificate-card]', - serialNumber: '[data-test-row-value="Serial number"]', - }, -}; diff --git a/ui/tests/helpers/pki/pki-helpers.ts b/ui/tests/helpers/pki/pki-helpers.ts new file mode 100644 index 000000000000..3552e93e748e --- /dev/null +++ b/ui/tests/helpers/pki/pki-helpers.ts @@ -0,0 +1,251 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import type StoreService from 'vault/services/store'; + +export const PKI_BASE_URL = `/vault/cluster/secrets/backend/pki/roles`; + +// Clears pki-related data and capabilities so that admin +// capabilities from setup don't rollover +export function clearRecords(store: StoreService) { + store.unloadAll('pki/action'); + store.unloadAll('pki/issuer'); + store.unloadAll('pki/key'); + store.unloadAll('pki/role'); + store.unloadAll('pki/sign-intermediate'); + store.unloadAll('pki/tidy'); + store.unloadAll('pki/config/urls'); + store.unloadAll('pki/config/crl'); + store.unloadAll('pki/config/cluster'); + store.unloadAll('pki/config/acme'); + store.unloadAll('pki/certificate/generate'); + store.unloadAll('pki/certificate/sign'); + store.unloadAll('capabilities'); +} + +/** + * The following are certificate values used for testing. They are exported under the CERTIFICATES object. + */ +// Expires Jan 10, 2033 +const rootPem = `-----BEGIN CERTIFICATE----- +MIIDezCCAmOgAwIBAgIUTBbQcZijQsmd0rjd6COikP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eeTdPl +H7TEkMEomRvt7NTRHGYRsm3Gzq4AA6PalzIxzwJrNgXfJDutNn/QwcVd5sImwYCO +GaHsOvGfc02w+Vqqva9EOEQSr6B90kA+vc30I6uSiugzV9TFAgMBAAGgKTAnBgkq +hkiG9w0BCQ4xGjAYMBYGA1UdEQQPMA2CC2V4YW1wbGUuY29tMA0GCSqGSIb3DQEB +CwUAA4IBAQAjm6JTU7axU6TzLlXlOp7hZ4+nep2/8vvJ9EOXzL8x/qtTTizctdG9 +Op70gywoUxAS2tatwa4fmW9DbA2eGiLU+Ibj/5b0Veq5DQdp1Qg3MLBP/+AcM/7m +rrgA9MhkpQahXCj4vXo6NeXYaTh6Jo/s8C9h3WxTD6ptDMiaPFcEuWcx0e3AjjH0 +pe7k9/MfB2wLfQ7+5wee/tCFWZN4tk8YfjQeQA1extXYKM/f8eu3Z/wjbbMOVpwb +xst+VTY7X9T8cU/hjDEoNG677meI+W5MgiwX0rxTpoz991fqr3vp7PELYj3GMyii +D1YfvqXieNij4UrduRqCXj1m8SVZlM+X +-----END CERTIFICATE REQUEST-----`; + +const componentPemBundle = `-----BEGIN CERTIFICATE----- +MIIDGjCCAgKgAwIBAgIUFvnhb2nQ8+KNS3SzjlfYDMHGIRgwDQYJKoZIhvcNAQEL +BQAwDTELMAkGA1UEAxMCZmEwHhcNMTgwMTEwMTg1NDI5WhcNMTgwMjExMTg1NDU5 +WjANMQswCQYDVQQDEwJmYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +AN2VtBn6EMlA4aYre/xoKHxlgNDxJnfSQWfs6yF/K201qPnt4QF9AXChatbmcKVn +OaURq+XEJrGVgF/u2lSos3NRZdhWVe8o3/sOetsGxcrd0gXAieOSmkqJjp27bYdl +uY3WsxhyiPvdfS6xz39OehsK/YCB6qCzwB4eEfSKqbkvfDL9sLlAiOlaoHC9pczf +6/FANKp35UDwInSwmq5vxGbnWk9zMkh5Jq6hjOWHZnVc2J8J49PYvkIM8uiHDgOE +w71T2xM5plz6crmZnxPCOcTKIdF7NTEP2lUfiqc9lONV9X1Pi4UclLPHJf5bwTmn +JaWgbKeY+IlF61/mgxzhC7cCAwEAAaNyMHAwDgYDVR0PAQH/BAQDAgEGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFLDtc6+HZN2lv60JSDAZq3+IHoq7MB8GA1Ud +IwQYMBaAFLDtc6+HZN2lv60JSDAZq3+IHoq7MA0GA1UdEQQGMASCAmZhMA0GCSqG +SIb3DQEBCwUAA4IBAQDVt6OddTV1MB0UvF5v4zL1bEB9bgXvWx35v/FdS+VGn/QP +cC2c4ZNukndyHhysUEPdqVg4+up1aXm4eKXzNmGMY/ottN2pEhVEWQyoIIA1tH0e +8Kv/bysYpHZKZuoGg5+mdlHS2p2Dh2bmYFyBLJ8vaeP83NpTs2cNHcmEvWh/D4UN +UmYDODRN4qh9xYruKJ8i89iMGQfbdcq78dCC4JwBIx3bysC8oF4lqbTYoYNVTnAi +LVqvLdHycEOMlqV0ecq8uMLhPVBalCmIlKdWNQFpXB0TQCsn95rCCdi7ZTsYk5zv +Q4raFvQrZth3Cz/X5yPTtQL78oBYrmHzoQKDFJ2z +-----END CERTIFICATE-----`; + +// for parse-pki-cert tests: +// certificate contains all allowable params +const loadedCert = `-----BEGIN CERTIFICATE-----\nMIIE7TCCA9WgAwIBAgIULcrWXSz3/kG81EgBo0A4Zt+ZgkYwDQYJKoZIhvcNAQEL\nBQAwga0xDzANBgNVBAYTBkZyYW5jZTESMBAGA1UECBMJQ2hhbXBhZ25lMQ4wDAYD\nVQQHEwVQYXJpczETMBEGA1UECRMKMjM0IHNlc2FtZTEPMA0GA1UEERMGMTIzNDU2\nMQ8wDQYDVQQKEwZXaWRnZXQxEDAOBgNVBAsTB0ZpbmFuY2UxGDAWBgNVBAMTD2Nv\nbW1vbi1uYW1lLmNvbTETMBEGA1UEBRMKY2VyZWFsMTI5MjAeFw0yMzAyMDMxNzI3\nMzNaFw0yMzAzMDcxNzI4M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OFdm0M\nmRzrDeabqGKoRBcsqcNBN8osrwVuyrg65Di87lUgmtVnWAp6YOztb/1YjOnSJKPN\nwh9adTLUOmT4AXweFeiTwJuEd84aBtBnoNxc4gl5vhdqsn2yAsk0C6F1wdGA/ROQ\n+I57BsEb0iyHWncX6mQje+NCThyCGaKUC4SQxzY0I03LqrVvBIQtVCcyIwIDAQAB\no38wfTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU\nCysygW7q23WnJvHH2WfrDlAr/a0wHwYDVR0jBBgwFoAUCysygW7q23WnJvHH2Wfr\nDlAr/a0wGgYDVR0RBBMwEYIPY29tbW9uLW5hbWUuY29tMA0GCSqGSIb3DQEBCwUA\nA4IBAQDPco+FIHXczf0HTwFAmIVu4HKaeIwDsVPxoUqqWEix8AyCsB5uqpKZasby\nedlrdBohM4dnoV+VmV0de04y95sdo3Ot60hm/czLog3tHg4o7AmfA7saS+5hCL1M\nCJWqoJHRFo0hOWJHpLJRWz5DqRZWspASoVozLOYyjRD+tNBjO5hK4FtaG6eri38t\nOpTt7sdInVODlntpNuuCVprPpHGj4kPOcViQULoFQq5fwyadpdjqSXmEGlt0to5Y\nMbTb4Jhj0HywgO53BUUmMzzY9idXh/8A7ThrM5LtqhxaYHLVhyeo+5e0mgiXKp+n\nQ8Uh4TNNTCvOUlAHycZNaxYTlEPn\n-----END CERTIFICATE-----`; +// contains unsupported subject and extension OIDs +const unsupportedOids = `-----BEGIN CERTIFICATE-----\nMIIEjDCCA3SgAwIBAgIUD4EeORgh/i+ZZFOk8KsGKQPWsoIwDQYJKoZIhvcNAQEL\nBQAwgZIxMTAvBgNVBAMMKGZhbmN5LWNlcnQtdW5zdXBwb3J0ZWQtc3Viai1hbmQt\nZXh0LW9pZHMxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZLYW5zYXMxDzANBgNVBAcM\nBlRvcGVrYTESMBAGA1UECgwJQWNtZSwgSW5jMRowGAYJKoZI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ZT/dcLlVeFejVXu5\nR+IPLmQU6NV7JAmy4zGap8awf12QTy3g410ecrSF94WWlu8bPoekfUnnP+kfzLPH\nCUAkRKxWDSRKX5C8cMMxacVBBaBIayuusLcHkHmxLLDw34PFzyz61gtZOJq7JYnD\nhU9YsNh6bCDmnBDBsDMOI7h8lBRQwTiWVoSD9YNVvFiY29YvFbJQGdh+pmBtf7E+\n1B/0t5NbvqlQSbhMM0QgYFhuCxr3BGNob7kRjgW4i+oh+Nc5ptA5q70QMaYudqRS\nd8SYWhRdxmH3qcHNPcR1iw==\n-----END CERTIFICATE-----`; +// unsupportedPem is same cert as above, formatted differently +const unsupportedPem = ` +-----BEGIN CERTIFICATE----- +MIIEjDCCA3SgAwIBAgIUD4EeORgh/i+ZZFOk8KsGKQPWsoIwDQYJKoZIhvcNAQEL +BQAwgZIxMTAvBgNVBAMMKGZhbmN5LWNlcnQtdW5zdXBwb3J0ZWQtc3Viai1hbmQt +ZXh0LW9pZHMxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZLYW5zYXMxDzANBgNVBAcM +BlRvcGVrYTESMBAGA1UECgwJQWNtZSwgSW5jMRowGAYJKoZIhvcNAQkBFgtmb29A +YmFyLmNvbTAeFw0yMzAxMjMxODQ3MjNaFw0zMzAxMjAxODQ3MjNaMIGSMTEwLwYD +VQQDDChmYW5jeS1jZXJ0LXVuc3VwcG9ydGVkLXN1YmotYW5kLWV4dC1vaWRzMQsw +CQYDVQQGEwJVUzEPMA0GA1UECAwGS2Fuc2FzMQ8wDQYDVQQHDAZUb3Bla2ExEjAQ +BgNVBAoMCUFjbWUsIEluYzEaMBgGCSqGSIb3DQEJARYLZm9vQGJhci5jb20wggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDyYH5qS7krfZ2tA5uZsY2qXbTb +tGNG1BsyDhZ/qqVlQybjDsHJZwNUbpfhBcCLaKyAwH1R9n54NOOOn6bYgfKWTgy3 +L7224YDAqYe7Y/GPjgI2MRvRf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SIGNING: +const newCSR = { + common_name: 'Short-Lived Int R1', + csr: `-----BEGIN CERTIFICATE REQUEST-----\nMIICYjCCAUoCAQAwHTEbMBkGA1UEAxMSU2hvcnQtTGl2ZWQgSW50IFIxMIIBIjAN\nBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqsvFU7lzt06n1w6BL+Waf9zd+Z3G\n90Kv0HAksoLaWYinhkxNIUTU8ar9HLa2WV4EoJbNq91Hn+jFc2SYEXtRV+jm0kEh\nz4C4AoQ4D0s83JcYNssiNbVA04wa5ovD0iA/pzwVz8TnJSfAAuZ3vXFlyIbQ3ESo\nzt9hGjo/JOpoBh67E7xkuzw4lnC2rXGHdh9pk1Di+wqREnKU4nuhDLnTC/LL+Mkm\n07F1aMAW3Z/PWFmmsDJHMhZnaYo2LGCwU4A0U1ED0XpwflobVbkzZDmCXOPEI8UX\nG6VcL36zWnzEQnlZKN91MAa+s0E4z40KHKVSblSkjYD1K6n0y787ic2mDwIDAQAB\noAAwDQYJKoZIhvcNAQELBQADggEBAFQtiJaRfaQS3jHr7aFeszB/JmDRQiOoML3g\nhA3EcVd2rvDjiqikwD9EFdLTJyYJfb+9yiKDJqB7Fw2GPSrFxrd+jC9qZRI3VEWK\n8VdflLbruc1FcqJcE/0z2hWa11eud1bMLq8U6AfxNHL4r4ukrp2D5elrdsrDnhZj\nwMi3FtEFd4RZVaWZYVmWcQTeH7Zz/LYwkVDgBuvC+SOCaNNo/dCurkAAoxw8obBj\n1FS2F/3oHQxMui8vS8j6sMWMPZ5D3Q0xSC3HBUNoI2ZC77Mxn9yfj6ianUXKOOlf\nQMRaPBVajxZm9ovV64QKr+7HK7W7U/fNEqvoKBUDCqEuWmSsxMk=\n-----END CERTIFICATE REQUEST-----`, +}; + +const oldParentIssuerCert = `-----BEGIN CERTIFICATE-----\nMIIDKzCCAhOgAwIBAgIUMCEF+bzBC4NQIWjE1sv/RbnYfUgwDQYJKoZIhvcNAQEL\nBQAwHTEbMBkGA1UEAx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oEOF97Gvqrgc+LEpNsU6lIRA\nkJ/nHe0CD2hf0aBQsGsOllYy/4QnrPlbowb4KizPknEMWdGcvfnlzzOJzo4/UuMk\nMZ9vn2GrINzfml/sLocOzP/MsPd8bBhXI2Emh2O9tJ4+zeHLhEzcM1gdNk8pp+wP\nEOks0EcN4UBkpEnDZcDTJVgp9XpWy19EEGqsxjBq6rlpIvPW8XHoH1jZSGY1KWBJ\nRGtDcGugwTxO9jYHz/a1qu4BVt5FFcb0L3IOvcr+3QCCeiJQHcVY8QRbO9M4AQk=\n-----END CERTIFICATE-----\n`; +// both certs generated with key type ed25519 +const unsupportedSignatureRoot = `-----BEGIN CERTIFICATE-----\nMIIBXTCCAQ+gAwIBAgIUcp9CkzsU5Pkv2ZJO8Gp+tJrzuJYwBQYDK2VwMBIxEDAO\nBgNVBAMTB215LXJvb3QwHhcNMjMwNzE4MTYyNzQ3WhcNMjMwODE5MTYyODE3WjAS\nMRAwDgYDVQQDEwdteS1yb290MCowBQYDK2VwAyEAmZ+By07QvgAEX1HRjhltJlgK\nA8il2LYUpH0uw7f2lXCjdzB1MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTAD\nAQH/MB0GA1UdDgQWBBTAcYaOaiKhDmYqSe6vg/lAtYspkDAfBgNVHSMEGDAWgBTA\ncYaOaiKhDmYqSe6vg/lAtYspkDASBgNVHREECzAJggdteS1yb290MAUGAytlcANB\nAG9xXZnKNEXRyfa91hm9S80PwlwIMh4MkWetwfPBn3M74cHzDK1okANmweca4RRq\nQHDPT7shx3CuosvL2Ori/ws=\n-----END CERTIFICATE-----`; +const unsupportedSignatureInt = `-----BEGIN CERTIFICATE-----\nMIICfTCCAWWgAwIBAgIUei2XIhhsP1/ytDciEGfA1C7t/sMwDQYJKoZIhvcNAQEL\nBQAwFjEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMjMwNzE4MTg1NDA3WhcNMjMw\nODE5MTg1NDM3WjASMRAwDgYDVQQDEwdpbnQtY3NyMCowBQYDK2VwAyEAa9vHnJA3\nnzA/fYiTUg8EhomjMtVp5O2c01nQRXEv72OjgcAwgb0wDgYDVR0PAQH/BAQDAgEG\nMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFGtjjUwrRGmFmYBHrUE38tSxvVM3\nMB8GA1UdIwQYMBaAFNng9+uArFyIUcD23XdvCSIfYiDPMEYGCCsGAQUFBwEBBDow\nODAZBggrBgEFBQcwAoYNaGFzaGljb3JwLmNvbTAbBggrBgEFBQcwAoYPdmF1bHRw\ncm9qZWN0LmlvMBIGA1UdEQQLMAmCB2ludC1jc3IwDQYJKoZIhvcNAQELBQADggEB\nAAOSNgZjesJG4BgLU8jQmOO7n6W8WcR+dT+ELDC1nLlEZ2BJCDSXXUX8AihIHKxn\nA9W4slABUacyJlAZo/o/wcxyfbA6PUXmHnoqEPZ3zXMwuLN/iRW7/uQvI6TIwnpH\nXETFARLmK8cfGgbhi24STkHTF4ljczkOab7sTUQTHELlo+F2gNtmgnyaBFCGUYor\nX1pkMBcBa9BWRsfhy8E+tBVVUrNNUddwzC/5nMLqT8XqENMndDoG7eeT9Ex6otZy\nzURkcq09FtcmyY2RBYkV4UzyHN7cESMIk/J33ZCNAfHaDGuOqTy5nYU5fTtjJcit\nwEcWiSesrKPCletBpuMpgiU=\n-----END CERTIFICATE-----\n`; + +export const CERTIFICATES = { + rootPem, + rootDer, + issuerPemBundle, + csr, + csr2, + componentPemBundle, + loadedCert, + pssTrueCert, + skeletonCert, + unsupportedOids, + unsupportedPem, + certWithoutCN, + newCSR, + oldParentIssuerCert, + parentIssuerCert, + intIssuerCert, + newlySignedCert, + unsupportedSignatureRoot, + unsupportedSignatureInt, +}; diff --git a/ui/tests/helpers/pki/pki-issuer-cross-sign.js b/ui/tests/helpers/pki/pki-issuer-cross-sign.js deleted file mode 100644 index 20fc59341824..000000000000 --- a/ui/tests/helpers/pki/pki-issuer-cross-sign.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { SELECTORS as CONFIGURE } from './pki-configure-create'; -import { SELECTORS as DETAILS } from './pki-issuer-details'; - -export const SELECTORS = { - objectListInput: (key, row = 0) => `[data-test-object-list-input="${key}-${row}"]`, - inputByName: (name) => `[data-test-input="${name}"]`, - addRow: '[data-test-object-list-add-button', - submitButton: '[data-test-cross-sign-submit]', - cancelButton: '[data-test-cross-sign-cancel]', - statusCount: '[data-test-cross-sign-status-count]', - signedIssuerRow: (row = 0) => `[data-test-info-table-row="${row}"]`, - signedIssuerCol: (attr) => `[data-test-info-table-column="${attr}"]`, - // for cross signing acceptance tests - configure: { ...CONFIGURE }, - details: { ...DETAILS }, - rowValue: (attr) => `[data-test-row-value="${attr}"]`, - copyButton: (attr) => `[data-test-value-div="${attr}"] [data-test-copy-button]`, -}; diff --git a/ui/tests/helpers/pki/pki-issuer-details.js b/ui/tests/helpers/pki/pki-issuer-details.js deleted file mode 100644 index 94bb801e98d0..000000000000 --- a/ui/tests/helpers/pki/pki-issuer-details.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - configure: '[data-test-pki-issuer-configure]', - copyButtonByName: (name) => `[data-test-value-div="${name}"] [data-test-copy-button]`, - crossSign: '[data-test-pki-issuer-cross-sign]', - defaultGroup: '[data-test-details-group="default"]', - download: '[data-test-issuer-download]', - groupTitle: '[data-test-group-title]', - parsingAlertBanner: '[data-test-parsing-error-alert-banner]', - rotateModal: '#pki-rotate-root-modal', - rotateModalGenerate: '[data-test-root-rotate-step-one]', - rotateRoot: '[data-test-pki-issuer-rotate-root]', - row: '[data-test-component="info-table-row"]', - signIntermediate: '[data-test-pki-issuer-sign-int]', - urlsGroup: '[data-test-details-group="Issuer URLs"]', - valueByName: (name) => `[data-test-value-div="${name}"]`, -}; diff --git a/ui/tests/helpers/pki/pki-key-form.js b/ui/tests/helpers/pki/pki-key-form.js deleted file mode 100644 index cc1e738a2c1e..000000000000 --- a/ui/tests/helpers/pki/pki-key-form.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - keyCreateButton: '[data-test-pki-key-save]', - keyCancelButton: '[data-test-pki-key-cancel]', - keyNameInput: '[data-test-input="keyName"]', - typeInput: '[data-test-input="type"]', - keyTypeInput: '[data-test-input="keyType"]', - keyBitsInput: '[data-test-input="keyBits"]', - validationError: '[data-test-pki-key-validation-error]', - fieldErrorByName: (name) => `[data-test-field-validation="${name}"]`, -}; diff --git a/ui/tests/helpers/pki/pki-not-valid-after-form.js b/ui/tests/helpers/pki/pki-not-valid-after-form.js deleted file mode 100644 index 4f7ed34f8f96..000000000000 --- a/ui/tests/helpers/pki/pki-not-valid-after-form.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - radioTtl: '[data-test-radio-button="ttl"]', - radioTtlLabel: '[data-test-radio-label="ttl"]', - radioDate: '[data-test-radio-button="not_after"]', - radioDateLabel: '[data-test-radio-label="specificDate"]', - ttlForm: '[data-test-ttl-inputs]', - ttlTimeInput: '[data-test-ttl-value="TTL"]', - ttlUnitInput: '[data-test-select="ttl-unit"]', - dateInput: '[data-test-input="not_after"]', -}; diff --git a/ui/tests/helpers/pki/pki-role-form.js b/ui/tests/helpers/pki/pki-role-form.js deleted file mode 100644 index 49a9d36b30d3..000000000000 --- a/ui/tests/helpers/pki/pki-role-form.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const PKI_BASE_URL = `/vault/cluster/secrets/backend/pki/roles`; - -export const SELECTORS = { - roleName: '[data-test-input="name"]', - issuerRef: '[data-test-input="issuerRef"]', - issuerRefSelect: '[data-test-select="issuerRef"]', - issuerRefToggle: '[data-test-toggle-label="issuerRef-toggle"]', - customTtl: '[data-test-field="customTtl"]', - backdateValidity: '[data-test-ttl-value="Backdate validity"]', - maxTtl: '[data-test-toggle-label="Max TTL"]', - generateLease: '[data-test-field="generateLease"]', - noStore: '[data-test-field="noStore"]', - addBasicConstraints: '[data-test-input="addBasicConstraints"]', - domainHandling: '[data-test-toggle-group="Domain handling"]', - keyParams: '[data-test-toggle-group="Key parameters"]', - keyType: '[data-test-input="keyType"]', - keyBits: '[data-test-input="keyBits"]', - signatureBits: '[data-test-input="signatureBits"]', - keyUsage: '[data-test-toggle-group="Key usage"]', - extKeyUsageOids: '[data-test-input="extKeyUsageOids"]', - digitalSignature: '[data-test-checkbox="DigitalSignature"]', - keyAgreement: '[data-test-checkbox="KeyAgreement"]', - keyEncipherment: '[data-test-checkbox="KeyEncipherment"]', - any: '[data-test-checkbox="Any"]', - serverAuth: '[data-test-checkbox="ServerAuth"]', - policyIdentifiers: '[data-test-toggle-group="Policy identifiers"]', - san: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', - additionalSubjectFields: '[data-test-toggle-group="Additional subject fields"]', - roleCreateButton: '[data-test-pki-role-save]', - roleCancelButton: '[data-test-pki-role-cancel]', -}; diff --git a/ui/tests/helpers/pki/pki-role-generate.js b/ui/tests/helpers/pki/pki-role-generate.js deleted file mode 100644 index 26a101763e90..000000000000 --- a/ui/tests/helpers/pki/pki-role-generate.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -export const SELECTORS = { - form: '[data-test-pki-generate-cert-form]', - commonNameField: '[data-test-input="commonName"]', - optionsToggle: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', - generateButton: '[data-test-pki-generate-button]', - cancelButton: '[data-test-pki-generate-cancel]', - downloadButton: '[data-test-pki-cert-download-button]', - revokeButton: '[data-test-pki-cert-revoke-button]', - serialNumber: '[data-test-value-div="Serial number"]', - certificate: '[data-test-value-div="Certificate"]', - inlineAlert: '[data-test-alert]', - commonNameInlineError: '[data-test-field="commonName"] [data-test-inline-alert]', - commonNameErrorBorder: '[data-test-input="commonName"]', -}; diff --git a/ui/tests/helpers/pki/pki-run-commands.js b/ui/tests/helpers/pki/pki-run-commands.js deleted file mode 100644 index 631a6507c54f..000000000000 --- a/ui/tests/helpers/pki/pki-run-commands.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -// Clears pki-related data and capabilities so that admin -// capabilities from setup don't rollover -export function clearRecords(store) { - store.unloadAll('pki/action'); - store.unloadAll('pki/issuer'); - store.unloadAll('pki/key'); - store.unloadAll('pki/role'); - store.unloadAll('pki/sign-intermediate'); - store.unloadAll('pki/tidy'); - store.unloadAll('pki/config/urls'); - store.unloadAll('pki/config/crl'); - store.unloadAll('pki/config/cluster'); - store.unloadAll('pki/config/acme'); - store.unloadAll('pki/certificate/generate'); - store.unloadAll('pki/certificate/sign'); - store.unloadAll('capabilities'); -} diff --git a/ui/tests/helpers/pki/pki-selectors.ts b/ui/tests/helpers/pki/pki-selectors.ts new file mode 100644 index 000000000000..92492666b9d2 --- /dev/null +++ b/ui/tests/helpers/pki/pki-selectors.ts @@ -0,0 +1,237 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +export const PKI_OVERVIEW = { + issuersCardTitle: '[data-test-overview-card-title="Issuers"]', + issuersCardSubtitle: '[data-test-overview-card-subtitle="Issuers"]', + issuersCardLink: '[data-test-overview-card-container="Issuers"] a', + issuersCardOverviewNum: '[data-test-overview-card-container="Issuers"] h2', + rolesCardTitle: '[data-test-overview-card-title="Roles"]', + rolesCardSubtitle: '[data-test-overview-card-subtitle="Roles"]', + rolesCardLink: '[data-test-overview-card-container="Roles"] a', + rolesCardOverviewNum: '[data-test-overview-card-container="Roles"] h2', + issueCertificate: '[data-test-overview-card-title="Issue certificate"]', + issueCertificateInput: '[data-test-issue-certificate-input]', + issueCertificatePowerSearch: '[data-test-issue-certificate-input] span', + issueCertificateButton: '[data-test-issue-certificate-button]', + viewCertificate: '[data-test-overview-card-title="View certificate"]', + viewCertificateInput: '[data-test-view-certificate-input]', + viewCertificatePowerSearch: '[data-test-view-certificate-input] span', + viewCertificateButton: '[data-test-view-certificate-button]', + viewIssuerInput: '[data-test-issue-issuer-input]', + viewIssuerPowerSearch: '[data-test-issue-issuer-input] span', + viewIssuerButton: '[data-test-view-issuer-button]', + firstPowerSelectOption: '[data-option-index="0"]', +}; + +// COMPONENTS +export const PKI_CONFIGURE_CREATE = { + // page::pki-configure-create + nextStepsBanner: '[data-test-config-next-steps]', + option: '[data-test-pki-config-option]', + optionByKey: (key: string) => `[data-test-pki-config-option="${key}"]`, + doneButton: '[data-test-done]', + configureButton: '[data-test-configure-pki-button]', + // pki-generate-root + generateRootOption: '[data-test-pki-config-option="generate-root"]', + // pki-ca-cert-import + importForm: '[data-test-pki-import-pem-bundle-form]', + importSubmit: '[data-test-pki-import-pem-bundle]', + importSectionLabel: '[data-test-import-section-label]', + importMapping: '[data-test-imported-bundle-mapping]', + importedIssuer: '[data-test-imported-issuer]', + importedKey: '[data-test-imported-key]', + // generate-intermediate + csrDetails: '[data-test-generate-csr-result]', +}; + +export const PKI_DELETE_ALL_ISSUERS = { + issuerLink: '[data-test-delete-all-issuers-link]', + deleteAllIssuerModal: '#confirmation-modal', + deleteAllIssuerInput: '[data-test-confirmation-modal-input="Delete all issuers?"]', + deleteAllIssuerButton: '[data-test-confirm-button="Delete all issuers?"]', +}; + +export const PKI_GENERATE_ROOT = { + mainSectionTitle: '[data-test-generate-root-title="Root parameters"]', + urlSectionTitle: '[data-test-generate-root-title="Issuer URLs"]', + keyParamsGroupToggle: '[data-test-toggle-group="Key parameters"]', + sanGroupToggle: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', + additionalGroupToggle: '[data-test-toggle-group="Additional subject fields"]', + toggleGroupDescription: '[data-test-toggle-group-description]', + groupFields: (group: string) => `[data-test-group="${group}"] [data-test-field]`, + formInvalidError: '[data-test-pki-generate-root-validation-error]', + urlsSection: '[data-test-urls-section]', + urlField: '[data-test-urls-section] [data-test-input]', + // Shown values after save + saved: { + certificate: '[data-test-value-div="Certificate"] [data-test-certificate-card]', + commonName: '[data-test-row-value="Common name"]', + issuerName: '[data-test-row-value="Issuer name"]', + issuerLink: '[data-test-value-div="Issuer ID"] a', + keyName: '[data-test-row-value="Key name"]', + keyLink: '[data-test-value-div="Key ID"] a', + privateKey: '[data-test-value-div="Private key"] [data-test-certificate-card]', + serialNumber: '[data-test-row-value="Serial number"]', + }, +}; + +export const PKI_CROSS_SIGN = { + objectListInput: (key: string, row = 0) => `[data-test-object-list-input="${key}-${row}"]`, + addRow: '[data-test-object-list-add-button', + statusCount: '[data-test-cross-sign-status-count]', + signedIssuerRow: (row = 0) => `[data-test-info-table-row="${row}"]`, + signedIssuerCol: (attr: string) => `[data-test-info-table-column="${attr}"]`, + rowValue: (attr: string) => `[data-test-row-value="${attr}"]`, + copyButton: (attr: string) => `[data-test-value-div="${attr}"] [data-test-copy-button]`, +}; + +export const PKI_ISSUER_DETAILS = { + configure: '[data-test-pki-issuer-configure]', + copyButtonByName: (name: string) => `[data-test-value-div="${name}"] [data-test-copy-button]`, + crossSign: '[data-test-pki-issuer-cross-sign]', + defaultGroup: '[data-test-details-group="default"]', + download: '[data-test-issuer-download]', + groupTitle: '[data-test-group-title]', + parsingAlertBanner: '[data-test-parsing-error-alert-banner]', + rotateModal: '#pki-rotate-root-modal', + rotateModalGenerate: '[data-test-root-rotate-step-one]', + rotateRoot: '[data-test-pki-issuer-rotate-root]', + row: '[data-test-component="info-table-row"]', + signIntermediate: '[data-test-pki-issuer-sign-int]', + urlsGroup: '[data-test-details-group="Issuer URLs"]', + valueByName: (name: string) => `[data-test-value-div="${name}"]`, +}; + +export const PKI_KEY_FORM = { + validationError: '[data-test-pki-key-validation-error]', +}; + +export const PKI_NOT_VALID_AFTER = { + radioTtl: '[data-test-radio-button="ttl"]', + radioTtlLabel: '[data-test-radio-label="ttl"]', + radioDate: '[data-test-radio-button="not_after"]', + radioDateLabel: '[data-test-radio-label="specificDate"]', + ttlForm: '[data-test-ttl-inputs]', + ttlTimeInput: '[data-test-ttl-value="TTL"]', + ttlUnitInput: '[data-test-select="ttl-unit"]', + dateInput: '[data-test-input="not_after"]', +}; + +export const PKI_ROLE_FORM = { + domainHandling: '[data-test-toggle-group="Domain handling"]', + keyParams: '[data-test-toggle-group="Key parameters"]', + keyUsage: '[data-test-toggle-group="Key usage"]', + digitalSignature: '[data-test-checkbox="DigitalSignature"]', + keyAgreement: '[data-test-checkbox="KeyAgreement"]', + keyEncipherment: '[data-test-checkbox="KeyEncipherment"]', + any: '[data-test-checkbox="Any"]', + serverAuth: '[data-test-checkbox="ServerAuth"]', + policyIdentifiers: '[data-test-toggle-group="Policy identifiers"]', + san: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', + additionalSubjectFields: '[data-test-toggle-group="Additional subject fields"]', +}; + +export const PKI_ROLE_GENERATE = { + form: '[data-test-pki-generate-cert-form]', + optionsToggle: '[data-test-toggle-group="Subject Alternative Name (SAN) Options"]', + downloadButton: '[data-test-pki-cert-download-button]', + revokeButton: '[data-test-pki-cert-revoke-button]', +}; + +// PAGES +export const PKI_CONFIG_EDIT = { + errorBanner: '[data-test-config-edit-error]', + acmeEditSection: '[data-test-acme-edit-section]', + configEditSection: '[data-test-cluster-config-edit-section]', + configInput: (attr: string) => `[data-test-input="${attr}"]`, + stringListInput: (attr: string) => `[data-test-input="${attr}"] [data-test-string-list-input="0"]`, + urlsEditSection: '[data-test-urls-edit-section]', + urlFieldInput: (attr: string) => `[data-test-input="${attr}"] textarea`, + urlFieldLabel: (attr: string) => `[data-test-input="${attr}"] label`, + crlEditSection: '[data-test-crl-edit-section]', + crlToggleInput: (attr: string) => `[data-test-input="${attr}"] input`, + crlTtlInput: (attr: string) => `[data-test-ttl-value="${attr}"]`, + crlFieldLabel: (attr: string) => `[data-test-input="${attr}"] label`, + saveButton: '[data-test-configuration-edit-save]', + cancelButton: '[data-test-configuration-edit-cancel]', + validationAlert: '[data-test-configuration-edit-validation-alert]', + deleteButton: (attr: string) => `[data-test-input="${attr}"] [data-test-string-list-button="delete"]`, + groupHeader: (group: string) => `[data-test-crl-header="${group}"]`, + checkboxInput: (attr: string) => `[data-test-input="${attr}"]`, +}; + +export const PKI_ISSUER_LIST = { + // Page::PkiIssuerList + issuerListItem: (id: string) => `[data-test-issuer-list="${id}"]`, + importIssuerLink: '[data-test-generate-issuer="import"]', + generateIssuerDropdown: '[data-test-issuer-generate-dropdown]', + generateIssuerRoot: '[data-test-generate-issuer="root"]', + generateIssuerIntermediate: '[data-test-generate-issuer="intermediate"]', + issuerPopupDetails: '[data-test-pki-issuer-details]', +}; + +export const PKI_KEYS = { + // key index + importKey: '[data-test-pki-key-import]', + generateKey: '[data-test-pki-key-generate]', + keyId: '[data-test-key="id"]', + keyName: '[data-test-key="name"]', + popupMenuDetails: '[data-test-key-menu-link="details"]', + popupMenuEdit: '[data-test-key-menu-link="edit"]', + // key details + keyDeleteButton: '[data-test-pki-key-delete]', + downloadButton: '[data-test-download-button]', + keyEditLink: '[data-test-pki-key-edit]', + nextStepsAlert: '[data-test-pki-key-next-steps]', +}; + +export const PKI_ROLE_DETAILS = { + issuerLabel: '[data-test-row-label="Issuer"]', + noStoreValue: '[data-test-value-div="Store in storage backend"]', + keyUsageValue: '[data-test-value-div="Key usage"]', + extKeyUsageValue: '[data-test-value-div="Ext key usage"]', + customTtlValue: '[data-test-value-div="Issued certificates expire after"]', + deleteRoleButton: '[data-test-pki-role-delete]', + generateCertLink: '[data-test-pki-role-generate-cert]', + signCertLink: '[data-test-pki-role-sign-cert]', + editRoleLink: '[data-test-pki-role-edit-link]', + createRoleLink: '[data-test-pki-role-create-link]', +}; + +export const PKI_TIDY_FORM = { + tidyFormName: (attr: string) => `[data-test-tidy-form="${attr}"]`, + inputByAttr: (attr: string) => `[data-test-input="${attr}"]`, + toggleInput: (attr: string) => `[data-test-input="${attr}"] input`, + intervalDuration: '[data-test-ttl-value="Automatic tidy enabled"]', + acmeAccountSafetyBuffer: '[data-test-ttl-value="Tidy ACME enabled"]', + toggleLabel: (label: string) => `[data-test-toggle-label="${label}"]`, + tidySectionHeader: (header: string) => `[data-test-tidy-header="${header}"]`, + tidySave: '[data-test-pki-tidy-button]', + tidyCancel: '[data-test-pki-tidy-cancel]', + tidyPauseDuration: '[data-test-ttl-value="Pause duration"]', + editAutoTidyButton: '[data-test-pki-edit-tidy-auto-link]', +}; + +export const PKI_TIDY = { + hdsAlertTitle: '[data-test-tidy-status-alert-title]', + hdsAlertDescription: '[data-test-tidy-status-alert-description]', + alertUpdatedAt: '[data-test-tidy-status-alert-updated-at]', + cancelTidyAction: '[data-test-cancel-tidy-action]', + hdsAlertButtonText: '[data-test-cancel-tidy-action] .hds-button__text', + timeStartedRow: '[data-test-value-div="Time started"]', + timeFinishedRow: '[data-test-value-div="Time finished"]', + cancelTidyModalBackground: '#pki-cancel-tidy-modal', + tidyEmptyStateConfigure: '[data-test-tidy-empty-state-configure]', + manualTidyToolbar: '[data-test-pki-manual-tidy-config]', + autoTidyToolbar: '[data-test-pki-auto-tidy-config]', + tidyConfigureModal: { + configureTidyModal: '#pki-tidy-modal', + tidyModalAutoButton: '[data-test-tidy-modal-auto-button]', + tidyModalManualButton: '[data-test-tidy-modal-manual-button]', + tidyModalCancelButton: '[data-test-tidy-modal-cancel-button]', + tidyOptionsModal: '[data-test-pki-tidy-options-modal]', + }, +}; diff --git a/ui/tests/helpers/policy-generator/pki.js b/ui/tests/helpers/pki/policy-generator.ts similarity index 86% rename from ui/tests/helpers/policy-generator/pki.js rename to ui/tests/helpers/pki/policy-generator.ts index 9b306c942e53..c3e2d0b34f71 100644 --- a/ui/tests/helpers/policy-generator/pki.js +++ b/ui/tests/helpers/pki/policy-generator.ts @@ -5,7 +5,7 @@ import { singularize } from 'ember-inflector'; -export const adminPolicy = (mountPath) => { +export const adminPolicy = (mountPath: string) => { return ` path "${mountPath}/*" { capabilities = ["create", "read", "update", "delete", "list"] @@ -14,7 +14,7 @@ export const adminPolicy = (mountPath) => { }; // keys require singularized paths for GET -export const readerPolicy = (mountPath, resource) => { +export const readerPolicy = (mountPath: string, resource: string) => { return ` path "${mountPath}/${resource}" { capabilities = ["read", "list"] @@ -30,7 +30,7 @@ export const readerPolicy = (mountPath, resource) => { }, `; }; -export const updatePolicy = (mountPath, resource) => { +export const updatePolicy = (mountPath: string, resource: string) => { return ` path "${mountPath}/${resource}" { capabilities = ["read", "list"] diff --git a/ui/tests/helpers/pki/values.js b/ui/tests/helpers/pki/values.js deleted file mode 100644 index dcea169d30ff..000000000000 --- a/ui/tests/helpers/pki/values.js +++ /dev/null @@ -1,204 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -// Expires Jan 10, 2033 -export const rootPem = `-----BEGIN CERTIFICATE----- -MIIDezCCAmOgAwIBAgIUTBbQcZijQsmd0rjd6COikPsrGyowDQYJKoZIhvcNAQEL -BQAwFDESMBAGA1UEAxMJdGVzdC1yb290MB4XDTIzMDEyMDE3NTcxMloXDTIzMDIy -MTE3NTc0MlowFDESMBAGA1UEAxMJdGVzdC1yb290MIIBIjANBgkqhkiG9w0BAQEF -AAOCAQ8AMIIBCgKCAQEAlUHfvQLsocXtvwRCpTnXGzwMCD+3KKK7y1+SUCgpAD9Y -RV2xLAbqh0iK3x2WI4+Pek1Ub6dYaWczzBob6wRq9iFB72uLPpbL8yRf+tc1egmP -wwJQS9qidb1hcSi4p6x/JwOpr2v2PDqJPDoHrfaHeJgCuBGS00qUFH7oHQz9Usim -lHjIbVNF3Qa1Hq2bgwkZmRjRn3Bez/xy3YEiQ41GTicUBqY4NAGWuS1LiHyEUW81 -iQ+1iGlbpuAL4H7lpKm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fjQeQA1extXYKM/f8eu3Z/wjbbMOVpwb -xst+VTY7X9T8cU/hjDEoNG677meI+W5MgiwX0rxTpoz991fqr3vp7PELYj3GMyii -D1YfvqXieNij4UrduRqCXj1m8SVZlM+X ------END CERTIFICATE REQUEST-----`; - -export const componentPemBundle = `-----BEGIN CERTIFICATE----- -MIIDGjCCAgKgAwIBAgIUFvnhb2nQ8+KNS3SzjlfYDMHGIRgwDQYJKoZIhvcNAQEL -BQAwDTELMAkGA1UEAxMCZmEwHhcNMTgwMTEwMTg1NDI5WhcNMTgwMjExMTg1NDU5 -WjANMQswCQYDVQQDEwJmYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -AN2VtBn6EMlA4aYre/xoKHxlgNDxJnfSQWfs6yF/K201qPnt4QF9AXChatbmcKVn -OaURq+XEJrGVgF/u2lSos3NRZdhWVe8o3/sOetsGxcrd0gXAieOSmkqJjp27bYdl -uY3WsxhyiPvdfS6xz39OehsK/YCB6qCzwB4eEfSKqbkvfDL9sLlAiOlaoHC9pczf -6/FANKp35UDwInSwmq5vxGbnWk9zMkh5Jq6hjOWHZnVc2J8J49PYvkIM8uiHDgOE -w71T2xM5plz6crmZnxPCOcTKIdF7NTEP2lUfiqc9lONV9X1Pi4UclLPHJf5bwTmn -JaWgbKeY+IlF61/mgxzhC7cCAwEAAaNyMHAwDgYDVR0PAQH/BAQDAgEGMA8GA1Ud -EwEB/wQFMAMBAf8wHQYDVR0OBBYEFLDtc6+HZN2lv60JSDAZq3+IHoq7MB8GA1Ud -IwQYMBaAFLDtc6+HZN2lv60JSDAZq3+IHoq7MA0GA1UdEQQGMASCAmZhMA0GCSqG -SIb3DQEBCwUAA4IBAQDVt6OddTV1MB0UvF5v4zL1bEB9bgXvWx35v/FdS+VGn/QP -cC2c4ZNukndyHhysUEPdqVg4+up1aXm4eKXzNmGMY/ottN2pEhVEWQyoIIA1tH0e -8Kv/bysYpHZKZuoGg5+mdlHS2p2Dh2bmYFyBLJ8vaeP83NpTs2cNHcmEvWh/D4UN -UmYDODRN4qh9xYruKJ8i89iMGQfbdcq78dCC4JwBIx3bysC8oF4lqbTYoYNVTnAi -LVqvLdHycEOMlqV0ecq8uMLhPVBalCmIlKdWNQFpXB0TQCsn95rCCdi7ZTsYk5zv -Q4raFvQrZth3Cz/X5yPTtQL78oBYrmHzoQKDFJ2z ------END CERTIFICATE-----`; - -// for parse-pki-cert tests: -// certificate contains all allowable params -export const loadedCert = `-----BEGIN CERTIFICATE-----\nMIIE7TCCA9WgAwIBAgIULcrWXSz3/kG81EgBo0A4Zt+ZgkYwDQYJKoZIhvcNAQEL\nBQAwga0xDzANBgNVBAYTBkZyYW5jZTESMBAGA1UECBMJQ2hhbXBhZ25lMQ4wDAYD\nVQQHEwVQYXJpczETMBEGA1UECRMKMjM0IHNlc2FtZTEPMA0GA1UEERMGMTIzNDU2\nMQ8wDQYDVQQKEwZXaWRnZXQxEDAOBgNVBAsTB0ZpbmFuY2UxGDAWBgNVBAMTD2Nv\nbW1vbi1uYW1lLmNvbTETMBEGA1UEBRMKY2VyZWFsMTI5MjAeFw0yMzAyMDMxNzI3\nMzNaFw0yMzAzMDcxNzI4MDNaMIGtMQ8wDQYDVQQGEwZGcmFuY2UxEjAQBgNVBAgT\nCUNoYW1wYWduZTEOMAwGA1UEBxMFUGFyaXMxEzARBgNVBAkTCjIzNCBzZXNhbWUx\nDzANBgNVBBETBjEyMzQ1NjEPMA0GA1UEChMGV2lkZ2V0MRAwDgYDVQQLEwdGaW5h\nbmNlMRgwFgYDVQQDEw9jb21tb24tbmFtZS5jb20xEzARBgNVBAUTCmNlcmVhbDEy\nOTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8NO7LXHp28SzOqmQv\nns4fGogKydEklWG4JEN3pM+k9nTyEgA8DFhtSLvcqF0cqhEydw4FVU+LEUGySUer\nmM4VNl9qglFBgmYE8TNgWkUw9ZP6MNgx13I8zXTXOIDj0iwXks02x8451oPbqqdq\nX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sVPxoUqqWEix8AyCsB5uqpKZasby\nedlrdBohM4dnoV+VmV0de04y95sdo3Ot60hm/czLog3tHg4o7AmfA7saS+5hCL1M\nCJWqoJHRFo0hOWJHpLJRWz5DqRZWspASoVozLOYyjRD+tNBjO5hK4FtaG6eri38t\nOpTt7sdInVODlntpNuuCVprPpHGj4kPOcViQULoFQq5fwyadpdjqSXmEGlt0to5Y\nMbTb4Jhj0HywgO53BUUmMzzY9idXh/8A7ThrM5LtqhxaYHLVhyeo+5e0mgiXKp+n\nQ8Uh4TNNTCvOUlAHycZNaxYTlEPn\n-----END CERTIFICATE-----`; -// contains unsupported subject and extension OIDs -export const unsupportedOids = `-----BEGIN CERTIFICATE-----\nMIIEjDCCA3SgAwIBAgIUD4EeORgh/i+ZZFOk8KsGKQPWsoIwDQYJKoZIhvcNAQEL\nBQAwgZIxMTAvBgNVBAMMKGZhbmN5LWNlcnQtdW5zdXBwb3J0ZWQtc3Viai1hbmQt\nZXh0LW9pZHMxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZLYW5zYXMxDzANBgNVBAcM\nBlRvcGVrYTESMBAGA1UECgwJQWNtZSwgSW5jMRowGAYJKoZIhvcNAQkBFgtmb29A\nYmFyLmNvbTAeFw0yMzAxMjMxODQ3MjNaFw0zMzAxMjAxODQ3MjNaMIGSMTEwLwYD\nVQQDDChmYW5jeS1jZXJ0LXVuc3VwcG9ydGVkLXN1YmotYW5kLWV4dC1vaWRzMQsw\nCQYDVQQGEwJVUzEPMA0GA1UECAwGS2Fuc2FzMQ8wDQYDVQQHDAZUb3Bla2ExEjAQ\nBgNVBAoMCUFjbWUsIEluYzEaMBgGCSqGSIb3DQEJARYLZm9vQGJhci5jb20wggEi\nMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDyYH5qS7krfZ2tA5uZsY2qXbTb\ntGNG1BsyDhZ/qqVlQybjDsHJZwNUbpfhBcCLaKyAwH1R9n54NOOOn6bYgfKWTgy3\nL7224YDAqYe7Y/GPjgI2MRvRfn6t2xzQxtJ0l0k8LeyNcwhiqYLQyOOfDdc127fm\nW40r2nmhLpH0i9e2I/YP1HQ+ldVgVBqeUTntgVSBfrQF56v9mAcvvHEa5sdHqmX4\nJ2lhWTnx9jqb7NZxCem76BlX1Gt5TpP3Ym2ZFVQI9fuPK4O8JVhk1KBCmIgR3Ft+\nPpFUs/c41EMunKJNzveYrInSDScaC6voIJpK23nMAiM1HckLfUUc/4UojD+VAgMB\nAAGjgdcwgdQwHQYDVR0OBBYEFH7tt4enejKTZtYjUKUUx6PXyzlgMB8GA1UdIwQY\nMBaAFH7tt4enejKTZtYjUKUUx6PXyzlgMA4GA1UdDwEB/wQEAwIFoDAgBgNVHSUB\nAf8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBCjBM\nBgNVHREERTBDhwTAngEmhgx1cmlTdXBwb3J0ZWSCEWRucy1OYW1lU3VwcG9ydGVk\noBoGAyoDBKATDBFleGFtcGxlIG90aGVybmFtZTANBgkqhkiG9w0BAQsFAAOCAQEA\nP6ckVJgbcJue+MK3RVDuG+Mh7dl89ynC7NwpQFRjLVZQuoMHZT/dcLlVeFejVXu5\nR+IPLmQU6NV7JAmy4zGap8awf12QTy3g410ecrSF94WWlu8bPoekfUnnP+kfzLPH\nCUAkRKxWDSRKX5C8cMMxacVBBaBIayuusLcHkHmxLLDw34PFzyz61gtZOJq7JYnD\nhU9YsNh6bCDmnBDBsDMOI7h8lBRQwTiWVoSD9YNVvFiY29YvFbJQGdh+pmBtf7E+\n1B/0t5NbvqlQSbhMM0QgYFhuCxr3BGNob7kRjgW4i+oh+Nc5ptA5q70QMaYudqRS\nd8SYWhRdxmH3qcHNPcR1iw==\n-----END CERTIFICATE-----`; -// unsupportedPem is same cert as above, formatted differently -export const unsupportedPem = ` ------BEGIN CERTIFICATE----- -MIIEjDCCA3SgAwIBAgIUD4EeORgh/i+ZZFOk8KsGKQPWsoIwDQYJKoZIhvcN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gNVHREERTBDhwTAngEmhgx1cmlTdXBwb3J0ZWSCEWRucy1OYW1lU3VwcG9ydGVk -oBoGAyoDBKATDBFleGFtcGxlIG90aGVybmFtZTANBgkqhkiG9w0BAQsFAAOCAQEA -P6ckVJgbcJue+MK3RVDuG+Mh7dl89ynC7NwpQFRjLVZQuoMHZT/dcLlVeFejVXu5 -R+IPLmQU6NV7JAmy4zGap8awf12QTy3g410ecrSF94WWlu8bPoekfUnnP+kfzLPH -CUAkRKxWDSRKX5C8cMMxacVBBaBIayuusLcHkHmxLLDw34PFzyz61gtZOJq7JYnD -hU9YsNh6bCDmnBDBsDMOI7h8lBRQwTiWVoSD9YNVvFiY29YvFbJQGdh+pmBtf7E+ -1B/0t5NbvqlQSbhMM0QgYFhuCxr3BGNob7kRjgW4i+oh+Nc5ptA5q70QMaYudqRS -d8SYWhRdxmH3qcHNPcR1iw== ------END CERTIFICATE-----`; -export const certWithoutCN = `-----BEGIN CERTIFICATE-----\nMIIDUDCCAjigAwIBAgIUEUpM5i7XMd/imZkR9XvonMaqPyYwDQYJKoZIhvcNAQEL\nBQAwHDEaMBgGCSqGSIb3DQEJARYLZm9vQGJhci5jb20wHhcNMjMwMTIzMjMyODEw\nWhcNMzMwMTIwMjMyODEwWjAcMRowGAYJKoZIhvcNAQkBFgtmb29AYmFyLmNvbTCC\nASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPGSdeqLICZcoUzxk88F8Tp+\nVNI+mS74L8pHyb9ZNZfeXPo0E9L5pi+KKI7rkxAtBGUecG1ENSxDDK9p6XZhWHSU\nZ6bdjOsjcIlfiM+1hhtDclIVxIDnz2Jt1/Vmnm8DXwdwVATWiFLTnfm288deNwsT\npl0ehAR3BadkZvteC6t+giEw/4qm1/FP53GEBOQeUWJDZRvtL37rdx4joFv3cR4w\nV0dukOjc5AGXtIOorO145OSZj8s7RsW3pfGcFUcOg7/flDxfK1UqFflQa7veLvKa\nWE/fOMyB/711QjSkTuQ5Rw3Rf9Fr2pqVJQgElTIW1SKaX5EJTB9mtGB34UqUXtsC\nAwEAAaOBiTCBhjAdBgNVHQ4EFgQUyhFP/fm+798mErPD5VQvEaAZQrswHwYDVR0j\nBBgwFoAUyhFP/fm+798mErPD5VQvEaAZQrswDgYDVR0PAQH/BAQDAgWgMCAGA1Ud\nJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEK\nMA0GCSqGSIb3DQEBCwUAA4IBAQCishzVkhuSAtqxgsZdYzBs3GpakGIio5zReW27\n6dk96hYCbbe4K3DtcFbRD1B8t6aTJlHxkFRaOWErSXu9WP3fUhIDNRE64Qsrg1zk\n3Km430qBlorXmTp6xhYHQfY5bn5rT2YY7AmaYIlIFxRhod43i5GDbBP+e+d/vTqR\nv1AJflYofeR4LeATP64B6a4R+QQVoxI43+pyH3ka+nRHwJBR9h8SMtJoqBy7x9pl\nYlBDa8lSn05doA3+e03VIzitvBBWI4oX1XB0tShSLk6YJXayIwe0ZNVvfYLIRKCp\nb4DUwChYzG/FwFSssUAqzVFhu3i+uU3Z47bsLVm0R5m7hLiZ\n-----END CERTIFICATE-----`; - -// CROSS-SIGNING: -export const newCSR = { - common_name: 'Short-Lived Int R1', - csr: `-----BEGIN CERTIFICATE REQUEST-----\nMIICYjCCAUoCAQAwHTEbMBkGA1UEAxMSU2hvcnQtTGl2ZWQgSW50IFIxMIIBIjAN\nBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqsvFU7lzt06n1w6BL+Waf9zd+Z3G\n90Kv0HAksoLaWYinhkxNIUTU8ar9HLa2WV4EoJbNq91Hn+jFc2SYEXtRV+jm0kEh\nz4C4AoQ4D0s83JcYNssiNbVA04wa5ovD0iA/pzwVz8TnJSfAAuZ3vXFlyIbQ3ESo\nzt9hGjo/JOpoBh67E7xkuzw4lnC2rXGHdh9pk1Di+wqREnKU4nuhDLnTC/LL+Mkm\n07F1aMAW3Z/PWFmmsDJHMhZnaYo2L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IIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqsvFU7lzt06n1w6BL+Wa\nf9zd+Z3G90Kv0HAksoLaWYinhkxNIUTU8ar9HLa2WV4EoJbNq91Hn+jFc2SYEXtR\nV+jm0kEhz4C4AoQ4D0s83JcYNssiNbVA04wa5ovD0iA/pzwVz8TnJSfAAuZ3vXFl\nyIbQ3ESozt9hGjo/JOpoBh67E7xkuzw4lnC2rXGHdh9pk1Di+wqREnKU4nuhDLnT\nC/LL+Mkm07F1aMAW3Z/PWFmmsDJHMhZnaYo2LGCwU4A0U1ED0XpwflobVbkzZDmC\nXOPEI8UXG6VcL36zWnzEQnlZKN91MAa+s0E4z40KHKVSblSkjYD1K6n0y787ic2m\nDwIDAQABo2MwYTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV\nHQ4EFgQUkBK+oGpo5DNj2pCKoUE08WFOxQUwHwYDVR0jBBgwFoAUxgchIBo+1F++\nIFW0F586I5QDFGYwDQYJKoZIhvcNAQELBQADggEBAJaems1vgEjxgb3d1y9PYxzN\nLZbuf/+0+BCVa9k4bEsbuhXhEecFdIi2OKS6fabeoEOF97Gvqrgc+LEpNsU6lIRA\nkJ/nHe0CD2hf0aBQsGsOllYy/4QnrPlbowb4KizPknEMWdGcvfnlzzOJzo4/UuMk\nMZ9vn2GrINzfml/sLocOzP/MsPd8bBhXI2Emh2O9tJ4+zeHLhEzcM1gdNk8pp+wP\nEOks0EcN4UBkpEnDZcDTJVgp9XpWy19EEGqsxjBq6rlpIvPW8XHoH1jZSGY1KWBJ\nRGtDcGugwTxO9jYHz/a1qu4BVt5FFcb0L3IOvcr+3QCCeiJQHcVY8QRbO9M4AQk=\n-----END CERTIFICATE-----\n`; -// both certs generated with key type ed25519 -export const unsupportedSignatureRoot = `-----BEGIN CERTIFICATE-----\nMIIBXTCCAQ+gAwIBAgIUcp9CkzsU5Pkv2ZJO8Gp+tJrzuJYwBQYDK2VwMBIxEDAO\nBgNVBAMTB215LXJvb3QwHhcNMjMwNzE4MTYyNzQ3WhcNMjMwODE5MTYyODE3WjAS\nMRAwDgYDVQQDEwdteS1yb290MCowBQYDK2VwAyEAmZ+By07QvgAEX1HRjhltJlgK\nA8il2LYUpH0uw7f2lXCjdzB1MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTAD\nAQH/MB0GA1UdDgQWBBTAcYaOaiKhDmYqSe6vg/lAtYspkDAfBgNVHSMEGDAWgBTA\ncYaOaiKhDmYqSe6vg/lAtYspkDASBgNVHREECzAJggdteS1yb290MAUGAytlcANB\nAG9xXZnKNEXRyfa91hm9S80PwlwIMh4MkWetwfPBn3M74cHzDK1okANmweca4RRq\nQHDPT7shx3CuosvL2Ori/ws=\n-----END CERTIFICATE-----`; -export const unsupportedSignatureInt = `-----BEGIN CERTIFICATE-----\nMIICfTCCAWWgAwIBAgIUei2XIhhsP1/ytDciEGfA1C7t/sMwDQYJKoZIhvcNAQEL\nBQAwFjEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMjMwNzE4MTg1NDA3WhcNMjMw\nODE5MTg1NDM3WjASMRAwDgYDVQQDEwdpbnQtY3NyMCowBQYDK2VwAyEAa9vHnJA3\nnzA/fYiTUg8EhomjMtVp5O2c01nQRXEv72OjgcAwgb0wDgYDVR0PAQH/BAQDAgEG\nMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFGtjjUwrRGmFmYBHrUE38tSxvVM3\nMB8GA1UdIwQYMBaAFNng9+uArFyIUcD23XdvCSIfYiDPMEYGCCsGAQUFBwEBBDow\nODAZBggrBgEFBQcwAoYNaGFzaGljb3JwLmNvbTAbBggrBgEFBQcwAoYPdmF1bHRw\ncm9qZWN0LmlvMBIGA1UdEQQLMAmCB2ludC1jc3IwDQYJKoZIhvcNAQELBQADggEB\nAAOSNgZjesJG4BgLU8jQmOO7n6W8WcR+dT+ELDC1nLlEZ2BJCDSXXUX8AihIHKxn\nA9W4slABUacyJlAZo/o/wcxyfbA6PUXmHnoqEPZ3zXMwuLN/iRW7/uQvI6TIwnpH\nXETFARLmK8cfGgbhi24STkHTF4ljczkOab7sTUQTHELlo+F2gNtmgnyaBFCGUYor\nX1pkMBcBa9BWRsfhy8E+tBVVUrNNUddwzC/5nMLqT8XqENMndDoG7eeT9Ex6otZy\nzURkcq09FtcmyY2RBYkV4UzyHN7cESMIk/J33ZCNAfHaDGuOqTy5nYU5fTtjJcit\nwEcWiSesrKPCletBpuMpgiU=\n-----END CERTIFICATE-----\n`; diff --git a/ui/tests/helpers/pki/workflow.js b/ui/tests/helpers/pki/workflow.js deleted file mode 100644 index c962265dd630..000000000000 --- a/ui/tests/helpers/pki/workflow.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { SELECTORS as ROLEFORM } from './pki-role-form'; -import { SELECTORS as GENERATECERT } from './pki-role-generate'; -import { SELECTORS as KEYFORM } from './pki-key-form'; -import { SELECTORS as KEYPAGES } from './page/pki-keys'; -import { SELECTORS as ISSUERDETAILS } from './pki-issuer-details'; -import { SELECTORS as CONFIGURATION } from './pki-configure-create'; -import { SELECTORS as DELETE } from './pki-delete-all-issuers'; -import { SELECTORS as TIDY } from './page/pki-tidy-form'; -import { SELECTORS as CONFIGEDIT } from './page/pki-configuration-edit'; -import { SELECTORS as GENROOT } from './pki-generate-root'; - -export const SELECTORS = { - breadcrumbContainer: '[data-test-breadcrumbs]', - breadcrumbs: '[data-test-breadcrumbs] li', - overviewBreadcrumb: '[data-test-breadcrumbs] li:nth-of-type(2) > a', - pageTitle: '[data-test-pki-role-page-title]', - emptyState: '[data-test-component="empty-state"]', - emptyStateTitle: '[data-test-empty-state-title]', - emptyStateLink: '.empty-state-actions a', - emptyStateMessage: '[data-test-empty-state-message]', - // TABS - overviewTab: '[data-test-secret-list-tab="Overview"]', - rolesTab: '[data-test-secret-list-tab="Roles"]', - issuersTab: '[data-test-secret-list-tab="Issuers"]', - certsTab: '[data-test-secret-list-tab="Certificates"]', - keysTab: '[data-test-secret-list-tab="Keys"]', - tidyTab: '[data-test-secret-list-tab="Tidy"]', - configTab: '[data-test-secret-list-tab="Configuration"]', - // ROLES - deleteRoleButton: '[data-test-pki-role-delete]', - generateCertLink: '[data-test-pki-role-generate-cert]', - signCertLink: '[data-test-pki-role-sign-cert]', - editRoleLink: '[data-test-pki-role-edit-link]', - createRoleLink: '[data-test-pki-role-create-link]', - roleForm: { - ...ROLEFORM, - }, - generateCertForm: { - ...GENERATECERT, - }, - // KEYS - keyForm: { - ...KEYFORM, - }, - keyPages: { - ...KEYPAGES, - }, - // ISSUERS - issuerListItem: (id) => `[data-test-issuer-list="${id}"]`, - importIssuerLink: '[data-test-generate-issuer="import"]', - generateIssuerDropdown: '[data-test-issuer-generate-dropdown]', - generateIssuerRoot: '[data-test-generate-issuer="root"]', - generateIssuerIntermediate: '[data-test-generate-issuer="intermediate"]', - issuerPopupMenu: '[data-test-popup-menu-trigger]', - issuerPopupDetails: '[data-test-popup-menu-details]', - issuerDetails: { - title: '[data-test-pki-issuer-page-title]', - ...ISSUERDETAILS, - }, - // CONFIGURATION - configuration: { - title: '[data-test-pki-configuration-page-title]', - emptyState: '[data-test-configuration-empty-state]', - nextStepsBanner: '[data-test-config-next-steps]', - importError: '[data-test-message-error]', - pkiBetaBanner: '[data-test-pki-configuration-banner]', - pkiBetaBannerLink: '[data-test-pki-configuration-banner] a', - ...CONFIGURATION, - ...DELETE, - ...TIDY, - ...GENROOT, - }, - // EDIT CONFIGURATION - configEdit: { - ...CONFIGEDIT, - }, -}; diff --git a/ui/tests/helpers/stubs.js b/ui/tests/helpers/stubs.js index 887fb82d1d1a..ab674dbf1fd8 100644 --- a/ui/tests/helpers/stubs.js +++ b/ui/tests/helpers/stubs.js @@ -3,11 +3,11 @@ * SPDX-License-Identifier: BUSL-1.1 */ +import { Response } from 'miragejs'; + export function capabilitiesStub(requestPath, capabilitiesArray) { // sample of capabilitiesArray: ['read', 'update'] return { - [requestPath]: capabilitiesArray, - capabilities: capabilitiesArray, request_id: '40f7e44d-af5c-9b60-bd20-df72eb17e294', lease_id: '', renewable: false, @@ -57,3 +57,26 @@ export function allowAllCapabilitiesStub(capabilitiesList = ['root']) { }; }; } + +/** + * returns a response with the given httpStatus and data based on status + * @param {number} httpStatus 403, 404, 204, or 200 (default) + * @param {object} payload what to return in the response if status is 200 + * @returns {Response} + */ +export function overrideResponse(httpStatus = 200, payload = {}) { + if (httpStatus === 403) { + return new Response( + 403, + { 'Content-Type': 'application/json' }, + JSON.stringify({ errors: ['permission denied'] }) + ); + } + if (httpStatus === 404) { + return new Response(404, { 'Content-Type': 'application/json' }); + } + if (httpStatus === 204) { + return new Response(204, { 'Content-Type': 'application/json' }); + } + return new Response(200, { 'Content-Type': 'application/json' }, payload); +} diff --git a/ui/tests/helpers/sync/sync-selectors.js b/ui/tests/helpers/sync/sync-selectors.js index 2bd7d9cc3f63..9a7123b45bd9 100644 --- a/ui/tests/helpers/sync/sync-selectors.js +++ b/ui/tests/helpers/sync/sync-selectors.js @@ -4,7 +4,7 @@ */ import { click, fillIn } from '@ember/test-helpers'; -import { SELECTORS as GENERAL } from 'vault/tests/helpers/general-selectors'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; export const PAGE = { ...GENERAL, diff --git a/ui/tests/integration/components/auth-config-form/options-test.js b/ui/tests/integration/components/auth-config-form/options-test.js index c55b16a97c46..8f51ae81eb61 100644 --- a/ui/tests/integration/components/auth-config-form/options-test.js +++ b/ui/tests/integration/components/auth-config-form/options-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { click, fillIn, render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -import { SELECTORS } from 'vault/tests/helpers/general-selectors'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { methods } from 'vault/helpers/mountable-auth-methods'; const userLockoutSupported = ['approle', 'ldap', 'userpass']; @@ -66,24 +66,24 @@ module('Integration | Component | auth-config-form options', function (hooks) { assert.dom('[data-test-user-lockout-section]').hasText('User lockout configuration'); - await click(SELECTORS.inputByAttr('config.listingVisibility')); - await fillIn(SELECTORS.inputByAttr('config.tokenType'), 'default-batch'); + await click(GENERAL.inputByAttr('config.listingVisibility')); + await fillIn(GENERAL.inputByAttr('config.tokenType'), 'default-batch'); - await click(SELECTORS.ttl.toggle('Default Lease TTL')); - await fillIn(SELECTORS.ttl.input('Default Lease TTL'), '30'); + await click(GENERAL.ttl.toggle('Default Lease TTL')); + await fillIn(GENERAL.ttl.input('Default Lease TTL'), '30'); - await fillIn(SELECTORS.inputByAttr('config.lockoutThreshold'), '7'); + await fillIn(GENERAL.inputByAttr('config.lockoutThreshold'), '7'); - await click(SELECTORS.ttl.toggle('Lockout duration')); - await fillIn(SELECTORS.ttl.input('Lockout duration'), '10'); + await click(GENERAL.ttl.toggle('Lockout duration')); + await fillIn(GENERAL.ttl.input('Lockout duration'), '10'); await fillIn( - `${SELECTORS.inputByAttr('config.lockoutDuration')} ${SELECTORS.selectByAttr('ttl-unit')}`, + `${GENERAL.inputByAttr('config.lockoutDuration')} ${GENERAL.selectByAttr('ttl-unit')}`, 'm' ); - await click(SELECTORS.ttl.toggle('Lockout counter reset')); - await fillIn(SELECTORS.ttl.input('Lockout counter reset'), '5'); + await click(GENERAL.ttl.toggle('Lockout counter reset')); + await fillIn(GENERAL.ttl.input('Lockout counter reset'), '5'); - await click(SELECTORS.inputByAttr('config.lockoutDisable')); + await click(GENERAL.inputByAttr('config.lockoutDisable')); await click('[data-test-save-config]'); }); @@ -124,23 +124,23 @@ module('Integration | Component | auth-config-form options', function (hooks) { .dom('[data-test-user-lockout-section]') .doesNotExist(`${type} method does not render user lockout section`); - await click(SELECTORS.inputByAttr('config.listingVisibility')); - await fillIn(SELECTORS.inputByAttr('config.tokenType'), 'default-batch'); + await click(GENERAL.inputByAttr('config.listingVisibility')); + await fillIn(GENERAL.inputByAttr('config.tokenType'), 'default-batch'); - await click(SELECTORS.ttl.toggle('Default Lease TTL')); - await fillIn(SELECTORS.ttl.input('Default Lease TTL'), '30'); + await click(GENERAL.ttl.toggle('Default Lease TTL')); + await fillIn(GENERAL.ttl.input('Default Lease TTL'), '30'); assert - .dom(SELECTORS.inputByAttr('config.lockoutThreshold')) + .dom(GENERAL.inputByAttr('config.lockoutThreshold')) .doesNotExist(`${type} method does not render lockout threshold`); assert - .dom(SELECTORS.ttl.toggle('Lockout duration')) + .dom(GENERAL.ttl.toggle('Lockout duration')) .doesNotExist(`${type} method does not render lockout duration `); assert - .dom(SELECTORS.ttl.toggle('Lockout counter reset')) + .dom(GENERAL.ttl.toggle('Lockout counter reset')) .doesNotExist(`${type} method does not render lockout counter reset`); assert - .dom(SELECTORS.inputByAttr('config.lockoutDisable')) + .dom(GENERAL.inputByAttr('config.lockoutDisable')) .doesNotExist(`${type} method does not render lockout disable`); await click('[data-test-save-config]'); @@ -175,25 +175,25 @@ module('Integration | Component | auth-config-form options', function (hooks) { await render(hbs``); assert - .dom(SELECTORS.inputByAttr('config.tokenType')) + .dom(GENERAL.inputByAttr('config.tokenType')) .doesNotExist('does not render tokenType for token auth method'); - await click(SELECTORS.inputByAttr('config.listingVisibility')); - await click(SELECTORS.ttl.toggle('Default Lease TTL')); - await fillIn(SELECTORS.ttl.input('Default Lease TTL'), '30'); + await click(GENERAL.inputByAttr('config.listingVisibility')); + await click(GENERAL.ttl.toggle('Default Lease TTL')); + await fillIn(GENERAL.ttl.input('Default Lease TTL'), '30'); assert.dom('[data-test-user-lockout-section]').doesNotExist('token does not render user lockout section'); assert - .dom(SELECTORS.inputByAttr('config.lockoutThreshold')) + .dom(GENERAL.inputByAttr('config.lockoutThreshold')) .doesNotExist('token method does not render lockout threshold'); assert - .dom(SELECTORS.ttl.toggle('Lockout duration')) + .dom(GENERAL.ttl.toggle('Lockout duration')) .doesNotExist('token method does not render lockout duration '); assert - .dom(SELECTORS.ttl.toggle('Lockout counter reset')) + .dom(GENERAL.ttl.toggle('Lockout counter reset')) .doesNotExist('token method does not render lockout counter reset'); assert - .dom(SELECTORS.inputByAttr('config.lockoutDisable')) + .dom(GENERAL.inputByAttr('config.lockoutDisable')) .doesNotExist('token method does not render lockout disable'); await click('[data-test-save-config]'); diff --git a/ui/tests/integration/components/certificate-card-test.js b/ui/tests/integration/components/certificate-card-test.js index 668004765494..e1942a1c84e8 100644 --- a/ui/tests/integration/components/certificate-card-test.js +++ b/ui/tests/integration/components/certificate-card-test.js @@ -7,7 +7,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'vault/tests/helpers'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import { rootPem, rootDer } from 'vault/tests/helpers/pki/values'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; const SELECTORS = { label: '[data-test-certificate-label]', @@ -16,6 +16,7 @@ const SELECTORS = { copyButton: '[data-test-copy-button]', copyIcon: '[data-test-icon="clipboard-copy"]', }; +const { rootPem, rootDer } = CERTIFICATES; module('Integration | Component | certificate-card', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/clients/page/counts-test.js b/ui/tests/integration/components/clients/page/counts-test.js index b65b7978504e..08391ff28f71 100644 --- a/ui/tests/integration/components/clients/page/counts-test.js +++ b/ui/tests/integration/components/clients/page/counts-test.js @@ -10,7 +10,9 @@ import { render, click, settled, findAll } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import clientsHandler, { LICENSE_START, STATIC_NOW } from 'vault/mirage/handlers/clients'; import { getUnixTime } from 'date-fns'; -import { SELECTORS as ts, dateDropdownSelect } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; +import { dateDropdownSelect } from 'vault/tests/helpers/clients/client-count-helpers'; import { selectChoose } from 'ember-power-select/test-support/helpers'; import timestamp from 'core/utils/timestamp'; import sinon from 'sinon'; @@ -64,9 +66,9 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); - assert.dom(ts.counts.startLabel).hasText('Client counting start date', 'Label renders for OSS'); + assert.dom(CLIENT_COUNT.counts.startLabel).hasText('Client counting start date', 'Label renders for OSS'); assert - .dom(ts.counts.description) + .dom(CLIENT_COUNT.counts.description) .hasText( 'This date is when client counting starts. Without this starting point, the data shown is not reliable.', 'Description renders for OSS' @@ -75,9 +77,9 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { versionService.set('type', 'enterprise'); await settled(); - assert.dom(ts.counts.startLabel).hasText('Billing start month', 'Label renders for Enterprise'); + assert.dom(CLIENT_COUNT.counts.startLabel).hasText('Billing start month', 'Label renders for Enterprise'); assert - .dom(ts.counts.description) + .dom(CLIENT_COUNT.counts.description) .hasText( 'This date comes from your license, and defines when client counting starts. Without this starting point, the data shown is not reliable.', 'Description renders for Enterprise' @@ -87,9 +89,9 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { test('it should populate start and end month displays', async function (assert) { await this.renderComponent(); - assert.dom(ts.counts.startMonth).hasText('July 2023', 'Start month renders'); + assert.dom(CLIENT_COUNT.counts.startMonth).hasText('July 2023', 'Start month renders'); assert - .dom(ts.calendarWidget.trigger) + .dom(CLIENT_COUNT.calendarWidget.trigger) .hasText('Jul 2023 - Jan 2024', 'Start and end months render in filter bar'); }); @@ -99,7 +101,7 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); assert - .dom(ts.emptyStateTitle) + .dom(GENERAL.emptyStateTitle) .hasText('No data received from July 2023 to January 2024', 'No data empty state renders'); }); @@ -109,7 +111,9 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); - assert.dom(ts.emptyStateTitle).hasText('You are not authorized', 'Activity error empty state renders'); + assert + .dom(GENERAL.emptyStateTitle) + .hasText('You are not authorized', 'Activity error empty state renders'); }); test('it should render config disabled alert', async function (assert) { @@ -117,7 +121,9 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); - assert.dom(ts.counts.configDisabled).hasText('Tracking is disabled', 'Config disabled alert renders'); + assert + .dom(CLIENT_COUNT.counts.configDisabled) + .hasText('Tracking is disabled', 'Config disabled alert renders'); }); test('it should send correct values on start and end date change', async function (assert) { @@ -134,18 +140,18 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await dateDropdownSelect('January', '2023'); expected.start_time = END_TIME; - await click(ts.calendarWidget.trigger); - await click(ts.calendarWidget.currentMonth); + await click(CLIENT_COUNT.calendarWidget.trigger); + await click(CLIENT_COUNT.calendarWidget.currentMonth); expected.start_time = getUnixTime(this.config.billingStartTimestamp); - await click(ts.calendarWidget.trigger); - await click(ts.calendarWidget.currentBillingPeriod); + await click(CLIENT_COUNT.calendarWidget.trigger); + await click(CLIENT_COUNT.calendarWidget.currentBillingPeriod); expected = { end_time: getUnixTime(new Date('2023-12-31T00:00:00Z')) }; - await click(ts.calendarWidget.trigger); - await click(ts.calendarWidget.customEndMonth); - await click(ts.calendarWidget.previousYear); - await click(ts.calendarWidget.calendarMonth('December')); + await click(CLIENT_COUNT.calendarWidget.trigger); + await click(CLIENT_COUNT.calendarWidget.customEndMonth); + await click(CLIENT_COUNT.calendarWidget.previousYear); + await click(CLIENT_COUNT.calendarWidget.calendarMonth('December')); }); test('it should render namespace and auth mount filters', async function (assert) { @@ -167,21 +173,21 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); - assert.dom(ts.counts.namespaces).includesText(this.namespace, 'Selected namespace renders'); - assert.dom(ts.counts.mountPaths).includesText(this.mountPath, 'Selected auth mount renders'); + assert.dom(CLIENT_COUNT.counts.namespaces).includesText(this.namespace, 'Selected namespace renders'); + assert.dom(CLIENT_COUNT.counts.mountPaths).includesText(this.mountPath, 'Selected auth mount renders'); - await click(`${ts.counts.namespaces} button`); + await click(`${CLIENT_COUNT.counts.namespaces} button`); // this is only necessary in tests since SearchSelect does not respond to initialValue changes // in the app the component is rerender on query param change assertion = null; - await click(`${ts.counts.mountPaths} button`); + await click(`${CLIENT_COUNT.counts.mountPaths} button`); assertion = (params) => assert.true(params.ns.includes('ns/'), 'Namespace value sent on change'); - await selectChoose(ts.counts.namespaces, '.ember-power-select-option', 0); + await selectChoose(CLIENT_COUNT.counts.namespaces, '.ember-power-select-option', 0); assertion = (params) => assert.true(params.mountPath.includes('auth/'), 'Auth mount value sent on change'); - await selectChoose(ts.counts.mountPaths, 'auth/authid0'); + await selectChoose(CLIENT_COUNT.counts.mountPaths, 'auth/authid0'); }); test('it should render start time discrepancy alert', async function (assert) { @@ -190,7 +196,7 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); assert - .dom(ts.counts.startDiscrepancy) + .dom(CLIENT_COUNT.counts.startDiscrepancy) .hasText( 'You requested data from June 2022. We only have data from July 2023, and that is what is being shown here.', 'Start discrepancy alert renders' @@ -212,18 +218,18 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); assert - .dom(ts.upgradeWarning) + .dom(CLIENT_COUNT.upgradeWarning) .hasTextContaining( `Client count data contains 2 upgrades Vault was upgraded during this time period. Keep this in mind while looking at the data. Visit our Client count FAQ for more information.`, 'it renders title and subtext' ); assert - .dom(`${ts.upgradeWarning} ul`) + .dom(`${CLIENT_COUNT.upgradeWarning} ul`) .doesNotHaveTextContaining( '1.9.1', 'Warning does not include subsequent patch releases (e.g. 1.9.1) of the same notable upgrade.' ); - const [first, second] = findAll(`${ts.upgradeWarning} li`); + const [first, second] = findAll(`${CLIENT_COUNT.upgradeWarning} li`); assert .dom(first) .hasText( @@ -246,8 +252,10 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); - assert.dom(ts.emptyStateTitle).hasText('No start date found', 'Empty state renders'); - assert.dom(ts.counts.startDropdown).exists('Date dropdown renders when start time is not provided'); + assert.dom(GENERAL.emptyStateTitle).hasText('No start date found', 'Empty state renders'); + assert + .dom(CLIENT_COUNT.counts.startDropdown) + .exists('Date dropdown renders when start time is not provided'); }); test('it should render catch all empty state', async function (assert) { @@ -256,7 +264,7 @@ module('Integration | Component | clients | Page::Counts', function (hooks) { await this.renderComponent(); assert - .dom(ts.emptyStateTitle) + .dom(GENERAL.emptyStateTitle) .hasText('No data received from July 2023 to January 2024', 'Empty state renders'); }); }); diff --git a/ui/tests/integration/components/clients/page/sync-test.js b/ui/tests/integration/components/clients/page/sync-test.js index 0d75c9ae3bd1..b7a326f98ece 100644 --- a/ui/tests/integration/components/clients/page/sync-test.js +++ b/ui/tests/integration/components/clients/page/sync-test.js @@ -10,14 +10,15 @@ import { render, findAll } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import clientsHandler, { LICENSE_START, STATIC_NOW } from 'vault/mirage/handlers/clients'; import { getUnixTime } from 'date-fns'; -import { SELECTORS } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; import { formatNumber } from 'core/helpers/format-number'; import { calculateAverage } from 'vault/utils/chart-helpers'; import { dateFormat } from 'core/helpers/date-format'; const START_TIME = getUnixTime(LICENSE_START); const END_TIME = getUnixTime(STATIC_NOW); -const { syncTab, charts, usageStats } = SELECTORS; +const { syncTab, charts, usageStats } = CLIENT_COUNT; module('Integration | Component | clients | Clients::Page::Sync', function (hooks) { setupRenderingTest(hooks); @@ -98,7 +99,7 @@ module('Integration | Component | clients | Clients::Page::Sync', function (hook await this.renderComponent(); assert.dom(charts.chart('Secrets sync usage')).doesNotExist('vertical bar chart does not render'); - assert.dom(SELECTORS.emptyStateTitle).hasText('No monthly secrets sync clients'); + assert.dom(GENERAL.emptyStateTitle).hasText('No monthly secrets sync clients'); const formattedTimestamp = dateFormat([this.activity.responseTimestamp, 'MMM d yyyy, h:mm:ss aaa'], { withTimeZone: true, }); @@ -130,11 +131,11 @@ module('Integration | Component | clients | Clients::Page::Sync', function (hook await this.renderComponent(); - assert.dom(SELECTORS.emptyStateTitle).hasText('No Secrets Sync clients'); + assert.dom(GENERAL.emptyStateTitle).hasText('No Secrets Sync clients'); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText('No data is available because Secrets Sync has not been activated.'); - assert.dom(SELECTORS.emptyStateActions).hasText('Activate Secrets Sync'); + assert.dom(GENERAL.emptyStateActions).hasText('Activate Secrets Sync'); assert.dom(charts.chart('Secrets sync usage')).doesNotExist(); assert.dom(syncTab.total).doesNotExist(); diff --git a/ui/tests/integration/components/clients/page/token-test.js b/ui/tests/integration/components/clients/page/token-test.js index cee69399aa14..a9ef898c9a7c 100644 --- a/ui/tests/integration/components/clients/page/token-test.js +++ b/ui/tests/integration/components/clients/page/token-test.js @@ -13,7 +13,8 @@ import { getUnixTime } from 'date-fns'; import { calculateAverage } from 'vault/utils/chart-helpers'; import { formatNumber } from 'core/helpers/format-number'; import { dateFormat } from 'core/helpers/date-format'; -import { SELECTORS as ts } from 'vault/tests/helpers/clients'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; const START_TIME = getUnixTime(LICENSE_START); const END_TIME = getUnixTime(STATIC_NOW); @@ -67,18 +68,18 @@ module('Integration | Component | clients | Page::Token', function (hooks) { }; const expectedTotal = getAverage(this.activity.byMonth); const expectedNew = getAverage(this.newActivity); - const chart = ts.charts.chart('monthly total'); + const chart = CLIENT_COUNT.charts.chart('monthly total'); await this.renderComponent(); assert - .dom(ts.charts.statTextValue('Average total clients per month')) + .dom(CLIENT_COUNT.charts.statTextValue('Average total clients per month')) .hasText(expectedTotal, 'renders correct total clients'); assert - .dom(ts.charts.statTextValue('Average new clients per month')) + .dom(CLIENT_COUNT.charts.statTextValue('Average new clients per month')) .hasText(expectedNew, 'renders correct new clients'); // assert bar chart is correct - findAll(`${chart} ${ts.charts.bar.xAxisLabel}`).forEach((e, i) => { + findAll(`${chart} ${CLIENT_COUNT.charts.bar.xAxisLabel}`).forEach((e, i) => { assert .dom(e) .hasText( @@ -87,7 +88,7 @@ module('Integration | Component | clients | Page::Token', function (hooks) { ); }); assert - .dom(`${chart} ${ts.charts.bar.dataBar}`) + .dom(`${chart} ${CLIENT_COUNT.charts.bar.dataBar}`) .exists( { count: this.activity.byMonth.filter((m) => m.clients).length * 2 }, 'renders two stacked data bars of entity/non-entity clients for each month' @@ -96,27 +97,31 @@ module('Integration | Component | clients | Page::Token', function (hooks) { withTimeZone: true, }); assert - .dom(`${chart} ${ts.charts.timestamp}`) + .dom(`${chart} ${CLIENT_COUNT.charts.timestamp}`) .hasText(`Updated ${formattedTimestamp}`, 'renders timestamp'); - assert.dom(`${chart} ${ts.charts.legendLabel(1)}`).hasText('Entity clients', 'Legend label renders'); - assert.dom(`${chart} ${ts.charts.legendLabel(2)}`).hasText('Non-entity clients', 'Legend label renders'); + assert + .dom(`${chart} ${CLIENT_COUNT.charts.legendLabel(1)}`) + .hasText('Entity clients', 'Legend label renders'); + assert + .dom(`${chart} ${CLIENT_COUNT.charts.legendLabel(2)}`) + .hasText('Non-entity clients', 'Legend label renders'); }); test('it should render monthly new chart', async function (assert) { const expectedNewEntity = formatNumber([calculateAverage(this.newActivity, 'entity_clients')]); const expectedNewNonEntity = formatNumber([calculateAverage(this.newActivity, 'non_entity_clients')]); - const chart = ts.charts.chart('monthly new'); + const chart = CLIENT_COUNT.charts.chart('monthly new'); await this.renderComponent(); assert - .dom(ts.charts.statTextValue('Average new entity clients per month')) + .dom(CLIENT_COUNT.charts.statTextValue('Average new entity clients per month')) .hasText(expectedNewEntity, 'renders correct new entity clients'); assert - .dom(ts.charts.statTextValue('Average new non-entity clients per month')) + .dom(CLIENT_COUNT.charts.statTextValue('Average new non-entity clients per month')) .hasText(expectedNewNonEntity, 'renders correct new nonentity clients'); // assert bar chart is correct - findAll(`${chart} ${ts.charts.bar.xAxisLabel}`).forEach((e, i) => { + findAll(`${chart} ${CLIENT_COUNT.charts.bar.xAxisLabel}`).forEach((e, i) => { assert .dom(e) .hasText( @@ -125,7 +130,7 @@ module('Integration | Component | clients | Page::Token', function (hooks) { ); }); assert - .dom(`${chart} ${ts.charts.bar.dataBar}`) + .dom(`${chart} ${CLIENT_COUNT.charts.bar.dataBar}`) .exists( { count: this.activity.byMonth.filter((m) => m.clients).length * 2 }, 'renders two stacked bars of new entity/non-entity clients for each month' @@ -134,10 +139,14 @@ module('Integration | Component | clients | Page::Token', function (hooks) { withTimeZone: true, }); assert - .dom(`${chart} ${ts.charts.timestamp}`) + .dom(`${chart} ${CLIENT_COUNT.charts.timestamp}`) .hasText(`Updated ${formattedTimestamp}`, 'renders timestamp'); - assert.dom(`${chart} ${ts.charts.legendLabel(1)}`).hasText('Entity clients', 'Legend label renders'); - assert.dom(`${chart} ${ts.charts.legendLabel(2)}`).hasText('Non-entity clients', 'Legend label renders'); + assert + .dom(`${chart} ${CLIENT_COUNT.charts.legendLabel(1)}`) + .hasText('Entity clients', 'Legend label renders'); + assert + .dom(`${chart} ${CLIENT_COUNT.charts.legendLabel(2)}`) + .hasText('Non-entity clients', 'Legend label renders'); }); test('it should render empty state for no new monthly data', async function (assert) { @@ -145,15 +154,15 @@ module('Integration | Component | clients | Page::Token', function (hooks) { ...d, new_clients: { month: d.month }, })); - const chart = ts.charts.chart('monthly-new'); + const chart = CLIENT_COUNT.charts.chart('monthly-new'); await this.renderComponent(); - assert.dom(`${chart} ${ts.charts.verticalBar}`).doesNotExist('Chart does not render'); - assert.dom(`${chart} ${ts.charts.legend}`).doesNotExist('Legend does not render'); - assert.dom(ts.emptyStateTitle).hasText('No new clients'); - assert.dom(ts.tokenTab.entity).doesNotExist('New client counts does not exist'); - assert.dom(ts.tokenTab.nonentity).doesNotExist('Average new client counts does not exist'); + assert.dom(`${chart} ${CLIENT_COUNT.charts.verticalBar}`).doesNotExist('Chart does not render'); + assert.dom(`${chart} ${CLIENT_COUNT.charts.legend}`).doesNotExist('Legend does not render'); + assert.dom(GENERAL.emptyStateTitle).hasText('No new clients'); + assert.dom(CLIENT_COUNT.tokenTab.entity).doesNotExist('New client counts does not exist'); + assert.dom(CLIENT_COUNT.tokenTab.nonentity).doesNotExist('Average new client counts does not exist'); }); test('it should render usage stats', async function (assert) { @@ -166,13 +175,13 @@ module('Integration | Component | clients | Page::Token', function (hooks) { const checkUsage = () => { assert - .dom(ts.charts.statTextValue('Total clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Total clients')) .hasText(formatNumber([entity_clients + non_entity_clients]), 'Total clients value renders'); assert - .dom(ts.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .hasText(formatNumber([entity_clients]), 'Entity clients value renders'); assert - .dom(ts.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .hasText(formatNumber([non_entity_clients]), 'Non-entity clients value renders'); }; diff --git a/ui/tests/integration/components/clients/running-total-test.js b/ui/tests/integration/components/clients/running-total-test.js index fc42e32aef4d..0bcd150f0d3c 100644 --- a/ui/tests/integration/components/clients/running-total-test.js +++ b/ui/tests/integration/components/clients/running-total-test.js @@ -15,7 +15,7 @@ import { findAll } from '@ember/test-helpers'; import { formatNumber } from 'core/helpers/format-number'; import timestamp from 'core/utils/timestamp'; import { setRunOptions } from 'ember-a11y-testing/test-support'; -import { SELECTORS as ts } from 'vault/tests/helpers/clients'; +import { CLIENT_COUNT } from 'vault/tests/helpers/clients/client-count-selectors'; const START_TIME = getUnixTime(LICENSE_START); @@ -77,23 +77,23 @@ module('Integration | Component | clients/running-total', function (hooks) { await this.renderComponent(); - assert.dom(ts.charts.chart('running total')).exists('running total component renders'); - assert.dom(ts.charts.lineChart).exists('line chart renders'); + assert.dom(CLIENT_COUNT.charts.chart('running total')).exists('running total component renders'); + assert.dom(CLIENT_COUNT.charts.lineChart).exists('line chart renders'); assert - .dom(ts.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .hasText(`${expectedTotalEntity}`, `renders correct total entity average ${expectedTotalEntity}`); assert - .dom(ts.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .hasText( `${expectedTotalNonEntity}`, `renders correct total nonentity average ${expectedTotalNonEntity}` ); assert - .dom(ts.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .hasText(`${expectedTotalSync}`, `renders correct total sync ${expectedTotalSync}`); // assert line chart is correct - findAll(ts.charts.line.xAxisLabel).forEach((e, i) => { + findAll(CLIENT_COUNT.charts.line.xAxisLabel).forEach((e, i) => { assert .dom(e) .hasText( @@ -102,7 +102,7 @@ module('Integration | Component | clients/running-total', function (hooks) { ); }); assert - .dom(ts.charts.line.plotPoint) + .dom(CLIENT_COUNT.charts.line.plotPoint) .exists( { count: this.byMonthActivity.filter((m) => m.clients).length }, 'renders correct number of plot points' @@ -121,20 +121,20 @@ module('Integration | Component | clients/running-total', function (hooks) { await this.renderComponent(); - assert.dom(ts.charts.chart('running total')).exists('running total component renders'); - assert.dom(ts.charts.lineChart).exists('line chart renders'); + assert.dom(CLIENT_COUNT.charts.chart('running total')).exists('running total component renders'); + assert.dom(CLIENT_COUNT.charts.lineChart).exists('line chart renders'); assert - .dom(ts.charts.statTextValue('Entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Entity clients')) .hasText(`${expectedTotalEntity}`, `renders correct total entity average ${expectedTotalEntity}`); assert - .dom(ts.charts.statTextValue('Non-entity clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')) .hasText( `${expectedTotalNonEntity}`, `renders correct total nonentity average ${expectedTotalNonEntity}` ); assert - .dom(ts.charts.statTextValue('Secrets sync clients')) + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) .hasText(`${expectedTotalSync}`, `renders correct total sync ${expectedTotalSync}`); }); @@ -150,14 +150,14 @@ module('Integration | Component | clients/running-total', function (hooks) { const expectedNewEntity = formatNumber([singleMonthNew.entity_clients]); const expectedNewNonEntity = formatNumber([singleMonthNew.non_entity_clients]); const expectedNewSyncs = formatNumber([singleMonthNew.secret_syncs]); - const { statTextValue } = ts.charts; + const { statTextValue } = CLIENT_COUNT.charts; this.byMonthActivity = [singleMonth]; this.isHistoricalMonth = true; await this.renderComponent(); - assert.dom(ts.charts.lineChart).doesNotExist('line chart does not render'); + assert.dom(CLIENT_COUNT.charts.lineChart).doesNotExist('line chart does not render'); assert.dom(statTextValue()).exists({ count: 8 }, 'renders 6 stat text containers'); assert .dom(`[data-test-new] ${statTextValue('New clients')}`) @@ -190,10 +190,12 @@ module('Integration | Component | clients/running-total', function (hooks) { await this.renderComponent(); - assert.dom(ts.charts.chart('running total')).exists('running total component renders'); - assert.dom(ts.charts.lineChart).exists('line chart renders'); - assert.dom(ts.charts.statTextValue('Entity clients')).exists(); - assert.dom(ts.charts.statTextValue('Non-entity clients')).exists(); - assert.dom(ts.charts.statTextValue('Secrets sync clients')).doesNotExist('does not render secret syncs'); + assert.dom(CLIENT_COUNT.charts.chart('running total')).exists('running total component renders'); + assert.dom(CLIENT_COUNT.charts.lineChart).exists('line chart renders'); + assert.dom(CLIENT_COUNT.charts.statTextValue('Entity clients')).exists(); + assert.dom(CLIENT_COUNT.charts.statTextValue('Non-entity clients')).exists(); + assert + .dom(CLIENT_COUNT.charts.statTextValue('Secrets sync clients')) + .doesNotExist('does not render secret syncs'); }); }); diff --git a/ui/tests/integration/components/config-ui/messages/page/create-and-edit-test.js b/ui/tests/integration/components/config-ui/messages/page/create-and-edit-test.js index be01689cff7c..e08430ed6285 100644 --- a/ui/tests/integration/components/config-ui/messages/page/create-and-edit-test.js +++ b/ui/tests/integration/components/config-ui/messages/page/create-and-edit-test.js @@ -11,8 +11,9 @@ import { render, click, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { datetimeLocalStringFormat } from 'core/utils/date-formatters'; import { format, addDays, startOfDay } from 'date-fns'; -import { PAGE } from 'vault/tests/helpers/config-ui/message-selectors'; +import { CUSTOM_MESSAGES } from 'vault/tests/helpers/config-ui/message-selectors'; import timestamp from 'core/utils/timestamp'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; module('Integration | Component | messages/page/create-and-edit', function (hooks) { setupRenderingTest(hooks); @@ -32,25 +33,25 @@ module('Integration | Component | messages/page/create-and-edit', function (hook owner: this.engine, }); - assert.dom(PAGE.title).hasText('Create message'); - assert.dom(PAGE.radio('authenticated')).exists(); - assert.dom(PAGE.radio('unauthenticated')).exists(); - assert.dom(PAGE.radio('authenticated')).isChecked(); - assert.dom(PAGE.radio('unauthenticated')).isNotChecked(); - assert.dom(PAGE.radio('banner')).exists(); - assert.dom(PAGE.radio('modal')).exists(); - assert.dom(PAGE.radio('banner')).isChecked(); - assert.dom(PAGE.radio('modal')).isNotChecked(); - assert.dom(PAGE.field('title')).exists(); - assert.dom(PAGE.field('message')).exists(); + assert.dom(GENERAL.title).hasText('Create message'); + assert.dom(CUSTOM_MESSAGES.radio('authenticated')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('unauthenticated')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('authenticated')).isChecked(); + assert.dom(CUSTOM_MESSAGES.radio('unauthenticated')).isNotChecked(); + assert.dom(CUSTOM_MESSAGES.radio('banner')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('modal')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('banner')).isChecked(); + assert.dom(CUSTOM_MESSAGES.radio('modal')).isNotChecked(); + assert.dom(CUSTOM_MESSAGES.field('title')).exists(); + assert.dom(CUSTOM_MESSAGES.field('message')).exists(); assert.dom('[data-test-kv-key="0"]').exists(); assert.dom('[data-test-kv-value="0"]').exists(); - assert.dom(PAGE.input('startTime')).exists(); + assert.dom(CUSTOM_MESSAGES.input('startTime')).exists(); assert - .dom(PAGE.input('startTime')) + .dom(CUSTOM_MESSAGES.input('startTime')) .hasValue(format(addDays(startOfDay(timestamp.now()), 1), datetimeLocalStringFormat)); - assert.dom(PAGE.input('endTime')).exists(); - assert.dom(PAGE.input('endTime')).hasValue(''); + assert.dom(CUSTOM_MESSAGES.input('endTime')).exists(); + assert.dom(CUSTOM_MESSAGES.input('endTime')).hasValue(''); }); test('it should display validation errors for invalid form fields', async function (assert) { @@ -59,22 +60,24 @@ module('Integration | Component | messages/page/create-and-edit', function (hook owner: this.engine, }); - await fillIn(PAGE.input('startTime'), '2024-01-20T00:00'); - await fillIn(PAGE.input('endTime'), '2024-01-01T00:00'); - await click(PAGE.button('create-message')); - assert.dom(PAGE.input('title')).hasClass('has-error-border'); - assert.dom(`${PAGE.fieldValidation('title')} ${PAGE.inlineErrorMessage}`).hasText('Title is required.'); - assert.dom(PAGE.input('message')).hasClass('has-error-border'); + await fillIn(CUSTOM_MESSAGES.input('startTime'), '2024-01-20T00:00'); + await fillIn(CUSTOM_MESSAGES.input('endTime'), '2024-01-01T00:00'); + await click(CUSTOM_MESSAGES.button('create-message')); + assert.dom(CUSTOM_MESSAGES.input('title')).hasClass('has-error-border'); assert - .dom(`${PAGE.fieldValidation('message')} ${PAGE.inlineErrorMessage}`) + .dom(`${CUSTOM_MESSAGES.fieldValidation('title')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) + .hasText('Title is required.'); + assert.dom(CUSTOM_MESSAGES.input('message')).hasClass('has-error-border'); + assert + .dom(`${CUSTOM_MESSAGES.fieldValidation('message')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) .hasText('Message is required.'); - assert.dom(PAGE.input('startTime')).hasClass('has-error-border'); + assert.dom(CUSTOM_MESSAGES.input('startTime')).hasClass('has-error-border'); assert - .dom(`${PAGE.fieldValidation('startTime')} ${PAGE.inlineErrorMessage}`) + .dom(`${CUSTOM_MESSAGES.fieldValidation('startTime')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) .hasText('Start time is after end time.'); - assert.dom(PAGE.input('endTime')).hasClass('has-error-border'); + assert.dom(CUSTOM_MESSAGES.input('endTime')).hasClass('has-error-border'); assert - .dom(`${PAGE.fieldValidation('endTime')} ${PAGE.inlineErrorMessage}`) + .dom(`${CUSTOM_MESSAGES.fieldValidation('endTime')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) .hasText('End time is before start time.'); }); @@ -88,23 +91,23 @@ module('Integration | Component | messages/page/create-and-edit', function (hook await render(hbs``, { owner: this.engine, }); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); await fillIn( - PAGE.input('startTime'), + CUSTOM_MESSAGES.input('startTime'), format(addDays(startOfDay(new Date('2023-12-12')), 1), datetimeLocalStringFormat) ); await click('#specificDate'); await fillIn( - PAGE.input('endTime'), + CUSTOM_MESSAGES.input('endTime'), format(addDays(startOfDay(new Date('2023-12-12')), 10), datetimeLocalStringFormat) ); await fillIn('[data-test-kv-key="0"]', 'Learn more'); await fillIn('[data-test-kv-value="0"]', 'www.learn.com'); - await click(PAGE.button('create-message')); + await click(CUSTOM_MESSAGES.button('create-message')); }); test('it should have form vaildations', async function (assert) { @@ -112,12 +115,18 @@ module('Integration | Component | messages/page/create-and-edit', function (hook await render(hbs``, { owner: this.engine, }); - await click(PAGE.button('create-message')); - assert.dom(PAGE.input('title')).hasClass('has-error-border', 'show error border for title field'); - assert.dom(`${PAGE.fieldValidation('title')} ${PAGE.inlineErrorMessage}`).hasText('Title is required.'); - assert.dom(PAGE.input('message')).hasClass('has-error-border', 'show error border for message field'); + await click(CUSTOM_MESSAGES.button('create-message')); + assert + .dom(CUSTOM_MESSAGES.input('title')) + .hasClass('has-error-border', 'show error border for title field'); + assert + .dom(`${CUSTOM_MESSAGES.fieldValidation('title')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) + .hasText('Title is required.'); assert - .dom(`${PAGE.fieldValidation('message')} ${PAGE.inlineErrorMessage}`) + .dom(CUSTOM_MESSAGES.input('message')) + .hasClass('has-error-border', 'show error border for message field'); + assert + .dom(`${CUSTOM_MESSAGES.fieldValidation('message')} ${CUSTOM_MESSAGES.inlineErrorMessage}`) .hasText('Message is required.'); }); @@ -139,23 +148,23 @@ module('Integration | Component | messages/page/create-and-edit', function (hook owner: this.engine, }); - assert.dom(PAGE.title).hasText('Edit message'); - assert.dom(PAGE.radio('authenticated')).exists(); - assert.dom(PAGE.radio('unauthenticated')).isChecked(); - assert.dom(PAGE.radio('modal')).exists(); - assert.dom(PAGE.radio('modal')).isChecked(); - assert.dom(PAGE.input('title')).hasValue('Hello world'); - assert.dom(PAGE.input('message')).hasValue('Blah blah blah. Some super long message.'); + assert.dom(GENERAL.title).hasText('Edit message'); + assert.dom(CUSTOM_MESSAGES.radio('authenticated')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('unauthenticated')).isChecked(); + assert.dom(CUSTOM_MESSAGES.radio('modal')).exists(); + assert.dom(CUSTOM_MESSAGES.radio('modal')).isChecked(); + assert.dom(CUSTOM_MESSAGES.input('title')).hasValue('Hello world'); + assert.dom(CUSTOM_MESSAGES.input('message')).hasValue('Blah blah blah. Some super long message.'); assert.dom('[data-test-kv-key="0"]').exists(); assert.dom('[data-test-kv-key="0"]').hasValue('Learn more'); assert.dom('[data-test-kv-value="0"]').exists(); assert.dom('[data-test-kv-value="0"]').hasValue('www.learnmore.com'); await click('#specificDate'); assert - .dom(PAGE.input('startTime')) + .dom(CUSTOM_MESSAGES.input('startTime')) .hasValue(format(new Date(this.message.startTime), datetimeLocalStringFormat)); assert - .dom(PAGE.input('endTime')) + .dom(CUSTOM_MESSAGES.input('endTime')) .hasValue(format(new Date(this.message.endTime), datetimeLocalStringFormat)); }); @@ -164,24 +173,26 @@ module('Integration | Component | messages/page/create-and-edit', function (hook await render(hbs``, { owner: this.engine, }); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview modal')).doesNotExist(); - assert.dom(PAGE.modal('preview image')).exists(); - assert.dom(PAGE.alertTitle('Awesome custom message title')).hasText('Awesome custom message title'); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview modal')).doesNotExist(); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).exists(); + assert + .dom(CUSTOM_MESSAGES.alertTitle('Awesome custom message title')) + .hasText('Awesome custom message title'); assert - .dom(PAGE.alertDescription('Awesome custom message title')) + .dom(CUSTOM_MESSAGES.alertDescription('Awesome custom message title')) .hasText( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); assert.dom('img').hasAttribute('src', '/ui/images/custom-messages-dashboard.png'); - await click(PAGE.modalButton('Close')); + await click(CUSTOM_MESSAGES.modalButton('Close')); await click('#unauthenticated'); - await click(PAGE.button('preview')); + await click(CUSTOM_MESSAGES.button('preview')); assert.dom('img').hasAttribute('src', '/ui/images/custom-messages-login.png'); }); @@ -190,14 +201,16 @@ module('Integration | Component | messages/page/create-and-edit', function (hook await render(hbs``, { owner: this.engine, }); - await click(PAGE.radio('modal')); - await fillIn(PAGE.input('title'), 'Preview modal title'); - await fillIn(PAGE.input('message'), 'Some preview modal message thats super long.'); - await click(PAGE.button('preview')); - assert.dom(PAGE.modal('preview modal')).exists(); - assert.dom(PAGE.modal('preview image')).doesNotExist(); - assert.dom(PAGE.modalTitle('Preview modal title')).hasText('Preview modal title'); - assert.dom(PAGE.modalBody('Preview modal title')).hasText('Some preview modal message thats super long.'); + await click(CUSTOM_MESSAGES.radio('modal')); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Preview modal title'); + await fillIn(CUSTOM_MESSAGES.input('message'), 'Some preview modal message thats super long.'); + await click(CUSTOM_MESSAGES.button('preview')); + assert.dom(CUSTOM_MESSAGES.modal('preview modal')).exists(); + assert.dom(CUSTOM_MESSAGES.modal('preview image')).doesNotExist(); + assert.dom(CUSTOM_MESSAGES.modalTitle('Preview modal title')).hasText('Preview modal title'); + assert + .dom(CUSTOM_MESSAGES.modalBody('Preview modal title')) + .hasText('Some preview modal message thats super long.'); }); test('it should show multiple modal message', async function (assert) { @@ -236,19 +249,19 @@ module('Integration | Component | messages/page/create-and-edit', function (hook owner: this.engine, } ); - await fillIn(PAGE.input('title'), 'Awesome custom message title'); + await fillIn(CUSTOM_MESSAGES.input('title'), 'Awesome custom message title'); await fillIn( - PAGE.input('message'), + CUSTOM_MESSAGES.input('message'), 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar mattis nunc sed blandit libero volutpat sed cras ornare.' ); - await click(PAGE.radio('modal')); - await click(PAGE.button('create-message')); - assert.dom(PAGE.modalTitle('Warning: more than one modal')).exists(); + await click(CUSTOM_MESSAGES.radio('modal')); + await click(CUSTOM_MESSAGES.button('create-message')); + assert.dom(CUSTOM_MESSAGES.modalTitle('Warning: more than one modal')).exists(); assert - .dom(PAGE.modalBody('Warning: more than one modal')) + .dom(CUSTOM_MESSAGES.modalBody('Warning: more than one modal')) .hasText( 'You have an active modal configured after the user logs in and are trying to create another one. It is recommended to avoid having more than one modal at once as it can be intrusive for users. Would you like to continue creating your message? Click “Confirm” to continue.' ); - await click(PAGE.modalButton('confirm')); + await click(CUSTOM_MESSAGES.modalButton('confirm')); }); }); diff --git a/ui/tests/integration/components/config-ui/messages/page/list-test.js b/ui/tests/integration/components/config-ui/messages/page/list-test.js index 94e9bb355b3d..bd95a13d27b8 100644 --- a/ui/tests/integration/components/config-ui/messages/page/list-test.js +++ b/ui/tests/integration/components/config-ui/messages/page/list-test.js @@ -9,7 +9,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupEngine } from 'ember-engines/test-support'; import { render, click } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import { PAGE } from 'vault/tests/helpers/config-ui/message-selectors'; +import { CUSTOM_MESSAGES } from 'vault/tests/helpers/config-ui/message-selectors'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; const META = { @@ -89,7 +89,7 @@ module('Integration | Component | messages/page/list', function (hooks) { }); assert.dom('[data-test-icon="message-circle"]').exists(); for (const message of this.messages) { - assert.dom(PAGE.listItem('Message title 1')).exists(); + assert.dom(CUSTOM_MESSAGES.listItem('Message title 1')).exists(); assert.dom(`[data-linked-block-title="${message.id}"]`).hasText(message.title); } }); @@ -121,14 +121,16 @@ module('Integration | Component | messages/page/list', function (hooks) { await render(hbs``, { owner: this.engine, }); - await click(PAGE.button('create message')); - assert.dom(PAGE.modalTitle('maximum-message-modal')).hasText('Maximum number of messages reached'); + await click(CUSTOM_MESSAGES.button('create message')); assert - .dom(PAGE.modalBody('maximum-message-modal')) + .dom(CUSTOM_MESSAGES.modalTitle('maximum-message-modal')) + .hasText('Maximum number of messages reached'); + assert + .dom(CUSTOM_MESSAGES.modalBody('maximum-message-modal')) .hasText( 'Vault can only store up to 100 messages. To create a message, delete one of your messages to clear up space.' ); - await click(PAGE.modalButton('maximum-message-modal')); + await click(CUSTOM_MESSAGES.modalButton('maximum-message-modal')); }); test('it should show the correct badge colors based on badge status', async function (assert) { @@ -137,8 +139,8 @@ module('Integration | Component | messages/page/list', function (hooks) { await render(hbs``, { owner: this.engine, }); - assert.dom(PAGE.badge('0')).hasClass('hds-badge--color-success'); - assert.dom(PAGE.badge('1')).hasClass('hds-badge--color-neutral'); - assert.dom(PAGE.badge('2')).hasClass('hds-badge--color-highlight'); + assert.dom(CUSTOM_MESSAGES.badge('0')).hasClass('hds-badge--color-success'); + assert.dom(CUSTOM_MESSAGES.badge('1')).hasClass('hds-badge--color-neutral'); + assert.dom(CUSTOM_MESSAGES.badge('2')).hasClass('hds-badge--color-highlight'); }); }); diff --git a/ui/tests/integration/components/console/log-json-test.js b/ui/tests/integration/components/console/log-json-test.js index 3304ba50c5de..25521136081a 100644 --- a/ui/tests/integration/components/console/log-json-test.js +++ b/ui/tests/integration/components/console/log-json-test.js @@ -23,7 +23,7 @@ module('Integration | Component | console/log json', function (hooks) { this.set('content', objectContent); - await render(hbs`{{console/log-json content=this.content}}`); + await render(hbs``); const instance = find('[data-test-component=code-mirror-modifier]').innerText; assert.strictEqual(instance, expectedText); }); diff --git a/ui/tests/integration/components/dashboard/client-count-card-test.js b/ui/tests/integration/components/dashboard/client-count-card-test.js index 936295c33251..3b0550b1cb58 100644 --- a/ui/tests/integration/components/dashboard/client-count-card-test.js +++ b/ui/tests/integration/components/dashboard/client-count-card-test.js @@ -11,7 +11,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import sinon from 'sinon'; import { LICENSE_START, STATIC_NOW } from 'vault/mirage/handlers/clients'; import timestamp from 'core/utils/timestamp'; -import { ACTIVITY_RESPONSE_STUB } from 'vault/tests/helpers/clients'; +import { ACTIVITY_RESPONSE_STUB } from 'vault/tests/helpers/clients/client-count-helpers'; module('Integration | Component | dashboard/client-count-card', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/dashboard/overview-test.js b/ui/tests/integration/components/dashboard/overview-test.js index b5a0ef429eda..6670e4d2ea4a 100644 --- a/ui/tests/integration/components/dashboard/overview-test.js +++ b/ui/tests/integration/components/dashboard/overview-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'vault/tests/helpers'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; +import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; module('Integration | Component | dashboard/overview', function (hooks) { setupRenderingTest(hooks); @@ -74,15 +74,15 @@ module('Integration | Component | dashboard/overview', function (hooks) { @refreshModel={{this.refreshModel}} /> ` ); - assert.dom(SELECTORS.cardHeader('Vault version')).exists(); - assert.dom(SELECTORS.cardName('secrets-engines')).exists(); - assert.dom(SELECTORS.emptyState('secrets-engines')).exists(); - assert.dom(SELECTORS.cardName('learn-more')).exists(); - assert.dom(SELECTORS.cardName('quick-actions')).exists(); - assert.dom(SELECTORS.emptyState('quick-actions')).exists(); - assert.dom(SELECTORS.cardName('configuration-details')).doesNotExist(); - assert.dom(SELECTORS.cardName('replication')).doesNotExist(); - assert.dom(SELECTORS.cardName('client-count')).doesNotExist(); + assert.dom(DASHBOARD.cardHeader('Vault version')).exists(); + assert.dom(DASHBOARD.cardName('secrets-engines')).exists(); + assert.dom(DASHBOARD.emptyState('secrets-engines')).exists(); + assert.dom(DASHBOARD.cardName('learn-more')).exists(); + assert.dom(DASHBOARD.cardName('quick-actions')).exists(); + assert.dom(DASHBOARD.emptyState('quick-actions')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).doesNotExist(); + assert.dom(DASHBOARD.cardName('replication')).doesNotExist(); + assert.dom(DASHBOARD.cardName('client-count')).doesNotExist(); }); test('it should hide client count and replication card on community', async function (assert) { @@ -102,13 +102,13 @@ module('Integration | Component | dashboard/overview', function (hooks) { ` ); - assert.dom(SELECTORS.cardHeader('Vault version')).exists(); - assert.dom(SELECTORS.cardName('secrets-engines')).exists(); - assert.dom(SELECTORS.cardName('learn-more')).exists(); - assert.dom(SELECTORS.cardName('quick-actions')).exists(); - assert.dom(SELECTORS.cardName('configuration-details')).exists(); - assert.dom(SELECTORS.cardName('replication')).doesNotExist(); - assert.dom(SELECTORS.cardName('client-count')).doesNotExist(); + assert.dom(DASHBOARD.cardHeader('Vault version')).exists(); + assert.dom(DASHBOARD.cardName('secrets-engines')).exists(); + assert.dom(DASHBOARD.cardName('learn-more')).exists(); + assert.dom(DASHBOARD.cardName('quick-actions')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).exists(); + assert.dom(DASHBOARD.cardName('replication')).doesNotExist(); + assert.dom(DASHBOARD.cardName('client-count')).doesNotExist(); }); test('it should show client count on enterprise w/ license', async function (assert) { @@ -132,12 +132,12 @@ module('Integration | Component | dashboard/overview', function (hooks) { @license={{this.license}} @refreshModel={{this.refreshModel}} />` ); - assert.dom(SELECTORS.cardHeader('Vault version')).exists(); - assert.dom(SELECTORS.cardName('secrets-engines')).exists(); - assert.dom(SELECTORS.cardName('learn-more')).exists(); - assert.dom(SELECTORS.cardName('quick-actions')).exists(); - assert.dom(SELECTORS.cardName('configuration-details')).exists(); - assert.dom(SELECTORS.cardName('client-count')).exists(); + assert.dom(DASHBOARD.cardHeader('Vault version')).exists(); + assert.dom(DASHBOARD.cardName('secrets-engines')).exists(); + assert.dom(DASHBOARD.cardName('learn-more')).exists(); + assert.dom(DASHBOARD.cardName('quick-actions')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).exists(); + assert.dom(DASHBOARD.cardName('client-count')).exists(); }); test('it should hide client count on enterprise w/o license ', async function (assert) { @@ -158,13 +158,13 @@ module('Integration | Component | dashboard/overview', function (hooks) { />` ); - assert.dom(SELECTORS.cardHeader('Vault version')).exists(); + assert.dom(DASHBOARD.cardHeader('Vault version')).exists(); assert.dom('[data-test-badge-namespace]').exists(); - assert.dom(SELECTORS.cardName('secrets-engines')).exists(); - assert.dom(SELECTORS.cardName('learn-more')).exists(); - assert.dom(SELECTORS.cardName('quick-actions')).exists(); - assert.dom(SELECTORS.cardName('configuration-details')).exists(); - assert.dom(SELECTORS.cardName('client-count')).doesNotExist(); + assert.dom(DASHBOARD.cardName('secrets-engines')).exists(); + assert.dom(DASHBOARD.cardName('learn-more')).exists(); + assert.dom(DASHBOARD.cardName('quick-actions')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).exists(); + assert.dom(DASHBOARD.cardName('client-count')).doesNotExist(); }); test('it should hide replication on enterprise not on root namespace', async function (assert) { @@ -190,14 +190,14 @@ module('Integration | Component | dashboard/overview', function (hooks) { @refreshModel={{this.refreshModel}} />` ); - assert.dom(SELECTORS.cardHeader('Vault version')).exists(); + assert.dom(DASHBOARD.cardHeader('Vault version')).exists(); assert.dom('[data-test-badge-namespace]').exists(); - assert.dom(SELECTORS.cardName('secrets-engines')).exists(); - assert.dom(SELECTORS.cardName('learn-more')).exists(); - assert.dom(SELECTORS.cardName('quick-actions')).exists(); - assert.dom(SELECTORS.cardName('configuration-details')).exists(); - assert.dom(SELECTORS.cardName('replication')).doesNotExist(); - assert.dom(SELECTORS.cardName('client-count')).exists(); + assert.dom(DASHBOARD.cardName('secrets-engines')).exists(); + assert.dom(DASHBOARD.cardName('learn-more')).exists(); + assert.dom(DASHBOARD.cardName('quick-actions')).exists(); + assert.dom(DASHBOARD.cardName('configuration-details')).exists(); + assert.dom(DASHBOARD.cardName('replication')).doesNotExist(); + assert.dom(DASHBOARD.cardName('client-count')).exists(); }); module('learn more card', function () { diff --git a/ui/tests/integration/components/dashboard/quick-actions-card-test.js b/ui/tests/integration/components/dashboard/quick-actions-card-test.js index 8122f9260f36..1563b722cc63 100644 --- a/ui/tests/integration/components/dashboard/quick-actions-card-test.js +++ b/ui/tests/integration/components/dashboard/quick-actions-card-test.js @@ -10,7 +10,7 @@ import { hbs } from 'ember-cli-htmlbars'; import { fillIn } from '@ember/test-helpers'; import { selectChoose } from 'ember-power-select/test-support/helpers'; -import { SELECTORS } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; +import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Integration | Component | dashboard/quick-actions-card', function (hooks) { @@ -105,32 +105,32 @@ module('Integration | Component | dashboard/quick-actions-card', function (hooks test('it should show quick action empty state if no engine is selected', async function (assert) { await this.renderComponent(); assert.dom('.title').hasText('Quick actions'); - assert.dom(SELECTORS.searchSelect('secrets-engines')).exists({ count: 1 }); - assert.dom(SELECTORS.emptyState('no-mount-selected')).exists({ count: 1 }); + assert.dom(DASHBOARD.searchSelect('secrets-engines')).exists({ count: 1 }); + assert.dom(DASHBOARD.emptyState('no-mount-selected')).exists({ count: 1 }); }); test('it should show correct actions for pki', async function (assert) { await this.renderComponent(); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), 'pki-0-test'); - await fillIn(SELECTORS.selectEl, 'Issue certificate'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - await fillIn(SELECTORS.selectEl, 'Issue certificate'); - assert.dom(SELECTORS.actionButton('Issue leaf certificate')).exists({ count: 1 }); - assert.dom(SELECTORS.subtitle('param')).hasText('Role to use'); - await fillIn(SELECTORS.selectEl, 'View certificate'); - assert.dom(SELECTORS.subtitle('param')).hasText('Certificate serial number'); - assert.dom(SELECTORS.actionButton('View certificate')).exists({ count: 1 }); - await fillIn(SELECTORS.selectEl, 'View issuer'); - assert.dom(SELECTORS.subtitle('param')).hasText('Issuer'); - assert.dom(SELECTORS.actionButton('View issuer')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), 'pki-0-test'); + await fillIn(DASHBOARD.selectEl, 'Issue certificate'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + await fillIn(DASHBOARD.selectEl, 'Issue certificate'); + assert.dom(DASHBOARD.actionButton('Issue leaf certificate')).exists({ count: 1 }); + assert.dom(DASHBOARD.subtitle('param')).hasText('Role to use'); + await fillIn(DASHBOARD.selectEl, 'View certificate'); + assert.dom(DASHBOARD.subtitle('param')).hasText('Certificate serial number'); + assert.dom(DASHBOARD.actionButton('View certificate')).exists({ count: 1 }); + await fillIn(DASHBOARD.selectEl, 'View issuer'); + assert.dom(DASHBOARD.subtitle('param')).hasText('Issuer'); + assert.dom(DASHBOARD.actionButton('View issuer')).exists({ count: 1 }); }); test('it should show correct actions for database', async function (assert) { await this.renderComponent(); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), 'database-test'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - await fillIn(SELECTORS.selectEl, 'Generate credentials for database'); - assert.dom(SELECTORS.subtitle('param')).hasText('Role to use'); - assert.dom(SELECTORS.actionButton('Generate credentials')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), 'database-test'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + await fillIn(DASHBOARD.selectEl, 'Generate credentials for database'); + assert.dom(DASHBOARD.subtitle('param')).hasText('Role to use'); + assert.dom(DASHBOARD.actionButton('Generate credentials')).exists({ count: 1 }); }); test('it should show correct actions for kv', async function (assert) { await this.renderComponent(); @@ -140,10 +140,10 @@ module('Integration | Component | dashboard/quick-actions-card', function (hooks 5, 'renders only kv v2, pki and db engines' ); - await selectChoose(SELECTORS.searchSelect('secrets-engines'), 'kv-v2-test'); - assert.dom(SELECTORS.emptyState('quick-actions')).doesNotExist(); - await fillIn(SELECTORS.selectEl, 'Find KV secrets'); - assert.dom(SELECTORS.kvSearchSelect).exists('Shows option to search fo KVv2 secret'); - assert.dom(SELECTORS.actionButton('Read secrets')).exists({ count: 1 }); + await selectChoose(DASHBOARD.searchSelect('secrets-engines'), 'kv-v2-test'); + assert.dom(DASHBOARD.emptyState('quick-actions')).doesNotExist(); + await fillIn(DASHBOARD.selectEl, 'Find KV secrets'); + assert.dom(DASHBOARD.kvSearchSelect).exists('Shows option to search fo KVv2 secret'); + assert.dom(DASHBOARD.actionButton('Read secrets')).exists({ count: 1 }); }); }); diff --git a/ui/tests/integration/components/dashboard/replication-card-test.js b/ui/tests/integration/components/dashboard/replication-card-test.js index 7ee7d0d2f452..e8d9a154bade 100644 --- a/ui/tests/integration/components/dashboard/replication-card-test.js +++ b/ui/tests/integration/components/dashboard/replication-card-test.js @@ -9,7 +9,7 @@ import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import timestamp from 'core/utils/timestamp'; -import { SELECTORS } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; +import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; module('Integration | Component | dashboard/replication-card', function (hooks) { setupRenderingTest(hooks); @@ -45,12 +45,12 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('DR primary')).hasText('DR primary'); - assert.dom(SELECTORS.tooltipTitle('DR primary')).hasText('running'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).exists(); - assert.dom(SELECTORS.title('Performance primary')).hasText('Performance primary'); - assert.dom(SELECTORS.tooltipTitle('Performance primary')).hasText('running'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'check-circle')).exists(); + assert.dom(DASHBOARD.title('DR primary')).hasText('DR primary'); + assert.dom(DASHBOARD.tooltipTitle('DR primary')).hasText('running'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).exists(); + assert.dom(DASHBOARD.title('Performance primary')).hasText('Performance primary'); + assert.dom(DASHBOARD.tooltipTitle('Performance primary')).hasText('running'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'check-circle')).exists(); }); test('it should display replication information if both dr and performance replication are enabled as features and only dr is setup', async function (assert) { this.replication = { @@ -72,17 +72,17 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('DR primary')).hasText('DR primary'); - assert.dom(SELECTORS.tooltipTitle('DR primary')).hasText('running'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).exists(); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).hasClass('has-text-success'); + assert.dom(DASHBOARD.title('DR primary')).hasText('DR primary'); + assert.dom(DASHBOARD.tooltipTitle('DR primary')).hasText('running'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).exists(); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'check-circle')).hasClass('has-text-success'); - assert.dom(SELECTORS.title('Performance primary')).hasText('Performance primary'); + assert.dom(DASHBOARD.title('Performance primary')).hasText('Performance primary'); - assert.dom(SELECTORS.tooltipTitle('Performance primary')).hasText('not set up'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')).exists(); + assert.dom(DASHBOARD.tooltipTitle('Performance primary')).hasText('not set up'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')).exists(); assert - .dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')) + .dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')) .hasClass('has-text-danger'); }); @@ -107,16 +107,16 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('state')).hasText('state'); - assert.dom(SELECTORS.subtext('state')).hasText('The current operating state of the cluster.'); - assert.dom(SELECTORS.tooltipTitle('state')).hasText('running'); - assert.dom(SELECTORS.tooltipIcon('dr', 'state', 'check-circle')).exists(); - assert.dom(SELECTORS.tooltipIcon('dr', 'state', 'check-circle')).hasClass('has-text-success'); - assert.dom(SELECTORS.statLabel('known secondaries')).hasText('known secondaries'); + assert.dom(DASHBOARD.title('state')).hasText('state'); + assert.dom(DASHBOARD.subtext('state')).hasText('The current operating state of the cluster.'); + assert.dom(DASHBOARD.tooltipTitle('state')).hasText('running'); + assert.dom(DASHBOARD.tooltipIcon('dr', 'state', 'check-circle')).exists(); + assert.dom(DASHBOARD.tooltipIcon('dr', 'state', 'check-circle')).hasClass('has-text-success'); + assert.dom(DASHBOARD.statLabel('known secondaries')).hasText('known secondaries'); assert - .dom(SELECTORS.statText('known secondaries')) + .dom(DASHBOARD.statText('known secondaries')) .hasText('Number of secondaries connected to this primary.'); - assert.dom(SELECTORS.statValue('known secondaries')).hasText('1'); + assert.dom(DASHBOARD.statValue('known secondaries')).hasText('1'); }); test('it should show correct icons if dr and performance replication is idle or shutdown states', async function (assert) { @@ -140,16 +140,16 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('DR primary')).hasText('DR primary'); - assert.dom(SELECTORS.tooltipTitle('DR primary')).hasText('idle'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'x-square')).exists(); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'DR primary', 'x-square')).hasClass('has-text-danger'); + assert.dom(DASHBOARD.title('DR primary')).hasText('DR primary'); + assert.dom(DASHBOARD.tooltipTitle('DR primary')).hasText('idle'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'x-square')).exists(); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'DR primary', 'x-square')).hasClass('has-text-danger'); - assert.dom(SELECTORS.title('Performance primary')).hasText('Performance primary'); - assert.dom(SELECTORS.tooltipTitle('Performance primary')).hasText('shutdown'); - assert.dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')).exists(); + assert.dom(DASHBOARD.title('Performance primary')).hasText('Performance primary'); + assert.dom(DASHBOARD.tooltipTitle('Performance primary')).hasText('shutdown'); + assert.dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')).exists(); assert - .dom(SELECTORS.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')) + .dom(DASHBOARD.tooltipIcon('dr-perf', 'Performance primary', 'x-circle')) .hasClass('has-text-danger'); }); @@ -173,8 +173,8 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('DR primary')).hasText('DR primary'); - assert.dom(SELECTORS.title('Performance primary')).hasText('Performance primary'); + assert.dom(DASHBOARD.title('DR primary')).hasText('DR primary'); + assert.dom(DASHBOARD.title('Performance primary')).hasText('Performance primary'); this.replication = { dr: { @@ -195,7 +195,7 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.title('Performance secondary')).hasText('Performance secondary'); + assert.dom(DASHBOARD.title('Performance secondary')).hasText('Performance secondary'); }); test('it should show empty state', async function (assert) { @@ -216,11 +216,11 @@ module('Integration | Component | dashboard/replication-card', function (hooks) @refresh={{this.refresh}} /> ` ); - assert.dom(SELECTORS.emptyState('replication')).exists(); - assert.dom(SELECTORS.emptyStateTitle('replication')).hasText('Replication not set up'); + assert.dom(DASHBOARD.emptyState('replication')).exists(); + assert.dom(DASHBOARD.emptyStateTitle('replication')).hasText('Replication not set up'); assert - .dom(SELECTORS.emptyStateMessage('replication')) + .dom(DASHBOARD.emptyStateMessage('replication')) .hasText('Data will be listed here. Enable a primary replication cluster to get started.'); - assert.dom(SELECTORS.emptyStateActions('replication')).hasText('Enable replication'); + assert.dom(DASHBOARD.emptyStateActions('replication')).hasText('Enable replication'); }); }); diff --git a/ui/tests/integration/components/dashboard/secrets-engines-card-test.js b/ui/tests/integration/components/dashboard/secrets-engines-card-test.js index c17238b0f5a6..8b529b94facb 100644 --- a/ui/tests/integration/components/dashboard/secrets-engines-card-test.js +++ b/ui/tests/integration/components/dashboard/secrets-engines-card-test.js @@ -7,7 +7,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'vault/tests/helpers'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import { SELECTORS } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; +import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors'; module('Integration | Component | dashboard/secrets-engines-card', function (hooks) { setupRenderingTest(hooks); @@ -102,8 +102,8 @@ module('Integration | Component | dashboard/secrets-engines-card', function (hoo test('it should display only five secrets engines and show help text for more than 5 engines', async function (assert) { await this.renderComponent(); - assert.dom(SELECTORS.cardHeader('Secrets engines')).hasText('Secrets engines'); - assert.dom(SELECTORS.tableRow('Secrets engines')).exists({ count: 5 }); + assert.dom(DASHBOARD.cardHeader('Secrets engines')).hasText('Secrets engines'); + assert.dom(DASHBOARD.tableRow('Secrets engines')).exists({ count: 5 }); assert.dom('[data-test-secrets-engine-total-help-text]').exists(); assert .dom('[data-test-secrets-engine-total-help-text]') @@ -114,18 +114,18 @@ module('Integration | Component | dashboard/secrets-engines-card', function (hoo test('it should display the secrets engines accessor and path', async function (assert) { await this.renderComponent(); - assert.dom(SELECTORS.cardHeader('Secrets engines')).hasText('Secrets engines'); - assert.dom(SELECTORS.tableRow('Secrets engines')).exists({ count: 5 }); + assert.dom(DASHBOARD.cardHeader('Secrets engines')).hasText('Secrets engines'); + assert.dom(DASHBOARD.tableRow('Secrets engines')).exists({ count: 5 }); this.secretsEngines.slice(0, 5).forEach((engine) => { - assert.dom(SELECTORS.secretsEnginesCard.secretEngineAccessorRow(engine.id)).hasText(engine.accessor); + assert.dom(DASHBOARD.secretsEnginesCard.secretEngineAccessorRow(engine.id)).hasText(engine.accessor); if (engine.description) { assert - .dom(SELECTORS.secretsEnginesCard.secretEngineDescription(engine.id)) + .dom(DASHBOARD.secretsEnginesCard.secretEngineDescription(engine.id)) .hasText(engine.description); } else { assert - .dom(SELECTORS.secretsEnginesCard.secretEngineDescription(engine.id)) + .dom(DASHBOARD.secretsEnginesCard.secretEngineDescription(engine.id)) .doesNotExist(engine.description); } }); diff --git a/ui/tests/integration/components/kubernetes/page/overview-test.js b/ui/tests/integration/components/kubernetes/page/overview-test.js index 5de7159310ba..3272759e8411 100644 --- a/ui/tests/integration/components/kubernetes/page/overview-test.js +++ b/ui/tests/integration/components/kubernetes/page/overview-test.js @@ -9,9 +9,10 @@ import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { render } from '@ember/test-helpers'; import { typeInSearch, clickTrigger, selectChoose } from 'ember-power-select/test-support/helpers'; -import { SELECTORS } from 'vault/tests/helpers/kubernetes/overview'; import hbs from 'htmlbars-inline-precompile'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { KUBERNETES_OVERVIEW } from 'vault/tests/helpers/kubernetes/kubernetes-selectors'; module('Integration | Component | kubernetes | Page::Overview', function (hooks) { setupRenderingTest(hooks); @@ -62,35 +63,35 @@ module('Integration | Component | kubernetes | Page::Overview', function (hooks) test('it should display role card', async function (assert) { await this.renderComponent(); - assert.dom(SELECTORS.rolesCardTitle).hasText('Roles'); + assert.dom(KUBERNETES_OVERVIEW.rolesCardTitle).hasText('Roles'); assert - .dom(SELECTORS.rolesCardSubTitle) + .dom(KUBERNETES_OVERVIEW.rolesCardSubTitle) .hasText('The number of Vault roles being used to generate Kubernetes credentials.'); - assert.dom(SELECTORS.rolesCardLink).hasText('View Roles'); + assert.dom(KUBERNETES_OVERVIEW.rolesCardLink).hasText('View Roles'); this.roles = []; await this.renderComponent(); - assert.dom(SELECTORS.rolesCardLink).hasText('Create Role'); + assert.dom(KUBERNETES_OVERVIEW.rolesCardLink).hasText('Create Role'); }); test('it should display correct number of roles in role card', async function (assert) { await this.renderComponent(); - assert.dom(SELECTORS.rolesCardNumRoles).hasText('2'); + assert.dom(KUBERNETES_OVERVIEW.rolesCardNumRoles).hasText('2'); this.roles = []; await this.renderComponent(); - assert.dom(SELECTORS.rolesCardNumRoles).hasText('None'); + assert.dom(KUBERNETES_OVERVIEW.rolesCardNumRoles).hasText('None'); }); test('it should display generate credentials card', async function (assert) { await this.renderComponent(); - assert.dom(SELECTORS.generateCredentialsCardTitle).hasText('Generate credentials'); + assert.dom(KUBERNETES_OVERVIEW.generateCredentialsCardTitle).hasText('Generate credentials'); assert - .dom(SELECTORS.generateCredentialsCardSubTitle) + .dom(KUBERNETES_OVERVIEW.generateCredentialsCardSubTitle) .hasText('Quickly generate credentials by typing the role name.'); }); @@ -100,21 +101,21 @@ module('Integration | Component | kubernetes | Page::Overview', function (hooks) assert.strictEqual(this.element.querySelectorAll('.ember-power-select-option').length, 2); await typeInSearch('role-0'); assert.strictEqual(this.element.querySelectorAll('.ember-power-select-option').length, 1); - assert.dom(SELECTORS.generateCredentialsCardButton).isDisabled(); + assert.dom(KUBERNETES_OVERVIEW.generateCredentialsCardButton).isDisabled(); await selectChoose('', '.ember-power-select-option', 2); - assert.dom(SELECTORS.generateCredentialsCardButton).isNotDisabled(); + assert.dom(KUBERNETES_OVERVIEW.generateCredentialsCardButton).isNotDisabled(); }); test('it should show ConfigCta when no config is set up', async function (assert) { this.promptConfig = true; await this.renderComponent(); - assert.dom(SELECTORS.emptyStateTitle).hasText('Kubernetes not configured'); + assert.dom(GENERAL.emptyStateTitle).hasText('Kubernetes not configured'); assert - .dom(SELECTORS.emptyStateMessage) + .dom(GENERAL.emptyStateMessage) .hasText( 'Get started by establishing the URL of the Kubernetes API to connect to, along with some additional options.' ); - assert.dom(SELECTORS.emptyStateActionText).hasText('Configure Kubernetes'); + assert.dom(GENERAL.emptyStateActions).hasText('Configure Kubernetes'); }); }); diff --git a/ui/tests/integration/components/kv-suggestion-input-test.js b/ui/tests/integration/components/kv-suggestion-input-test.js index 6fae4067cd62..d75cc31de6d7 100644 --- a/ui/tests/integration/components/kv-suggestion-input-test.js +++ b/ui/tests/integration/components/kv-suggestion-input-test.js @@ -8,12 +8,12 @@ import { setupRenderingTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { render, click, fillIn, settled, typeIn } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -import { SELECTORS } from 'vault/tests/helpers/general-selectors'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; const { searchSelect: { option, options }, kvSuggestion: { input }, -} = SELECTORS; +} = GENERAL; module('Integration | Component | kv-suggestion-input', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/ldap/page/configuration-test.js b/ui/tests/integration/components/ldap/page/configuration-test.js index 9a881fcd4c5d..44e439b512c4 100644 --- a/ui/tests/integration/components/ldap/page/configuration-test.js +++ b/ui/tests/integration/components/ldap/page/configuration-test.js @@ -10,7 +10,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { render, click } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { duration } from 'core/helpers/format-duration'; -import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap'; +import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers'; import { setRunOptions } from 'ember-a11y-testing/test-support'; const selectors = { diff --git a/ui/tests/integration/components/ldap/page/configure-test.js b/ui/tests/integration/components/ldap/page/configure-test.js index b2b3ed958ca9..f69047ee2cdb 100644 --- a/ui/tests/integration/components/ldap/page/configure-test.js +++ b/ui/tests/integration/components/ldap/page/configure-test.js @@ -11,7 +11,7 @@ import { render, click, fillIn } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { Response } from 'miragejs'; import sinon from 'sinon'; -import { generateBreadcrumbs } from 'vault/tests/helpers/ldap'; +import { generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers'; const selectors = { radioCard: '[data-test-radio-card="OpenLDAP"]', diff --git a/ui/tests/integration/components/ldap/page/libraries-test.js b/ui/tests/integration/components/ldap/page/libraries-test.js index 32ff5450cb61..39f355e116aa 100644 --- a/ui/tests/integration/components/ldap/page/libraries-test.js +++ b/ui/tests/integration/components/ldap/page/libraries-test.js @@ -10,7 +10,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { render, click, fillIn } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; -import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap'; +import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Integration | Component | ldap | Page::Libraries', function (hooks) { diff --git a/ui/tests/integration/components/ldap/page/overview-test.js b/ui/tests/integration/components/ldap/page/overview-test.js index 19cc7f1ec884..b9365083d6a4 100644 --- a/ui/tests/integration/components/ldap/page/overview-test.js +++ b/ui/tests/integration/components/ldap/page/overview-test.js @@ -9,7 +9,7 @@ import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { render, click } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap'; +import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers'; import sinon from 'sinon'; import { setRunOptions } from 'ember-a11y-testing/test-support'; diff --git a/ui/tests/integration/components/ldap/page/roles-test.js b/ui/tests/integration/components/ldap/page/roles-test.js index ff5807992fdf..ce1c91ac73cc 100644 --- a/ui/tests/integration/components/ldap/page/roles-test.js +++ b/ui/tests/integration/components/ldap/page/roles-test.js @@ -10,7 +10,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { render, click, fillIn } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; -import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap'; +import { createSecretsEngine, generateBreadcrumbs } from 'vault/tests/helpers/ldap/ldap-helpers'; import sinon from 'sinon'; module('Integration | Component | ldap | Page::Roles', function (hooks) { diff --git a/ui/tests/integration/components/oidc/assignment-form-test.js b/ui/tests/integration/components/oidc/assignment-form-test.js index 16bc99096a93..ea8f32e2bc49 100644 --- a/ui/tests/integration/components/oidc/assignment-form-test.js +++ b/ui/tests/integration/components/oidc/assignment-form-test.js @@ -9,8 +9,8 @@ import { render, fillIn, click, findAll } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import oidcConfigHandlers from 'vault/mirage/handlers/oidc-config'; -import { overrideMirageResponse } from 'vault/tests/helpers/oidc-config'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { overrideResponse } from 'vault/tests/helpers/stubs'; module('Integration | Component | oidc/assignment-form', function (hooks) { setupRenderingTest(hooks); @@ -95,8 +95,8 @@ module('Integration | Component | oidc/assignment-form', function (hooks) { test('it should use fallback component on create if no permissions for entities or groups', async function (assert) { assert.expect(2); this.model = this.store.createRecord('oidc/assignment'); - this.server.get('/identity/entity/id', () => overrideMirageResponse(403)); - this.server.get('/identity/group/id', () => overrideMirageResponse(403)); + this.server.get('/identity/entity/id', () => overrideResponse(403)); + this.server.get('/identity/group/id', () => overrideResponse(403)); await render(hbs` overrideMirageResponse(403)); - this.server.get('/identity/group/id', () => overrideMirageResponse(403)); + this.server.get('/identity/entity/id', () => overrideResponse(403)); + this.server.get('/identity/group/id', () => overrideResponse(403)); await render(hbs` overrideMirageResponse(403)); + this.server.get('/identity/oidc/assignment', () => overrideResponse(403)); await render(hbs` overrideCapabilities(OIDC_BASE_URL + '/clients')); + this.server.post('/sys/capabilities-self', () => capabilitiesStub(OIDC_BASE_URL + '/clients')); await render(hbs` { const { paths } = JSON.parse(req.requestBody); if (paths[0] === 'identity/oidc/client/first-client') { - return overrideCapabilities('identity/oidc/client/first-client', ['read']); + return capabilitiesStub('identity/oidc/client/first-client', ['read']); } else { - return overrideCapabilities('identity/oidc/client/second-client', ['deny']); + return capabilitiesStub('identity/oidc/client/second-client', ['deny']); } }); await render(hbs``); diff --git a/ui/tests/integration/components/oidc/key-form-test.js b/ui/tests/integration/components/oidc/key-form-test.js index a77e6915a0c6..47b52f1763ce 100644 --- a/ui/tests/integration/components/oidc/key-form-test.js +++ b/ui/tests/integration/components/oidc/key-form-test.js @@ -9,14 +9,9 @@ import { render, fillIn, click, findAll } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import oidcConfigHandlers from 'vault/mirage/handlers/oidc-config'; -import { - OIDC_BASE_URL, - CLIENT_LIST_RESPONSE, - SELECTORS, - overrideMirageResponse, - overrideCapabilities, -} from 'vault/tests/helpers/oidc-config'; +import { OIDC_BASE_URL, CLIENT_LIST_RESPONSE, SELECTORS } from 'vault/tests/helpers/oidc-config'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { capabilitiesStub, overrideResponse } from 'vault/tests/helpers/stubs'; module('Integration | Component | oidc/key-form', function (hooks) { setupRenderingTest(hooks); @@ -25,7 +20,7 @@ module('Integration | Component | oidc/key-form', function (hooks) { hooks.beforeEach(function () { oidcConfigHandlers(this.server); this.store = this.owner.lookup('service:store'); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); setRunOptions({ rules: { // TODO: fix RadioCard component (replace with HDS) @@ -177,7 +172,7 @@ module('Integration | Component | oidc/key-form', function (hooks) { this.model = this.store.peekRecord('oidc/key', 'test-key'); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(403)); + this.server.get('/identity/oidc/client', () => overrideResponse(403)); await render(hbs` overrideCapabilities(OIDC_BASE_URL + '/keys')); + this.server.post('/sys/capabilities-self', () => capabilitiesStub(OIDC_BASE_URL + '/keys')); await render(hbs` overrideMirageResponse(null, CLIENT_LIST_RESPONSE)); + this.server.get('/identity/oidc/client', () => overrideResponse(null, { data: CLIENT_LIST_RESPONSE })); setRunOptions({ rules: { // TODO: Fix SearchSelect component @@ -193,8 +188,8 @@ module('Integration | Component | oidc/provider-form', function (hooks) { test('it should render fallback for search select', async function (assert) { assert.expect(2); this.model = this.store.createRecord('oidc/provider'); - this.server.get('/identity/oidc/scope', () => overrideMirageResponse(403)); - this.server.get('/identity/oidc/client', () => overrideMirageResponse(403)); + this.server.get('/identity/oidc/scope', () => overrideResponse(403)); + this.server.get('/identity/oidc/client', () => overrideResponse(403)); await render(hbs` overrideCapabilities(OIDC_BASE_URL + '/providers')); + this.server.post('/sys/capabilities-self', () => capabilitiesStub(OIDC_BASE_URL + '/providers')); await render(hbs` { const { paths } = JSON.parse(req.requestBody); if (paths[0] === 'identity/oidc/provider/first-provider') { - return overrideCapabilities('identity/oidc/provider/first-provider', ['read']); + return capabilitiesStub('identity/oidc/provider/first-provider', ['read']); } else { - return overrideCapabilities('identity/oidc/provider/second-provider', ['deny']); + return capabilitiesStub('identity/oidc/provider/second-provider', ['deny']); } }); await render(hbs``); diff --git a/ui/tests/integration/components/oidc/scope-form-test.js b/ui/tests/integration/components/oidc/scope-form-test.js index 40d960de3a25..b14bfd814604 100644 --- a/ui/tests/integration/components/oidc/scope-form-test.js +++ b/ui/tests/integration/components/oidc/scope-form-test.js @@ -8,7 +8,8 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, fillIn, click, findAll } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS, OIDC_BASE_URL, overrideCapabilities } from 'vault/tests/helpers/oidc-config'; +import { SELECTORS, OIDC_BASE_URL } from 'vault/tests/helpers/oidc-config'; +import { capabilitiesStub } from 'vault/tests/helpers/stubs'; module('Integration | Component | oidc/scope-form', function (hooks) { setupRenderingTest(hooks); @@ -190,7 +191,7 @@ module('Integration | Component | oidc/scope-form', function (hooks) { test('it should render error alerts when API returns an error', async function (assert) { assert.expect(2); this.model = this.store.createRecord('oidc/scope'); - this.server.post('/sys/capabilities-self', () => overrideCapabilities(OIDC_BASE_URL + '/scopes')); + this.server.post('/sys/capabilities-self', () => capabilitiesStub(OIDC_BASE_URL + '/scopes')); await render(hbs` { - assert.dom(SELECTORS.urlFieldInput(name)).exists(`renders ${name} input`); + assert.dom(PKI_CONFIG_EDIT.urlFieldInput(name)).exists(`renders ${name} input`); }); - assert.dom(SELECTORS.urlFieldInput('issuingCertificates')).hasValue('hashicorp.com'); - assert.dom(SELECTORS.urlFieldInput('crlDistributionPoints')).hasValue('some-crl-distribution.com'); - assert.dom(SELECTORS.urlFieldInput('ocspServers')).hasValue('ocsp-stuff.com'); + assert.dom(PKI_CONFIG_EDIT.urlFieldInput('issuingCertificates')).hasValue('hashicorp.com'); + assert.dom(PKI_CONFIG_EDIT.urlFieldInput('crlDistributionPoints')).hasValue('some-crl-distribution.com'); + assert.dom(PKI_CONFIG_EDIT.urlFieldInput('ocspServers')).hasValue('ocsp-stuff.com'); // cluster config - await fillIn(SELECTORS.configInput('path'), 'https://pr-a.vault.example.com/v1/ns1/pki-root'); - await fillIn(SELECTORS.configInput('aiaPath'), 'http://another-path.com'); + await fillIn(PKI_CONFIG_EDIT.configInput('path'), 'https://pr-a.vault.example.com/v1/ns1/pki-root'); + await fillIn(PKI_CONFIG_EDIT.configInput('aiaPath'), 'http://another-path.com'); // acme config; - await click(SELECTORS.configInput('enabled')); - await fillIn(SELECTORS.stringListInput('allowedRoles'), 'my-role'); - await fillIn(SELECTORS.stringListInput('allowedIssuers'), '*'); - await fillIn(SELECTORS.configInput('eabPolicy'), 'new-account-required'); - await fillIn(SELECTORS.configInput('dnsResolver'), 'some-dns'); + await click(PKI_CONFIG_EDIT.configInput('enabled')); + await fillIn(PKI_CONFIG_EDIT.stringListInput('allowedRoles'), 'my-role'); + await fillIn(PKI_CONFIG_EDIT.stringListInput('allowedIssuers'), '*'); + await fillIn(PKI_CONFIG_EDIT.configInput('eabPolicy'), 'new-account-required'); + await fillIn(PKI_CONFIG_EDIT.configInput('dnsResolver'), 'some-dns'); // urls - await fillIn(SELECTORS.urlFieldInput('issuingCertificates'), 'update-hashicorp.com'); - await fillIn(SELECTORS.urlFieldInput('crlDistributionPoints'), 'test-crl.com'); - await fillIn(SELECTORS.urlFieldInput('ocspServers'), 'ocsp.com'); + await fillIn(PKI_CONFIG_EDIT.urlFieldInput('issuingCertificates'), 'update-hashicorp.com'); + await fillIn(PKI_CONFIG_EDIT.urlFieldInput('crlDistributionPoints'), 'test-crl.com'); + await fillIn(PKI_CONFIG_EDIT.urlFieldInput('ocspServers'), 'ocsp.com'); // confirm default toggle state and text this.crl.eachAttribute((name, { options }) => { if (['expiry', 'ocspExpiry'].includes(name)) { - assert.dom(SELECTORS.crlToggleInput(name)).isChecked(`${name} defaults to toggled on`); - assert.dom(SELECTORS.crlFieldLabel(name)).hasTextContaining(options.label); - assert.dom(SELECTORS.crlFieldLabel(name)).hasTextContaining(options.helperTextEnabled); + assert.dom(PKI_CONFIG_EDIT.crlToggleInput(name)).isChecked(`${name} defaults to toggled on`); + assert.dom(PKI_CONFIG_EDIT.crlFieldLabel(name)).hasTextContaining(options.label); + assert.dom(PKI_CONFIG_EDIT.crlFieldLabel(name)).hasTextContaining(options.helperTextEnabled); } if (['autoRebuildGracePeriod', 'deltaRebuildInterval'].includes(name)) { - assert.dom(SELECTORS.crlToggleInput(name)).isNotChecked(`${name} defaults off`); - assert.dom(SELECTORS.crlFieldLabel(name)).hasTextContaining(options.labelDisabled); - assert.dom(SELECTORS.crlFieldLabel(name)).hasTextContaining(options.helperTextDisabled); + assert.dom(PKI_CONFIG_EDIT.crlToggleInput(name)).isNotChecked(`${name} defaults off`); + assert.dom(PKI_CONFIG_EDIT.crlFieldLabel(name)).hasTextContaining(options.labelDisabled); + assert.dom(PKI_CONFIG_EDIT.crlFieldLabel(name)).hasTextContaining(options.helperTextDisabled); } }); // toggle everything on - await click(SELECTORS.crlToggleInput('autoRebuildGracePeriod')); + await click(PKI_CONFIG_EDIT.crlToggleInput('autoRebuildGracePeriod')); assert - .dom(SELECTORS.crlFieldLabel('autoRebuildGracePeriod')) + .dom(PKI_CONFIG_EDIT.crlFieldLabel('autoRebuildGracePeriod')) .hasTextContaining( 'Auto-rebuild on Vault will rebuild the CRL in the below grace period before expiration', 'it renders auto rebuild toggled on text' ); - await click(SELECTORS.crlToggleInput('deltaRebuildInterval')); + await click(PKI_CONFIG_EDIT.crlToggleInput('deltaRebuildInterval')); assert - .dom(SELECTORS.crlFieldLabel('deltaRebuildInterval')) + .dom(PKI_CONFIG_EDIT.crlFieldLabel('deltaRebuildInterval')) .hasTextContaining( 'Delta CRL building on Vault will rebuild the delta CRL at the interval below:', 'it renders delta crl build toggled on text' ); // assert ttl values update model attributes - await fillIn(SELECTORS.crlTtlInput('Expiry'), '48'); - await fillIn(SELECTORS.crlTtlInput('Auto-rebuild on'), '24'); - await fillIn(SELECTORS.crlTtlInput('Delta CRL building on'), '45'); - await fillIn(SELECTORS.crlTtlInput('OCSP responder APIs enabled'), '24'); + await fillIn(PKI_CONFIG_EDIT.crlTtlInput('Expiry'), '48'); + await fillIn(PKI_CONFIG_EDIT.crlTtlInput('Auto-rebuild on'), '24'); + await fillIn(PKI_CONFIG_EDIT.crlTtlInput('Delta CRL building on'), '45'); + await fillIn(PKI_CONFIG_EDIT.crlTtlInput('OCSP responder APIs enabled'), '24'); - await click(SELECTORS.saveButton); + await click(PKI_CONFIG_EDIT.saveButton); }); test('it removes urls and sends false crl values', async function (assert) { @@ -249,28 +249,28 @@ module('Integration | Component | page/pki-configuration-edit', function (hooks) this.context ); - await click(SELECTORS.deleteButton('issuingCertificates')); - await click(SELECTORS.deleteButton('crlDistributionPoints')); - await click(SELECTORS.deleteButton('ocspServers')); + await click(PKI_CONFIG_EDIT.deleteButton('issuingCertificates')); + await click(PKI_CONFIG_EDIT.deleteButton('crlDistributionPoints')); + await click(PKI_CONFIG_EDIT.deleteButton('ocspServers')); // toggle everything off - await click(SELECTORS.crlToggleInput('expiry')); - assert.dom(SELECTORS.crlFieldLabel('expiry')).hasText('No expiry The CRL will not be built.'); + await click(PKI_CONFIG_EDIT.crlToggleInput('expiry')); + assert.dom(PKI_CONFIG_EDIT.crlFieldLabel('expiry')).hasText('No expiry The CRL will not be built.'); assert - .dom(SELECTORS.crlToggleInput('autoRebuildGracePeriod')) + .dom(PKI_CONFIG_EDIT.crlToggleInput('autoRebuildGracePeriod')) .doesNotExist('expiry off hides the auto rebuild toggle'); assert - .dom(SELECTORS.crlToggleInput('deltaRebuildInterval')) + .dom(PKI_CONFIG_EDIT.crlToggleInput('deltaRebuildInterval')) .doesNotExist('expiry off hides delta crl toggle'); - await click(SELECTORS.crlToggleInput('ocspExpiry')); + await click(PKI_CONFIG_EDIT.crlToggleInput('ocspExpiry')); assert - .dom(SELECTORS.crlFieldLabel('ocspExpiry')) + .dom(PKI_CONFIG_EDIT.crlFieldLabel('ocspExpiry')) .hasTextContaining( 'OCSP responder APIs disabled Requests cannot be made to check if an individual certificate is valid.', 'it renders correct toggled off text' ); - await click(SELECTORS.saveButton); + await click(PKI_CONFIG_EDIT.saveButton); }); test('it renders enterprise only params', async function (assert) { @@ -315,13 +315,13 @@ module('Integration | Component | page/pki-configuration-edit', function (hooks) this.context ); - assert.dom(SELECTORS.groupHeader('Certificate Revocation List (CRL)')).exists(); - assert.dom(SELECTORS.groupHeader('Online Certificate Status Protocol (OCSP)')).exists(); - assert.dom(SELECTORS.groupHeader('Unified Revocation')).exists(); - await click(SELECTORS.checkboxInput('crossClusterRevocation')); - await click(SELECTORS.checkboxInput('unifiedCrl')); - await click(SELECTORS.checkboxInput('unifiedCrlOnExistingPaths')); - await click(SELECTORS.saveButton); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Certificate Revocation List (CRL)')).exists(); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Online Certificate Status Protocol (OCSP)')).exists(); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Unified Revocation')).exists(); + await click(PKI_CONFIG_EDIT.checkboxInput('crossClusterRevocation')); + await click(PKI_CONFIG_EDIT.checkboxInput('unifiedCrl')); + await click(PKI_CONFIG_EDIT.checkboxInput('unifiedCrlOnExistingPaths')); + await click(PKI_CONFIG_EDIT.saveButton); }); test('it does not render enterprise only params for OSS', async function (assert) { @@ -363,13 +363,13 @@ module('Integration | Component | page/pki-configuration-edit', function (hooks) this.context ); - assert.dom(SELECTORS.checkboxInput('crossClusterRevocation')).doesNotExist(); - assert.dom(SELECTORS.checkboxInput('unifiedCrl')).doesNotExist(); - assert.dom(SELECTORS.checkboxInput('unifiedCrlOnExistingPaths')).doesNotExist(); - assert.dom(SELECTORS.groupHeader('Certificate Revocation List (CRL)')).exists(); - assert.dom(SELECTORS.groupHeader('Online Certificate Status Protocol (OCSP)')).exists(); - assert.dom(SELECTORS.groupHeader('Unified Revocation')).doesNotExist(); - await click(SELECTORS.saveButton); + assert.dom(PKI_CONFIG_EDIT.checkboxInput('crossClusterRevocation')).doesNotExist(); + assert.dom(PKI_CONFIG_EDIT.checkboxInput('unifiedCrl')).doesNotExist(); + assert.dom(PKI_CONFIG_EDIT.checkboxInput('unifiedCrlOnExistingPaths')).doesNotExist(); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Certificate Revocation List (CRL)')).exists(); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Online Certificate Status Protocol (OCSP)')).exists(); + assert.dom(PKI_CONFIG_EDIT.groupHeader('Unified Revocation')).doesNotExist(); + await click(PKI_CONFIG_EDIT.saveButton); }); test('it renders empty states if no update capabilities', async function (assert) { @@ -390,22 +390,22 @@ module('Integration | Component | page/pki-configuration-edit', function (hooks) ); assert - .dom(`${SELECTORS.configEditSection} [data-test-component="empty-state"]`) + .dom(`${PKI_CONFIG_EDIT.configEditSection} [data-test-component="empty-state"]`) .hasText( "You do not have permission to set this mount's the cluster config Ask your administrator if you think you should have access to: POST /pki-engine/config/cluster" ); assert - .dom(`${SELECTORS.acmeEditSection} [data-test-component="empty-state"]`) + .dom(`${PKI_CONFIG_EDIT.acmeEditSection} [data-test-component="empty-state"]`) .hasText( "You do not have permission to set this mount's ACME config Ask your administrator if you think you should have access to: POST /pki-engine/config/acme" ); assert - .dom(`${SELECTORS.urlsEditSection} [data-test-component="empty-state"]`) + .dom(`${PKI_CONFIG_EDIT.urlsEditSection} [data-test-component="empty-state"]`) .hasText( "You do not have permission to set this mount's URLs Ask your administrator if you think you should have access to: POST /pki-engine/config/urls" ); assert - .dom(`${SELECTORS.crlEditSection} [data-test-component="empty-state"]`) + .dom(`${PKI_CONFIG_EDIT.crlEditSection} [data-test-component="empty-state"]`) .hasText( "You do not have permission to set this mount's revocation configuration Ask your administrator if you think you should have access to: POST /pki-engine/config/crl" ); @@ -438,21 +438,21 @@ module('Integration | Component | page/pki-configuration-edit', function (hooks) this.context ); - await click(SELECTORS.saveButton); + await click(PKI_CONFIG_EDIT.saveButton); assert - .dom(SELECTORS.errorBanner) + .dom(PKI_CONFIG_EDIT.errorBanner) .hasText( 'Error POST config/cluster: something wrong with cluster POST config/acme: something wrong with acme POST config/urls: something wrong with urls POST config/crl: something wrong with crl' ); - assert.dom(`${SELECTORS.errorBanner} ul`).hasClass('bullet'); + assert.dom(`${PKI_CONFIG_EDIT.errorBanner} ul`).hasClass('bullet'); // change 3 out of 4 requests to be successful to assert single error renders correctly this.server.post(`/${this.backend}/config/acme`, () => new Response(200)); this.server.post(`/${this.backend}/config/cluster`, () => new Response(200)); this.server.post(`/${this.backend}/config/crl`, () => new Response(200)); - await click(SELECTORS.saveButton); - assert.dom(SELECTORS.errorBanner).hasText('Error POST config/urls: something wrong with urls'); - assert.dom(`${SELECTORS.errorBanner} ul`).doesNotHaveClass('bullet'); + await click(PKI_CONFIG_EDIT.saveButton); + assert.dom(PKI_CONFIG_EDIT.errorBanner).hasText('Error POST config/urls: something wrong with urls'); + assert.dom(`${PKI_CONFIG_EDIT.errorBanner} ul`).doesNotHaveClass('bullet'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-configure-create-test.js b/ui/tests/integration/components/pki/page/pki-configure-create-test.js index 3574f8bc8041..785ba0e6d5ab 100644 --- a/ui/tests/integration/components/pki/page/pki-configure-create-test.js +++ b/ui/tests/integration/components/pki/page/pki-configure-create-test.js @@ -8,8 +8,9 @@ import { setupRenderingTest } from 'vault/tests/helpers'; import { click, render } from '@ember/test-helpers'; import { setupEngine } from 'ember-engines/test-support'; import { hbs } from 'ember-cli-htmlbars'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-configure-create'; import sinon from 'sinon'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_CONFIGURE_CREATE } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | page/pki-configure-create', function (hooks) { setupRenderingTest(hooks); @@ -40,22 +41,22 @@ module('Integration | Component | page/pki-configure-create', function (hooks) { `, this.context ); - assert.dom(SELECTORS.breadcrumbContainer).exists('breadcrumbs exist'); - assert.dom(SELECTORS.title).hasText('Configure PKI'); - assert.dom(SELECTORS.option).exists({ count: 3 }, 'Three configuration options are shown'); - assert.dom(SELECTORS.cancelButton).exists('Cancel link is shown'); - assert.dom(SELECTORS.saveButton).isDisabled('Done button is disabled'); + assert.dom(GENERAL.breadcrumbs).exists(); + assert.dom(GENERAL.title).hasText('Configure PKI'); + assert.dom(PKI_CONFIGURE_CREATE.option).exists({ count: 3 }); + assert.dom(GENERAL.cancelButton).exists('Cancel link is shown'); + assert.dom(GENERAL.saveButton).isDisabled('Done button is disabled'); - await click(SELECTORS.optionByKey('import')); - assert.dom(SELECTORS.optionByKey('import')).isChecked('Selected item is checked'); + await click(PKI_CONFIGURE_CREATE.optionByKey('import')); + assert.dom(PKI_CONFIGURE_CREATE.optionByKey('import')).isChecked(); - await click(SELECTORS.optionByKey('generate-csr')); - assert.dom(SELECTORS.optionByKey('generate-csr')).isChecked('Selected item is checked'); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-csr')); + assert.dom(PKI_CONFIGURE_CREATE.optionByKey('generate-csr')).isChecked(); - await click(SELECTORS.optionByKey('generate-root')); - assert.dom(SELECTORS.optionByKey('generate-root')).isChecked('Selected item is checked'); + await click(PKI_CONFIGURE_CREATE.optionByKey('generate-root')); + assert.dom(PKI_CONFIGURE_CREATE.optionByKey('generate-root')).isChecked(); - await click(SELECTORS.generateRootCancel); - assert.ok(this.cancelSpy.calledOnce); + await click(GENERAL.cancelButton); + assert.true(this.cancelSpy.calledOnce, 'cancel action is called'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-issuer-generate-intermediate-test.js b/ui/tests/integration/components/pki/page/pki-issuer-generate-intermediate-test.js index b1f7da478a62..6abae5870c2f 100644 --- a/ui/tests/integration/components/pki/page/pki-issuer-generate-intermediate-test.js +++ b/ui/tests/integration/components/pki/page/pki-issuer-generate-intermediate-test.js @@ -12,8 +12,8 @@ import { Response } from 'miragejs'; import { v4 as uuidv4 } from 'uuid'; import { setupRenderingTest } from 'vault/tests/helpers'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-configure-create'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; /** * this test is for the page component only. A separate test is written for the form rendered @@ -53,11 +53,11 @@ module('Integration | Component | page/pki-issuer-generate-intermediate', functi owner: this.engine, } ); - assert.dom('[data-test-pki-page-title]').hasText('Generate intermediate CSR'); - await fillIn(SELECTORS.typeField, 'internal'); - await fillIn(SELECTORS.inputByName('commonName'), 'foobar'); + assert.dom(GENERAL.title).hasText('Generate intermediate CSR'); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'foobar'); await click('[data-test-save]'); - assert.dom('[data-test-pki-page-title]').hasText('View Generated CSR'); + assert.dom(GENERAL.title).hasText('View Generated CSR'); }); test('it does not update title if API response is an error', async function (assert) { @@ -73,13 +73,13 @@ module('Integration | Component | page/pki-issuer-generate-intermediate', functi owner: this.engine, } ); - assert.dom('[data-test-pki-page-title]').hasText('Generate intermediate CSR'); + assert.dom(GENERAL.title).hasText('Generate intermediate CSR'); // Fill in - await fillIn(SELECTORS.typeField, 'internal'); - await fillIn(SELECTORS.inputByName('commonName'), 'foobar'); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'foobar'); await click('[data-test-save]'); assert - .dom('[data-test-pki-page-title]') + .dom(GENERAL.title) .hasText('Generate intermediate CSR', 'title does not change if response is unsuccessful'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-issuer-generate-root-test.js b/ui/tests/integration/components/pki/page/pki-issuer-generate-root-test.js index bedc774af097..6e0538a418c3 100644 --- a/ui/tests/integration/components/pki/page/pki-issuer-generate-root-test.js +++ b/ui/tests/integration/components/pki/page/pki-issuer-generate-root-test.js @@ -12,9 +12,9 @@ import { Response } from 'miragejs'; import { v4 as uuidv4 } from 'uuid'; import { setupRenderingTest } from 'vault/tests/helpers'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-configure-create'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; /** * this test is for the page component only. A separate test is written for the form rendered @@ -63,11 +63,11 @@ module('Integration | Component | page/pki-issuer-generate-root', function (hook owner: this.engine, } ); - assert.dom('[data-test-pki-page-title]').hasText('Generate root'); - await fillIn(SELECTORS.typeField, 'internal'); - await fillIn(SELECTORS.inputByName('commonName'), 'foobar'); - await click(SELECTORS.generateRootSave); - assert.dom('[data-test-pki-page-title]').hasText('View generated root'); + assert.dom(GENERAL.title).hasText('Generate root'); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'foobar'); + await click(GENERAL.saveButton); + assert.dom(GENERAL.title).hasText('View generated root'); }); test('it does not update title if API response is an error', async function (assert) { @@ -80,13 +80,11 @@ module('Integration | Component | page/pki-issuer-generate-root', function (hook owner: this.engine, } ); - assert.dom('[data-test-pki-page-title]').hasText('Generate root'); + assert.dom(GENERAL.title).hasText('Generate root'); // Fill in - await fillIn(SELECTORS.typeField, 'internal'); - await fillIn(SELECTORS.inputByName('commonName'), 'foobar'); - await click(SELECTORS.generateRootSave); - assert - .dom('[data-test-pki-page-title]') - .hasText('Generate root', 'title does not change if response is unsuccessful'); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + await fillIn(GENERAL.inputByAttr('commonName'), 'foobar'); + await click(GENERAL.saveButton); + assert.dom(GENERAL.title).hasText('Generate root', 'title does not change if response is unsuccessful'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-issuer-import-test.js b/ui/tests/integration/components/pki/page/pki-issuer-import-test.js index dae6192da0c0..14f3151d866f 100644 --- a/ui/tests/integration/components/pki/page/pki-issuer-import-test.js +++ b/ui/tests/integration/components/pki/page/pki-issuer-import-test.js @@ -12,6 +12,8 @@ import { Response } from 'miragejs'; import { v4 as uuidv4 } from 'uuid'; import { setupRenderingTest } from 'vault/tests/helpers'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_CONFIGURE_CREATE } from 'vault/tests/helpers/pki/pki-selectors'; /** * this test is for the page component only. A separate test is written for the form rendered @@ -45,28 +47,25 @@ module('Integration | Component | page/pki-issuer-import', function (hooks) { await render(hbs``, { owner: this.engine, }); - assert.dom('[data-test-pki-page-title]').hasText('Import a CA'); + assert.dom(GENERAL.title).hasText('Import a CA'); await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', 'dummy-pem-bundle'); - await click('[data-test-pki-import-pem-bundle]'); - assert.dom('[data-test-pki-page-title]').hasText('View imported items'); + await click(PKI_CONFIGURE_CREATE.importSubmit); + assert.dom(GENERAL.title).hasText('View imported items'); }); test('it does not update title if API response is an error', async function (assert) { assert.expect(2); - // this.server.post('/pki-component/issuers/import/bundle', () => new Response(404, {}, { errors: ['Some error occurred'] })); this.server.post(`/pki-component/issuers/import/bundle`, () => new Response(404, {}, { errors: [] })); await render(hbs``, { owner: this.engine, }); - assert.dom('[data-test-pki-page-title]').hasText('Import a CA'); + assert.dom(GENERAL.title).hasText('Import a CA'); // Fill in await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', 'dummy-pem-bundle'); - await click('[data-test-pki-import-pem-bundle]'); - assert - .dom('[data-test-pki-page-title]') - .hasText('Import a CA', 'title does not change if response is unsuccessful'); + await click(PKI_CONFIGURE_CREATE.importSubmit); + assert.dom(GENERAL.title).hasText('Import a CA', 'title does not change if response is unsuccessful'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-issuer-list-test.js b/ui/tests/integration/components/pki/page/pki-issuer-list-test.js index e2fc2c7e1c59..3263b6ca2b88 100644 --- a/ui/tests/integration/components/pki/page/pki-issuer-list-test.js +++ b/ui/tests/integration/components/pki/page/pki-issuer-list-test.js @@ -9,7 +9,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupRenderingTest } from 'vault/tests/helpers'; -import { STANDARD_META } from 'vault/tests/helpers/pki'; +import { STANDARD_META } from 'vault/tests/helpers/pagination'; /** * this test is for the page component only. A separate test is written for the form rendered diff --git a/ui/tests/integration/components/pki/page/pki-issuer-rotate-root-test.js b/ui/tests/integration/components/pki/page/pki-issuer-rotate-root-test.js index b359e43f0434..3e5ce13c1283 100644 --- a/ui/tests/integration/components/pki/page/pki-issuer-rotate-root-test.js +++ b/ui/tests/integration/components/pki/page/pki-issuer-rotate-root-test.js @@ -9,14 +9,14 @@ import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import sinon from 'sinon'; import { hbs } from 'ember-cli-htmlbars'; -import { loadedCert } from 'vault/tests/helpers/pki/values'; import camelizeKeys from 'vault/utils/camelize-object-keys'; import { parseCertificate } from 'vault/utils/parse-pki-cert'; -import { SELECTORS as S } from 'vault/tests/helpers/pki/pki-generate-root'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +import { PKI_CONFIGURE_CREATE } from 'vault/tests/helpers/pki/pki-selectors'; const SELECTORS = { - pageTitle: '[data-test-pki-page-title]', nextSteps: '[data-test-rotate-next-steps]', toolbarCrossSign: '[data-test-pki-issuer-cross-sign]', toolbarSignInt: '[data-test-pki-issuer-sign-int]', @@ -24,17 +24,13 @@ const SELECTORS = { oldRadioSelect: 'input#use-old-root-settings', customRadioSelect: 'input#customize-new-root-certificate', toggle: '[data-test-details-toggle]', - input: (attr) => `[data-test-input="${attr}"]`, - infoRowValue: (attr) => `[data-test-value-div="${attr}"]`, validationError: '[data-test-pki-rotate-root-validation-error]', rotateRootForm: '[data-test-pki-rotate-old-settings-form]', - rotateRootSave: '[data-test-pki-rotate-root-save]', - rotateRootCancel: '[data-test-pki-rotate-root-cancel]', doneButton: '[data-test-done]', // root form generateRootForm: '[data-test-pki-config-generate-root-form]', - ...S, }; +const { loadedCert } = CERTIFICATES; module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) { setupRenderingTest(hooks); @@ -96,19 +92,19 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) `, { owner: this.engine } ); - assert.dom(SELECTORS.pageTitle).hasText('Generate New Root'); + assert.dom(GENERAL.title).hasText('Generate New Root'); assert.dom(SELECTORS.oldRadioSelect).isChecked('defaults to use-old-settings'); assert.dom(SELECTORS.rotateRootForm).exists('it renders old settings form'); assert - .dom(SELECTORS.input('commonName')) + .dom(GENERAL.inputByAttr('commonName')) .hasValue(this.parsedRootCert.commonName, 'common name prefilled with root cert cn'); assert.dom(SELECTORS.toggle).hasText('Old root settings', 'toggle renders correct text'); - assert.dom(SELECTORS.input('issuerName')).exists('renders issuer name input'); + assert.dom(GENERAL.inputByAttr('issuerName')).exists('renders issuer name input'); assert.strictEqual(findAll('[data-test-row-label]').length, 0, 'it hides the old root info table rows'); await click(SELECTORS.toggle); assert.strictEqual(findAll('[data-test-row-label]').length, 19, 'it shows the old root info table rows'); assert - .dom(SELECTORS.infoRowValue('Issuer name')) + .dom(GENERAL.infoRowValue('Issuer name')) .hasText(this.oldRoot.issuerName, 'renders correct issuer data'); await click(SELECTORS.toggle); assert.strictEqual(findAll('[data-test-row-label]').length, 0, 'it hides again'); @@ -117,21 +113,25 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) await click(SELECTORS.customRadioSelect); assert.dom(SELECTORS.generateRootForm).exists('it renders generate root form'); assert - .dom(SELECTORS.input('permittedDnsDomains')) + .dom(GENERAL.inputByAttr('permittedDnsDomains')) .hasValue(this.parsedRootCert.permittedDnsDomains, 'form is prefilled with values from old root'); - await click(SELECTORS.generateRootCancel); + await click(GENERAL.cancelButton); assert.ok(this.onCancel.calledOnce, 'custom form calls @onCancel passed from parent'); await click(SELECTORS.oldRadioSelect); - await click(SELECTORS.rotateRootCancel); + await click(GENERAL.cancelButton); assert.ok(this.onCancel.calledTwice, 'old root settings form calls @onCancel from parent'); // validations - await fillIn(SELECTORS.input('commonName'), ''); - await fillIn(SELECTORS.input('issuerName'), 'default'); - await click(SELECTORS.rotateRootSave); + await fillIn(GENERAL.inputByAttr('commonName'), ''); + await fillIn(GENERAL.inputByAttr('issuerName'), 'default'); + await click(GENERAL.saveButton); assert.dom(SELECTORS.validationError).hasText('There are 2 errors with this form.'); - assert.dom(SELECTORS.input('commonName')).hasClass('has-error-border', 'common name has error border'); - assert.dom(SELECTORS.input('issuerName')).hasClass('has-error-border', 'issuer name has error border'); + assert + .dom(GENERAL.inputByAttr('commonName')) + .hasClass('has-error-border', 'common name has error border'); + assert + .dom(GENERAL.inputByAttr('issuerName')) + .hasClass('has-error-border', 'issuer name has error border'); }); test('it sends request to rotate/internal on save when using old root settings', async function (assert) { @@ -151,7 +151,7 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) `, { owner: this.engine } ); - await click(SELECTORS.rotateRootSave); + await click(GENERAL.saveButton); }); function testEndpoint(test, type) { @@ -173,8 +173,8 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) { owner: this.engine } ); await click(SELECTORS.customRadioSelect); - await fillIn(SELECTORS.typeField, type); - await click(SELECTORS.generateRootSave); + await fillIn(GENERAL.inputByAttr('type'), type); + await click(GENERAL.saveButton); }); } testEndpoint(test, 'internal'); @@ -205,21 +205,21 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) `, { owner: this.engine } ); - assert.dom(SELECTORS.pageTitle).hasText('View Issuer Certificate'); + assert.dom(GENERAL.title).hasText('View Issuer Certificate'); assert .dom(SELECTORS.nextSteps) .hasText( 'Next steps Your new root has been generated. Make sure to copy and save the private_key as it is only available once. If you’re ready, you can begin cross-signing issuers now. If not, the option to cross-sign is available when you use this certificate. Cross-sign issuers' ); - assert.dom(SELECTORS.infoRowValue('Certificate')).exists(); - assert.dom(SELECTORS.infoRowValue('Issuer name')).exists(); - assert.dom(SELECTORS.infoRowValue('Issuing CA')).exists(); - assert.dom(SELECTORS.infoRowValue('Private key')).exists(); - assert.dom(`${SELECTORS.infoRowValue('Private key type')} span`).hasText('rsa'); - assert.dom(SELECTORS.infoRowValue('Serial number')).hasText(this.returnedData.serial_number); - assert.dom(SELECTORS.infoRowValue('Key ID')).hasText(this.returnedData.key_id); + assert.dom(GENERAL.infoRowValue('Certificate')).exists(); + assert.dom(GENERAL.infoRowValue('Issuer name')).exists(); + assert.dom(GENERAL.infoRowValue('Issuing CA')).exists(); + assert.dom(GENERAL.infoRowValue('Private key')).exists(); + assert.dom(`${GENERAL.infoRowValue('Private key type')} span`).hasText('rsa'); + assert.dom(GENERAL.infoRowValue('Serial number')).hasText(this.returnedData.serial_number); + assert.dom(GENERAL.infoRowValue('Key ID')).hasText(this.returnedData.key_id); - await click(SELECTORS.doneButton); + await click(PKI_CONFIGURE_CREATE.doneButton); assert.ok(this.onComplete.calledOnce, 'clicking done fires @onComplete from parent'); }); @@ -242,7 +242,7 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) `, { owner: this.engine } ); - assert.dom(SELECTORS.pageTitle).hasText('View Issuer Certificate'); + assert.dom(GENERAL.title).hasText('View Issuer Certificate'); assert.dom(SELECTORS.toolbarCrossSign).exists(); assert.dom(SELECTORS.toolbarSignInt).exists(); assert.dom(SELECTORS.toolbarDownload).exists(); @@ -251,13 +251,13 @@ module('Integration | Component | page/pki-issuer-rotate-root', function (hooks) .hasText( 'Next steps Your new root has been generated. If you’re ready, you can begin cross-signing issuers now. If not, the option to cross-sign is available when you use this certificate. Cross-sign issuers' ); - assert.dom(SELECTORS.infoRowValue('Certificate')).exists(); - assert.dom(SELECTORS.infoRowValue('Issuer name')).exists(); - assert.dom(SELECTORS.infoRowValue('Issuing CA')).exists(); - assert.dom(`${SELECTORS.infoRowValue('Private key')} span`).hasText('internal'); - assert.dom(`${SELECTORS.infoRowValue('Private key type')} span`).hasText('internal'); - assert.dom(SELECTORS.infoRowValue('Serial number')).hasText(this.returnedData.serial_number); - assert.dom(SELECTORS.infoRowValue('Key ID')).hasText(this.returnedData.key_id); + assert.dom(GENERAL.infoRowValue('Certificate')).exists(); + assert.dom(GENERAL.infoRowValue('Issuer name')).exists(); + assert.dom(GENERAL.infoRowValue('Issuing CA')).exists(); + assert.dom(`${GENERAL.infoRowValue('Private key')} span`).hasText('internal'); + assert.dom(`${GENERAL.infoRowValue('Private key type')} span`).hasText('internal'); + assert.dom(GENERAL.infoRowValue('Serial number')).hasText(this.returnedData.serial_number); + assert.dom(GENERAL.infoRowValue('Key ID')).hasText(this.returnedData.key_id); await click(SELECTORS.doneButton); assert.ok(this.onComplete.calledOnce, 'clicking done fires @onComplete from parent'); diff --git a/ui/tests/integration/components/pki/page/pki-key-details-test.js b/ui/tests/integration/components/pki/page/pki-key-details-test.js index f0dc9619d949..7575748cfdef 100644 --- a/ui/tests/integration/components/pki/page/pki-key-details-test.js +++ b/ui/tests/integration/components/pki/page/pki-key-details-test.js @@ -9,7 +9,8 @@ import { click, render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-keys'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_KEYS } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki key details page', function (hooks) { setupRenderingTest(hooks); @@ -48,14 +49,16 @@ module('Integration | Component | pki key details page', function (hooks) { { owner: this.engine } ); - assert.dom(SELECTORS.keyIdValue).hasText(' 724862ff-6438-bad0-b598-77a6c7f4e934', 'key id renders'); - assert.dom(SELECTORS.keyNameValue).hasText('test-key', 'key name renders'); - assert.dom(SELECTORS.keyTypeValue).hasText('ec', 'key type renders'); - assert.dom(SELECTORS.keyBitsValue).doesNotExist('does not render empty value'); - assert.dom(SELECTORS.keyEditLink).exists('renders edit link'); - assert.dom(SELECTORS.keyDeleteButton).exists('renders delete button'); - await click(SELECTORS.keyDeleteButton); - await click(SELECTORS.confirmDelete); + assert + .dom(GENERAL.infoRowValue('Key ID')) + .hasText(' 724862ff-6438-bad0-b598-77a6c7f4e934', 'key id renders'); + assert.dom(GENERAL.infoRowValue('Key name')).hasText('test-key', 'key name renders'); + assert.dom(GENERAL.infoRowValue('Key type')).hasText('ec', 'key type renders'); + assert.dom(GENERAL.infoRowLabel('Key bits')).doesNotExist('does not render empty value'); + assert.dom(PKI_KEYS.keyEditLink).exists('renders edit link'); + assert.dom(PKI_KEYS.keyDeleteButton).exists('renders delete button'); + await click(PKI_KEYS.keyDeleteButton); + await click(GENERAL.confirmButton); }); test('it does not render actions when capabilities are false', async function (assert) { @@ -72,8 +75,8 @@ module('Integration | Component | pki key details page', function (hooks) { { owner: this.engine } ); - assert.dom(SELECTORS.keyDeleteButton).doesNotExist('does not render delete button if no permission'); - assert.dom(SELECTORS.keyEditLink).doesNotExist('does not render edit button if no permission'); + assert.dom(PKI_KEYS.keyDeleteButton).doesNotExist('does not render delete button if no permission'); + assert.dom(PKI_KEYS.keyEditLink).doesNotExist('does not render edit button if no permission'); }); test('it renders the private key as a component when there is a private key', async function (assert) { @@ -81,9 +84,9 @@ module('Integration | Component | pki key details page', function (hooks) { await render( hbs` `, { owner: this.engine } diff --git a/ui/tests/integration/components/pki/page/pki-key-list-test.js b/ui/tests/integration/components/pki/page/pki-key-list-test.js index a9f56c301531..dadb3a3e23f6 100644 --- a/ui/tests/integration/components/pki/page/pki-key-list-test.js +++ b/ui/tests/integration/components/pki/page/pki-key-list-test.js @@ -9,8 +9,9 @@ import { click, render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-keys'; -import { STANDARD_META } from 'vault/tests/helpers/pki'; +import { STANDARD_META } from 'vault/tests/helpers/pagination'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_KEYS } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki key list page', function (hooks) { setupRenderingTest(hooks); @@ -61,8 +62,8 @@ module('Integration | Component | pki key list page', function (hooks) { assert .dom('[data-test-empty-state-title]') .hasText('No keys yet', 'renders empty state that no keys exist'); - assert.dom(SELECTORS.importKey).exists('renders toolbar with import action'); - assert.dom(SELECTORS.generateKey).exists('renders toolbar with generate action'); + assert.dom(PKI_KEYS.importKey).exists('renders toolbar with import action'); + assert.dom(PKI_KEYS.generateKey).exists('renders toolbar with generate action'); }); test('it renders list of keys and actions when permission allowed', async function (assert) { @@ -80,15 +81,15 @@ module('Integration | Component | pki key list page', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.keyName).hasText('test-key', 'linked block renders key id'); + assert.dom(PKI_KEYS.keyName).hasText('test-key', 'linked block renders key id'); assert - .dom(SELECTORS.keyId) + .dom(PKI_KEYS.keyId) .hasText('724862ff-6438-bad0-b598-77a6c7f4e934', 'linked block renders key name'); - assert.dom(SELECTORS.importKey).exists('renders import action'); - assert.dom(SELECTORS.generateKey).exists('renders generate action'); - await click(SELECTORS.popupMenuTrigger); - assert.dom(SELECTORS.popupMenuDetails).exists('details link exists'); - assert.dom(SELECTORS.popupMenuEdit).exists('edit link exists'); + assert.dom(PKI_KEYS.importKey).exists('renders import action'); + assert.dom(PKI_KEYS.generateKey).exists('renders generate action'); + await click(GENERAL.menuTrigger); + assert.dom(PKI_KEYS.popupMenuDetails).exists('details link exists'); + assert.dom(PKI_KEYS.popupMenuEdit).exists('edit link exists'); }); test('it hides actions when permission denied', async function (assert) { @@ -106,8 +107,8 @@ module('Integration | Component | pki key list page', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.importKey).doesNotExist('renders import action'); - assert.dom(SELECTORS.generateKey).doesNotExist('renders generate action'); - assert.dom(SELECTORS.popupMenuTrigger).doesNotExist('does not render popup menu when no permission'); + assert.dom(PKI_KEYS.importKey).doesNotExist('renders import action'); + assert.dom(PKI_KEYS.generateKey).doesNotExist('renders generate action'); + assert.dom(GENERAL.menuTrigger).doesNotExist('does not render popup menu when no permission'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-overview-test.js b/ui/tests/integration/components/pki/page/pki-overview-test.js index dbb5562ddca3..6043e0181dee 100644 --- a/ui/tests/integration/components/pki/page/pki-overview-test.js +++ b/ui/tests/integration/components/pki/page/pki-overview-test.js @@ -9,7 +9,7 @@ import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/overview'; +import { PKI_OVERVIEW } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | Page::PkiOverview', function (hooks) { setupRenderingTest(hooks); @@ -39,9 +39,9 @@ module('Integration | Component | Page::PkiOverview', function (hooks) { hbs`,`, { owner: this.engine } ); - assert.dom(SELECTORS.issuersCardTitle).hasText('Issuers'); - assert.dom(SELECTORS.issuersCardOverviewNum).hasText('2'); - assert.dom(SELECTORS.issuersCardLink).hasText('View issuers'); + assert.dom(PKI_OVERVIEW.issuersCardTitle).hasText('Issuers'); + assert.dom(PKI_OVERVIEW.issuersCardOverviewNum).hasText('2'); + assert.dom(PKI_OVERVIEW.issuersCardLink).hasText('View issuers'); }); test('shows the correct information on roles card', async function (assert) { @@ -49,15 +49,15 @@ module('Integration | Component | Page::PkiOverview', function (hooks) { hbs`,`, { owner: this.engine } ); - assert.dom(SELECTORS.rolesCardTitle).hasText('Roles'); - assert.dom(SELECTORS.rolesCardOverviewNum).hasText('3'); - assert.dom(SELECTORS.rolesCardLink).hasText('View roles'); + assert.dom(PKI_OVERVIEW.rolesCardTitle).hasText('Roles'); + assert.dom(PKI_OVERVIEW.rolesCardOverviewNum).hasText('3'); + assert.dom(PKI_OVERVIEW.rolesCardLink).hasText('View roles'); this.roles = 404; await render( hbs`,`, { owner: this.engine } ); - assert.dom(SELECTORS.rolesCardOverviewNum).hasText('0'); + assert.dom(PKI_OVERVIEW.rolesCardOverviewNum).hasText('0'); }); test('shows the input search fields for View Certificates card', async function (assert) { @@ -65,9 +65,9 @@ module('Integration | Component | Page::PkiOverview', function (hooks) { hbs`,`, { owner: this.engine } ); - assert.dom(SELECTORS.issueCertificate).hasText('Issue certificate'); - assert.dom(SELECTORS.issueCertificateInput).exists(); - assert.dom(SELECTORS.issueCertificateButton).hasText('Issue'); + assert.dom(PKI_OVERVIEW.issueCertificate).hasText('Issue certificate'); + assert.dom(PKI_OVERVIEW.issueCertificateInput).exists(); + assert.dom(PKI_OVERVIEW.issueCertificateButton).hasText('Issue'); }); test('shows the input search fields for Issue Certificates card', async function (assert) { @@ -75,8 +75,8 @@ module('Integration | Component | Page::PkiOverview', function (hooks) { hbs`,`, { owner: this.engine } ); - assert.dom(SELECTORS.viewCertificate).hasText('View certificate'); - assert.dom(SELECTORS.viewCertificateInput).exists(); - assert.dom(SELECTORS.viewCertificateButton).hasText('View'); + assert.dom(PKI_OVERVIEW.viewCertificate).hasText('View certificate'); + assert.dom(PKI_OVERVIEW.viewCertificateInput).exists(); + assert.dom(PKI_OVERVIEW.viewCertificateButton).hasText('View'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-role-details-test.js b/ui/tests/integration/components/pki/page/pki-role-details-test.js index 018a2883b6bf..dd279795b91f 100644 --- a/ui/tests/integration/components/pki/page/pki-role-details-test.js +++ b/ui/tests/integration/components/pki/page/pki-role-details-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-role-details'; +import { PKI_ROLE_DETAILS } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki role details page', function (hooks) { setupRenderingTest(hooks); @@ -34,15 +34,17 @@ module('Integration | Component | pki role details page', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.issuerLabel).hasText('Issuer', 'Label is'); + assert.dom(PKI_ROLE_DETAILS.issuerLabel).hasText('Issuer', 'Label is'); assert - .dom(`${SELECTORS.keyUsageValue} [data-test-icon="minus"]`) + .dom(`${PKI_ROLE_DETAILS.keyUsageValue} [data-test-icon="minus"]`) .exists('Key usage shows dash when array is empty'); assert - .dom(SELECTORS.extKeyUsageValue) + .dom(PKI_ROLE_DETAILS.extKeyUsageValue) .hasText('bar,baz', 'Key usage shows comma-joined values when array has items'); - assert.dom(SELECTORS.noStoreValue).containsText('Yes', 'noStore shows opposite of what the value is'); - assert.dom(SELECTORS.customTtlValue).containsText('10 minutes', 'TTL shown as duration'); + assert + .dom(PKI_ROLE_DETAILS.noStoreValue) + .containsText('Yes', 'noStore shows opposite of what the value is'); + assert.dom(PKI_ROLE_DETAILS.customTtlValue).containsText('10 minutes', 'TTL shown as duration'); }); test('it should render the notAfter date if present', async function (assert) { @@ -61,6 +63,8 @@ module('Integration | Component | pki role details page', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.customTtlValue).containsText('May', 'Formats the notAfter date instead of TTL'); + assert + .dom(PKI_ROLE_DETAILS.customTtlValue) + .containsText('May', 'Formats the notAfter date instead of TTL'); }); }); diff --git a/ui/tests/integration/components/pki/page/pki-tidy-status-test.js b/ui/tests/integration/components/pki/page/pki-tidy-status-test.js index 610d91bd2dc4..d324e60502bb 100644 --- a/ui/tests/integration/components/pki/page/pki-tidy-status-test.js +++ b/ui/tests/integration/components/pki/page/pki-tidy-status-test.js @@ -9,7 +9,7 @@ import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-tidy'; +import { PKI_TIDY } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | Page::PkiTidyStatus', function (hooks) { setupRenderingTest(hooks); @@ -62,44 +62,44 @@ module('Integration | Component | Page::PkiTidyStatus', function (hooks) { { owner: this.engine } ); // running state - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy in progress'); - assert.dom(SELECTORS.cancelTidyAction).exists(); - assert.dom(SELECTORS.hdsAlertButtonText).hasText('Cancel tidy'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy in progress'); + assert.dom(PKI_TIDY.cancelTidyAction).exists(); + assert.dom(PKI_TIDY.hdsAlertButtonText).hasText('Cancel tidy'); // inactive state this.tidyStatus.state = 'Inactive'; await render( hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy is inactive'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy is inactive'); // finished state this.tidyStatus.state = 'Finished'; await render( hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy operation finished'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy operation finished'); // error state this.tidyStatus.state = 'Error'; await render( hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy operation failed'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy operation failed'); // cancelling state this.tidyStatus.state = 'Cancelling'; await render( hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy operation cancelling'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy operation cancelling'); // cancelled state this.tidyStatus.state = 'Cancelled'; await render( hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.hdsAlertTitle).hasText('Tidy operation cancelled'); + assert.dom(PKI_TIDY.hdsAlertTitle).hasText('Tidy operation cancelled'); }); test('shows the fields even if the data returns null values', async function (assert) { this.tidyStatus.time_started = null; @@ -108,7 +108,7 @@ module('Integration | Component | Page::PkiTidyStatus', function (hooks) { hbs``, { owner: this.engine } ); - assert.dom(SELECTORS.timeStartedRow).exists(); - assert.dom(SELECTORS.timeFinishedRow).exists(); + assert.dom(PKI_TIDY.timeStartedRow).exists(); + assert.dom(PKI_TIDY.timeFinishedRow).exists(); }); }); 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 9e7c6120b537..67bbdc0684da 100644 --- a/ui/tests/integration/components/pki/pki-generate-root-test.js +++ b/ui/tests/integration/components/pki/pki-generate-root-test.js @@ -11,7 +11,8 @@ import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import Sinon from 'sinon'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-generate-root'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_GENERATE_ROOT } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki-generate-root', function (hooks) { setupRenderingTest(hooks); @@ -38,7 +39,7 @@ module('Integration | Component | pki-generate-root', function (hooks) { ); assert.dom('h2').exists({ count: 1 }, 'One H2 title without @urls'); - assert.dom(SELECTORS.mainSectionTitle).hasText('Root parameters'); + assert.dom(PKI_GENERATE_ROOT.mainSectionTitle).hasText('Root parameters'); assert.dom('[data-test-toggle-group]').exists({ count: 3 }, '3 toggle groups shown'); }); @@ -50,33 +51,33 @@ module('Integration | Component | pki-generate-root', function (hooks) { } ); - await click(SELECTORS.additionalGroupToggle); + await click(PKI_GENERATE_ROOT.additionalGroupToggle); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText('These fields provide more information about the client to which the certificate belongs.'); assert - .dom(`[data-test-group="Additional subject fields"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Additional subject fields')) .exists({ count: 7 }, '7 form fields under Additional Fields toggle'); - await click(SELECTORS.sanGroupToggle); + await click(PKI_GENERATE_ROOT.sanGroupToggle); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'SAN fields are an extension that allow you specify additional host names (sites, IP addresses, common names, etc.) to be protected by a single certificate.' ); assert - .dom(`[data-test-group="Subject Alternative Name (SAN) Options"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Subject Alternative Name (SAN) Options')) .exists({ count: 6 }, '7 form fields under SANs toggle'); - await click(SELECTORS.keyParamsGroupToggle); + await click(PKI_GENERATE_ROOT.keyParamsGroupToggle); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'Please choose a type to see key parameter options.', 'Shows empty state description before type is selected' ); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 0 }, '0 form fields under keyParams toggle'); }); @@ -88,75 +89,75 @@ module('Integration | Component | pki-generate-root', function (hooks) { owner: this.engine, } ); - await click(SELECTORS.keyParamsGroupToggle); + await click(PKI_GENERATE_ROOT.keyParamsGroupToggle); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 0 }, '0 form fields under keyParams toggle'); this.set('type', 'exported'); - await fillIn(SELECTORS.typeField, this.type); + await fillIn(GENERAL.inputByAttr('type'), this.type); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'This certificate type is exported. This means the private key will be returned in the response. Below, you will name the key and define its type and key bits.', `has correct description for type=${this.type}` ); assert.strictEqual(this.model.type, this.type); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 4 }, '4 form fields under keyParams toggle'); - assert.dom(SELECTORS.fieldByName('keyName')).exists(`Key name field shown when type=${this.type}`); - assert.dom(SELECTORS.fieldByName('keyType')).exists(`Key type field shown when type=${this.type}`); - assert.dom(SELECTORS.fieldByName('keyBits')).exists(`Key bits field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyName')).exists(`Key name field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyType')).exists(`Key type field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyBits')).exists(`Key bits field shown when type=${this.type}`); this.set('type', 'internal'); - await fillIn(SELECTORS.typeField, this.type); + await fillIn(GENERAL.inputByAttr('type'), this.type); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'This certificate type is internal. This means that the private key will not be returned and cannot be retrieved later. Below, you will name the key and define its type and key bits.', `has correct description for type=${this.type}` ); assert.strictEqual(this.model.type, this.type); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 3 }, '3 form fields under keyParams toggle'); - assert.dom(SELECTORS.fieldByName('keyName')).exists(`Key name field shown when type=${this.type}`); - assert.dom(SELECTORS.fieldByName('keyType')).exists(`Key type field shown when type=${this.type}`); - assert.dom(SELECTORS.fieldByName('keyBits')).exists(`Key bits field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyName')).exists(`Key name field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyType')).exists(`Key type field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyBits')).exists(`Key bits field shown when type=${this.type}`); this.set('type', 'existing'); - await fillIn(SELECTORS.typeField, this.type); + await fillIn(GENERAL.inputByAttr('type'), this.type); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'You chose to use an existing key. This means that we’ll use the key reference to create the CSR or root. Please provide the reference to the key.', `has correct description for type=${this.type}` ); assert.strictEqual(this.model.type, this.type); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 1 }, '1 form field under keyParams toggle'); - assert.dom(SELECTORS.fieldByName('keyRef')).exists(`Key reference field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyRef')).exists(`Key reference field shown when type=${this.type}`); this.set('type', 'kms'); - await fillIn(SELECTORS.typeField, this.type); + await fillIn(GENERAL.inputByAttr('type'), this.type); assert - .dom(SELECTORS.toggleGroupDescription) + .dom(PKI_GENERATE_ROOT.toggleGroupDescription) .hasText( 'This certificate type is kms, meaning managed keys will be used. Below, you will name the key and tell Vault where to find it in your KMS or HSM. Learn more about managed keys.', `has correct description for type=${this.type}` ); assert.strictEqual(this.model.type, this.type); assert - .dom(`[data-test-group="Key parameters"] ${SELECTORS.formField}`) + .dom(PKI_GENERATE_ROOT.groupFields('Key parameters')) .exists({ count: 3 }, '3 form fields under keyParams toggle'); - assert.dom(SELECTORS.fieldByName('keyName')).exists(`Key name field shown when type=${this.type}`); + assert.dom(GENERAL.fieldByAttr('keyName')).exists(`Key name field shown when type=${this.type}`); assert - .dom(SELECTORS.fieldByName('managedKeyName')) + .dom(GENERAL.fieldByAttr('managedKeyName')) .exists(`Managed key name field shown when type=${this.type}`); assert - .dom(SELECTORS.fieldByName('managedKeyId')) + .dom(GENERAL.fieldByAttr('managedKeyId')) .exists(`Managed key id field shown when type=${this.type}`); }); @@ -170,8 +171,8 @@ module('Integration | Component | pki-generate-root', function (hooks) { } ); - await click(SELECTORS.generateRootSave); - assert.dom(SELECTORS.formInvalidError).exists('Shows overall error form'); + await click(GENERAL.saveButton); + assert.dom(PKI_GENERATE_ROOT.formInvalidError).exists('Shows overall error form'); assert.ok(saveSpy.notCalled); }); @@ -184,7 +185,7 @@ module('Integration | Component | pki-generate-root', function (hooks) { } ); - assert.dom(SELECTORS.urlsSection).doesNotExist(); + assert.dom(PKI_GENERATE_ROOT.urlsSection).doesNotExist(); }); test('it renders when urls model passed', async function (assert) { @@ -194,9 +195,9 @@ module('Integration | Component | pki-generate-root', function (hooks) { owner: this.engine, } ); - assert.dom(SELECTORS.urlsSection).exists(); + assert.dom(PKI_GENERATE_ROOT.urlsSection).exists(); assert.dom('h2').exists({ count: 2 }, 'two H2 titles are visible on page load'); - assert.dom(SELECTORS.urlSectionTitle).hasText('Issuer URLs'); + assert.dom(PKI_GENERATE_ROOT.urlSectionTitle).hasText('Issuer URLs'); }); }); }); diff --git a/ui/tests/integration/components/pki/pki-import-pem-bundle-test.js b/ui/tests/integration/components/pki/pki-import-pem-bundle-test.js index 9d66236426ce..2d22ed570899 100644 --- a/ui/tests/integration/components/pki/pki-import-pem-bundle-test.js +++ b/ui/tests/integration/components/pki/pki-import-pem-bundle-test.js @@ -9,8 +9,10 @@ import { render, click, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { issuerPemBundle } from 'vault/tests/helpers/pki/values'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +import { PKI_CONFIGURE_CREATE } from 'vault/tests/helpers/pki/pki-selectors'; +const { issuerPemBundle } = CERTIFICATES; module('Integration | Component | PkiImportPemBundle', function (hooks) { setupRenderingTest(hooks); setupMirage(hooks); @@ -85,7 +87,7 @@ module('Integration | Component | PkiImportPemBundle', function (hooks) { await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); assert.strictEqual(this.model.pemBundle, this.pemBundle, 'PEM bundle updated on model'); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); }); test('it hits correct endpoint when userIssuer=false', async function (assert) { @@ -126,7 +128,7 @@ module('Integration | Component | PkiImportPemBundle', function (hooks) { await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); assert.strictEqual(this.model.pemBundle, this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); }); test('it shows the bundle mapping on success', async function (assert) { @@ -160,7 +162,7 @@ module('Integration | Component | PkiImportPemBundle', function (hooks) { await click('[data-test-text-toggle]'); await fillIn('[data-test-text-file-textarea]', this.pemBundle); - await click('[data-test-pki-import-pem-bundle]'); + await click(PKI_CONFIGURE_CREATE.importSubmit); assert .dom('[data-test-import-pair]') diff --git a/ui/tests/integration/components/pki/pki-issuer-cross-sign-test.js b/ui/tests/integration/components/pki/pki-issuer-cross-sign-test.js index 2c8f87bbd5b9..f1c7b92284bf 100644 --- a/ui/tests/integration/components/pki/pki-issuer-cross-sign-test.js +++ b/ui/tests/integration/components/pki/pki-issuer-cross-sign-test.js @@ -10,15 +10,9 @@ import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { Response } from 'miragejs'; import { hbs } from 'ember-cli-htmlbars'; -import { - intIssuerCert, - newCSR, - newlySignedCert, - oldParentIssuerCert, - parentIssuerCert, - unsupportedOids, -} from 'vault/tests/helpers/pki/values'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-issuer-cross-sign'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +import { PKI_CROSS_SIGN } from 'vault/tests/helpers/pki/pki-selectors'; const FIELDS = [ { @@ -40,6 +34,8 @@ const FIELDS = [ helpText: `This is your new issuer’s name in the API.`, }, ]; +const { intIssuerCert, newCSR, newlySignedCert, oldParentIssuerCert, parentIssuerCert, unsupportedOids } = + CERTIFICATES; module('Integration | Component | pki issuer cross sign', function (hooks) { setupRenderingTest(hooks); setupEngine(hooks, 'pki'); @@ -189,19 +185,19 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { }); // fill out form and submit for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key), this.testInputs[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key), this.testInputs[field.key]); } - await click(SELECTORS.submitButton); + await click(GENERAL.saveButton); - assert.dom(SELECTORS.statusCount).hasText('Cross-signing complete (1 successful, 0 errors)'); + assert.dom(PKI_CROSS_SIGN.statusCount).hasText('Cross-signing complete (1 successful, 0 errors)'); assert - .dom(`${SELECTORS.signedIssuerRow()} [data-test-icon="check-circle"]`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow()} [data-test-icon="check-circle"]`) .exists('row has success icon'); for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(this.testInputs[field.key], `${field.key} displays correct value`); - assert.dom(`${SELECTORS.signedIssuerCol(field.key)} a`).hasTagName('a'); + assert.dom(`${PKI_CROSS_SIGN.signedIssuerCol(field.key)} a`).hasTagName('a'); } }); @@ -247,32 +243,32 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { // fill out form and submit for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key), this.testInputs[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key), this.testInputs[field.key]); } - await click(SELECTORS.addRow); + await click(PKI_CROSS_SIGN.addRow); for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key, 1), nonexistentIssuer[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key, 1), nonexistentIssuer[field.key]); } - await click(SELECTORS.addRow); + await click(PKI_CROSS_SIGN.addRow); for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key, 2), unsupportedCert[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key, 2), unsupportedCert[field.key]); } - await click(SELECTORS.submitButton); + await click(GENERAL.saveButton); - assert.dom(SELECTORS.statusCount).hasText('Cross-signing complete (0 successful, 3 errors)'); + assert.dom(PKI_CROSS_SIGN.statusCount).hasText('Cross-signing complete (0 successful, 3 errors)'); for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerRow()} ${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow()} ${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(this.testInputs[field.key], `first row has correct values`); } for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerRow(1)} ${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow(1)} ${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(nonexistentIssuer[field.key], `second row has correct values`); } for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerRow(2)} ${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow(2)} ${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(unsupportedCert[field.key], `third row has correct values`); } }); @@ -295,13 +291,13 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { // fill out form and submit for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key), this.testInputs[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key), this.testInputs[field.key]); } - await click(SELECTORS.submitButton); + await click(GENERAL.saveButton); - assert.dom(SELECTORS.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); + assert.dom(PKI_CROSS_SIGN.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); assert - .dom(`${SELECTORS.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) .exists('row has failure icon'); assert.dom('[data-test-cross-sign-alert-title]').hasText('Cross-sign failed'); @@ -311,7 +307,7 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(this.testInputs[field.key], `${field.key} displays correct value`); } }); @@ -328,12 +324,12 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { }); // fill out form and submit for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key), this.testInputs[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key), this.testInputs[field.key]); } - await click(SELECTORS.submitButton); - assert.dom(SELECTORS.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); + await click(GENERAL.saveButton); + assert.dom(PKI_CROSS_SIGN.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); assert - .dom(`${SELECTORS.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) .exists('row has failure icon'); assert .dom('[data-test-cross-sign-alert-title]') @@ -346,7 +342,7 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(this.testInputs[field.key], `${field.key} displays correct value`); } }); @@ -367,12 +363,12 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { }); // fill out form and submit for (const field of FIELDS) { - await fillIn(SELECTORS.objectListInput(field.key), this.testInputs[field.key]); + await fillIn(PKI_CROSS_SIGN.objectListInput(field.key), this.testInputs[field.key]); } - await click(SELECTORS.submitButton); - assert.dom(SELECTORS.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); + await click(GENERAL.saveButton); + assert.dom(PKI_CROSS_SIGN.statusCount).hasText('Cross-signing complete (0 successful, 1 error)'); assert - .dom(`${SELECTORS.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) + .dom(`${PKI_CROSS_SIGN.signedIssuerRow()} [data-test-icon="alert-circle-fill"]`) .exists('row has failure icon'); assert.dom('[data-test-cross-sign-alert-title]').hasText('Cross-sign failed'); assert @@ -381,7 +377,7 @@ module('Integration | Component | pki issuer cross sign', function (hooks) { for (const field of FIELDS) { assert - .dom(`${SELECTORS.signedIssuerCol(field.key)}`) + .dom(`${PKI_CROSS_SIGN.signedIssuerCol(field.key)}`) .hasText(this.testInputs[field.key], `${field.key} displays correct value`); } }); diff --git a/ui/tests/integration/components/pki/pki-issuer-details-test.js b/ui/tests/integration/components/pki/pki-issuer-details-test.js index b38f8e804703..7fa9ed525828 100644 --- a/ui/tests/integration/components/pki/pki-issuer-details-test.js +++ b/ui/tests/integration/components/pki/pki-issuer-details-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'vault/tests/helpers'; import { render, settled } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-issuer-details'; +import { PKI_ISSUER_DETAILS } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | page/pki-issuer-details', function (hooks) { setupRenderingTest(hooks); @@ -30,12 +30,12 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.context ); - assert.dom(SELECTORS.rotateRoot).doesNotExist(); - assert.dom(SELECTORS.crossSign).doesNotExist(); - assert.dom(SELECTORS.signIntermediate).doesNotExist(); - assert.dom(SELECTORS.download).hasText('Download'); - assert.dom(SELECTORS.configure).doesNotExist(); - assert.dom(SELECTORS.parsingAlertBanner).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.rotateRoot).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.crossSign).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.signIntermediate).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.download).hasText('Download'); + assert.dom(PKI_ISSUER_DETAILS.configure).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.parsingAlertBanner).doesNotExist(); }); test('it renders toolbar actions depending on passed capabilities', async function (assert) { @@ -59,12 +59,12 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.context ); - assert.dom(SELECTORS.parsingAlertBanner).doesNotExist(); - assert.dom(SELECTORS.rotateRoot).hasText('Rotate this root'); - assert.dom(SELECTORS.crossSign).hasText('Cross-sign issuers'); - assert.dom(SELECTORS.signIntermediate).hasText('Sign Intermediate'); - assert.dom(SELECTORS.download).hasText('Download'); - assert.dom(SELECTORS.configure).hasText('Configure'); + assert.dom(PKI_ISSUER_DETAILS.parsingAlertBanner).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.rotateRoot).hasText('Rotate this root'); + assert.dom(PKI_ISSUER_DETAILS.crossSign).hasText('Cross-sign issuers'); + assert.dom(PKI_ISSUER_DETAILS.signIntermediate).hasText('Sign Intermediate'); + assert.dom(PKI_ISSUER_DETAILS.download).hasText('Download'); + assert.dom(PKI_ISSUER_DETAILS.configure).hasText('Configure'); this.set('canRotate', false); this.set('canCrossSign', false); @@ -72,11 +72,11 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.set('canConfigure', false); await settled(); - assert.dom(SELECTORS.rotateRoot).doesNotExist(); - assert.dom(SELECTORS.crossSign).doesNotExist(); - assert.dom(SELECTORS.signIntermediate).doesNotExist(); - assert.dom(SELECTORS.download).hasText('Download'); - assert.dom(SELECTORS.configure).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.rotateRoot).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.crossSign).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.signIntermediate).doesNotExist(); + assert.dom(PKI_ISSUER_DETAILS.download).hasText('Download'); + assert.dom(PKI_ISSUER_DETAILS.configure).doesNotExist(); }); test('it renders correct details by default', async function (assert) { @@ -88,24 +88,26 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { ); // Default group details: - assert.dom(SELECTORS.defaultGroup).exists('Default group of details exists'); - assert.dom(SELECTORS.valueByName('Certificate')).exists('Certificate detail exists'); - assert.dom(SELECTORS.copyButtonByName('Certificate')).exists('Certificate is copyable'); - assert.dom(SELECTORS.valueByName('CA Chain')).exists('CA Chain detail exists'); - assert.dom(SELECTORS.copyButtonByName('CA Chain')).exists('CA Chain is copyable'); - assert.dom(SELECTORS.valueByName('Common name')).exists('Common name detail exists'); - assert.dom(SELECTORS.valueByName('Issuer name')).exists('Issuer name detail exists'); - assert.dom(SELECTORS.valueByName('Issuer ID')).exists('Issuer ID detail exists'); - assert.dom(SELECTORS.copyButtonByName('Issuer ID')).exists('Issuer ID is copyable'); - assert.dom(SELECTORS.valueByName('Default key ID')).exists('Default key ID detail exists'); + assert.dom(PKI_ISSUER_DETAILS.defaultGroup).exists('Default group of details exists'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('Certificate')).exists('Certificate detail exists'); + assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('Certificate')).exists('Certificate is copyable'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('CA Chain')).exists('CA Chain detail exists'); + assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('CA Chain')).exists('CA Chain is copyable'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('Common name')).exists('Common name detail exists'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('Issuer name')).exists('Issuer name detail exists'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('Issuer ID')).exists('Issuer ID detail exists'); + assert.dom(PKI_ISSUER_DETAILS.copyButtonByName('Issuer ID')).exists('Issuer ID is copyable'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('Default key ID')).exists('Default key ID detail exists'); // Issuer URLs group details: - assert.dom(SELECTORS.urlsGroup).exists('Issuer URLs group of details exists'); - assert.dom(SELECTORS.valueByName('Issuing certificates')).exists('Issuing certificates detail exists'); + assert.dom(PKI_ISSUER_DETAILS.urlsGroup).exists('Issuer URLs group of details exists'); assert - .dom(SELECTORS.valueByName('CRL distribution points')) + .dom(PKI_ISSUER_DETAILS.valueByName('Issuing certificates')) + .exists('Issuing certificates detail exists'); + assert + .dom(PKI_ISSUER_DETAILS.valueByName('CRL distribution points')) .exists('CRL distribution points detail exists'); - assert.dom(SELECTORS.valueByName('OCSP servers')).exists('OCSP servers detail exists'); + assert.dom(PKI_ISSUER_DETAILS.valueByName('OCSP servers')).exists('OCSP servers detail exists'); }); test('it renders parsing error banner if issuer certificate contains unsupported OIDs', async function (assert) { @@ -128,9 +130,9 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.context ); - assert.dom(SELECTORS.parsingAlertBanner).exists(); + assert.dom(PKI_ISSUER_DETAILS.parsingAlertBanner).exists(); assert - .dom(SELECTORS.parsingAlertBanner) + .dom(PKI_ISSUER_DETAILS.parsingAlertBanner) .hasText( "There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI. Parsing error(s): certificate contains stuff we cannot parse" ); @@ -156,9 +158,9 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.context ); - assert.dom(SELECTORS.parsingAlertBanner).exists(); + assert.dom(PKI_ISSUER_DETAILS.parsingAlertBanner).exists(); assert - .dom(SELECTORS.parsingAlertBanner) + .dom(PKI_ISSUER_DETAILS.parsingAlertBanner) .hasText( "There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI." ); @@ -184,9 +186,9 @@ module('Integration | Component | page/pki-issuer-details', function (hooks) { this.context ); - assert.dom(SELECTORS.parsingAlertBanner).exists(); + assert.dom(PKI_ISSUER_DETAILS.parsingAlertBanner).exists(); assert - .dom(SELECTORS.parsingAlertBanner) + .dom(PKI_ISSUER_DETAILS.parsingAlertBanner) .hasText( "There was an error parsing certificate metadata Vault cannot display unparsed values, but this will not interfere with the certificate's functionality. However, if you wish to cross-sign this issuer it must be done manually using the CLI." ); diff --git a/ui/tests/integration/components/pki/pki-key-form-test.js b/ui/tests/integration/components/pki/pki-key-form-test.js index d48c19217bef..54a62b171fd7 100644 --- a/ui/tests/integration/components/pki/pki-key-form-test.js +++ b/ui/tests/integration/components/pki/pki-key-form-test.js @@ -3,14 +3,15 @@ * SPDX-License-Identifier: BUSL-1.1 */ +import sinon from 'sinon'; import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render, click, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-key-form'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import sinon from 'sinon'; +import { PKI_KEY_FORM } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki key form', function (hooks) { setupRenderingTest(hooks); @@ -38,20 +39,20 @@ module('Integration | Component | pki key form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.keyNameInput).exists('renders name input'); - assert.dom(SELECTORS.typeInput).exists('renders type input'); - assert.dom(SELECTORS.keyTypeInput).exists('renders key type input'); - assert.dom(SELECTORS.keyBitsInput).exists('renders key bits input'); + assert.dom(GENERAL.inputByAttr('keyName')).exists('renders name input'); + assert.dom(GENERAL.inputByAttr('type')).exists('renders type input'); + assert.dom(GENERAL.inputByAttr('keyType')).exists('renders key type input'); + assert.dom(GENERAL.inputByAttr('keyBits')).exists('renders key bits input'); - await click(SELECTORS.keyCreateButton); + await click(GENERAL.saveButton); assert - .dom(SELECTORS.fieldErrorByName('type')) + .dom(GENERAL.validation('type')) .hasTextContaining('Type is required.', 'renders presence validation for type of key'); assert - .dom(SELECTORS.fieldErrorByName('keyType')) + .dom(GENERAL.validation('keyType')) .hasTextContaining('Please select a key type.', 'renders selection prompt for key type'); assert - .dom(SELECTORS.validationError) + .dom(PKI_KEY_FORM.validationError) .hasTextContaining('There are 2 errors with this form.', 'renders correct form error count'); }); @@ -85,11 +86,11 @@ module('Integration | Component | pki key form', function (hooks) { { owner: this.engine } ); - await fillIn(SELECTORS.keyNameInput, 'test-key'); - await fillIn(SELECTORS.typeInput, 'exported'); - assert.dom(SELECTORS.keyBitsInput).isDisabled('key bits disabled when no key type selected'); - await fillIn(SELECTORS.keyTypeInput, 'rsa'); - await click(SELECTORS.keyCreateButton); + await fillIn(GENERAL.inputByAttr('keyName'), 'test-key'); + await fillIn(GENERAL.inputByAttr('type'), 'exported'); + assert.dom(GENERAL.inputByAttr('keyBits')).isDisabled('key bits disabled when no key type selected'); + await fillIn(GENERAL.inputByAttr('keyType'), 'rsa'); + await click(GENERAL.saveButton); }); test('it generates a key type=internal', async function (assert) { @@ -121,10 +122,10 @@ module('Integration | Component | pki key form', function (hooks) { { owner: this.engine } ); - await fillIn(SELECTORS.keyNameInput, 'test-key'); - await fillIn(SELECTORS.typeInput, 'internal'); - assert.dom(SELECTORS.keyBitsInput).isDisabled('key bits disabled when no key type selected'); - await fillIn(SELECTORS.keyTypeInput, 'rsa'); - await click(SELECTORS.keyCreateButton); + await fillIn(GENERAL.inputByAttr('keyName'), 'test-key'); + await fillIn(GENERAL.inputByAttr('type'), 'internal'); + assert.dom(GENERAL.inputByAttr('keyBits')).isDisabled('key bits disabled when no key type selected'); + await fillIn(GENERAL.inputByAttr('keyType'), 'rsa'); + await click(GENERAL.saveButton); }); }); diff --git a/ui/tests/integration/components/pki/pki-key-parameters-test.js b/ui/tests/integration/components/pki/pki-key-parameters-test.js index b41a2b14aaba..8250d03f6f81 100644 --- a/ui/tests/integration/components/pki/pki-key-parameters-test.js +++ b/ui/tests/integration/components/pki/pki-key-parameters-test.js @@ -8,8 +8,8 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-role-form'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; module('Integration | Component | pki key parameters', function (hooks) { setupRenderingTest(hooks); @@ -40,9 +40,9 @@ module('Integration | Component | pki key parameters', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.keyType).hasValue('rsa'); - assert.dom(SELECTORS.keyBits).hasValue('2048'); - assert.dom(SELECTORS.signatureBits).hasValue('0'); + assert.dom(GENERAL.inputByAttr('keyType')).hasValue('rsa'); + assert.dom(GENERAL.inputByAttr('keyBits')).hasValue('2048'); + assert.dom(GENERAL.inputByAttr('signatureBits')).hasValue('0'); }); test('it should set the model properties of key_type and key_bits when key_type changes', async function (assert) { @@ -65,7 +65,7 @@ module('Integration | Component | pki key parameters', function (hooks) { '0', 'sets the default value for signature_bits on the model.' ); - await fillIn(SELECTORS.keyType, 'ec'); + await fillIn(GENERAL.inputByAttr('keyType'), 'ec'); assert.strictEqual(this.model.keyType, 'ec', 'sets the new selected value for key_type on the model.'); assert.strictEqual( this.model.keyBits, @@ -73,7 +73,7 @@ module('Integration | Component | pki key parameters', function (hooks) { 'sets the new selected value for key_bits on the model based on the selection of key_type.' ); - await fillIn(SELECTORS.keyType, 'ed25519'); + await fillIn(GENERAL.inputByAttr('keyType'), 'ed25519'); assert.strictEqual( this.model.keyType, 'ed25519', @@ -85,8 +85,8 @@ module('Integration | Component | pki key parameters', function (hooks) { 'sets the new selected value for key_bits on the model based on the selection of key_type.' ); - await fillIn(SELECTORS.keyType, 'ec'); - await fillIn(SELECTORS.keyBits, '384'); + await fillIn(GENERAL.inputByAttr('keyType'), 'ec'); + await fillIn(GENERAL.inputByAttr('keyBits'), '384'); assert.strictEqual(this.model.keyType, 'ec', 'sets the new selected value for key_type on the model.'); assert.strictEqual( this.model.keyBits, @@ -94,14 +94,14 @@ module('Integration | Component | pki key parameters', function (hooks) { 'sets the new selected value for key_bits on the model based on the selection of key_type.' ); - await fillIn(SELECTORS.signatureBits, '384'); + await fillIn(GENERAL.inputByAttr('signatureBits'), '384'); assert.strictEqual( this.model.signatureBits, '384', 'sets the new selected value for signature_bits on the model.' ); - await fillIn(SELECTORS.signatureBits, '0'); + await fillIn(GENERAL.inputByAttr('signatureBits'), '0'); assert.strictEqual( this.model.signatureBits, '0', diff --git a/ui/tests/integration/components/pki/pki-key-usage-test.js b/ui/tests/integration/components/pki/pki-key-usage-test.js index 55429b135c52..5d8671183c56 100644 --- a/ui/tests/integration/components/pki/pki-key-usage-test.js +++ b/ui/tests/integration/components/pki/pki-key-usage-test.js @@ -8,7 +8,8 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, click, findAll } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-role-form'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_ROLE_FORM } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki-key-usage', function (hooks) { setupRenderingTest(hooks); @@ -33,11 +34,11 @@ module('Integration | Component | pki-key-usage', function (hooks) { { owner: this.engine } ); assert.strictEqual(findAll('.b-checkbox').length, 19, 'it render 19 checkboxes'); - assert.dom(SELECTORS.digitalSignature).isChecked('Digital Signature is true by default'); - assert.dom(SELECTORS.keyAgreement).isChecked('Key Agreement is true by default'); - assert.dom(SELECTORS.keyEncipherment).isChecked('Key Encipherment is true by default'); - assert.dom(SELECTORS.any).isNotChecked('Any is false by default'); - assert.dom(SELECTORS.extKeyUsageOids).exists('Extended Key usage oids renders'); + assert.dom(PKI_ROLE_FORM.digitalSignature).isChecked('Digital Signature is true by default'); + assert.dom(PKI_ROLE_FORM.keyAgreement).isChecked('Key Agreement is true by default'); + assert.dom(PKI_ROLE_FORM.keyEncipherment).isChecked('Key Encipherment is true by default'); + assert.dom(PKI_ROLE_FORM.any).isNotChecked('Any is false by default'); + assert.dom(GENERAL.inputByAttr('extKeyUsageOids')).exists('Extended Key usage oids renders'); }); test('it should set the model properties of key_usage and ext_key_usage based on the checkbox selections', async function (assert) { @@ -53,9 +54,9 @@ module('Integration | Component | pki-key-usage', function (hooks) { { owner: this.engine } ); - await click(SELECTORS.digitalSignature); - await click(SELECTORS.any); - await click(SELECTORS.serverAuth); + await click(PKI_ROLE_FORM.digitalSignature); + await click(PKI_ROLE_FORM.any); + await click(PKI_ROLE_FORM.serverAuth); assert.deepEqual( this.model.keyUsage, diff --git a/ui/tests/integration/components/pki/pki-not-valid-after-form-test.js b/ui/tests/integration/components/pki/pki-not-valid-after-form-test.js index 5157c8b6d0a3..7885155794b6 100644 --- a/ui/tests/integration/components/pki/pki-not-valid-after-form-test.js +++ b/ui/tests/integration/components/pki/pki-not-valid-after-form-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, click, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-not-valid-after-form'; +import { PKI_NOT_VALID_AFTER } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki-not-valid-after-form', function (hooks) { setupRenderingTest(hooks); @@ -38,9 +38,9 @@ module('Integration | Component | pki-not-valid-after-form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.ttlForm).exists('shows the TTL picker'); - assert.dom(SELECTORS.ttlTimeInput).hasValue('', 'default TTL is empty'); - assert.dom(SELECTORS.radioTtl).isChecked('ttl is selected by default'); + assert.dom(PKI_NOT_VALID_AFTER.ttlForm).exists('shows the TTL picker'); + assert.dom(PKI_NOT_VALID_AFTER.ttlTimeInput).hasValue('', 'default TTL is empty'); + assert.dom(PKI_NOT_VALID_AFTER.radioTtl).isChecked('ttl is selected by default'); }); test('it clears and resets model properties from cache when changing radio selection', async function (assert) { @@ -55,17 +55,17 @@ module('Integration | Component | pki-not-valid-after-form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.radioTtl).isChecked('notBeforeDate radio is selected'); - assert.dom(SELECTORS.ttlForm).exists({ count: 1 }, 'shows TTL form'); - assert.dom(SELECTORS.radioDate).isNotChecked('NotAfter selection not checked'); - assert.dom(SELECTORS.dateInput).doesNotExist('does not show date input field'); + assert.dom(PKI_NOT_VALID_AFTER.radioTtl).isChecked('notBeforeDate radio is selected'); + assert.dom(PKI_NOT_VALID_AFTER.ttlForm).exists({ count: 1 }, 'shows TTL form'); + assert.dom(PKI_NOT_VALID_AFTER.radioDate).isNotChecked('NotAfter selection not checked'); + assert.dom(PKI_NOT_VALID_AFTER.dateInput).doesNotExist('does not show date input field'); - await click(SELECTORS.radioDateLabel); + await click(PKI_NOT_VALID_AFTER.radioDateLabel); - assert.dom(SELECTORS.radioDate).isChecked('selects NotAfter radio when label clicked'); - assert.dom(SELECTORS.dateInput).exists({ count: 1 }, 'shows date input field'); - assert.dom(SELECTORS.radioTtl).isNotChecked('notBeforeDate radio is deselected'); - assert.dom(SELECTORS.ttlForm).doesNotExist('hides TTL form'); + assert.dom(PKI_NOT_VALID_AFTER.radioDate).isChecked('selects NotAfter radio when label clicked'); + assert.dom(PKI_NOT_VALID_AFTER.dateInput).exists({ count: 1 }, 'shows date input field'); + assert.dom(PKI_NOT_VALID_AFTER.radioTtl).isNotChecked('notBeforeDate radio is deselected'); + assert.dom(PKI_NOT_VALID_AFTER.ttlForm).doesNotExist('hides TTL form'); const utcDate = '1994-11-05'; const notAfterExpected = '1994-11-05T00:00:00.000Z'; @@ -106,13 +106,13 @@ module('Integration | Component | pki-not-valid-after-form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.radioTtl).isChecked('notBeforeDate radio is selected'); - assert.dom(SELECTORS.ttlForm).exists({ count: 1 }, 'shows TTL form'); - assert.dom(SELECTORS.radioDate).isNotChecked('NotAfter selection not checked'); - assert.dom(SELECTORS.dateInput).doesNotExist('does not show date input field'); + assert.dom(PKI_NOT_VALID_AFTER.radioTtl).isChecked('notBeforeDate radio is selected'); + assert.dom(PKI_NOT_VALID_AFTER.ttlForm).exists({ count: 1 }, 'shows TTL form'); + assert.dom(PKI_NOT_VALID_AFTER.radioDate).isNotChecked('NotAfter selection not checked'); + assert.dom(PKI_NOT_VALID_AFTER.dateInput).doesNotExist('does not show date input field'); - assert.dom(SELECTORS.ttlTimeInput).hasValue('100', 'TTL value is correctly shown'); - assert.dom(SELECTORS.ttlUnitInput).hasValue('m', 'TTL unit is correctly shown'); + assert.dom(PKI_NOT_VALID_AFTER.ttlTimeInput).hasValue('100', 'TTL value is correctly shown'); + assert.dom(PKI_NOT_VALID_AFTER.ttlUnitInput).hasValue('m', 'TTL unit is correctly shown'); }); test('Form renders properly for edit when notAfter present', async function (assert) { const utcDate = '1994-11-05T00:00:00.000Z'; @@ -128,11 +128,11 @@ module('Integration | Component | pki-not-valid-after-form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.radioDate).isChecked('notAfter radio is selected'); - assert.dom(SELECTORS.dateInput).exists({ count: 1 }, 'shows date picker'); - assert.dom(SELECTORS.radioTtl).isNotChecked('ttl radio not selected'); - assert.dom(SELECTORS.ttlForm).doesNotExist('does not show date TTL picker'); + assert.dom(PKI_NOT_VALID_AFTER.radioDate).isChecked('notAfter radio is selected'); + assert.dom(PKI_NOT_VALID_AFTER.dateInput).exists({ count: 1 }, 'shows date picker'); + assert.dom(PKI_NOT_VALID_AFTER.radioTtl).isNotChecked('ttl radio not selected'); + assert.dom(PKI_NOT_VALID_AFTER.ttlForm).doesNotExist('does not show date TTL picker'); // Due to timezones, can't check specific match on input date - assert.dom(SELECTORS.dateInput).hasAnyValue('date input shows date'); + assert.dom(PKI_NOT_VALID_AFTER.dateInput).hasAnyValue('date input shows date'); }); }); diff --git a/ui/tests/integration/components/pki/pki-role-form-test.js b/ui/tests/integration/components/pki/pki-role-form-test.js index 417316ff61c9..c89b085380b1 100644 --- a/ui/tests/integration/components/pki/pki-role-form-test.js +++ b/ui/tests/integration/components/pki/pki-role-form-test.js @@ -8,7 +8,8 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, click, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-role-form'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_ROLE_FORM } from 'vault/tests/helpers/pki/pki-selectors'; import { setupMirage } from 'ember-cli-mirage/test-support'; import sinon from 'sinon'; import { setRunOptions } from 'ember-a11y-testing/test-support'; @@ -48,19 +49,21 @@ module('Integration | Component | pki-role-form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.issuerRefToggle).exists('shows issuer ref toggle'); - assert.dom(SELECTORS.backdateValidity).exists('shows form-field backdate validity'); - assert.dom(SELECTORS.customTtl).exists('shows custom yielded form field'); - assert.dom(SELECTORS.maxTtl).exists('shows form-field max ttl'); - assert.dom(SELECTORS.generateLease).exists('shows form-field generateLease'); - assert.dom(SELECTORS.noStore).exists('shows form-field no store'); - assert.dom(SELECTORS.addBasicConstraints).exists('shows form-field add basic constraints'); - assert.dom(SELECTORS.domainHandling).exists('shows form-field group add domain handling'); - assert.dom(SELECTORS.keyParams).exists('shows form-field group key params'); - assert.dom(SELECTORS.keyUsage).exists('shows form-field group key usage'); - assert.dom(SELECTORS.policyIdentifiers).exists('shows form-field group policy identifiers'); - assert.dom(SELECTORS.san).exists('shows form-field group SAN'); - assert.dom(SELECTORS.additionalSubjectFields).exists('shows form-field group additional subject fields'); + assert.dom(GENERAL.ttl.toggle('issuerRef-toggle')).exists(); + assert.dom(GENERAL.ttl.input('Backdate validity')).exists(); + assert.dom(GENERAL.fieldByAttr('customTtl')).exists(); + assert.dom(GENERAL.ttl.toggle('Max TTL')).exists(); + assert.dom(GENERAL.fieldByAttr('generateLease')).exists(); + assert.dom(GENERAL.fieldByAttr('noStore')).exists(); + assert.dom(GENERAL.inputByAttr('addBasicConstraints')).exists(); + assert.dom(PKI_ROLE_FORM.domainHandling).exists('shows form-field group add domain handling'); + assert.dom(PKI_ROLE_FORM.keyParams).exists('shows form-field group key params'); + assert.dom(PKI_ROLE_FORM.keyUsage).exists('shows form-field group key usage'); + assert.dom(PKI_ROLE_FORM.policyIdentifiers).exists('shows form-field group policy identifiers'); + assert.dom(PKI_ROLE_FORM.san).exists('shows form-field group SAN'); + assert + .dom(PKI_ROLE_FORM.additionalSubjectFields) + .exists('shows form-field group additional subject fields'); }); test('it should save a new pki role with various options selected', async function (assert) { @@ -99,30 +102,30 @@ module('Integration | Component | pki-role-form', function (hooks) { { owner: this.engine } ); - await click(SELECTORS.roleCreateButton); + await click(GENERAL.saveButton); assert - .dom(SELECTORS.roleName) + .dom(GENERAL.inputByAttr('name')) .hasClass('has-error-border', 'shows border error on role name field when no role name is submitted'); assert .dom('[data-test-inline-error-message]') .includesText('Name is required.', 'show correct error message'); - await fillIn(SELECTORS.roleName, 'test-role'); + await fillIn(GENERAL.inputByAttr('name'), 'test-role'); await click('[data-test-input="addBasicConstraints"]'); - await click(SELECTORS.domainHandling); + await click(PKI_ROLE_FORM.domainHandling); await click('[data-test-input="allowedDomainsTemplate"]'); - await click(SELECTORS.policyIdentifiers); + await click(PKI_ROLE_FORM.policyIdentifiers); await fillIn('[data-test-input="policyIdentifiers"] [data-test-string-list-input="0"]', 'some-oid'); - await click(SELECTORS.san); + await click(PKI_ROLE_FORM.san); await click('[data-test-input="allowUriSansTemplate"]'); - await click(SELECTORS.additionalSubjectFields); + await click(PKI_ROLE_FORM.additionalSubjectFields); await fillIn( '[data-test-input="allowedSerialNumbers"] [data-test-string-list-input="0"]', 'some-serial-number' ); - await click(SELECTORS.roleCreateButton); + await click(GENERAL.saveButton); }); test('it should update attributes on the model on update', async function (assert) { @@ -148,9 +151,9 @@ module('Integration | Component | pki-role-form', function (hooks) { `, { owner: this.engine } ); - await click(SELECTORS.issuerRefToggle); - await fillIn(SELECTORS.issuerRefSelect, 'issuer-1'); - await click(SELECTORS.roleCreateButton); + await click(GENERAL.ttl.toggle('issuerRef-toggle')); + await fillIn(GENERAL.selectByAttr('issuerRef'), 'issuer-1'); + await click(GENERAL.saveButton); assert.strictEqual(this.role.issuerRef, 'issuer-1', 'Issuer Ref correctly saved on create'); }); @@ -202,21 +205,29 @@ module('Integration | Component | pki-role-form', function (hooks) { { owner: this.engine } ); - await click(SELECTORS.issuerRefToggle); - await fillIn(SELECTORS.issuerRefSelect, 'issuer-1'); + await click(GENERAL.ttl.toggle('issuerRef-toggle')); + await fillIn(GENERAL.selectByAttr('issuerRef'), 'issuer-1'); - await click(SELECTORS.keyParams); - assert.dom(SELECTORS.keyType).hasValue('rsa'); - assert.dom(SELECTORS.keyBits).hasValue('3072', 'dropdown has model value, not default value (2048)'); - assert.dom(SELECTORS.signatureBits).hasValue('512', 'dropdown has model value, not default value (0)'); + await click(PKI_ROLE_FORM.keyParams); + assert.dom(GENERAL.inputByAttr('keyType')).hasValue('rsa'); + assert + .dom(GENERAL.inputByAttr('keyBits')) + .hasValue('3072', 'dropdown has model value, not default value (2048)'); + assert + .dom(GENERAL.inputByAttr('signatureBits')) + .hasValue('512', 'dropdown has model value, not default value (0)'); - await fillIn(SELECTORS.keyType, 'ec'); - await fillIn(SELECTORS.keyBits, '224'); - assert.dom(SELECTORS.keyBits).hasValue('224', 'dropdown has selected value, not default value (256)'); - await fillIn(SELECTORS.signatureBits, '384'); - assert.dom(SELECTORS.signatureBits).hasValue('384', 'dropdown has selected value, not default value (0)'); + await fillIn(GENERAL.inputByAttr('keyType'), 'ec'); + await fillIn(GENERAL.inputByAttr('keyBits'), '224'); + assert + .dom(GENERAL.inputByAttr('keyBits')) + .hasValue('224', 'dropdown has selected value, not default value (256)'); + await fillIn(GENERAL.inputByAttr('signatureBits'), '384'); + assert + .dom(GENERAL.inputByAttr('signatureBits')) + .hasValue('384', 'dropdown has selected value, not default value (0)'); - await click(SELECTORS.roleCreateButton); + await click(GENERAL.saveButton); assert.strictEqual(this.role.issuerRef, 'issuer-1', 'Issuer Ref correctly saved on create'); }); }); diff --git a/ui/tests/integration/components/pki/pki-role-generate-test.js b/ui/tests/integration/components/pki/pki-role-generate-test.js index 1eab0863dc1a..a5d4fbc2874f 100644 --- a/ui/tests/integration/components/pki/pki-role-generate-test.js +++ b/ui/tests/integration/components/pki/pki-role-generate-test.js @@ -10,7 +10,8 @@ import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupEngine } from 'ember-engines/test-support'; import Sinon from 'sinon'; -import { SELECTORS } from 'vault/tests/helpers/pki/pki-role-generate'; +import { GENERAL } from 'vault/tests/helpers/general-selectors'; +import { PKI_ROLE_GENERATE } from 'vault/tests/helpers/pki/pki-selectors'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; module('Integration | Component | pki-role-generate', function (hooks) { @@ -42,10 +43,10 @@ module('Integration | Component | pki-role-generate', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.form).exists('shows the cert generate form'); - assert.dom(SELECTORS.commonNameField).exists('shows the common name field'); - assert.dom(SELECTORS.optionsToggle).exists('toggle exists'); - await fillIn(SELECTORS.commonNameField, 'example.com'); + assert.dom(PKI_ROLE_GENERATE.form).exists('shows the cert generate form'); + assert.dom(GENERAL.inputByAttr('commonName')).exists('shows the common name field'); + assert.dom(PKI_ROLE_GENERATE.optionsToggle).exists('toggle exists'); + await fillIn(GENERAL.inputByAttr('commonName'), 'example.com'); assert.strictEqual(this.model.commonName, 'example.com', 'Filling in the form updates the model'); }); @@ -68,10 +69,12 @@ module('Integration | Component | pki-role-generate', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.form).doesNotExist('Does not show the form'); - assert.dom(SELECTORS.downloadButton).exists('shows the download button'); - assert.dom(SELECTORS.revokeButton).exists('shows the revoke button'); - assert.dom(SELECTORS.certificate).exists({ count: 1 }, 'shows certificate info row'); - assert.dom(SELECTORS.serialNumber).hasText('abcd-efgh-ijkl', 'shows serial number info row'); + assert.dom(PKI_ROLE_GENERATE.form).doesNotExist('Does not show the form'); + assert.dom(PKI_ROLE_GENERATE.downloadButton).exists('shows the download button'); + assert.dom(PKI_ROLE_GENERATE.revokeButton).exists('shows the revoke button'); + assert.dom(GENERAL.infoRowValue('Certificate')).exists({ count: 1 }, 'shows certificate info row'); + assert + .dom(GENERAL.infoRowValue('Serial number')) + .hasText('abcd-efgh-ijkl', 'shows serial number info row'); }); }); diff --git a/ui/tests/integration/components/pki/pki-tidy-form-test.js b/ui/tests/integration/components/pki/pki-tidy-form-test.js index 1c7d6800f699..929a506c76c4 100644 --- a/ui/tests/integration/components/pki/pki-tidy-form-test.js +++ b/ui/tests/integration/components/pki/pki-tidy-form-test.js @@ -9,7 +9,7 @@ import { click, render, fillIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupEngine } from 'ember-engines/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-tidy-form'; +import { PKI_TIDY_FORM } from 'vault/tests/helpers/pki/pki-selectors'; module('Integration | Component | pki tidy form', function (hooks) { setupRenderingTest(hooks); @@ -51,31 +51,33 @@ module('Integration | Component | pki tidy form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.toggleInput('intervalDuration')).isNotChecked('Automatic tidy is disabled'); + assert.dom(PKI_TIDY_FORM.toggleInput('intervalDuration')).isNotChecked('Automatic tidy is disabled'); assert.dom(`[data-test-ttl-form-label="Automatic tidy disabled"]`).exists('renders disabled label text'); this.autoTidy.eachAttribute((attr) => { if (attr === 'enabled' || attr === 'intervalDuration') return; - assert.dom(SELECTORS.inputByAttr(attr)).doesNotExist(`does not render ${attr} when auto tidy disabled`); + assert + .dom(PKI_TIDY_FORM.inputByAttr(attr)) + .doesNotExist(`does not render ${attr} when auto tidy disabled`); }); sectionHeaders.forEach((group) => { - assert.dom(SELECTORS.tidySectionHeader(group)).doesNotExist(`does not render ${group} header`); + assert.dom(PKI_TIDY_FORM.tidySectionHeader(group)).doesNotExist(`does not render ${group} header`); }); // ENABLE AUTO TIDY - await click(SELECTORS.toggleInput('intervalDuration')); - assert.dom(SELECTORS.toggleInput('intervalDuration')).isChecked('Automatic tidy is enabled'); + await click(PKI_TIDY_FORM.toggleInput('intervalDuration')); + assert.dom(PKI_TIDY_FORM.toggleInput('intervalDuration')).isChecked('Automatic tidy is enabled'); assert.dom(`[data-test-ttl-form-label="Automatic tidy enabled"]`).exists('renders enabled text'); this.autoTidy.eachAttribute((attr) => { const skipFields = ['enabled', 'tidyAcme', 'intervalDuration']; if (skipFields.includes(attr)) return; // combined with duration ttl or asserted elsewhere - assert.dom(SELECTORS.inputByAttr(attr)).exists(`renders ${attr} when auto tidy enabled`); + assert.dom(PKI_TIDY_FORM.inputByAttr(attr)).exists(`renders ${attr} when auto tidy enabled`); }); sectionHeaders.forEach((group) => { - assert.dom(SELECTORS.tidySectionHeader(group)).exists(`renders ${group} header`); + assert.dom(PKI_TIDY_FORM.tidySectionHeader(group)).exists(`renders ${group} header`); }); }); @@ -97,7 +99,7 @@ module('Integration | Component | pki tidy form', function (hooks) { this.autoTidy.eachAttribute((attr) => { if (skipFields.includes(attr)) return; - assert.dom(SELECTORS.inputByAttr(attr)).exists(`renders ${attr} for auto tidyType`); + assert.dom(PKI_TIDY_FORM.inputByAttr(attr)).exists(`renders ${attr} for auto tidyType`); }); await render( @@ -111,11 +113,11 @@ module('Integration | Component | pki tidy form', function (hooks) { `, { owner: this.engine } ); - assert.dom(SELECTORS.toggleInput('intervalDuration')).doesNotExist('hides automatic tidy toggle'); + assert.dom(PKI_TIDY_FORM.toggleInput('intervalDuration')).doesNotExist('hides automatic tidy toggle'); this.manualTidy.eachAttribute((attr) => { if (skipFields.includes(attr)) return; - assert.dom(SELECTORS.inputByAttr(attr)).exists(`renders ${attr} for manual tidyType`); + assert.dom(PKI_TIDY_FORM.inputByAttr(attr)).exists(`renders ${attr} for manual tidyType`); }); }); @@ -144,11 +146,13 @@ module('Integration | Component | pki tidy form', function (hooks) { ); assert - .dom(SELECTORS.tidySectionHeader('Cross-cluster operations')) + .dom(PKI_TIDY_FORM.tidySectionHeader('Cross-cluster operations')) .doesNotExist(`does not render ent header`); enterpriseFields.forEach((entAttr) => { - assert.dom(SELECTORS.inputByAttr(entAttr)).doesNotExist(`does not render ${entAttr} for auto tidyType`); + assert + .dom(PKI_TIDY_FORM.inputByAttr(entAttr)) + .doesNotExist(`does not render ${entAttr} for auto tidyType`); }); // tidyType = manual @@ -166,7 +170,7 @@ module('Integration | Component | pki tidy form', function (hooks) { enterpriseFields.forEach((entAttr) => { assert - .dom(SELECTORS.inputByAttr(entAttr)) + .dom(PKI_TIDY_FORM.inputByAttr(entAttr)) .doesNotExist(`does not render ${entAttr} for manual tidyType`); }); }); @@ -208,23 +212,25 @@ module('Integration | Component | pki tidy form', function (hooks) { { owner: this.engine } ); - assert.dom(SELECTORS.toggleInput('intervalDuration')).isNotChecked('Automatic tidy is disabled'); - assert.dom(SELECTORS.toggleLabel('Automatic tidy disabled')).exists('auto tidy has disabled label'); + assert.dom(PKI_TIDY_FORM.toggleInput('intervalDuration')).isNotChecked('Automatic tidy is disabled'); + assert.dom(PKI_TIDY_FORM.toggleLabel('Automatic tidy disabled')).exists('auto tidy has disabled label'); assert.false(this.autoTidy.enabled, 'enabled is false on model'); // enable auto-tidy - await click(SELECTORS.toggleInput('intervalDuration')); - await fillIn(SELECTORS.intervalDuration, 10); + await click(PKI_TIDY_FORM.toggleInput('intervalDuration')); + await fillIn(PKI_TIDY_FORM.intervalDuration, 10); - assert.dom(SELECTORS.toggleInput('intervalDuration')).isChecked('toggle enabled auto tidy'); - assert.dom(SELECTORS.toggleLabel('Automatic tidy enabled')).exists('auto tidy has enabled label'); + assert.dom(PKI_TIDY_FORM.toggleInput('intervalDuration')).isChecked('toggle enabled auto tidy'); + assert.dom(PKI_TIDY_FORM.toggleLabel('Automatic tidy enabled')).exists('auto tidy has enabled label'); - assert.dom(SELECTORS.toggleInput('acmeAccountSafetyBuffer')).isNotChecked('ACME tidy is disabled'); - assert.dom(SELECTORS.toggleLabel('Tidy ACME disabled')).exists('ACME label has correct disabled text'); + assert.dom(PKI_TIDY_FORM.toggleInput('acmeAccountSafetyBuffer')).isNotChecked('ACME tidy is disabled'); + assert + .dom(PKI_TIDY_FORM.toggleLabel('Tidy ACME disabled')) + .exists('ACME label has correct disabled text'); assert.false(this.autoTidy.tidyAcme, 'tidyAcme is false on model'); - await click(SELECTORS.toggleInput('acmeAccountSafetyBuffer')); - await fillIn(SELECTORS.acmeAccountSafetyBuffer, 60); + await click(PKI_TIDY_FORM.toggleInput('acmeAccountSafetyBuffer')); + await fillIn(PKI_TIDY_FORM.acmeAccountSafetyBuffer, 60); assert.true(this.autoTidy.tidyAcme, 'tidyAcme toggles to true'); const fillInValues = { @@ -237,16 +243,16 @@ module('Integration | Component | pki tidy form', function (hooks) { const skipFields = ['enabled', 'tidyAcme', 'intervalDuration', 'acmeAccountSafetyBuffer']; // combined with duration ttl or asserted separately if (skipFields.includes(attr)) return; if (type === 'boolean') { - await click(SELECTORS.inputByAttr(attr)); + await click(PKI_TIDY_FORM.inputByAttr(attr)); } if (type === 'string') { - await fillIn(SELECTORS.toggleInput(attr), `${fillInValues[attr]}`); + await fillIn(PKI_TIDY_FORM.toggleInput(attr), `${fillInValues[attr]}`); } }); - assert.dom(SELECTORS.toggleInput('acmeAccountSafetyBuffer')).isChecked('ACME tidy is enabled'); - assert.dom(SELECTORS.toggleLabel('Tidy ACME enabled')).exists('ACME label has correct enabled text'); - await click(SELECTORS.tidySave); + assert.dom(PKI_TIDY_FORM.toggleInput('acmeAccountSafetyBuffer')).isChecked('ACME tidy is enabled'); + assert.dom(PKI_TIDY_FORM.toggleLabel('Tidy ACME enabled')).exists('ACME label has correct enabled text'); + await click(PKI_TIDY_FORM.tidySave); }); test('it updates auto-tidy config', async function (assert) { @@ -277,8 +283,8 @@ module('Integration | Component | pki tidy form', function (hooks) { { owner: this.engine } ); - await click(SELECTORS.tidySave); - await click(SELECTORS.tidyCancel); + await click(PKI_TIDY_FORM.tidySave); + await click(PKI_TIDY_FORM.tidyCancel); }); test('it saves and performs manual tidy', async function (assert) { @@ -308,7 +314,7 @@ module('Integration | Component | pki tidy form', function (hooks) { { owner: this.engine } ); - await click(SELECTORS.tidySave); - await click(SELECTORS.tidyCancel); + await click(PKI_TIDY_FORM.tidySave); + await click(PKI_TIDY_FORM.tidyCancel); }); }); diff --git a/ui/tests/integration/components/secret-edit-test.js b/ui/tests/integration/components/secret-edit-test.js index 88136b5ca6e7..17ceef4879ad 100644 --- a/ui/tests/integration/components/secret-edit-test.js +++ b/ui/tests/integration/components/secret-edit-test.js @@ -10,6 +10,7 @@ import { resolve } from 'rsvp'; import { run } from '@ember/runloop'; import Service from '@ember/service'; import hbs from 'htmlbars-inline-precompile'; +import codemirror from 'vault/tests/helpers/codemirror'; let capabilities; const storeService = Service.extend({ @@ -22,7 +23,6 @@ module('Integration | Component | secret edit', function (hooks) { hooks.beforeEach(function () { capabilities = null; - this.codeMirror = this.owner.lookup('service:code-mirror'); this.set('key', { id: 'Foobar' }); run(() => { this.owner.unregister('service:store'); @@ -40,7 +40,7 @@ module('Integration | Component | secret edit', function (hooks) { }, }); - await render(hbs`{{secret-edit mode=this.mode model=this.model key=this.key }}`); + await render(hbs``); assert.dom('[data-test-toggle-input="json"]').isDisabled(); }); @@ -54,7 +54,7 @@ module('Integration | Component | secret edit', function (hooks) { }, }); - await render(hbs`{{secret-edit mode=this.mode model=this.model key=this.key }}`); + await render(hbs``); assert.dom('[data-test-toggle-input="json"]').isNotDisabled(); }); @@ -64,10 +64,11 @@ module('Integration | Component | secret edit', function (hooks) { secretData: null, }); - await render(hbs`{{secret-edit mode=this.mode model=this.model preferAdvancedEdit=true key=this.key }}`); + await render( + hbs`` + ); - const instance = document.querySelector('.CodeMirror').CodeMirror; - instance.setValue(JSON.stringify([{ foo: 'bar' }])); + codemirror().setValue(JSON.stringify([{ foo: 'bar' }])); await settled(); assert .dom('[data-test-message-error]') @@ -84,7 +85,7 @@ module('Integration | Component | secret edit', function (hooks) { float: '1.234', }, }); - await render(hbs``); + await render(hbs``); assert.dom('[data-test-secret-save]').isNotDisabled(); }); @@ -102,10 +103,11 @@ module('Integration | Component | secret edit', function (hooks) { canReadSecretData: true, }); - await render(hbs`{{secret-edit mode=this.mode model=this.model preferAdvancedEdit=true key=this.key }}`); + await render( + hbs`` + ); - const instance = document.querySelector('.CodeMirror').CodeMirror; - instance.setValue(JSON.stringify([{ foo: 'bar' }])); + codemirror().setValue(JSON.stringify([{ foo: 'bar' }])); await settled(); assert .dom('[data-test-message-error]') diff --git a/ui/tests/integration/components/secret-list-header-test.js b/ui/tests/integration/components/secret-list-header-test.js index da4340a3b051..b78fd2890b52 100644 --- a/ui/tests/integration/components/secret-list-header-test.js +++ b/ui/tests/integration/components/secret-list-header-test.js @@ -5,11 +5,21 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { getContext, render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import mirageToModels from 'vault/tests/helpers/mirage-to-models'; + +const mirageToModels = (data) => { + const context = getContext(); + const store = context.owner.lookup('service:store'); + const modelName = Array.isArray(data) ? data[0].modelName : data.modelName; + const json = context.server.serializerOrRegistry.serialize(data); + store.push(json); + return Array.isArray(data) + ? data.map(({ id }) => store.peekRecord(modelName, id)) + : store.peekRecord(modelName, data.id); +}; module('Integration | Component | secret-list-header', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/shamir/flow-test.js b/ui/tests/integration/components/shamir/flow-test.js index c29d4a401a08..adc609e2a9fd 100644 --- a/ui/tests/integration/components/shamir/flow-test.js +++ b/ui/tests/integration/components/shamir/flow-test.js @@ -11,7 +11,7 @@ import { hbs } from 'ember-cli-htmlbars'; import Service from '@ember/service'; import { run } from '@ember/runloop'; import { reject, resolve } from 'rsvp'; -import { SHAMIR_FORM } from 'vault/tests/helpers/components/shamir'; +import { SHAMIR_FORM } from 'vault/tests/helpers/components/shamir-selectors'; const licenseError = { httpStatus: 500, errors: ['failed because licensing is in an invalid state'] }; const response = { diff --git a/ui/tests/integration/components/shamir/form-test.js b/ui/tests/integration/components/shamir/form-test.js index a4886af38f31..e3234156ca33 100644 --- a/ui/tests/integration/components/shamir/form-test.js +++ b/ui/tests/integration/components/shamir/form-test.js @@ -8,7 +8,7 @@ import sinon from 'sinon'; import { setupRenderingTest } from 'vault/tests/helpers'; import { click, render, settled, typeIn } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import { SHAMIR_FORM } from 'vault/tests/helpers/components/shamir'; +import { SHAMIR_FORM } from 'vault/tests/helpers/components/shamir-selectors'; module('Integration | Component | shamir/form', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/text-file-test.js b/ui/tests/integration/components/text-file-test.js index b857d3beb95e..d46d65b03122 100644 --- a/ui/tests/integration/components/text-file-test.js +++ b/ui/tests/integration/components/text-file-test.js @@ -8,8 +8,8 @@ import { setupRenderingTest } from 'vault/tests/helpers'; import { click, fillIn, render, triggerEvent } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import sinon from 'sinon'; -import { componentPemBundle } from 'vault/tests/helpers/pki/values'; import { setRunOptions } from 'ember-a11y-testing/test-support'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; const SELECTORS = { label: '[data-test-text-file-label]', @@ -17,6 +17,7 @@ const SELECTORS = { textarea: '[data-test-text-file-textarea]', fileUpload: '[data-test-text-file-input]', }; +const { componentPemBundle } = CERTIFICATES; module('Integration | Component | text-file', function (hooks) { setupRenderingTest(hooks); diff --git a/ui/tests/integration/components/transit-key-actions-test.js b/ui/tests/integration/components/transit-key-actions-test.js index 544f22f85608..c4cfc92b5b4b 100644 --- a/ui/tests/integration/components/transit-key-actions-test.js +++ b/ui/tests/integration/components/transit-key-actions-test.js @@ -8,10 +8,11 @@ import { resolve } from 'rsvp'; import Service from '@ember/service'; import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render, click, find, findAll, fillIn, blur, triggerEvent } from '@ember/test-helpers'; +import { render, click, find, fillIn, blur, triggerEvent } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { encodeString } from 'vault/utils/b64'; import waitForError from 'vault/tests/helpers/wait-for-error'; +import codemirror from 'vault/tests/helpers/codemirror'; const storeStub = Service.extend({ callArgs: null, @@ -104,7 +105,7 @@ module('Integration | Component | transit key actions', function (hooks) { await render(hbs` `); - find('#plaintext-control .CodeMirror').CodeMirror.setValue('plaintext'); + codemirror('#plaintext-control').setValue('plaintext'); await click('button[type="submit"]'); assert.deepEqual( this.storeService.callArgs, @@ -125,7 +126,7 @@ module('Integration | Component | transit key actions', function (hooks) { await click('dialog button'); // Encrypt again, with pre-encoded value and checkbox selected const preEncodedValue = encodeString('plaintext'); - find('#plaintext-control .CodeMirror').CodeMirror.setValue(preEncodedValue); + codemirror('#plaintext-control').setValue(preEncodedValue); await click('input[data-test-transit-input="encodedBase64"]'); await click('button[type="submit"]'); @@ -154,7 +155,7 @@ module('Integration | Component | transit key actions', function (hooks) { await render(hbs` `); - findAll('.CodeMirror')[0].CodeMirror.setValue('plaintext'); + codemirror().setValue('plaintext'); assert.dom('#key_version').exists({ count: 1 }, 'it renders the key version selector'); await triggerEvent('#key_version', 'change'); @@ -183,8 +184,7 @@ module('Integration | Component | transit key actions', function (hooks) { await render(hbs` `); - // await fillIn('#plaintext', 'plaintext'); - find('#plaintext-control .CodeMirror').CodeMirror.setValue('plaintext'); + codemirror('#plaintext-control').setValue('plaintext'); assert.dom('#key_version').doesNotExist('it does not render the selector when there is only one key'); }); @@ -195,11 +195,7 @@ module('Integration | Component | transit key actions', function (hooks) { this.set('storeService.keyActionReturnVal', { plaintext }); this.set('selectedAction', 'decrypt'); - assert.strictEqual( - find('#ciphertext-control .CodeMirror').CodeMirror.getValue(), - '', - 'does not prefill ciphertext value' - ); + assert.strictEqual(codemirror('#ciphertext-control').getValue(), '', 'does not prefill ciphertext value'); }); const setupExport = async function () { diff --git a/ui/tests/integration/components/ttl-picker-test.js b/ui/tests/integration/components/ttl-picker-test.js index fab1872b5d40..1719ada00334 100644 --- a/ui/tests/integration/components/ttl-picker-test.js +++ b/ui/tests/integration/components/ttl-picker-test.js @@ -8,7 +8,7 @@ import { setupRenderingTest } from 'ember-qunit'; import { render, click, fillIn } from '@ember/test-helpers'; import sinon from 'sinon'; import hbs from 'htmlbars-inline-precompile'; -import selectors from 'vault/tests/helpers/components/ttl-picker'; +import { TTL_PICKER } from 'vault/tests/helpers/components/ttl-picker-selectors'; import { setRunOptions } from 'ember-a11y-testing/test-support'; module('Integration | Component | ttl-picker', function (hooks) { @@ -29,9 +29,9 @@ module('Integration | Component | ttl-picker', function (hooks) { @label={{this.label}} @hideToggle={{this.hideToggle}} @onChange={{this.onChange}} />`); - assert.dom(selectors.ttlFormGroup).exists('TTL Form fields exist'); - assert.dom(selectors.ttlValue).hasValue(''); - assert.dom(selectors.ttlUnit).hasValue('s'); + assert.dom(TTL_PICKER.ttlFormGroup).exists('TTL Form fields exist'); + assert.dom(TTL_PICKER.ttlValue).hasValue(''); + assert.dom(TTL_PICKER.ttlUnit).hasValue('s'); }); test('it calls the change fn with the correct values', async function (assert) { @@ -44,8 +44,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @onChange={{this.onChange}} @initialValue="30m" /> `); - assert.dom(selectors.ttlUnit).hasValue('m', 'unit value shows m (minutes)'); - await fillIn(selectors.ttlValue, '10'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'unit value shows m (minutes)'); + await fillIn(TTL_PICKER.ttlValue, '10'); await assert.ok(changeSpy.calledOnce, 'it calls the passed onChange'); assert.ok( changeSpy.calledWithExactly({ @@ -68,8 +68,8 @@ module('Integration | Component | ttl-picker', function (hooks) { /> `); - assert.dom(selectors.ttlUnit).hasValue('h', 'unit value initially shows as h (hours)'); - assert.dom(selectors.ttlValue).hasValue('3', 'time value initially shows as 3'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('h', 'unit value initially shows as h (hours)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('3', 'time value initially shows as 3'); }); test('it fails gracefully when initialValue is not parseable', async function (assert) { @@ -85,8 +85,8 @@ module('Integration | Component | ttl-picker', function (hooks) { /> `); - assert.dom(selectors.ttlValue).hasValue('', 'time value initially shows as empty'); - assert.dom(selectors.ttlUnit).hasValue('s', 'unit value initially shows as s (seconds)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('', 'time value initially shows as empty'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('s', 'unit value initially shows as s (seconds)'); assert.ok(changeSpy.notCalled, 'onChange is not called on init'); }); @@ -102,11 +102,11 @@ module('Integration | Component | ttl-picker', function (hooks) { /> `); - assert.dom(selectors.ttlUnit).hasValue('h', 'unit value initially shows as h (hours)'); - assert.dom(selectors.ttlValue).hasValue('1', 'time value initially shows as 1'); - await fillIn(selectors.ttlUnit, 'm'); - assert.dom(selectors.ttlUnit).hasValue('m', 'unit value changed to m (minutes)'); - assert.dom(selectors.ttlValue).hasValue('60', 'time value recalculates to fit unit'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('h', 'unit value initially shows as h (hours)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('1', 'time value initially shows as 1'); + await fillIn(TTL_PICKER.ttlUnit, 'm'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'unit value changed to m (minutes)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('60', 'time value recalculates to fit unit'); assert.ok( changeSpy.calledWithExactly({ enabled: true, @@ -130,11 +130,11 @@ module('Integration | Component | ttl-picker', function (hooks) { /> `); - assert.dom(selectors.ttlUnit).hasValue('s', 'unit value starts as s (seconds)'); - assert.dom(selectors.ttlValue).hasValue('30', 'time value starts as 30'); - await fillIn(selectors.ttlUnit, 'm'); - assert.dom(selectors.ttlUnit).hasValue('m', 'unit value changed to m (minutes)'); - assert.dom(selectors.ttlValue).hasValue('30', 'time value is still 30'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('s', 'unit value starts as s (seconds)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('30', 'time value starts as 30'); + await fillIn(TTL_PICKER.ttlUnit, 'm'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'unit value changed to m (minutes)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('30', 'time value is still 30'); assert.ok( changeSpy.calledWithExactly({ enabled: true, @@ -238,8 +238,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @onChange={{this.onChange}} /> `); - assert.dom(selectors.toggle).isNotChecked('Toggle is unchecked by default'); - assert.dom(selectors.ttlFormGroup).doesNotExist('TTL Form is not rendered'); + assert.dom(TTL_PICKER.toggle).isNotChecked('Toggle is unchecked by default'); + assert.dom(TTL_PICKER.ttlFormGroup).doesNotExist('TTL Form is not rendered'); }); test('it shows time and unit inputs when initialEnabled', async function (assert) { @@ -253,8 +253,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @changeOnInit={{true}} /> `); - assert.dom(selectors.toggle).isChecked('Toggle is checked when initialEnabled is true'); - assert.dom(selectors.ttlFormGroup).exists('TTL Form is rendered'); + assert.dom(TTL_PICKER.toggle).isChecked('Toggle is checked when initialEnabled is true'); + assert.dom(TTL_PICKER.ttlFormGroup).exists('TTL Form is rendered'); assert.ok(changeSpy.notCalled, 'onChange not called because initialValue not parsed'); }); @@ -267,8 +267,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialEnabled={{true}} /> `); - assert.dom(selectors.ttlValue).hasValue('2', 'time value is 2'); - assert.dom(selectors.ttlUnit).hasValue('h', 'unit is hours'); + assert.dom(TTL_PICKER.ttlValue).hasValue('2', 'time value is 2'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('h', 'unit is hours'); assert.ok( this.onChange.notCalled, 'it does not call onChange after render when changeOnInit is not set' @@ -284,7 +284,7 @@ module('Integration | Component | ttl-picker', function (hooks) { @onChange={{this.onChange}} /> `); - await click(selectors.toggle); + await click(TTL_PICKER.toggle); assert.ok(changeSpy.calledOnce, 'it calls the passed onChange'); assert.ok( changeSpy.calledWith({ @@ -304,11 +304,11 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialValue="100m" /> `); - assert.dom(selectors.toggle).isNotChecked('Toggle is off'); - assert.dom(selectors.ttlFormGroup).doesNotExist('TTL Form not shown on mount'); - await click(selectors.toggle); - assert.dom(selectors.ttlValue).hasValue('100', 'time after toggle is 100'); - assert.dom(selectors.ttlUnit).hasValue('m', 'Unit is minutes after toggle'); + assert.dom(TTL_PICKER.toggle).isNotChecked('Toggle is off'); + assert.dom(TTL_PICKER.ttlFormGroup).doesNotExist('TTL Form not shown on mount'); + await click(TTL_PICKER.toggle); + assert.dom(TTL_PICKER.ttlValue).hasValue('100', 'time after toggle is 100'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'Unit is minutes after toggle'); }); test('it is enabled on init if initialEnabled is true', async function (assert) { @@ -319,13 +319,13 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialEnabled={{true}} /> `); - assert.dom(selectors.toggle).isChecked('Toggle is on'); - assert.dom(selectors.ttlFormGroup).exists(); - assert.dom(selectors.ttlValue).hasValue('100', 'time is shown on mount'); - assert.dom(selectors.ttlUnit).hasValue('m', 'Unit is shown on mount'); - await click(selectors.toggle); - assert.dom(selectors.toggle).isNotChecked('Toggle is off'); - assert.dom(selectors.ttlFormGroup).doesNotExist('TTL Form no longer shows after toggle'); + assert.dom(TTL_PICKER.toggle).isChecked('Toggle is on'); + assert.dom(TTL_PICKER.ttlFormGroup).exists(); + assert.dom(TTL_PICKER.ttlValue).hasValue('100', 'time is shown on mount'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'Unit is shown on mount'); + await click(TTL_PICKER.toggle); + assert.dom(TTL_PICKER.toggle).isNotChecked('Toggle is off'); + assert.dom(TTL_PICKER.ttlFormGroup).doesNotExist('TTL Form no longer shows after toggle'); }); test('it is enabled on init if initialEnabled evals to truthy', async function (assert) { @@ -336,9 +336,9 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialEnabled="100m" /> `); - assert.dom(selectors.toggle).isChecked('Toggle is enabled'); - assert.dom(selectors.ttlValue).hasValue('100', 'time value is shown on mount'); - assert.dom(selectors.ttlUnit).hasValue('m', 'Unit matches what is passed in'); + assert.dom(TTL_PICKER.toggle).isChecked('Toggle is enabled'); + assert.dom(TTL_PICKER.ttlValue).hasValue('100', 'time value is shown on mount'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'Unit matches what is passed in'); }); test('it converts days to go safe time', async function (assert) { @@ -348,7 +348,7 @@ module('Integration | Component | ttl-picker', function (hooks) { @onChange={{this.onChange}} /> `); - await click(selectors.toggle); + await click(TTL_PICKER.toggle); assert.ok(this.onChange.calledOnce, 'it calls the passed onChange'); assert.ok( this.onChange.calledWith({ @@ -369,8 +369,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialEnabled="true" /> `); - assert.dom(selectors.ttlValue).hasValue('1000', 'time value is converted'); - assert.dom(selectors.ttlUnit).hasValue('m', 'unit value is m (minutes)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('1000', 'time value is converted'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('m', 'unit value is m (minutes)'); }); test('it converts to the largest round unit on init when no unit provided', async function (assert) { @@ -381,8 +381,8 @@ module('Integration | Component | ttl-picker', function (hooks) { @initialEnabled="true" /> `); - assert.dom(selectors.ttlValue).hasValue('1', 'time value is converted'); - assert.dom(selectors.ttlUnit).hasValue('d', 'unit value is d (days)'); + assert.dom(TTL_PICKER.ttlValue).hasValue('1', 'time value is converted'); + assert.dom(TTL_PICKER.ttlUnit).hasValue('d', 'unit value is d (days)'); }); }); }); diff --git a/ui/tests/integration/utils/client-count-utils-test.js b/ui/tests/integration/utils/client-count-utils-test.js index 710adddb24d5..f9c1c256e05f 100644 --- a/ui/tests/integration/utils/client-count-utils-test.js +++ b/ui/tests/integration/utils/client-count-utils-test.js @@ -19,12 +19,12 @@ import { MIXED_ACTIVITY_RESPONSE_STUB as MIXED_RESPONSE, VERSION_HISTORY, SERIALIZED_ACTIVITY_RESPONSE, -} from 'vault/tests/helpers/clients'; +} from 'vault/tests/helpers/clients/client-count-helpers'; /* -formatByNamespace, formatByMonths, destructureClientCounts are utils -used to normalize the sys/counters/activity response in the clients/activity -serializer. these functions are tested individually here, instead of all at once +formatByNamespace, formatByMonths, destructureClientCounts are utils +used to normalize the sys/counters/activity response in the clients/activity +serializer. these functions are tested individually here, instead of all at once in a serializer test for easier debugging */ module('Integration | Util | client count utils', function (hooks) { diff --git a/ui/tests/integration/utils/parse-pki-cert-test.js b/ui/tests/integration/utils/parse-pki-cert-test.js index 4b31833da475..8329cdc72505 100644 --- a/ui/tests/integration/utils/parse-pki-cert-test.js +++ b/ui/tests/integration/utils/parse-pki-cert-test.js @@ -12,7 +12,10 @@ import { Certificate } from 'pkijs'; import { addHours, fromUnixTime, isSameDay } from 'date-fns'; import errorMessage from 'vault/utils/error-message'; import { OTHER_OIDs, SAN_TYPES } from 'vault/utils/parse-pki-cert-oids'; -import { +import { verifyCertificates, jsonToCertObject, verifySignature } from 'vault/utils/parse-pki-cert'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; + +const { certWithoutCN, loadedCert, pssTrueCert, @@ -20,10 +23,7 @@ import { unsupportedOids, unsupportedSignatureRoot, unsupportedSignatureInt, -} from 'vault/tests/helpers/pki/values'; -import { verifyCertificates } from 'vault/utils/parse-pki-cert'; -import { jsonToCertObject } from 'vault/utils/parse-pki-cert'; -import { verifySignature } from 'vault/utils/parse-pki-cert'; +} = CERTIFICATES; module('Integration | Util | parse pki certificate', function (hooks) { setupTest(hooks); diff --git a/ui/tests/unit/adapters/aws-credential-test.js b/ui/tests/unit/adapters/aws-credential-test.js index 5f804fdedf0f..527338900cdc 100644 --- a/ui/tests/unit/adapters/aws-credential-test.js +++ b/ui/tests/unit/adapters/aws-credential-test.js @@ -5,41 +5,46 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +const storeStub = { + pushPayload() {}, + serializerFor() { + return { + serializeIntoHash() {}, + }; + }, +}; + +const makeSnapshot = (obj) => { + obj.role = { + backend: 'aws', + name: 'foo', + }; + obj.attr = (attr) => obj[attr]; + return obj; +}; + +const type = { + modelName: 'aws-credential', +}; module('Unit | Adapter | aws credential', function (hooks) { setupTest(hooks); + setupMirage(hooks); hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); + this.getAssertion = () => {}; + this.postAssertion = () => {}; + this.server.get('/aws/creds/foo', (schema, req) => { + this.getAssertion(req); + return {}; + }); + this.server.post('/aws/creds/foo', (schema, req) => { + this.postAssertion(req); + return {}; + }); }); - const storeStub = { - pushPayload() {}, - serializerFor() { - return { - serializeIntoHash() {}, - }; - }, - }; - - const makeSnapshot = (obj) => { - obj.role = { - backend: 'aws', - name: 'foo', - }; - obj.attr = (attr) => obj[attr]; - return obj; - }; - - const type = { - modelName: 'aws-credential', - }; - const cases = [ ['iam_user type', [storeStub, type, makeSnapshot({ credentialType: 'iam_user', ttl: '3h' })], 'GET'], [ @@ -82,19 +87,19 @@ module('Unit | Adapter | aws credential', function (hooks) { { ttl: '3h', role_arn: 'arn' }, ], ]; - cases.forEach(([description, args, expectedMethod, expectedRequestBody]) => { + + cases.forEach(([description, args, method, expectedRequestBody]) => { test(`aws-credential: ${description}`, function (assert) { - assert.expect(3); + assert.expect(2); + const assertionName = method === 'GET' ? 'getAssertion' : 'postAssertion'; + this.set(assertionName, (req) => { + assert.strictEqual(req.method, method, `query calls the correct url with method ${method}`); + const body = JSON.parse(req.requestBody); + const expected = expectedRequestBody ? expectedRequestBody : null; + assert.deepEqual(body, expected); + }); const adapter = this.owner.lookup('adapter:aws-credential'); adapter.createRecord(...args); - const { method, url, requestBody } = this.server.handledRequests[0]; - assert.strictEqual(url, '/v1/aws/creds/foo', `calls the correct url`); - assert.strictEqual( - method, - expectedMethod, - `${description} uses the correct http verb: ${expectedMethod}` - ); - assert.strictEqual(requestBody, expectedRequestBody ? JSON.stringify(expectedRequestBody) : null); }); }); }); diff --git a/ui/tests/unit/adapters/identity/entity-alias-test.js b/ui/tests/unit/adapters/identity/entity-alias-test.js index e6605140199a..5b0b5a9c0590 100644 --- a/ui/tests/unit/adapters/identity/entity-alias-test.js +++ b/ui/tests/unit/adapters/identity/entity-alias-test.js @@ -6,37 +6,31 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import testCases from './_test-cases'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; module('Unit | Adapter | identity/entity-alias', function (hooks) { setupTest(hooks); - - hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); - }); + setupMirage(hooks); const cases = testCases('identity/entity-alias'); cases.forEach((testCase) => { test(`entity-alias#${testCase.adapterMethod}`, function (assert) { - assert.expect(2); + assert.expect(3); + const method = testCase.method.toLowerCase(); + const url = testCase.url.replace('/v1', '').split('?')[0]; + const queryParams = testCase.url.includes('?list=true') ? { list: 'true' } : {}; + this.server[method](url, (schema, req) => { + assert.true( + testCase.url.includes(url), + `${testCase.adapterMethod} calls the correct url: ${testCase.url}` + ); + assert.strictEqual(req.method, testCase.method, `uses the correct http verb: ${testCase.method}`); + assert.deepEqual(req.queryParams, queryParams, 'calls with correct query params'); + return {}; + }); const adapter = this.owner.lookup('adapter:identity/entity-alias'); adapter[testCase.adapterMethod](...testCase.args); - const { url, method } = this.server.handledRequests[0]; - assert.strictEqual( - url, - testCase.url, - `${testCase.adapterMethod} calls the correct url: ${testCase.url}` - ); - assert.strictEqual( - method, - testCase.method, - `${testCase.adapterMethod} uses the correct http verb: ${testCase.method}` - ); }); }); }); diff --git a/ui/tests/unit/adapters/identity/entity-test.js b/ui/tests/unit/adapters/identity/entity-test.js index a6211ec8bda0..6857dc86f6a2 100644 --- a/ui/tests/unit/adapters/identity/entity-test.js +++ b/ui/tests/unit/adapters/identity/entity-test.js @@ -6,37 +6,31 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import testCases from './_test-cases'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; module('Unit | Adapter | identity/entity', function (hooks) { setupTest(hooks); - - hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); - }); + setupMirage(hooks); const cases = testCases('identit/entity'); cases.forEach((testCase) => { test(`entity#${testCase.adapterMethod}`, function (assert) { - assert.expect(2); + assert.expect(3); + const method = testCase.method.toLowerCase(); + const url = testCase.url.replace('/v1', '').split('?')[0]; + const queryParams = testCase.url.includes('?list=true') ? { list: 'true' } : {}; + this.server[method](url, (schema, req) => { + assert.true( + testCase.url.includes(url), + `${testCase.adapterMethod} calls the correct url: ${testCase.url}` + ); + assert.strictEqual(req.method, testCase.method, `uses the correct http verb: ${testCase.method}`); + assert.deepEqual(req.queryParams, queryParams, 'calls with correct query params'); + return {}; + }); const adapter = this.owner.lookup('adapter:identity/entity'); adapter[testCase.adapterMethod](...testCase.args); - const { url, method } = this.server.handledRequests[0]; - assert.strictEqual( - url, - testCase.url, - `${testCase.adapterMethod} calls the correct url: ${testCase.url}` - ); - assert.strictEqual( - method, - testCase.method, - `${testCase.adapterMethod} uses the correct http verb: ${testCase.method}` - ); }); }); }); diff --git a/ui/tests/unit/adapters/identity/group-alias-test.js b/ui/tests/unit/adapters/identity/group-alias-test.js index a6d92478f55b..d4d537184e8b 100644 --- a/ui/tests/unit/adapters/identity/group-alias-test.js +++ b/ui/tests/unit/adapters/identity/group-alias-test.js @@ -6,37 +6,31 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import testCases from './_test-cases'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; module('Unit | Adapter | identity/group-alias', function (hooks) { setupTest(hooks); - - hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); - }); + setupMirage(hooks); const cases = testCases('identity/group-alias'); cases.forEach((testCase) => { test(`group-alias#${testCase.adapterMethod}`, function (assert) { - assert.expect(2); + assert.expect(3); + const method = testCase.method.toLowerCase(); + const url = testCase.url.replace('/v1', '').split('?')[0]; + const queryParams = testCase.url.includes('?list=true') ? { list: 'true' } : {}; + this.server[method](url, (schema, req) => { + assert.true( + testCase.url.includes(url), + `${testCase.adapterMethod} calls the correct url: ${testCase.url}` + ); + assert.strictEqual(req.method, testCase.method, `usses the correct http verb: ${testCase.method}`); + assert.deepEqual(req.queryParams, queryParams, 'calls with correct query params'); + return {}; + }); const adapter = this.owner.lookup('adapter:identity/group-alias'); adapter[testCase.adapterMethod](...testCase.args); - const { url, method } = this.server.handledRequests[0]; - assert.strictEqual( - url, - testCase.url, - `${testCase.adapterMethod} calls the correct url: ${testCase.url}` - ); - assert.strictEqual( - method, - testCase.method, - `${testCase.adapterMethod} uses the correct http verb: ${testCase.method}` - ); }); }); }); diff --git a/ui/tests/unit/adapters/identity/group-test.js b/ui/tests/unit/adapters/identity/group-test.js index b314cb3b831d..34c237a3a903 100644 --- a/ui/tests/unit/adapters/identity/group-test.js +++ b/ui/tests/unit/adapters/identity/group-test.js @@ -6,37 +6,31 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import testCases from './_test-cases'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; module('Unit | Adapter | identity/group', function (hooks) { setupTest(hooks); - - hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); - }); + setupMirage(hooks); const cases = testCases('identit/entity'); cases.forEach((testCase) => { test(`group#${testCase.adapterMethod}`, function (assert) { - assert.expect(2); + assert.expect(3); + const method = testCase.method.toLowerCase(); + const url = testCase.url.replace('/v1', '').split('?')[0]; + const queryParams = testCase.url.includes('?list=true') ? { list: 'true' } : {}; + this.server[method](url, (schema, req) => { + assert.true( + testCase.url.includes(url), + `${testCase.adapterMethod} calls the correct url: ${testCase.url}` + ); + assert.strictEqual(req.method, testCase.method, `usses the correct http verb: ${testCase.method}`); + assert.deepEqual(req.queryParams, queryParams, 'calls with correct query params'); + return {}; + }); const adapter = this.owner.lookup('adapter:identity/group'); adapter[testCase.adapterMethod](...testCase.args); - const { url, method } = this.server.handledRequests[0]; - assert.strictEqual( - url, - testCase.url, - `${testCase.adapterMethod} calls the correct url: ${testCase.url}` - ); - assert.strictEqual( - method, - testCase.method, - `${testCase.adapterMethod} uses the correct http verb: ${testCase.method}` - ); }); }); }); diff --git a/ui/tests/unit/adapters/pki/action-test.js b/ui/tests/unit/adapters/pki/action-test.js index f08f13ff11a5..a98149b97821 100644 --- a/ui/tests/unit/adapters/pki/action-test.js +++ b/ui/tests/unit/adapters/pki/action-test.js @@ -7,7 +7,9 @@ import { module, test } from 'qunit'; import { setupTest } from 'vault/tests/helpers'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { allowAllCapabilitiesStub } from 'vault/tests/helpers/stubs'; -import { rootPem } from 'vault/tests/helpers/pki/values'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; + +const { rootPem } = CERTIFICATES; module('Unit | Adapter | pki/action', function (hooks) { setupTest(hooks); diff --git a/ui/tests/unit/adapters/pki/certificate/sign-test.js b/ui/tests/unit/adapters/pki/certificate/sign-test.js index 02cbf0ca5746..54ca16155d31 100644 --- a/ui/tests/unit/adapters/pki/certificate/sign-test.js +++ b/ui/tests/unit/adapters/pki/certificate/sign-test.js @@ -6,8 +6,9 @@ import { module, test } from 'qunit'; import { setupTest } from 'vault/tests/helpers'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { csr2 } from 'vault/tests/helpers/pki/values'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; +const { csr2 } = CERTIFICATES; module('Unit | Adapter | pki/certificate/sign', function (hooks) { setupTest(hooks); setupMirage(hooks); diff --git a/ui/tests/unit/adapters/secret-engine-test.js b/ui/tests/unit/adapters/secret-engine-test.js index 38288d5847c4..ddbcbc81cbde 100644 --- a/ui/tests/unit/adapters/secret-engine-test.js +++ b/ui/tests/unit/adapters/secret-engine-test.js @@ -5,18 +5,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import apiStub from 'vault/tests/helpers/noop-all-api-requests'; +import { setupMirage } from 'ember-cli-mirage/test-support'; module('Unit | Adapter | secret engine', function (hooks) { setupTest(hooks); - - hooks.beforeEach(function () { - this.server = apiStub(); - }); - - hooks.afterEach(function () { - this.server.shutdown(); - }); + setupMirage(hooks); const storeStub = { serializerFor() { @@ -29,46 +22,32 @@ module('Unit | Adapter | secret engine', function (hooks) { modelName: 'secret-engine', }; - const cases = [ - { - description: 'Empty query', - adapterMethod: 'query', - args: [storeStub, type, {}], - url: '/v1/sys/internal/ui/mounts', - method: 'GET', - }, - { - description: 'Query with a path', - adapterMethod: 'query', - args: [storeStub, type, { path: 'foo' }], - url: '/v1/sys/internal/ui/mounts/foo', - method: 'GET', - }, + test('Empty query', function (assert) { + assert.expect(1); + this.server.get('/sys/internal/ui/mounts', () => { + assert.ok('query calls the correct url'); + return {}; + }); + const adapter = this.owner.lookup('adapter:secret-engine'); + adapter['query'](storeStub, type, {}); + }); + test('Query with a path', function (assert) { + assert.expect(1); + this.server.get('/sys/internal/ui/mounts/foo', () => { + assert.ok('query calls the correct url'); + return {}; + }); + const adapter = this.owner.lookup('adapter:secret-engine'); + adapter['query'](storeStub, type, { path: 'foo' }); + }); - { - description: 'Query with nested path', - adapterMethod: 'query', - args: [storeStub, type, { path: 'foo/bar/baz' }], - url: '/v1/sys/internal/ui/mounts/foo/bar/baz', - method: 'GET', - }, - ]; - cases.forEach((testCase) => { - test(`secret-engine: ${testCase.description}`, function (assert) { - assert.expect(2); - const adapter = this.owner.lookup('adapter:secret-engine'); - adapter[testCase.adapterMethod](...testCase.args); - const { url, method } = this.server.handledRequests[0]; - assert.strictEqual( - url, - testCase.url, - `${testCase.adapterMethod} calls the correct url: ${testCase.url}` - ); - assert.strictEqual( - method, - testCase.method, - `${testCase.adapterMethod} uses the correct http verb: ${testCase.method}` - ); + test('Query with nested path', function (assert) { + assert.expect(1); + this.server.get('/sys/internal/ui/mounts/foo/bar/baz', () => { + assert.ok('query calls the correct url'); + return {}; }); + const adapter = this.owner.lookup('adapter:secret-engine'); + adapter['query'](storeStub, type, { path: 'foo/bar/baz' }); }); }); diff --git a/ui/tests/unit/serializers/pki/action-test.js b/ui/tests/unit/serializers/pki/action-test.js index 6fa31c2845fc..b61208aa958c 100644 --- a/ui/tests/unit/serializers/pki/action-test.js +++ b/ui/tests/unit/serializers/pki/action-test.js @@ -5,7 +5,9 @@ import { module, test } from 'qunit'; import { setupTest } from 'vault/tests/helpers'; -import { rootPem } from 'vault/tests/helpers/pki/values'; +import { CERTIFICATES } from 'vault/tests/helpers/pki/pki-helpers'; + +const { rootPem } = CERTIFICATES; module('Unit | Serializer | pki/action', function (hooks) { setupTest(hooks);