vault/ui/tests/unit/adapters/auth-method-test.js
claire bontempo 225cd9d19f
UI: Align auth method ttl with tune value (#26663)
* refactor findAll to use internal/ui/mounts when authenticated as well

* format ttl in details view

* include hours in format for easy comparison to CLI return

* Revert "include hours in format for easy comparison to CLI return"

This reverts commit 990aaf5d1e157ccd83389ecd54011b8971f7e52d.

* add changelog

* revert adapter change

* add new adapter method instead of updating existing

* add test for ttl

* revert and use findAll again

* update mirage endpoints

* remove query obj

* Revert "update mirage endpoints"

This reverts commit f5fb333bf46b8ee86fbd134cbbd9fde85a72c9a1.

* another one that snuck into a separate commit

* use adapterOption to manage endpoint logic

* add adapter tests

* Update changelog/26663.txt

Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>

* add test that ttl inputs aren not checked

---------

Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
2024-04-30 18:19:22 +01:00

68 lines
2.0 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
module('Unit | Adapter | auth method', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
hooks.beforeEach(async function () {
this.store = this.owner.lookup('service:store');
this.mockResponse = {
data: {
auth: {
'approle/': {
accessor: 'auth_approle_43e5a627',
config: {
default_lease_ttl: 2764800,
force_no_cache: false,
listing_visibility: 'hidden',
max_lease_ttl: 2764800,
token_type: 'default-service',
},
uuid: '7a8bc146-76d0-3a9c-9feb-47a6713a85b3',
},
},
},
};
});
test('findAll makes request to correct endpoint with no adapterOptions', async function (assert) {
assert.expect(1);
this.server.get('sys/auth', () => {
assert.ok(true, 'request made to sys/auth when no options are passed to findAll');
return { data: this.mockResponse.data.auth };
});
await this.store.findAll('auth-method');
});
test('findAll makes request to correct endpoint when unauthenticated is true', async function (assert) {
assert.expect(1);
this.server.get('sys/internal/ui/mounts', () => {
assert.ok(true, 'request made to correct endpoint when unauthenticated');
return this.mockResponse;
});
await this.store.findAll('auth-method', { adapterOptions: { unauthenticated: true } });
});
test('findAll makes request to correct endpoint when useMountsEndpoint is true', async function (assert) {
assert.expect(1);
this.server.get('sys/internal/ui/mounts', () => {
assert.ok(true, 'request made to correct endpoint when useMountsEndpoint');
return this.mockResponse;
});
await this.store.findAll('auth-method', { adapterOptions: { useMountsEndpoint: true } });
});
});