Files
ghaymah-dns-net-sec-tests/scripts/test_helm_command_support.js
T

43 lines
1.5 KiB
JavaScript

const fs = require('fs');
async function main() {
const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8'));
const topology = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/soc_project_topology.json', 'utf8'));
const testerId = topology.services.tester.id;
console.log('Testing if values.command is supported by ghaymah-app helm chart...');
const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + tokenData.token, 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `mutation TestCommand($id: uuid!, $values: json!) {
update_ghaymah_cloud_resources_by_pk(pk_columns: { id: $id }, _set: { values: $values }) {
id status values message
}
}`,
variables: {
id: testerId,
values: {
name: 'soc-tester',
projectId: topology.projectId,
resourceTier: 't1',
ports: [{ number: 7681, expose: true }],
container: { image: 'tsl0922/ttyd:alpine' },
command: ['/bin/sh', '-c', 'echo "COMMAND_SUPPORTED" > /tmp/cmd_support.txt && exec ttyd -W bash'],
publicAccess: {
enabled: true,
domain: topology.services.tester.domain,
baseDomain: 'hosted.ghaymah.systems'
}
}
}
})
});
const data = await res.json();
console.log('Update result:', JSON.stringify(data));
}
main().catch(console.error);