Skip to content

Commit 4dc540d

Browse files
committed
fix all the last items for testing and layouts
1 parent a584911 commit 4dc540d

File tree

3 files changed

+50
-53
lines changed

3 files changed

+50
-53
lines changed

wrongsecrets-balancer/src/kubernetes.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,15 +2072,15 @@ const getJuiceShopInstances = () => {
20722072
limit: 200,
20732073
})
20742074
.catch((error) => {
2075-
logger.info("error for getJuiceShopInstances: {}", error);
2075+
logger.info('error for getJuiceShopInstances: {}', error);
20762076
throw new Error(error.response.body.message);
20772077
});
20782078
};
20792079

20802080
const updateLastRequestTimestampForTeam = (teamname) => {
20812081
const options = { headers: { 'Content-type': PatchUtils.PATCH_FORMAT_JSON_MERGE_PATCH } };
2082-
return k8sAppsApi.patchNamespacedDeployment(
2083-
{
2082+
return k8sAppsApi
2083+
.patchNamespacedDeployment({
20842084
name: `t-${teamname}-wrongsecrets`,
20852085
namespace: `t-${teamname}`,
20862086
body: {
@@ -2092,12 +2092,11 @@ const updateLastRequestTimestampForTeam = (teamname) => {
20922092
},
20932093
},
20942094
options: options,
2095-
},
2096-
).catch((error) => {
2097-
logger.info("error for updateLastRequestTimestampForTeam: {}", error);
2095+
})
2096+
.catch((error) => {
2097+
logger.info('error for updateLastRequestTimestampForTeam: {}', error);
20982098
throw new Error(error.response.body.message);
2099-
}
2100-
);
2099+
});
21012100
};
21022101

21032102
const changePasscodeHashForTeam = async (teamname, passcodeHash) => {

wrongsecrets-balancer/src/teams/teams.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -934,46 +934,46 @@ router.get('/:team/wait-till-ready', validator.params(paramsSchema), awaitReadin
934934

935935
module.exports = router;
936936

937-
const listInstances = async (req, res) => {
938-
try {
939-
logger.info('Listing all team instances');
940-
941-
const instances = await getJuiceShopInstances();
942-
943-
// Fix: Check if instances and instances.body exist
944-
if (!instances || !instances.body || !instances.body.items) {
945-
logger.warn('No instances found or invalid response structure');
946-
return res.status(200).json({
947-
items: [],
948-
});
949-
}
950-
951-
const teams = instances.body.items
952-
.filter((deployment) => deployment.metadata.labels.app === 'wrongsecrets')
953-
.map((deployment) => {
954-
const team = deployment.metadata.labels.team;
955-
const annotations = deployment.metadata.annotations || {};
956-
957-
return {
958-
team,
959-
name: deployment.metadata.name,
960-
ready: deployment.status?.readyReplicas > 0,
961-
createdAt: new Date(deployment.metadata.creationTimestamp),
962-
lastConnect: new Date(
963-
parseInt(annotations['wrongsecrets-ctf-party/lastRequest']) ||
964-
deployment.metadata.creationTimestamp
965-
),
966-
};
967-
});
968-
969-
res.status(200).json({
970-
items: teams,
971-
});
972-
} catch (error) {
973-
logger.error('Error listing instances:', error.message);
974-
res.status(500).json({
975-
error: 'Failed to list instances',
976-
message: error.message,
977-
});
978-
}
979-
};
937+
// const listInstances = async (req, res) => {
938+
// try {
939+
// logger.info('Listing all team instances');
940+
941+
// const instances = await getJuiceShopInstances();
942+
943+
// // Fix: Check if instances and instances.body exist
944+
// if (!instances || !instances.body || !instances.body.items) {
945+
// logger.warn('No instances found or invalid response structure');
946+
// return res.status(200).json({
947+
// items: [],
948+
// });
949+
// }
950+
951+
// const teams = instances.body.items
952+
// .filter((deployment) => deployment.metadata.labels.app === 'wrongsecrets')
953+
// .map((deployment) => {
954+
// const team = deployment.metadata.labels.team;
955+
// const annotations = deployment.metadata.annotations || {};
956+
957+
// return {
958+
// team,
959+
// name: deployment.metadata.name,
960+
// ready: deployment.status?.readyReplicas > 0,
961+
// createdAt: new Date(deployment.metadata.creationTimestamp),
962+
// lastConnect: new Date(
963+
// parseInt(annotations['wrongsecrets-ctf-party/lastRequest']) ||
964+
// deployment.metadata.creationTimestamp
965+
// ),
966+
// };
967+
// });
968+
969+
// res.status(200).json({
970+
// items: teams,
971+
// });
972+
// } catch (error) {
973+
// logger.error('Error listing instances:', error.message);
974+
// res.status(500).json({
975+
// error: 'Failed to list instances',
976+
// message: error.message,
977+
// });
978+
// }
979+
// };

wrongsecrets-balancer/src/teams/teams.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,12 @@ test('create team fails when max instances is reached', async () => {
120120
});
121121
getJuiceShopInstances.mockImplementation(async () => {
122122
return {
123-
body: {
124123
items: [
125124
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9,
126125
10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8,
127126
9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7,
128127
8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
129128
],
130-
},
131129
};
132130
});
133131

0 commit comments

Comments
 (0)