Files
threshold-ui/e2e-tests/helpers/boundary-http/targets.js
T
Lisbet Alvarez e310b5abfa Add e2e test for target sort and modify e2e dc testing workflow to build binary (#3176)
* test: 💍 add e2e test case for sort target name

* chore: 🤖 update desktop e2e workflow to use boundary ent repo

* fix: 🐛 make sure org is fully loaded before sorting

* fix: 🐛 add missing step to move binary to correct folder

* refactor: 💡 update to wait for table load in test

* test: 💍 validate cache status

* fix: 🐛 remove unneeded flag so tests use enos binary

* refactor: 💡 use commit from ui-ent repo to build binary

* fix: 🐛 update selector due to changes from main merge

* fix: 🐛 update selector for dropdown link

* fix: 🐛 reopen dropdown after switching org + add workflow input

* docs: ✏️ clean up comments in workflow file
2026-03-05 12:41:45 -08:00

105 lines
2.6 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import { nanoid } from 'nanoid';
import { checkResponse } from './responseHelper.js';
/**
* Creates a new target
* @param {import('@playwright/test').APIRequestContext} request
* @param {string} scopeId ID of the scope where target will be created
* @param {string} type type of the target: 'tcp, 'ssh'
* @param {number} port default port of the target
* @param {string} address Optional target address
* @returns {Promise<Serializable>}
*/
export async function createTarget(
request,
{ scopeId, name, type, port, address },
) {
const response = await request.post(`/v1/targets`, {
data: {
name: name || `Target-${nanoid()}`,
scope_id: scopeId,
type: type,
attributes: {
default_port: port,
},
address,
},
});
return checkResponse(response);
}
/**
* Adds a brokered credential to a target
* @param request
* @param {Object} target The target to attach the credential to
* @param {string[]} credentialIds The credential IDs to attach to the target
* @return {Promise<Serializable>}
*/
export async function addBrokeredCredentials(
request,
{ target, credentialIds },
) {
const response = await request.post(
`/v1/targets/${target.id}:add-credential-sources`,
{
data: {
brokered_credential_source_ids: credentialIds,
version: target.version,
},
},
);
return checkResponse(response);
}
/**
* Adds an injected credential to a target
* @param request
* @param {Object} target The target to attach the credential to
* @param {string[]} credentialIds The credential IDs to attach to the target
* @return {Promise<Serializable>}
*/
export async function addInjectedCredentials(
request,
{ target, credentialIds },
) {
const response = await request.post(
`/v1/targets/${target.id}:add-credential-sources`,
{
data: {
injected_application_credential_source_ids: credentialIds,
version: target.version,
},
},
);
return checkResponse(response);
}
/**
* Adds a host source to a target
* @param request
* @param {Object} target The target to attach the host source to
* @param {string[]} hostSourceIds The host source IDs to attach to the target
* @return {Promise<Serializable>}
*/
export async function addHostSource(request, { target, hostSourceIds }) {
const response = await request.post(
`/v1/targets/${target.id}:add-host-sources`,
{
data: {
host_source_ids: hostSourceIds,
version: target.version,
},
},
);
return checkResponse(response);
}