* refactor: 💡 Move e2e tests to new folder * refactor: 💡 Convert desktop tests to mjs and use es6 imports * refactor: 💡 Use module setting for e2e directory and remove mjs * refactor: 💡 Remove "e2e" in all scripts in package.json
30 lines
741 B
JavaScript
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();
|
|
}
|