Files
threshold-ui/ui/admin/tests/e2e/helpers/boundary-http/targets.mjs
T
Michael Li 075d8c6d8f refact(e2e): Create HTTP methods and more page objects (#2448)
* refact(e2e): Create LoginPage

* refact(e2e): Create http methods

* refact(e2e): Create more methods
2024-08-23 10:17:10 -04:00

30 lines
741 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { nanoid } from 'nanoid';
/**
* 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
* @returns {Promise<Serializable>}
*/
export async function createTargetHttp(request, scopeId, type, port) {
const target = await request.post(`/v1/targets`, {
data: {
name: 'Target ' + nanoid(),
scope_id: scopeId,
type: type,
attributes: {
default_port: port,
},
},
});
return await target.json();
}