Repository: hashicorp/vault
File: ui/tests/acceptance/secrets/backend/totp/key-test.js (JavaScript)

Code before:
    await click(SES.createSecret);
    await createVaultKey(keyName, issuer, accountName);
    await settled();
    await listPage.visit({ backend: path, id: keyName });
    await click('[data-test-popup-menu-trigger]');
    assert.dom('.hds-dropdown li:nth-of-type(2)').hasText('Delete', 'first list item is "details"');
    await click('.hds-dropdown li:nth-of-type(2) [data-test-confirm-action-trigger]');
    await click('[data-test-confirm-button]');
    assert.dom(SES.secretLink(keyName)).doesNotExist(`${keyName}: key is no longer in the list`);
  });

  test('it creates a key with Vault as the provider', async function (assert) {
    // Setup TOTP engine
    const mountPath = `totp-${this.uid}`;
    await enablePage.enable('totp', mountPath);

    const path = `totp-${this.uid}`;
    const keyName = 'totp-key';
    const issuer = 'totp-issuer';
    const accountName = 'totp-acount';

    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${path}/list`,
      'After enabling totp secrets engine it navigates to keys list'
    );

    await click(SES.createSecret);
    assert.dom(SES.secretHeader).hasText('Create a TOTP key', 'It renders the create key page');

    await createVaultKey(keyName, issuer, accountName);
    await waitUntil(() => currentURL() === `/vault/secrets/${path}/show/${keyName}`); // flaky without this
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${path}/show/${keyName}`,
      'totp: navigates to the show page on creation'
    );
  });
});


Review comment (security):
This assertion feels like it makes more sense in the enabling a secret engine workflow, not here in just totp key CRUD actions

Code after:
    );
  });

  test('it deletes a key via menu option', async function (assert) {
    await click(SES.createSecret);
    await createVaultKey(this.keyName, this.issuer, this.accountName);
    await waitUntil(() => currentURL() === `/vault/secrets/${this.path}/show/${this.keyName}`);
    await visit(`/vault/secrets/${this.path}`);
    await click(GENERAL.menuTrigger);
    await click(GENERAL.confirmTrigger);
    await click(GENERAL.confirmButton);
    assert.dom(SES.secretLink(this.keyName)).doesNotExist(`${this.keyName}: key is no longer in the list`);

    const [flashMessage] = this.flashSuccessSpy.lastCall.args;
    assert.strictEqual(flashMessage, `${this.keyName} was successfully deleted.`);
  });

  test('it creates a key with Vault as the provider', async function (assert) {
    await click(SES.createSecret);
    assert.dom(SES.secretHeader).hasText('Create a TOTP key', 'It renders the create key page');

    await createVaultKey(this.keyName, this.issuer, this.accountName);
    await waitUntil(() => currentURL() === `/vault/secrets/${this.path}/show/${this.keyName}`);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${this.path}/show/${this.keyName}`,
      'totp: navigates to the show page on creation'
    );

    const [flashMessage] = this.flashSuccessSpy.lastCall.args;
    assert.strictEqual(flashMessage, 'Successfully created key.');
  });

  test('it creates a key with another service as the provider with URL', async function (assert) {
    await click(SES.createSecret);
    assert.dom(SES.secretHeader).hasText('Create a TOTP key', 'It renders the create key page');
    await createNonVaultKey(this.keyName, this.issuer, this.accountName, this.url);
    await waitUntil(() => currentURL() === `/vault/secrets/${this.path}/show/${this.keyName}`);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${this.path}/show/${this.keyName}`,
      'totp: navigates to the show page on creation'
    );

    const [flashMessage] = this.flashSuccessSpy.lastCall.args;
    assert.strictEqual(flashMessage, 'Successfully created key.');
  });

  test('it creates a key with another service as the provider with key', async function (assert) {
    await click(SES.createSecret);
    assert.dom(SES.secretHeader).hasText('Create a TOTP key', 'It renders the create key page');