vault/ui/tests/helpers/ldap/ldap-helpers.js
Chelsea Shaw 2ce68778e4
UI: Fix LDAP Mirage Handler (#28432)
* update ldap mirage scenario to allow check-in/check-out action

* update libraries test to mount engine

* update mirage, fix tests

* update lease renew CLI command

* fix test

* update tests
2024-09-20 13:44:29 -05:00

41 lines
1.1 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { visit, currentURL } from '@ember/test-helpers';
export const createSecretsEngine = (store) => {
store.pushPayload('secret-engine', {
modelName: 'secret-engine',
data: {
accessor: 'ldap_7e838627',
path: 'ldap-test/',
type: 'ldap',
},
});
return store.peekRecord('secret-engine', 'ldap-test');
};
export const generateBreadcrumbs = (backend, childRoute) => {
const breadcrumbs = [{ label: 'Secrets', route: 'secrets', linkExternal: true }];
const root = { label: backend };
if (childRoute) {
root.route = 'overview';
breadcrumbs.push({ label: childRoute });
}
breadcrumbs.splice(1, 0, root);
return breadcrumbs;
};
const baseURL = (backend) => `/vault/secrets/${backend}/ldap/`;
const stripLeadingSlash = (uri) => (uri.charAt(0) === '/' ? uri.slice(1) : uri);
export const isURL = (uri, backend = 'ldap-test') => {
return currentURL() === `${baseURL(backend)}${stripLeadingSlash(uri)}`;
};
export const visitURL = (uri, backend = 'ldap-test') => {
return visit(`${baseURL(backend)}${stripLeadingSlash(uri)}`);
};